1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-12 19:10:32 +03:00

AT32F435 SD card support (#14018) (#14122)

This commit is contained in:
Steve Evans 2025-01-03 18:35:29 +00:00 committed by GitHub
parent 3cd5de187a
commit 0d14c63cfe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 37 additions and 4 deletions

View file

@ -23,6 +23,7 @@
*/
#include "msc_bot_scsi.h"
#include "msc_diskio.h"
#include "usbd_msc_mem.h"
/** @addtogroup AT32F435_437_middlewares_usbd_class
* @{
@ -112,6 +113,8 @@ void bot_scsi_init(void *udev)
pmsc->csw_struct.dCSWSignature = 0;
pmsc->csw_struct.dCSWTag = CSW_BCSWSTATUS_PASS;
USBD_STORAGE_fops->Init(0);
usbd_flush_tx_fifo(pudev, USBD_MSC_BULK_IN_EPT&0x7F);
/* set out endpoint to receive status */

View file

@ -61,6 +61,7 @@ MCU_COMMON_SRC = \
msc/usbd_storage.c \
msc/usbd_storage_emfat.c \
msc/emfat.c \
msc/emfat_file.c
msc/emfat_file.c \
msc/usbd_storage_sd_spi.c
MCU_EXCLUDES =

View file

@ -179,6 +179,35 @@ uint8_t mscStart(void)
IOInit(IOGetByTag(IO_TAG(PA11)), OWNER_USB, 0);
IOInit(IOGetByTag(IO_TAG(PA12)), OWNER_USB, 0);
switch (blackboxConfig()->device) {
#ifdef USE_SDCARD
case BLACKBOX_DEVICE_SDCARD:
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
#ifdef USE_FLASHFS
case BLACKBOX_DEVICE_FLASH:
USBD_STORAGE_fops = &USBD_MSC_EMFAT_fops;
break;
#endif
default:
return 1;
}
msc_usb_gpio_config();
crm_periph_clock_enable(OTG_CLOCK, TRUE);
msc_usb_clock48m_select(USB_CLK_HEXT);
@ -199,7 +228,7 @@ uint8_t mscStart(void)
int8_t msc_disk_capacity(uint8_t lun, uint32_t *block_num, uint32_t *block_size)
{
return USBD_MSC_EMFAT_fops.GetCapacity(lun, block_num, block_size);
return USBD_STORAGE_fops->GetCapacity(lun, block_num, block_size);
}
int8_t msc_disk_read(
@ -208,7 +237,7 @@ int8_t msc_disk_read(
uint8_t *buf, // Pointer to the buffer to save data
uint16_t blk_len) // number of blocks to be read
{
return USBD_MSC_EMFAT_fops.Read(lun, buf, blk_addr, blk_len);
return USBD_STORAGE_fops->Read(lun, buf, blk_addr, blk_len);
}
int8_t msc_disk_write(uint8_t lun,
@ -228,7 +257,7 @@ uint8_t *get_inquiry(uint8_t lun)
{
UNUSED(lun);
return (uint8_t *)USBD_MSC_EMFAT_fops.pInquiry;
return (uint8_t *)USBD_STORAGE_fops->pInquiry;
}
uint8_t msc_get_readonly(uint8_t lun)