diff --git a/examples/stm32/f4/stm32f4-discovery/usb_msc/msc.c b/examples/stm32/f4/stm32f4-discovery/usb_msc/msc.c index af46bd9..918c702 100644 --- a/examples/stm32/f4/stm32f4-discovery/usb_msc/msc.c +++ b/examples/stm32/f4/stm32f4-discovery/usb_msc/msc.c @@ -20,8 +20,8 @@ #include -#include -#include +#include +#include #include #include @@ -104,18 +104,22 @@ static uint8_t usbd_control_buffer[128]; int main(void) { - rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_120MHZ]); rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN); rcc_peripheral_enable_clock(&RCC_AHB2ENR, RCC_AHB2ENR_OTGFSEN); - gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9 | GPIO11 | GPIO12); + gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, + GPIO9 | GPIO11 | GPIO12); gpio_set_af(GPIOA, GPIO_AF10, GPIO9 | GPIO11 | GPIO12); - msc_dev = usbd_init(&otgfs_usb_driver, &dev_descr, &config_descr, usb_strings, 3, usbd_control_buffer, sizeof(usbd_control_buffer)); + msc_dev = usbd_init(&otgfs_usb_driver, &dev_descr, &config_descr, + usb_strings, 3, + usbd_control_buffer, sizeof(usbd_control_buffer)); + ramdisk_init(); - usb_msc_init(msc_dev, 0x82, 64, 0x01, 64, "VendorID", "ProductID", "0.00", ramdisk_blocks(), ramdisk_read, ramdisk_write); + usb_msc_init(msc_dev, 0x82, 64, 0x01, 64, "VendorID", "ProductID", + "0.00", ramdisk_blocks(), ramdisk_read, ramdisk_write); for (;;) { usbd_poll(msc_dev); diff --git a/examples/stm32/f4/stm32f4-discovery/usb_msc/ramdisk.c b/examples/stm32/f4/stm32f4-discovery/usb_msc/ramdisk.c index 271ec37..5504ab0 100644 --- a/examples/stm32/f4/stm32f4-discovery/usb_msc/ramdisk.c +++ b/examples/stm32/f4/stm32f4-discovery/usb_msc/ramdisk.c @@ -22,22 +22,26 @@ #include "ramdisk.h" #define WBVAL(x) ((x) & 0xFF), (((x) >> 8) & 0xFF) -#define QBVAL(x) ((x) & 0xFF), (((x) >> 8) & 0xFF), (((x) >> 16) & 0xFF), (((x) >> 24) & 0xFF) +#define QBVAL(x) ((x) & 0xFF), (((x) >> 8) & 0xFF),\ + (((x) >> 16) & 0xFF), (((x) >> 24) & 0xFF) // filesystem size is 512kB (1024 * SECTOR_SIZE) -#define SECTOR_COUNT 1024 -#define SECTOR_SIZE 512 -#define BYTES_PER_SECTOR 512 -#define SECTORS_PER_CLUSTER 4 -#define RESERVED_SECTORS 1 -#define FAT_COPIES 2 -#define ROOT_ENTRIES 512 -#define ROOT_ENTRY_LENGTH 32 -#define FILEDATA_START_CLUSTER 3 -#define DATA_REGION_SECTOR (RESERVED_SECTORS + FAT_COPIES + (ROOT_ENTRIES * ROOT_ENTRY_LENGTH) / BYTES_PER_SECTOR) -#define FILEDATA_START_SECTOR (DATA_REGION_SECTOR + (FILEDATA_START_CLUSTER - 2) * SECTORS_PER_CLUSTER) +#define SECTOR_COUNT 1024 +#define SECTOR_SIZE 512 +#define BYTES_PER_SECTOR 512 +#define SECTORS_PER_CLUSTER 4 +#define RESERVED_SECTORS 1 +#define FAT_COPIES 2 +#define ROOT_ENTRIES 512 +#define ROOT_ENTRY_LENGTH 32 +#define FILEDATA_START_CLUSTER 3 +#define DATA_REGION_SECTOR (RESERVED_SECTORS + FAT_COPIES + \ + (ROOT_ENTRIES * ROOT_ENTRY_LENGTH) / BYTES_PER_SECTOR) +#define FILEDATA_START_SECTOR (DATA_REGION_SECTOR + \ + (FILEDATA_START_CLUSTER - 2) * SECTORS_PER_CLUSTER) + // filesize is 64kB (128 * SECTOR_SIZE) -#define FILEDATA_SECTOR_COUNT 128 +#define FILEDATA_SECTOR_COUNT 128 uint8_t BootSector[] = { 0xEB, 0x3C, 0x90, // code to jump to the bootstrap code