mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 03:20:00 +03:00
parent
3cd5de187a
commit
0d14c63cfe
3 changed files with 37 additions and 4 deletions
|
@ -23,6 +23,7 @@
|
||||||
*/
|
*/
|
||||||
#include "msc_bot_scsi.h"
|
#include "msc_bot_scsi.h"
|
||||||
#include "msc_diskio.h"
|
#include "msc_diskio.h"
|
||||||
|
#include "usbd_msc_mem.h"
|
||||||
|
|
||||||
/** @addtogroup AT32F435_437_middlewares_usbd_class
|
/** @addtogroup AT32F435_437_middlewares_usbd_class
|
||||||
* @{
|
* @{
|
||||||
|
@ -112,6 +113,8 @@ void bot_scsi_init(void *udev)
|
||||||
pmsc->csw_struct.dCSWSignature = 0;
|
pmsc->csw_struct.dCSWSignature = 0;
|
||||||
pmsc->csw_struct.dCSWTag = CSW_BCSWSTATUS_PASS;
|
pmsc->csw_struct.dCSWTag = CSW_BCSWSTATUS_PASS;
|
||||||
|
|
||||||
|
USBD_STORAGE_fops->Init(0);
|
||||||
|
|
||||||
usbd_flush_tx_fifo(pudev, USBD_MSC_BULK_IN_EPT&0x7F);
|
usbd_flush_tx_fifo(pudev, USBD_MSC_BULK_IN_EPT&0x7F);
|
||||||
|
|
||||||
/* set out endpoint to receive status */
|
/* set out endpoint to receive status */
|
||||||
|
|
|
@ -61,6 +61,7 @@ MCU_COMMON_SRC = \
|
||||||
msc/usbd_storage.c \
|
msc/usbd_storage.c \
|
||||||
msc/usbd_storage_emfat.c \
|
msc/usbd_storage_emfat.c \
|
||||||
msc/emfat.c \
|
msc/emfat.c \
|
||||||
msc/emfat_file.c
|
msc/emfat_file.c \
|
||||||
|
msc/usbd_storage_sd_spi.c
|
||||||
|
|
||||||
MCU_EXCLUDES =
|
MCU_EXCLUDES =
|
||||||
|
|
|
@ -179,6 +179,35 @@ uint8_t mscStart(void)
|
||||||
IOInit(IOGetByTag(IO_TAG(PA11)), OWNER_USB, 0);
|
IOInit(IOGetByTag(IO_TAG(PA11)), OWNER_USB, 0);
|
||||||
IOInit(IOGetByTag(IO_TAG(PA12)), 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();
|
msc_usb_gpio_config();
|
||||||
crm_periph_clock_enable(OTG_CLOCK, TRUE);
|
crm_periph_clock_enable(OTG_CLOCK, TRUE);
|
||||||
msc_usb_clock48m_select(USB_CLK_HEXT);
|
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)
|
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(
|
int8_t msc_disk_read(
|
||||||
|
@ -208,7 +237,7 @@ int8_t msc_disk_read(
|
||||||
uint8_t *buf, // Pointer to the buffer to save data
|
uint8_t *buf, // Pointer to the buffer to save data
|
||||||
uint16_t blk_len) // number of blocks to be read
|
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,
|
int8_t msc_disk_write(uint8_t lun,
|
||||||
|
@ -228,7 +257,7 @@ uint8_t *get_inquiry(uint8_t lun)
|
||||||
{
|
{
|
||||||
UNUSED(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)
|
uint8_t msc_get_readonly(uint8_t lun)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue