diff --git a/make/mcu/STM32F4.mk b/make/mcu/STM32F4.mk index f510b0825..3455c55cd 100644 --- a/make/mcu/STM32F4.mk +++ b/make/mcu/STM32F4.mk @@ -197,7 +197,13 @@ VCP_SRC = \ endif MSC_SRC = \ - drivers/usb_msc_f4xx.c + drivers/usb_msc_f4xx.c \ + msc/usbd_msc_desc.c + +ifneq ($(filter SDCARD,$(FEATURES)),) +MSC_SRC += \ + msc/usbd_storage_sd_spi.c +endif DSP_LIB := $(ROOT)/lib/main/CMSIS/DSP DEVICE_FLAGS += -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -D__FPU_PRESENT=1 -DUNALIGNED_SUPPORT_DISABLE -DARM_MATH_CM4 diff --git a/make/source.mk b/make/source.mk index e86ee108d..99b2c6db5 100644 --- a/make/source.mk +++ b/make/source.mk @@ -382,7 +382,8 @@ SRC += \ drivers/sdcard.c \ drivers/sdcard_standard.c \ io/asyncfatfs/asyncfatfs.c \ - io/asyncfatfs/fat_standard.c + io/asyncfatfs/fat_standard.c \ + $(MSC_SRC) endif ifneq ($(filter VCP,$(FEATURES)),) diff --git a/src/main/drivers/usb_msc_f4xx.c b/src/main/drivers/usb_msc_f4xx.c index 471621120..1db9bd469 100644 --- a/src/main/drivers/usb_msc_f4xx.c +++ b/src/main/drivers/usb_msc_f4xx.c @@ -26,7 +26,7 @@ #include "platform.h" -#ifdef USB_MSC +#ifdef USE_USB_MSC #include "build/build_config.h" diff --git a/src/main/fc/fc_init.c b/src/main/fc/fc_init.c index 67757a444..9417ea992 100644 --- a/src/main/fc/fc_init.c +++ b/src/main/fc/fc_init.c @@ -71,7 +71,7 @@ #include "drivers/usb_io.h" #include "drivers/vtx_rtc6705.h" #include "drivers/vtx_common.h" -#ifdef USB_MSC +#ifdef USE_USB_MSC #include "drivers/usb_msc.h" #endif @@ -453,7 +453,7 @@ void init(void) #endif #endif // USE_SPI -#ifdef USB_MSC +#ifdef USE_USB_MSC /* MSC mode will start after init, but will not allow scheduler to run, * so there is no bottleneck in reading and writing data */ mscButtonInit(); diff --git a/src/main/interface/cli.c b/src/main/interface/cli.c index 06ee8be62..c498b4798 100644 --- a/src/main/interface/cli.c +++ b/src/main/interface/cli.c @@ -3723,7 +3723,7 @@ static void cliDiff(char *cmdline) printConfig(cmdline, true); } -#ifdef USB_MSC +#ifdef USE_USB_MSC static void cliMsc(char *cmdline) { UNUSED(cmdline); @@ -3872,7 +3872,7 @@ const clicmd_t cmdTable[] = { #ifdef USE_VTX_CONTROL CLI_COMMAND_DEF("vtx", "vtx channels on switch", NULL, cliVtx), #endif -#ifdef USB_MSC +#ifdef USE_USB_MSC CLI_COMMAND_DEF("msc", "switch into msc mode", NULL, cliMsc), #endif }; diff --git a/src/main/target/STM32F4DISCOVERY/target.h b/src/main/target/STM32F4DISCOVERY/target.h index ab1e60ee6..6261c0bfe 100644 --- a/src/main/target/STM32F4DISCOVERY/target.h +++ b/src/main/target/STM32F4DISCOVERY/target.h @@ -55,7 +55,6 @@ // GYRO section -- end #define USE_VCP -#define USB_MSC #define MSC_BUTTON PA0 #define VBUS_SENSING_PIN PA9 #define VBUS_SENSING_ENABLED diff --git a/src/main/target/WORMFC/target.h b/src/main/target/WORMFC/target.h index 4dd704d6a..43151e281 100644 --- a/src/main/target/WORMFC/target.h +++ b/src/main/target/WORMFC/target.h @@ -66,7 +66,6 @@ #define INVERTER_PIN_UART3 PB12 #define USE_VCP -#define USB_MSC #define USB_CDC_HID #define VBUS_SENSING_PIN PA9 #define VBUS_SENSING_ENABLED diff --git a/src/main/target/WORMFC/target.mk b/src/main/target/WORMFC/target.mk index 71b9ff286..8c25943fe 100644 --- a/src/main/target/WORMFC/target.mk +++ b/src/main/target/WORMFC/target.mk @@ -16,5 +16,4 @@ TARGET_SRC += \ drivers/sdcard_standard.c \ io/asyncfatfs/asyncfatfs.c \ io/asyncfatfs/fat_standard.c \ - msc/usbd_storage_sdio.c \ - msc/usbd_msc_desc.c \ No newline at end of file + msc/usbd_storage_sdio.c diff --git a/src/main/target/common_fc_post.h b/src/main/target/common_fc_post.h index 1c4708c34..d0ec45eed 100644 --- a/src/main/target/common_fc_post.h +++ b/src/main/target/common_fc_post.h @@ -102,3 +102,7 @@ #ifndef USE_ADC #undef USE_ADC_INTERNAL #endif + +#if !defined(USE_SDCARD) +#undef USE_USB_MSC +#endif diff --git a/src/main/target/common_fc_pre.h b/src/main/target/common_fc_pre.h index af947f4fc..0c4396d7c 100644 --- a/src/main/target/common_fc_pre.h +++ b/src/main/target/common_fc_pre.h @@ -51,6 +51,7 @@ #define USE_GYRO_DATA_ANALYSE #define USE_ADC #define USE_ADC_INTERNAL +#define USE_USB_MSC #if defined(STM32F40_41xxx) || defined(STM32F411xE) #define USE_OVERCLOCK