Switch USBD storage fops table according to sdcard config

This commit is contained in:
jflyper 2018-11-30 15:45:44 +09:00
parent 8a4ea0785e
commit 0cf8679b5c
4 changed files with 42 additions and 8 deletions

View File

@ -46,6 +46,7 @@
#include "drivers/accgyro/accgyro_mpu.h"
#include "pg/sdcard.h"
#include "pg/usb.h"
#include "usb_core.h"
@ -84,7 +85,20 @@ uint8_t mscStart(void)
switch (blackboxConfig()->device) {
#ifdef USE_SDCARD
case BLACKBOX_DEVICE_SDCARD:
USBD_STORAGE_fops = &USBD_MSC_MICRO_SDIO_fops;
switch (sdcardConfig()->mode) {
#ifdef USE_SDCARD_SDIO
case SDCARD_MODE_SDIO:
USBD_STORAGE_fops = &USBD_MSC_MICRO_SDIO_fops;
break;
#endif
#ifdef USE_SDCARD_SPI
case SDCARD_MODE_SPI:
USBD_STORAGE_fops = &USBD_MSC_MICRO_SD_SPI_fops;
break;
#endif
default:
return 1;
}
break;
#endif

View File

@ -45,6 +45,7 @@
#include "drivers/accgyro/accgyro_mpu.h"
#include "pg/sdcard.h"
#include "pg/usb.h"
#include "vcp_hal/usbd_cdc_interface.h"
@ -88,7 +89,20 @@ uint8_t mscStart(void)
switch (blackboxConfig()->device) {
#ifdef USE_SDCARD
case BLACKBOX_DEVICE_SDCARD:
USBD_MSC_RegisterStorage(&USBD_Device, &USBD_MSC_MICRO_SDIO_fops);
switch (sdcardConfig()->mode) {
#ifdef USE_SDCARD_SDIO
case SDCARD_MODE_SDIO:
USBD_MSC_RegisterStorage(&USBD_Device, &USBD_MSC_MICRO_SDIO_fops);
break;
#endif
#ifdef USE_SDCARD_SPI
case SDCARD_MODE_SPI:
USBD_MSC_RegisterStorage(&USBD_Device, &USBD_MSC_MICRO_SD_SPI_fops);
break;
#endif
default:
return 1;
}
break;
#endif

View File

@ -29,18 +29,24 @@
#ifdef USE_HAL_DRIVER
extern USBD_StorageTypeDef *USBD_STORAGE_fops;
#ifdef USE_SDCARD
#ifdef USE_SDCARD_SDIO
extern USBD_StorageTypeDef USBD_MSC_MICRO_SDIO_fops;
#endif
#ifdef USE_SDCARD_SPI
extern USBD_StorageTypeDef USBD_MSC_MICRO_SD_SPI_fops;
#endif
#ifdef USE_FLASHFS
extern USBD_StorageTypeDef USBD_MSC_EMFAT_fops;
#endif
#else
#else // USE_HAL_DRIVER
extern USBD_STORAGE_cb_TypeDef *USBD_STORAGE_fops;
#ifdef USE_SDCARD
#ifdef USE_SDCARD_SDIO
extern USBD_STORAGE_cb_TypeDef USBD_MSC_MICRO_SDIO_fops;
#endif
#ifdef USE_SDCARD_SPI
extern USBD_STORAGE_cb_TypeDef USBD_MSC_MICRO_SD_SPI_fops;
#endif
#ifdef USE_FLASHFS
extern USBD_STORAGE_cb_TypeDef USBD_MSC_EMFAT_fops;
#endif
#endif
#endif // USE_HAL_DRIVER

View File

@ -110,7 +110,7 @@ static uint8_t STORAGE_Inquirydata[] = {//36
};
#ifdef USE_HAL_DRIVER
USBD_StorageTypeDef USBD_MSC_MICRO_SDIO_fops =
USBD_StorageTypeDef USBD_MSC_MICRO_SD_SPI_fops =
{
STORAGE_Init,
STORAGE_GetCapacity,
@ -122,7 +122,7 @@ USBD_StorageTypeDef USBD_MSC_MICRO_SDIO_fops =
(int8_t*)STORAGE_Inquirydata,
};
#else
USBD_STORAGE_cb_TypeDef USBD_MSC_MICRO_SDIO_fops =
USBD_STORAGE_cb_TypeDef USBD_MSC_MICRO_SD_SPI_fops =
{
STORAGE_Init,
STORAGE_GetCapacity,