STM32Cubemx update
authorMichael McMaster <michael@codesrc.com>
Mon, 21 Oct 2019 10:38:51 +0000 (20:38 +1000)
committerMichael McMaster <michael@codesrc.com>
Mon, 21 Oct 2019 10:38:51 +0000 (20:38 +1000)
19 files changed:
Makefile
STM32CubeMX/SCSI2SD-V6/.mxproject
STM32CubeMX/SCSI2SD-V6/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_sd.c
STM32CubeMX/SCSI2SD-V6/Inc/bsp_driver_sd.h [deleted file]
STM32CubeMX/SCSI2SD-V6/Inc/stm32f2xx_hal_conf.h
STM32CubeMX/SCSI2SD-V6/Inc/stm32f2xx_it.h
STM32CubeMX/SCSI2SD-V6/SCSI2SD-V6.ioc
STM32CubeMX/SCSI2SD-V6/Src/bsp_driver_sd.c [deleted file]
STM32CubeMX/SCSI2SD-V6/Src/fsmc.c
STM32CubeMX/SCSI2SD-V6/Src/gpio.c
STM32CubeMX/SCSI2SD-V6/Src/main.c
STM32CubeMX/SCSI2SD-V6/Src/sdio.c
STM32CubeMX/SCSI2SD-V6/Src/spi.c
STM32CubeMX/SCSI2SD-V6/Src/stm32f2xx_hal_msp.c
STM32CubeMX/SCSI2SD-V6/Src/stm32f2xx_it.c
STM32CubeMX/SCSI2SD-V6/Src/usbd_conf.c
src/firmware/bsp_driver_sd.c [new file with mode: 0755]
src/firmware/bsp_driver_sd.h [new file with mode: 0755]
src/firmware/cubemx.patch [new file with mode: 0644]

index 9be0d9a64b08408f3c6fc163a6cadf642b759ce9..364f84636908e4b4f891240acf961271cabdcc96 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,6 @@ STM32CubeMX_INCUDE = \
 
 all: build/firmware.dfu
 
-build/stm32cubemx/bsp_driver_sd.o: STM32CubeMX/SCSI2SD-V6/Src/bsp_driver_sd.c
 build/stm32cubemx/fsmc.o: STM32CubeMX/SCSI2SD-V6/Src/fsmc.c
 build/stm32cubemx/gpio.o: STM32CubeMX/SCSI2SD-V6/Src/gpio.c
 build/stm32cubemx/main.o: STM32CubeMX/SCSI2SD-V6/Src/main.c
@@ -148,6 +147,7 @@ SRC = \
        src/firmware/tape.c \
        src/firmware/time.c \
        src/firmware/vendor.c \
+       src/firmware/bsp_driver_sd.c \
        ${USBCOMPOSITE_SRC}
 
 build/firmware.elf: $(SRC) rtl/fpga_bitmap.o $(STM32OBJS)
index 86661c5d85fe74e27ed76a6f6b672dbf78d43a0b..c566edb405ff96f1e05ce56a8e9df0a2a2974d09 100755 (executable)
@@ -1,13 +1,14 @@
 [PreviousGenFiles]
-HeaderPath=Z:/projects/SCSI2SD/git-v6/STM32CubeMX/SCSI2SD-V6/Inc
-SourcePath=Z:/projects/SCSI2SD/git-v6/STM32CubeMX/SCSI2SD-V6/Src
-SourceFiles=gpio.h;dma.h;ffconf.h;bsp_driver_sd.h;fatfs.h;fsmc.h;sdio.h;spi.h;tim.h;usart.h;usb_device.h;usbd_conf.h;usbd_desc.h;usbd_storage_if.h;usb_host.h;usbh_conf.h;stm32f2xx_it.h;stm32f2xx_hal_conf.h;mxconstants.h;gpio.c;dma.c;bsp_driver_sd.c;fatfs.c;fsmc.c;sdio.c;spi.c;tim.c;usart.c;usb_device.c;usbd_conf.c;usbd_desc.c;usbd_storage_if.c;usb_host.c;usbh_conf.c;stm32f2xx_it.c;stm32f2xx_hal_msp.c;main.c;
-HeaderFiles=gpio.h;dma.h;ffconf.h;bsp_driver_sd.h;fatfs.h;fsmc.h;sdio.h;spi.h;tim.h;usart.h;usb_device.h;usbd_conf.h;usbd_desc.h;usbd_storage_if.h;usb_host.h;usbh_conf.h;stm32f2xx_it.h;stm32f2xx_hal_conf.h;mxconstants.h;
+HeaderPath=C:/Users/Michael/projects/SCSI2SD-V6/STM32CubeMX/SCSI2SD-V6/Inc
+SourcePath=C:/Users/Michael/projects/SCSI2SD-V6/STM32CubeMX/SCSI2SD-V6/Src
+SourceFiles=gpio.h;dma.h;ffconf.h;bsp_driver_sd.h;fatfs.h;fsmc.h;sdio.h;spi.h;tim.h;usart.h;usb_device.h;usbd_conf.h;usbd_desc.h;usbd_storage_if.h;usb_host.h;usbh_conf.h;stm32f2xx_it.h;stm32f2xx_hal_conf.h;mxconstants.h;gpio.c;dma.c;bsp_driver_sd.c;fatfs.c;fsmc.c;sdio.c;spi.c;tim.c;usart.c;usb_device.c;usbd_conf.c;usbd_desc.c;usbd_storage_if.c;usb_host.c;usbh_conf.c;stm32f2xx_it.c;stm32f2xx_hal_msp.c;main.c;sys.c;usb_otg_hs.c;
+HeaderFiles=gpio.h;dma.h;ffconf.h;bsp_driver_sd.h;fatfs.h;fsmc.h;sdio.h;spi.h;tim.h;usart.h;usb_device.h;usbd_conf.h;usbd_desc.h;usbd_storage_if.h;usb_host.h;usbh_conf.h;stm32f2xx_it.h;stm32f2xx_hal_conf.h;;sys.h;usb_otg_hs.h;mxconstants.h;
 
 [PreviousLibFiles]
-LibFiles=Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_gpio.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_gpio_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_dma_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_dma.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_pcd_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_pcd.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_ll_usb.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_hcd.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_ll_fsmc.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_sd.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_ll_sdmmc.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_spi.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_tim.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_tim_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_uart.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_def.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_rcc.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_rcc_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_cortex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_flash.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_flash_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_pwr.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_pwr_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_sram.h;Middlewares/Third_Party/FatFs/src/drivers/sd_diskio.h;Middlewares/Third_Party/FatFs/src/drivers/usbh_diskio.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h;Middlewares/ST/STM32_USB_Device_Library/Class/HID/Inc/usbd_hid.h;Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_core.h;Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_ctlreq.h;Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_def.h;Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_ioreq.h;Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_pipes.h;Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc/usbh_msc.h;Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc/usbh_msc_bot.h;Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc/usbh_msc_scsi.h;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_gpio.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_dma.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pcd_ex.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pcd.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_ll_usb.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_dma_ex.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_hcd.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_ll_fsmc.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_sd.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_ll_sdmmc.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_spi.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_tim.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_tim_ex.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_uart.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_flash.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_flash_ex.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_rcc.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_rcc_ex.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_cortex.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pwr.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pwr_ex.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_sram.c;Middlewares/Third_Party/FatFs/src/option/syscall.c;Middlewares/Third_Party/FatFs/src/option/ccsbcs.c;Middlewares/Third_Party/FatFs/src/drivers/sd_diskio.c;Middlewares/Third_Party/FatFs/src/drivers/usbh_diskio.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;Middlewares/ST/STM32_USB_Device_Library/Class/HID/Src/usbd_hid.c;Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_core.c;Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ctlreq.c;Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ioreq.c;Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_pipes.c;Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc.c;Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_bot.c;Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_scsi.c;Drivers/CMSIS/Device/ST/STM32F2xx/Source/Templates/system_stm32f2xx.c;Middlewares/Third_Party/FatFs/src/diskio.h;Middlewares/Third_Party/FatFs/src/ff.h;Middlewares/Third_Party/FatFs/src/ffconf_template.h;Middlewares/Third_Party/FatFs/src/ff_gen_drv.h;Middlewares/Third_Party/FatFs/src/integer.h;Middlewares/Third_Party/FatFs/src/diskio.c;Middlewares/Third_Party/FatFs/src/ff.c;Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/arm_math.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cmFunc.h;Drivers/CMSIS/Include/core_cmInstr.h;Drivers/CMSIS/Include/core_cmSimd.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Device/ST/STM32F2xx/Include/stm32f205xx.h;Drivers/CMSIS/Device/ST/STM32F2xx/Include/stm32f207xx.h;Drivers/CMSIS/Device/ST/STM32F2xx/Include/stm32f215xx.h;Drivers/CMSIS/Device/ST/STM32F2xx/Include/stm32f217xx.h;Drivers/CMSIS/Device/ST/STM32F2xx/Include/stm32f2xx.h;Drivers/CMSIS/Device/ST/STM32F2xx/Include/system_stm32f2xx.h;
+LibFiles=Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_gpio.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_gpio_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_dma_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_dma.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_pcd_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_pcd.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_ll_usb.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_def.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_rcc.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_rcc_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_cortex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_flash.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_flash_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_pwr.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_pwr_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_ll_fsmc.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_sram.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_sd.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_ll_sdmmc.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_spi.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_tim.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_tim_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_uart.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h;Middlewares/ST/STM32_USB_Device_Library/Class/HID/Inc/usbd_hid.h;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_gpio.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_dma.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pcd_ex.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pcd.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_ll_usb.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_flash.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_flash_ex.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_rcc.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_rcc_ex.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_cortex.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pwr.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pwr_ex.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_dma_ex.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_ll_fsmc.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_sram.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_sd.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_ll_sdmmc.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_spi.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_tim.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_tim_ex.c;Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_uart.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;Middlewares/ST/STM32_USB_Device_Library/Class/HID/Src/usbd_hid.c;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_gpio.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_gpio_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_dma_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_dma.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_pcd_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_pcd.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_ll_usb.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_def.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_rcc.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_rcc_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_cortex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_flash.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_flash_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_pwr.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_pwr_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_ll_fsmc.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_sram.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_sd.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_ll_sdmmc.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_spi.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_tim.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_tim_ex.h;Drivers/STM32F2xx_HAL_Driver/Inc/stm32f2xx_hal_uart.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h;Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h;Middlewares/ST/STM32_USB_Device_Library/Class/HID/Inc/usbd_hid.h;Drivers/CMSIS/Device/ST/STM32F2xx/Include/stm32f205xx.h;Drivers/CMSIS/Device/ST/STM32F2xx/Include/stm32f2xx.h;Drivers/CMSIS/Device/ST/STM32F2xx/Include/system_stm32f2xx.h;Drivers/CMSIS/Device/ST/STM32F2xx/Source/Templates/system_stm32f2xx.c;Drivers/CMSIS/Include/arm_common_tables.h;Drivers/CMSIS/Include/arm_const_structs.h;Drivers/CMSIS/Include/arm_math.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cmFunc.h;Drivers/CMSIS/Include/core_cmInstr.h;Drivers/CMSIS/Include/core_cmSimd.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_sc300.h;
 
 [PreviousUsedTStudioFiles]
-HeaderPath=..\Drivers\STM32F2xx_HAL_Driver\Inc;..\Drivers\STM32F2xx_HAL_Driver\Inc\Legacy;..\Middlewares\Third_Party\FatFs\src\drivers;..\Middlewares\ST\STM32_USB_Device_Library\Core\Inc;..\Middlewares\ST\STM32_USB_Device_Library\Class\HID\Inc;..\Middlewares\ST\STM32_USB_Host_Library\Core\Inc;..\Middlewares\ST\STM32_USB_Host_Library\Class\MSC\Inc;..\Middlewares\Third_Party\FatFs\src;..\Drivers\CMSIS\Include;..\Drivers\CMSIS\Device\ST\STM32F2xx\Include;
-SourceFiles=../Src/main.c;../Src/gpio.c;../Src/dma.c;../Src/bsp_driver_sd.c;../Src/fatfs.c;../Src/fsmc.c;../Src/sdio.c;../Src/spi.c;../Src/tim.c;../Src/usart.c;../Src/usb_device.c;../Src/usbd_conf.c;../Src/usbd_desc.c;../Src/usb_host.c;../Src/usbh_conf.c;../Src/stm32f2xx_it.c;../Src/stm32f2xx_hal_msp.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_gpio.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_dma.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pcd_ex.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pcd.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_ll_usb.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_dma_ex.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_hcd.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_ll_fsmc.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_sd.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_ll_sdmmc.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_spi.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_tim.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_tim_ex.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_uart.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_flash.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_flash_ex.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_rcc.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_rcc_ex.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_cortex.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pwr.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pwr_ex.c;../Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_sram.c;../Middlewares/Third_Party/FatFs/src/option/syscall.c;../Middlewares/Third_Party/FatFs/src/option/ccsbcs.c;../Middlewares/Third_Party/FatFs/src/drivers/sd_diskio.c;../Middlewares/Third_Party/FatFs/src/drivers/usbh_diskio.c;../Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;../Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;../Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;../Middlewares/ST/STM32_USB_Device_Library/Class/HID/Src/usbd_hid.c;../Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_core.c;../Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ctlreq.c;../Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ioreq.c;../Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_pipes.c;../Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc.c;../Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_bot.c;../Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_scsi.c;../Middlewares/Third_Party/FatFs/src/diskio.c;../Middlewares/Third_Party/FatFs/src/ff.c;../Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;../Drivers/CMSIS/Device/ST/STM32F2xx/Source/Templates/system_stm32f2xx.c;../Drivers/CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc/startup_stm32f205xx.s;../Middlewares/Third_Party/FatFs/src/option/syscall.c;../Middlewares/Third_Party/FatFs/src/option/ccsbcs.c;../Middlewares/Third_Party/FatFs/src/drivers/sd_diskio.c;../Middlewares/Third_Party/FatFs/src/drivers/usbh_diskio.c;../Middlewares/Third_Party/FatFs/src/diskio.c;../Middlewares/Third_Party/FatFs/src/ff.c;../Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;../Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;../Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;../Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;../Middlewares/ST/STM32_USB_Device_Library/Class/HID/Src/usbd_hid.c;../Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_core.c;../Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ctlreq.c;../Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ioreq.c;../Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_pipes.c;../Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc.c;../Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_bot.c;../Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_scsi.c;
+HeaderPath=..\Drivers\STM32F2xx_HAL_Driver\Inc;..\Drivers\STM32F2xx_HAL_Driver\Inc\Legacy;..\Middlewares\ST\STM32_USB_Device_Library\Core\Inc;..\Middlewares\ST\STM32_USB_Device_Library\Class\HID\Inc;..\Drivers\CMSIS\Device\ST\STM32F2xx\Include;..\Drivers\CMSIS\Include;..\Inc;
+SourceFiles=..\Src\main.c;..\Src\gpio.c;..\Src\dma.c;..\Src\fsmc.c;..\Src\sdio.c;..\Src\spi.c;..\Src\sys.c;..\Src\tim.c;..\Src\usart.c;..\Src\usb_device.c;..\Src\usbd_conf.c;..\Src\usbd_desc.c;..\Src\stm32f2xx_it.c;..\Src\stm32f2xx_hal_msp.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_gpio.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_dma.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pcd_ex.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pcd.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_ll_usb.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_flash.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_flash_ex.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_rcc.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_rcc_ex.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_cortex.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pwr.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pwr_ex.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_dma_ex.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_ll_fsmc.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_sram.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_sd.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_ll_sdmmc.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_spi.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_tim.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_tim_ex.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_uart.c;..\Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;..\Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;..\Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;..\Middlewares/ST/STM32_USB_Device_Library/Class/HID/Src/usbd_hid.c;..\\Src/system_stm32f2xx.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_gpio.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_dma.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pcd_ex.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pcd.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_ll_usb.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_flash.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_flash_ex.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_rcc.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_rcc_ex.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_cortex.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pwr.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pwr_ex.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_dma_ex.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_ll_fsmc.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_sram.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_sd.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_ll_sdmmc.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_spi.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_tim.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_tim_ex.c;..\Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_uart.c;..\Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;..\Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;..\Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;..\Middlewares/ST/STM32_USB_Device_Library/Class/HID/Src/usbd_hid.c;..\\Src/system_stm32f2xx.c;..\Drivers/CMSIS/Device/ST/STM32F2xx/Source/Templates/system_stm32f2xx.c;;..\Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c;..\Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c;..\Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c;..\Middlewares/ST/STM32_USB_Device_Library/Class/HID/Src/usbd_hid.c;
+CDefines=__weak:__attribute__((weak));__packed:__attribute__((__packed__));USE_HAL_DRIVER;STM32F205xx;USE_HAL_DRIVER;USE_HAL_DRIVER;
 
index 7312d0e343b159635b163f4c772f0276e8fdbe7f..4df41a0aac8160d65abc7ff2a03352b027b1d3c9 100755 (executable)
 
 /* Includes ------------------------------------------------------------------*/
 #include "stm32f2xx_hal.h"
+
 #ifdef HAL_SD_MODULE_ENABLED
 
 /** @addtogroup STM32F2xx_HAL_Driver
@@ -892,7 +893,7 @@ HAL_SD_ErrorTypedef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pRead
                                 SDIO_IT_STBITERR));
   
   /* Enable SDIO DMA transfer */
-  // MM disabled, as this fails on fast cards. __HAL_SD_SDIO_DMA_ENABLE();
+  __HAL_SD_SDIO_DMA_ENABLE();
   
   /* Configure DMA user callbacks */
   hsd->hdmarx->XferCpltCallback  = SD_DMA_RxCplt;
@@ -901,29 +902,26 @@ HAL_SD_ErrorTypedef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pRead
   /* Enable the DMA Stream */
   HAL_DMA_Start_IT(hsd->hdmarx, (uint32_t)&hsd->Instance->FIFO, (uint32_t)pReadBuffer, (uint32_t)(BlockSize * NumberOfBlocks)/4);
   
-  sdio_cmdinitstructure.Response         = SDIO_RESPONSE_SHORT;
-  sdio_cmdinitstructure.WaitForInterrupt = SDIO_WAIT_NO;
-  sdio_cmdinitstructure.CPSM             = SDIO_CPSM_ENABLE;
-  
   if (hsd->CardType == HIGH_CAPACITY_SD_CARD)
   {
     BlockSize = 512;
     ReadAddr /= 512;
-  } else {
+  }
   
-    /* Set Block Size for Card */ 
-    sdio_cmdinitstructure.Argument         = (uint32_t)BlockSize;
-    sdio_cmdinitstructure.CmdIndex         = SD_CMD_SET_BLOCKLEN;
-
-    SDIO_SendCommand(hsd->Instance, &sdio_cmdinitstructure);
+  /* Set Block Size for Card */ 
+  sdio_cmdinitstructure.Argument         = (uint32_t)BlockSize;
+  sdio_cmdinitstructure.CmdIndex         = SD_CMD_SET_BLOCKLEN;
+  sdio_cmdinitstructure.Response         = SDIO_RESPONSE_SHORT;
+  sdio_cmdinitstructure.WaitForInterrupt = SDIO_WAIT_NO;
+  sdio_cmdinitstructure.CPSM             = SDIO_CPSM_ENABLE;
+  SDIO_SendCommand(hsd->Instance, &sdio_cmdinitstructure);
   
-    /* Check for error conditions */
-    errorstate = SD_CmdResp1Error(hsd, SD_CMD_SET_BLOCKLEN);
+  /* Check for error conditions */
+  errorstate = SD_CmdResp1Error(hsd, SD_CMD_SET_BLOCKLEN);
   
-    if (errorstate != SD_OK)
-    {
-      return errorstate;
-    }
+  if (errorstate != SD_OK)
+  {
+    return errorstate;
   }
   
   /* Configure the SD DPSM (Data Path State Machine) */ 
@@ -933,11 +931,6 @@ HAL_SD_ErrorTypedef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pRead
   sdio_datainitstructure.TransferDir   = SDIO_TRANSFER_DIR_TO_SDIO;
   sdio_datainitstructure.TransferMode  = SDIO_TRANSFER_MODE_BLOCK;
   sdio_datainitstructure.DPSM          = SDIO_DPSM_ENABLE;
-
-  // We cannot enable DMA too early on UHS-I class 3 SD cards, or else the
-  // data is just discarded before the dpsm is started.
-  __HAL_SD_SDIO_DMA_ENABLE();
-
   SDIO_DataConfig(hsd->Instance, &sdio_datainitstructure);
   
   /* Check number of blocks command */
@@ -1024,30 +1017,28 @@ HAL_SD_ErrorTypedef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pWri
   HAL_DMA_Start_IT(hsd->hdmatx, (uint32_t)pWriteBuffer, (uint32_t)&hsd->Instance->FIFO, (uint32_t)(BlockSize * NumberOfBlocks)/4);
 
   /* Enable SDIO DMA transfer */
-  // MM disabled, as this fails on fast cards. __HAL_SD_SDIO_DMA_ENABLE();
-  
-  sdio_cmdinitstructure.Response         = SDIO_RESPONSE_SHORT;
-  sdio_cmdinitstructure.WaitForInterrupt = SDIO_WAIT_NO;
-  sdio_cmdinitstructure.CPSM             = SDIO_CPSM_ENABLE;
+  __HAL_SD_SDIO_DMA_ENABLE();
   
   if (hsd->CardType == HIGH_CAPACITY_SD_CARD)
   {
     BlockSize = 512;
     WriteAddr /= 512;
-  } else {
-       /* Set Block Size for Card */ 
-    sdio_cmdinitstructure.Argument         = (uint32_t)BlockSize;
-    sdio_cmdinitstructure.CmdIndex         = SD_CMD_SET_BLOCKLEN;
+  }
 
-    SDIO_SendCommand(hsd->Instance, &sdio_cmdinitstructure);
+  /* Set Block Size for Card */ 
+  sdio_cmdinitstructure.Argument         = (uint32_t)BlockSize;
+  sdio_cmdinitstructure.CmdIndex         = SD_CMD_SET_BLOCKLEN;
+  sdio_cmdinitstructure.Response         = SDIO_RESPONSE_SHORT;
+  sdio_cmdinitstructure.WaitForInterrupt = SDIO_WAIT_NO;
+  sdio_cmdinitstructure.CPSM             = SDIO_CPSM_ENABLE;
+  SDIO_SendCommand(hsd->Instance, &sdio_cmdinitstructure);
 
-    /* Check for error conditions */
-    errorstate = SD_CmdResp1Error(hsd, SD_CMD_SET_BLOCKLEN);
+  /* Check for error conditions */
+  errorstate = SD_CmdResp1Error(hsd, SD_CMD_SET_BLOCKLEN);
 
-    if (errorstate != SD_OK)
-    {
-      return errorstate;
-    }
+  if (errorstate != SD_OK)
+  {
+    return errorstate;
   }
   
   /* Check number of blocks command */
@@ -1058,34 +1049,13 @@ HAL_SD_ErrorTypedef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pWri
   }
   else
   {
-    /* MM: Prepare for write */
-    sdio_cmdinitstructure.Argument         = (uint32_t)(hsd->RCA << 16);
-    sdio_cmdinitstructure.CmdIndex         = SD_CMD_APP_CMD;
-    SDIO_SendCommand(hsd->Instance, &sdio_cmdinitstructure);
-    errorstate = SD_CmdResp1Error(hsd, SD_CMD_APP_CMD);
-    if (errorstate != SD_OK)
-    {
-      return errorstate;
-    }
-    sdio_cmdinitstructure.Argument         = (uint32_t)NumberOfBlocks;
-    sdio_cmdinitstructure.CmdIndex         = SD_CMD_SET_BLOCK_COUNT;
-    SDIO_SendCommand(hsd->Instance, &sdio_cmdinitstructure);
-    errorstate = SD_CmdResp1Error(hsd, SD_CMD_SET_BLOCK_COUNT);
-    if (errorstate != SD_OK)
-    {
-      return errorstate;
-    }
-  
-    /* /MM */
-
     /* Send CMD25 WRITE_MULT_BLOCK with argument data address */
     sdio_cmdinitstructure.CmdIndex = SD_CMD_WRITE_MULT_BLOCK;
   }
-
+  
   sdio_cmdinitstructure.Argument         = (uint32_t)WriteAddr;
   SDIO_SendCommand(hsd->Instance, &sdio_cmdinitstructure);
 
-
   /* Check for error conditions */
   if(NumberOfBlocks > 1)
   {
@@ -1108,11 +1078,6 @@ HAL_SD_ErrorTypedef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pWri
   sdio_datainitstructure.TransferDir   = SDIO_TRANSFER_DIR_TO_CARD;
   sdio_datainitstructure.TransferMode  = SDIO_TRANSFER_MODE_BLOCK;
   sdio_datainitstructure.DPSM          = SDIO_DPSM_ENABLE;
-
-  // We cannot enable DMA too early on UHS-I class 3 SD cards, or else the
-  // data is just discarded before the dpsm is started.
-  __HAL_SD_SDIO_DMA_ENABLE();
-
   SDIO_DataConfig(hsd->Instance, &sdio_datainitstructure);
   
   hsd->SdTransferErr = errorstate;
@@ -1151,9 +1116,7 @@ HAL_SD_ErrorTypedef HAL_SD_CheckReadOperation(SD_HandleTypeDef *hsd, uint32_t Ti
   
   timeout = Timeout;
   
-  /* Wait until the Rx transfer is no longer active. IE. fifo is empty.
-Once FIFO is empty, the DMA will have finished and DmaTransferCplt should
-be true */
+  /* Wait until the Rx transfer is no longer active */
   while((__HAL_SD_SDIO_GET_FLAG(hsd, SDIO_FLAG_RXACT)) && (timeout > 0))
   {
     timeout--;  
@@ -1953,12 +1916,10 @@ HAL_SD_ErrorTypedef HAL_SD_HighSpeed (SD_HandleTypeDef *hsd)
     __HAL_SD_SDIO_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS);
     
     /* Test if the switch mode HS is ok */
-    // MM: These bits (0 to 271) are reserved in the spec I'm looking at ???
-    // Should be safe to ignore the result.
-    //if ((SD_hs[13]& 2) != 2)
-    //{
-      //errorstate = SD_UNSUPPORTED_FEATURE;
-    //} 
+    if ((SD_hs[13]& 2) != 2)
+    {
+      errorstate = SD_UNSUPPORTED_FEATURE;
+    } 
   }
   
   return errorstate;
diff --git a/STM32CubeMX/SCSI2SD-V6/Inc/bsp_driver_sd.h b/STM32CubeMX/SCSI2SD-V6/Inc/bsp_driver_sd.h
deleted file mode 100755 (executable)
index 49a0a50..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- ******************************************************************************
-  * @file    bsp_driver_sd.h (based on stm324x9i_eval_sd.h)
-  * @brief   This file contains the common defines and functions prototypes for 
-  *          the bsp_driver_sd.c driver.
-  ******************************************************************************
-  *
-  * COPYRIGHT(c) 2016 STMicroelectronics
-  *
-  * Redistribution and use in source and binary forms, with or without modification,
-  * are permitted provided that the following conditions are met:
-  *   1. Redistributions of source code must retain the above copyright notice,
-  *      this list of conditions and the following disclaimer.
-  *   2. Redistributions in binary form must reproduce the above copyright notice,
-  *      this list of conditions and the following disclaimer in the documentation
-  *      and/or other materials provided with the distribution.
-  *   3. Neither the name of STMicroelectronics nor the names of its contributors
-  *      may be used to endorse or promote products derived from this software
-  *      without specific prior written permission.
-  *
-  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-  *
-  ******************************************************************************
-  */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __STM32F2XX_SD_H
-#define __STM32F2XX_SD_H
-
-#ifdef __cplusplus
- extern "C" {
-#endif 
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32f2xx_hal.h"
-
-/* Exported constants --------------------------------------------------------*/ 
-
-/** 
-  * @brief  SD status structure definition  
-  */     
-#define   MSD_OK         0x00
-#define   MSD_ERROR      0x01
-#ifndef SD_CardInfo
-  #define SD_CardInfo HAL_SD_CardInfoTypedef
-#endif
-  
-/** @defgroup STM324x9I_EVAL_SD_Exported_Constants
-  * @{
-  */ 
-#define SD_DATATIMEOUT           ((uint32_t)0xFFFFFFFF)
-
-#define SD_PRESENT               ((uint8_t)0x01)
-#define SD_NOT_PRESENT           ((uint8_t)0x00)
-
-/* USER CODE BEGIN 0 */ 
-   
-/* DMA definitions for SD DMA transfer */
-/*
-#define __DMAx_TxRx_CLK_ENABLE            __DMA2_CLK_ENABLE
-#define SD_DMAx_Tx_CHANNEL                DMA_CHANNEL_4
-#define SD_DMAx_Rx_CHANNEL                DMA_CHANNEL_4
-#define SD_DMAx_Tx_STREAM                 DMA2_Stream6  
-#define SD_DMAx_Rx_STREAM                 DMA2_Stream3  
-#define SD_DMAx_Tx_IRQn                   DMA2_Stream6_IRQn
-#define SD_DMAx_Rx_IRQn                   DMA2_Stream3_IRQn
-#define SD_DMAx_Tx_IRQHandler             DMA2_Stream6_IRQHandler   
-#define SD_DMAx_Rx_IRQHandler             DMA2_Stream3_IRQHandler  
-*/
-
-/* Exported functions --------------------------------------------------------*/   
-uint8_t BSP_SD_Init(void);
-uint8_t BSP_SD_ITConfig(void);
-void BSP_SD_DetectIT(void);
-__weak void BSP_SD_DetectCallback(void);
-uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
-uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
-uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
-uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
-uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr);
-void BSP_SD_IRQHandler(void);
-void BSP_SD_DMA_Tx_IRQHandler(void);
-void BSP_SD_DMA_Rx_IRQHandler(void);
-HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void);
-void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo);
-uint8_t BSP_SD_IsDetected(void);
-/* USER CODE END 0 */ 
-   
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __STM32F2XX_SD_H */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
index c899300dbef0ec1c421d63560d372acaa7edba42..ef23c94f0f01f5f0f80b9da501907bc2af22f051 100755 (executable)
@@ -5,7 +5,7 @@
   ******************************************************************************
   * @attention
   *
-  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
+  * <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
   *
   * Redistribution and use in source and binary forms, with or without modification,
   * are permitted provided that the following conditions are met:
@@ -76,7 +76,7 @@
 //#define HAL_SMARTCARD_MODULE_ENABLED   
 //#define HAL_WWDG_MODULE_ENABLED   
 #define HAL_PCD_MODULE_ENABLED
-#define HAL_HCD_MODULE_ENABLED
+//#define HAL_HCD_MODULE_ENABLED   
 #define HAL_GPIO_MODULE_ENABLED
 #define HAL_DMA_MODULE_ENABLED
 #define HAL_RCC_MODULE_ENABLED
index 4c7075abee39ce7cfc2310469f2fecbc5e225536..a2efe1f724387a22bc3b07362b4b52a9b52847b2 100755 (executable)
@@ -4,7 +4,7 @@
   * @brief   This file contains the headers of the interrupt handlers.
   ******************************************************************************
   *
-  * COPYRIGHT(c) 2016 STMicroelectronics
+  * COPYRIGHT(c) 2019 STMicroelectronics
   *
   * Redistribution and use in source and binary forms, with or without modification,
   * are permitted provided that the following conditions are met:
 /* Exported functions ------------------------------------------------------- */
 
 void SysTick_Handler(void);
-void EXTI3_IRQHandler(void);
 void EXTI4_IRQHandler(void);
 void SDIO_IRQHandler(void);
 void DMA2_Stream3_IRQHandler(void);
 void OTG_FS_IRQHandler(void);
 void DMA2_Stream6_IRQHandler(void);
-void OTG_HS_IRQHandler(void);
 
 #ifdef __cplusplus
 }
index b490328d1862d0318cc28d2cd0796adace70597f..3516c750e56732654dc38b5c13a3a22910534f1e 100755 (executable)
@@ -1,5 +1,4 @@
 #MicroXplorer Configuration settings - do not modify
-Dma.MEMTOMEM.0.Channel=DMA_CHANNEL_0
 Dma.MEMTOMEM.0.Direction=DMA_MEMORY_TO_MEMORY
 Dma.MEMTOMEM.0.FIFOMode=DMA_FIFOMODE_ENABLE
 Dma.MEMTOMEM.0.FIFOThreshold=DMA_FIFO_THRESHOLD_FULL
@@ -12,8 +11,7 @@ Dma.MEMTOMEM.0.PeriphBurst=DMA_PBURST_INC4
 Dma.MEMTOMEM.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD
 Dma.MEMTOMEM.0.PeriphInc=DMA_PINC_ENABLE
 Dma.MEMTOMEM.0.Priority=DMA_PRIORITY_LOW
-Dma.MEMTOMEM.0.RequestParameters=Instance,Channel,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst
-Dma.MEMTOMEM.1.Channel=DMA_CHANNEL_0
+Dma.MEMTOMEM.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst
 Dma.MEMTOMEM.1.Direction=DMA_MEMORY_TO_MEMORY
 Dma.MEMTOMEM.1.FIFOMode=DMA_FIFOMODE_ENABLE
 Dma.MEMTOMEM.1.FIFOThreshold=DMA_FIFO_THRESHOLD_FULL
@@ -26,13 +24,12 @@ Dma.MEMTOMEM.1.PeriphBurst=DMA_PBURST_INC8
 Dma.MEMTOMEM.1.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD
 Dma.MEMTOMEM.1.PeriphInc=DMA_PINC_DISABLE
 Dma.MEMTOMEM.1.Priority=DMA_PRIORITY_LOW
-Dma.MEMTOMEM.1.RequestParameters=Instance,Channel,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst
+Dma.MEMTOMEM.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst
 Dma.Request0=MEMTOMEM
 Dma.Request1=MEMTOMEM
 Dma.Request2=SDIO_TX
 Dma.Request3=SDIO_RX
 Dma.RequestsNb=4
-Dma.SDIO_RX.3.Channel=DMA_CHANNEL_4
 Dma.SDIO_RX.3.Direction=DMA_PERIPH_TO_MEMORY
 Dma.SDIO_RX.3.FIFOMode=DMA_FIFOMODE_ENABLE
 Dma.SDIO_RX.3.FIFOThreshold=DMA_FIFO_THRESHOLD_FULL
@@ -40,13 +37,12 @@ Dma.SDIO_RX.3.Instance=DMA2_Stream6
 Dma.SDIO_RX.3.MemBurst=DMA_MBURST_INC4
 Dma.SDIO_RX.3.MemDataAlignment=DMA_MDATAALIGN_WORD
 Dma.SDIO_RX.3.MemInc=DMA_MINC_ENABLE
-Dma.SDIO_RX.3.Mode=DMA_NORMAL
+Dma.SDIO_RX.3.Mode=DMA_PFCTRL
 Dma.SDIO_RX.3.PeriphBurst=DMA_PBURST_INC4
 Dma.SDIO_RX.3.PeriphDataAlignment=DMA_PDATAALIGN_WORD
 Dma.SDIO_RX.3.PeriphInc=DMA_PINC_DISABLE
-Dma.SDIO_RX.3.Priority=DMA_PRIORITY_LOW
-Dma.SDIO_RX.3.RequestParameters=Instance,Channel,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst
-Dma.SDIO_TX.2.Channel=DMA_CHANNEL_4
+Dma.SDIO_RX.3.Priority=DMA_PRIORITY_VERY_HIGH
+Dma.SDIO_RX.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst
 Dma.SDIO_TX.2.Direction=DMA_MEMORY_TO_PERIPH
 Dma.SDIO_TX.2.FIFOMode=DMA_FIFOMODE_ENABLE
 Dma.SDIO_TX.2.FIFOThreshold=DMA_FIFO_THRESHOLD_FULL
@@ -54,36 +50,33 @@ Dma.SDIO_TX.2.Instance=DMA2_Stream3
 Dma.SDIO_TX.2.MemBurst=DMA_MBURST_INC4
 Dma.SDIO_TX.2.MemDataAlignment=DMA_MDATAALIGN_WORD
 Dma.SDIO_TX.2.MemInc=DMA_MINC_ENABLE
-Dma.SDIO_TX.2.Mode=DMA_NORMAL
+Dma.SDIO_TX.2.Mode=DMA_PFCTRL
 Dma.SDIO_TX.2.PeriphBurst=DMA_PBURST_INC4
 Dma.SDIO_TX.2.PeriphDataAlignment=DMA_PDATAALIGN_WORD
 Dma.SDIO_TX.2.PeriphInc=DMA_PINC_DISABLE
-Dma.SDIO_TX.2.Priority=DMA_PRIORITY_LOW
-Dma.SDIO_TX.2.RequestParameters=Instance,Channel,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst
-FSMC.AddressHoldTime1=2
-FSMC.AddressSetupTime1=3
-FSMC.BusTurnAroundDuration1=0
-FSMC.DataSetupTime1=5
+Dma.SDIO_TX.2.Priority=DMA_PRIORITY_VERY_HIGH
+Dma.SDIO_TX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst
+FSMC.AddressHoldTime1=1
+FSMC.AddressSetupTime1=2
+FSMC.BusTurnAroundDuration1=1
+FSMC.DataSetupTime1=4
 FSMC.IPParameters=WriteOperation1,AddressSetupTime1,AddressHoldTime1,DataSetupTime1,BusTurnAroundDuration1
 FSMC.WriteOperation1=FSMC_WRITE_OPERATION_ENABLE
-File.Version=5
+File.Version=6
 KeepUserPlacement=true
 Mcu.Family=STM32F2
 Mcu.IP0=DMA
-Mcu.IP1=FATFS
-Mcu.IP10=USB_DEVICE
-Mcu.IP11=USB_HOST
-Mcu.IP12=USB_OTG_FS
-Mcu.IP13=USB_OTG_HS
-Mcu.IP2=FSMC
-Mcu.IP3=NVIC
-Mcu.IP4=RCC
-Mcu.IP5=SDIO
-Mcu.IP6=SPI1
-Mcu.IP7=SYS
-Mcu.IP8=TIM4
-Mcu.IP9=USART3
-Mcu.IPNb=14
+Mcu.IP1=FSMC
+Mcu.IP10=USB_OTG_FS
+Mcu.IP2=NVIC
+Mcu.IP3=RCC
+Mcu.IP4=SDIO
+Mcu.IP5=SPI1
+Mcu.IP6=SYS
+Mcu.IP7=TIM4
+Mcu.IP8=USART3
+Mcu.IP9=USB_DEVICE
+Mcu.IPNb=11
 Mcu.Name=STM32F205V(B-C-E-F-G)Tx
 Mcu.Package=LQFP100
 Mcu.Pin0=PE2
@@ -111,69 +104,78 @@ Mcu.Pin28=PE8
 Mcu.Pin29=PE9
 Mcu.Pin3=PE5
 Mcu.Pin30=PE10
-Mcu.Pin31=PB10
-Mcu.Pin32=PB11
-Mcu.Pin33=PB12
-Mcu.Pin34=PB13
-Mcu.Pin35=PB14
-Mcu.Pin36=PB15
-Mcu.Pin37=PD11
-Mcu.Pin38=PD12
-Mcu.Pin39=PD13
+Mcu.Pin31=PE11
+Mcu.Pin32=PE12
+Mcu.Pin33=PE13
+Mcu.Pin34=PE14
+Mcu.Pin35=PE15
+Mcu.Pin36=PB10
+Mcu.Pin37=PB11
+Mcu.Pin38=PB12
+Mcu.Pin39=PB13
 Mcu.Pin4=PE6
-Mcu.Pin40=PD14
-Mcu.Pin41=PD15
-Mcu.Pin42=PC6
-Mcu.Pin43=PC7
-Mcu.Pin44=PC8
-Mcu.Pin45=PC9
-Mcu.Pin46=PA8
-Mcu.Pin47=PA9
-Mcu.Pin48=PA11
-Mcu.Pin49=PA12
+Mcu.Pin40=PB14
+Mcu.Pin41=PB15
+Mcu.Pin42=PD8
+Mcu.Pin43=PD9
+Mcu.Pin44=PD10
+Mcu.Pin45=PD11
+Mcu.Pin46=PD12
+Mcu.Pin47=PD13
+Mcu.Pin48=PD14
+Mcu.Pin49=PD15
 Mcu.Pin5=PC13
-Mcu.Pin50=PA13
-Mcu.Pin51=PA14
-Mcu.Pin52=PA15
-Mcu.Pin53=PC10
-Mcu.Pin54=PC11
-Mcu.Pin55=PC12
-Mcu.Pin56=PD0
-Mcu.Pin57=PD1
-Mcu.Pin58=PD2
-Mcu.Pin59=PD3
+Mcu.Pin50=PC6
+Mcu.Pin51=PC7
+Mcu.Pin52=PC8
+Mcu.Pin53=PC9
+Mcu.Pin54=PA8
+Mcu.Pin55=PA9
+Mcu.Pin56=PA10
+Mcu.Pin57=PA11
+Mcu.Pin58=PA12
+Mcu.Pin59=PA13
 Mcu.Pin6=PC14-OSC32_IN
-Mcu.Pin60=PD4
-Mcu.Pin61=PD5
-Mcu.Pin62=PD7
-Mcu.Pin63=PB3
-Mcu.Pin64=PB4
-Mcu.Pin65=PB5
-Mcu.Pin66=PB6
-Mcu.Pin67=PB7
-Mcu.Pin68=PB8
-Mcu.Pin69=PB9
+Mcu.Pin60=PA14
+Mcu.Pin61=PA15
+Mcu.Pin62=PC10
+Mcu.Pin63=PC11
+Mcu.Pin64=PC12
+Mcu.Pin65=PD0
+Mcu.Pin66=PD1
+Mcu.Pin67=PD2
+Mcu.Pin68=PD3
+Mcu.Pin69=PD4
 Mcu.Pin7=PC15-OSC32_OUT
-Mcu.Pin70=VP_FATFS_VS_SDIO
-Mcu.Pin71=VP_FATFS_VS_USB
-Mcu.Pin72=VP_TIM4_VS_ControllerModeClock
-Mcu.Pin73=VP_USB_DEVICE_VS_USB_DEVICE_HID_FS
-Mcu.Pin74=VP_USB_HOST_VS_USB_HOST_MSC_HS
+Mcu.Pin70=PD5
+Mcu.Pin71=PD7
+Mcu.Pin72=PB3
+Mcu.Pin73=PB4
+Mcu.Pin74=PB5
+Mcu.Pin75=PB6
+Mcu.Pin76=PB7
+Mcu.Pin77=PB8
+Mcu.Pin78=PB9
+Mcu.Pin79=PE0
 Mcu.Pin8=PH0-OSC_IN
+Mcu.Pin80=PE1
+Mcu.Pin81=VP_TIM4_VS_ControllerModeClock
+Mcu.Pin82=VP_USB_DEVICE_VS_USB_DEVICE_HID_FS
 Mcu.Pin9=PH1-OSC_OUT
-Mcu.PinsNb=75
+Mcu.PinsNb=83
+Mcu.ThirdPartyNb=0
 Mcu.UserConstants=
 Mcu.UserName=STM32F205VCTx
 MxCube.Version=4.11.0
 MxDb.Version=DB.4.0.110
-NVIC.DMA2_Stream3_IRQn=true\:0\:0\:false
-NVIC.DMA2_Stream6_IRQn=true\:0\:0\:false
-NVIC.EXTI4_IRQn=true\:10\:0\:true
-NVIC.OTG_FS_IRQn=true\:0\:0\:false
-NVIC.OTG_HS_IRQn=true\:0\:0\:false
+NVIC.DMA2_Stream3_IRQn=true\:0\:0\:false\:false\:true\:true\:true
+NVIC.DMA2_Stream6_IRQn=true\:0\:0\:false\:false\:true\:true\:true
+NVIC.EXTI4_IRQn=true\:10\:0\:true\:false\:true\:true\:true
+NVIC.ForceEnableDMAVector=true
+NVIC.OTG_FS_IRQn=true\:0\:0\:false\:false\:true\:true\:true
 NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
-NVIC.SDIO_IRQn=true\:0\:0\:false
-NVIC.SysTick_IRQn=true\:0\:0\:false
+NVIC.SDIO_IRQn=true\:0\:0\:true\:false\:true\:true\:true
+NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:true\:true
 PA0-WKUP.GPIOParameters=GPIO_PuPd,GPIO_Label
 PA0-WKUP.GPIO_Label=UNUSED_PA0
 PA0-WKUP.GPIO_PuPd=GPIO_PULLDOWN
@@ -184,6 +186,10 @@ PA1.GPIO_Label=UNUSED_PA1
 PA1.GPIO_PuPd=GPIO_PULLDOWN
 PA1.Locked=true
 PA1.Signal=GPIO_Input
+PA10.GPIOParameters=GPIO_PuPd
+PA10.GPIO_PuPd=GPIO_PULLDOWN
+PA10.Locked=true
+PA10.Signal=GPIO_Input
 PA11.Mode=Device_Only
 PA11.Signal=USB_OTG_FS_DM
 PA12.Mode=Device_Only
@@ -204,12 +210,10 @@ PA3.GPIO_Label=UNUSED_PA3
 PA3.GPIO_PuPd=GPIO_PULLDOWN
 PA3.Locked=true
 PA3.Signal=GPIO_Input
-PA4.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_Mode
+PA4.GPIOParameters=GPIO_Label
 PA4.GPIO_Label=nSPICFG_CS
-PA4.GPIO_Mode=GPIO_MODE_INPUT
-PA4.GPIO_PuPd=GPIO_NOPULL
 PA4.Locked=true
-PA4.Signal=GPIO_Input
+PA4.Signal=GPIO_Output
 PA5.Mode=Full_Duplex_Master
 PA5.Signal=SPI1_SCK
 PA6.Mode=Full_Duplex_Master
@@ -249,26 +253,37 @@ PB13.GPIO_Label=UNUSED_PB13
 PB13.GPIO_PuPd=GPIO_PULLDOWN
 PB13.Locked=true
 PB13.Signal=GPIO_Input
-PB14.Mode=Host_FS
-PB14.Signal=USB_OTG_HS_DM
-PB15.Mode=Host_FS
-PB15.Signal=USB_OTG_HS_DP
-PB2.GPIOParameters=GPIO_Label
+PB14.GPIOParameters=GPIO_PuPd,GPIO_Mode
+PB14.GPIO_Mode=GPIO_MODE_INPUT
+PB14.GPIO_PuPd=GPIO_PULLDOWN
+PB14.Locked=true
+PB14.Signal=GPIO_Input
+PB15.GPIOParameters=GPIO_PuPd,GPIO_Mode
+PB15.GPIO_Mode=GPIO_MODE_INPUT
+PB15.GPIO_PuPd=GPIO_PULLDOWN
+PB15.Locked=true
+PB15.Signal=GPIO_Input
+PB2.GPIOParameters=GPIO_PuPd,GPIO_Label
 PB2.GPIO_Label=BOOT1
+PB2.GPIO_PuPd=GPIO_PULLDOWN
 PB2.Locked=true
 PB2.Signal=GPIO_Input
 PB3.Mode=JTAG(5-pin)
 PB3.Signal=SYS_JTDO-SWO
 PB4.Mode=JTAG(5-pin)
 PB4.Signal=SYS_JTRST
-PB5.GPIOParameters=GPIO_Label
+PB5.GPIOParameters=GPIO_PuPd,GPIO_Label
 PB5.GPIO_Label=UNUSED_PB5
+PB5.GPIO_PuPd=GPIO_PULLDOWN
 PB5.Locked=true
 PB5.Signal=GPIO_Input
-PB6.GPIOParameters=GPIO_Label
+PB6.GPIOParameters=GPIO_PuPd,GPIO_Label
 PB6.GPIO_Label=UNUSED_PB6
+PB6.GPIO_PuPd=GPIO_PULLDOWN
 PB6.Locked=true
 PB6.Signal=GPIO_Input
+PB7.GPIOParameters=GPIO_Speed_High_Default
+PB7.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
 PB7.Signal=FSMC_NL
 PB8.GPIOParameters=GPIO_PuPd,GPIO_Label
 PB8.GPIO_Label=nSD_WP
@@ -290,8 +305,12 @@ PC1.GPIO_Label=UNUSED_PC1
 PC1.GPIO_PuPd=GPIO_PULLDOWN
 PC1.Locked=true
 PC1.Signal=GPIO_Input
+PC10.GPIOParameters=GPIO_PuPd
+PC10.GPIO_PuPd=GPIO_PULLUP
 PC10.Mode=SD_4_bits_Wide_bus
 PC10.Signal=SDIO_D2
+PC11.GPIOParameters=GPIO_PuPd
+PC11.GPIO_PuPd=GPIO_PULLUP
 PC11.Mode=SD_4_bits_Wide_bus
 PC11.Signal=SDIO_D3
 PC12.Mode=SD_4_bits_Wide_bus
@@ -341,38 +360,26 @@ PC7.GPIO_Label=nFGPA_CDONE
 PC7.GPIO_PuPd=GPIO_NOPULL
 PC7.Locked=true
 PC7.Signal=GPIO_Input
+PC8.GPIOParameters=GPIO_PuPd
+PC8.GPIO_PuPd=GPIO_PULLUP
 PC8.Mode=SD_4_bits_Wide_bus
 PC8.Signal=SDIO_D0
+PC9.GPIOParameters=GPIO_PuPd
+PC9.GPIO_PuPd=GPIO_PULLUP
 PC9.Mode=SD_4_bits_Wide_bus
 PC9.Signal=SDIO_D1
-PCC.Checker=false
-PCC.Line=STM32F2x5
-PCC.MCU=STM32F205V(B-C-E-F-G)Tx
-PCC.MXVersion=4.11.0
-PCC.PartNumber=STM32F205VCTx
-PCC.Seq0=1
-PCC.Seq0.Step0.Average_Current=39.68 mA
-PCC.Seq0.Step0.CPU_Frequency=120.0 MHz
-PCC.Seq0.Step0.Category=Datasheet
-PCC.Seq0.Step0.DMIPS=150.0
-PCC.Seq0.Step0.Duration=30 s
-PCC.Seq0.Step0.Frequency=4.0 MHz
-PCC.Seq0.Step0.Memory=RAM/FLASH/ART
-PCC.Seq0.Step0.Mode=RUN
-PCC.Seq0.Step0.Oscillator=HSE PLL
-PCC.Seq0.Step0.Peripherals=DMA1 DMA2 FSMC GPIOA GPIOB GPIOC GPIOD GPIOE GPIOH SDIO SPI1 USB_OTG_FS USB_OTG_HS
-PCC.Seq0.Step0.TaMax=98.98
-PCC.Seq0.Step0.User's_Consumption=0 mA
-PCC.Seq0.Step0.Vcore=No-Scale
-PCC.Seq0.Step0.Vdd=3.3
-PCC.Seq0.Step0.Voltage_Source=Vbus
-PCC.Series=STM32F2
-PCC.Temperature=25
-PCC.Vdd=3.3
-PD0.Mode=8b-da1
+PD0.GPIOParameters=GPIO_Speed_High_Default
+PD0.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
+PD0.Mode=16b-da1
 PD0.Signal=FSMC_DA2
-PD1.Mode=8b-da1
+PD1.GPIOParameters=GPIO_Speed_High_Default
+PD1.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
+PD1.Mode=16b-da1
 PD1.Signal=FSMC_DA3
+PD10.GPIOParameters=GPIO_Speed_High_Default
+PD10.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
+PD10.Mode=16b-da1
+PD10.Signal=FSMC_DA15
 PD11.GPIOParameters=GPIO_PuPd,GPIO_Label
 PD11.GPIO_Label=UNUSED_PD11
 PD11.GPIO_PuPd=GPIO_PULLDOWN
@@ -385,10 +392,16 @@ PD13.GPIO_Label=FPGA_RST
 PD13.GPIO_PuPd=GPIO_NOPULL
 PD13.Locked=true
 PD13.Signal=GPIO_Output
-PD14.Mode=8b-da1
+PD14.GPIOParameters=GPIO_Speed_High_Default
+PD14.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
+PD14.Mode=16b-da1
 PD14.Signal=FSMC_DA0
-PD15.Mode=8b-da1
+PD15.GPIOParameters=GPIO_Speed_High_Default
+PD15.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
+PD15.Mode=16b-da1
 PD15.Signal=FSMC_DA1
+PD2.GPIOParameters=GPIO_PuPd
+PD2.GPIO_PuPd=GPIO_PULLUP
 PD2.Mode=SD_4_bits_Wide_bus
 PD2.Signal=SDIO_CMD
 PD3.GPIOParameters=GPIO_PuPd,GPIO_Label
@@ -396,14 +409,58 @@ PD3.GPIO_Label=FSMC_UNUSED_CLK
 PD3.GPIO_PuPd=GPIO_PULLDOWN
 PD3.Locked=true
 PD3.Signal=GPIO_Input
+PD4.GPIOParameters=GPIO_Speed_High_Default
+PD4.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
 PD4.Mode=MuxedPsram1
 PD4.Signal=FSMC_NOE
+PD5.GPIOParameters=GPIO_Speed_High_Default
+PD5.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
 PD5.Mode=MuxedPsram1
 PD5.Signal=FSMC_NWE
+PD7.GPIOParameters=GPIO_Speed_High_Default
+PD7.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
 PD7.Mode=NorPsramChipSelect1_1
 PD7.Signal=FSMC_NE1
-PE10.Mode=8b-da1
+PD8.GPIOParameters=GPIO_Speed_High_Default
+PD8.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
+PD8.Mode=16b-da1
+PD8.Signal=FSMC_DA13
+PD9.GPIOParameters=GPIO_Speed_High_Default
+PD9.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
+PD9.Mode=16b-da1
+PD9.Signal=FSMC_DA14
+PE0.GPIOParameters=GPIO_Speed_High_Default
+PE0.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
+PE0.Mode=2ByteEnable1
+PE0.Signal=FSMC_NBL0
+PE1.GPIOParameters=GPIO_Speed_High_Default
+PE1.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
+PE1.Mode=2ByteEnable1
+PE1.Signal=FSMC_NBL1
+PE10.GPIOParameters=GPIO_Speed_High_Default
+PE10.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
+PE10.Mode=16b-da1
 PE10.Signal=FSMC_DA7
+PE11.GPIOParameters=GPIO_Speed_High_Default
+PE11.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
+PE11.Mode=16b-da1
+PE11.Signal=FSMC_DA8
+PE12.GPIOParameters=GPIO_Speed_High_Default
+PE12.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
+PE12.Mode=16b-da1
+PE12.Signal=FSMC_DA9
+PE13.GPIOParameters=GPIO_Speed_High_Default
+PE13.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
+PE13.Mode=16b-da1
+PE13.Signal=FSMC_DA10
+PE14.GPIOParameters=GPIO_Speed_High_Default
+PE14.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
+PE14.Mode=16b-da1
+PE14.Signal=FSMC_DA11
+PE15.GPIOParameters=GPIO_Speed_High_Default
+PE15.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
+PE15.Mode=16b-da1
+PE15.Signal=FSMC_DA12
 PE2.GPIOParameters=GPIO_PuPd,GPIO_Label
 PE2.GPIO_Label=FPGA_GPIO2
 PE2.GPIO_PuPd=GPIO_PULLDOWN
@@ -411,7 +468,7 @@ PE2.Locked=true
 PE2.Signal=GPIO_Input
 PE3.GPIOParameters=GPIO_PuPd,GPIO_Label
 PE3.GPIO_Label=FPGA_GPIO3
-PE3.GPIO_PuPd=GPIO_PULLDOWN
+PE3.GPIO_PuPd=GPIO_NOPULL
 PE3.Locked=true
 PE3.Signal=GPIO_Input
 PE4.Locked=true
@@ -426,34 +483,50 @@ PE6.GPIO_Label=UNUSED_PE6
 PE6.GPIO_PuPd=GPIO_PULLDOWN
 PE6.Locked=true
 PE6.Signal=GPIO_Input
-PE7.Mode=8b-da1
+PE7.GPIOParameters=GPIO_Speed_High_Default
+PE7.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
+PE7.Mode=16b-da1
 PE7.Signal=FSMC_DA4
-PE8.Mode=8b-da1
+PE8.GPIOParameters=GPIO_Speed_High_Default
+PE8.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
+PE8.Mode=16b-da1
 PE8.Signal=FSMC_DA5
-PE9.Mode=8b-da1
+PE9.GPIOParameters=GPIO_Speed_High_Default
+PE9.GPIO_Speed_High_Default=GPIO_SPEED_MEDIUM
+PE9.Mode=16b-da1
 PE9.Signal=FSMC_DA6
 PH0-OSC_IN.Mode=HSE-External-Oscillator
 PH0-OSC_IN.Signal=RCC_OSC_IN
 PH1-OSC_OUT.Mode=HSE-External-Oscillator
 PH1-OSC_OUT.Signal=RCC_OSC_OUT
-ProjectManager.AskForMigrate=true
+PinOutPanel.RotationAngle=0
+ProjectManager.AskForMigrate=false
 ProjectManager.BackupPrevious=false
 ProjectManager.CompilerOptimize=2
 ProjectManager.ComputerToolchain=false
 ProjectManager.CoupleFile=true
+ProjectManager.CustomerFirmwarePackage=
+ProjectManager.DefaultFWLocation=true
 ProjectManager.DeletePrevious=true
 ProjectManager.DeviceId=STM32F205VCTx
 ProjectManager.FirmwarePackage=STM32Cube FW_F2 V1.2.0
 ProjectManager.FreePins=true
 ProjectManager.HalAssertFull=false
+ProjectManager.HeapSize=0x200
 ProjectManager.KeepUserCode=true
 ProjectManager.LastFirmware=true
 ProjectManager.LibraryCopy=0
+ProjectManager.MainLocation=Src
+ProjectManager.NoMain=false
+ProjectManager.PreviousToolchain=
 ProjectManager.ProjectBuild=false
 ProjectManager.ProjectFileName=SCSI2SD-V6.ioc
 ProjectManager.ProjectName=SCSI2SD-V6
+ProjectManager.StackSize=0x400
 ProjectManager.TargetToolchain=TrueSTUDIO
 ProjectManager.ToolChainLocation=
+ProjectManager.UnderRoot=false
+ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_FSMC_Init-FSMC-false-HAL-true,5-MX_SDIO_SD_Init-SDIO-false-HAL-true,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_TIM4_Init-TIM4-false-HAL-true,8-MX_USART3_UART_Init-USART3-false-HAL-true,9-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false
 RCC.48MHZClocksFreq_Value=48000000
 RCC.AHBFreq_Value=108000000
 RCC.APB1CLKDivider=RCC_HCLK_DIV4
@@ -470,7 +543,7 @@ RCC.HCLKFreq_Value=108000000
 RCC.HSE_VALUE=20000000
 RCC.HSI_VALUE=16000000
 RCC.I2SClocksFreq_Value=96000000
-RCC.IPParameters=FamilyName,LSE_VALUE,HSI_VALUE,SYSCLKFreq_VALUE,AHBFreq_Value,CortexFreq_Value,APB1Freq_Value,APB2Freq_Value,HSE_VALUE,RTCHSEDivFreq_Value,LSI_VALUE,RTCFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,PLLCLKFreq_Value,48MHZClocksFreq_Value,VCOI2SOutputFreq_Value,VcooutputI2S,I2SClocksFreq_Value,RCC_MCO1Source,HCLKFreq_Value,FCLKCortexFreq_Value,APB1TimFreq_Value,APB2TimFreq_Value,EthernetFreq_Value,MCO2PinFreq_Value,APB1CLKDivider,APB2CLKDivider,MCO1PinFreq_Value,SYSCLKSource,PLLM,PLLN,PLLQ,PLLP
+RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLM,PLLN,PLLP,PLLQ,RCC_MCO1Source,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VcooutputI2S
 RCC.LSE_VALUE=32768
 RCC.LSI_VALUE=32000
 RCC.MCO1PinFreq_Value=108000000
@@ -489,41 +562,30 @@ RCC.VCOI2SOutputFreq_Value=192000000
 RCC.VCOInputFreq_Value=1000000
 RCC.VCOOutputFreq_Value=432000000
 RCC.VcooutputI2S=96000000
-SDIO.BusWide=SDIO_BUS_WIDE_1B
-SDIO.IPParameters=BusWide,WideMode
-SDIO.WideMode=SDIO_BUS_WIDE_4B
 SH.FSMC_NL.0=FSMC_NL,MuxedPsram1
 SH.FSMC_NL.ConfNb=1
 SH.GPXTI4.0=GPIO_EXTI4
 SH.GPXTI4.ConfNb=1
 SH.S_TIM4_CH1.0=TIM4_CH1,TriggerSource_TI1FP1
 SH.S_TIM4_CH1.ConfNb=1
-SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16
+SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_4
 SPI1.CLKPhase=SPI_PHASE_2EDGE
 SPI1.CLKPolarity=SPI_POLARITY_HIGH
-SPI1.CalculateBaudRate=3.375 MBits/s
-SPI1.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,CLKPolarity,CLKPhase
+SPI1.CalculateBaudRate=13.5 MBits/s
+SPI1.IPParameters=Mode,CalculateBaudRate,BaudRatePrescaler,CLKPolarity,CLKPhase,VirtualType
 SPI1.Mode=SPI_MODE_MASTER
-USB_DEVICE.CLASS_NAME-HID_FS=HID
-USB_DEVICE.IPParameters=VirtualMode-HID_FS,VirtualModeFS,USBD_HandleTypeDef-HID_FS,CLASS_NAME-HID_FS
+SPI1.VirtualType=VM_MASTER
+USART3.IPParameters=VirtualMode
+USART3.VirtualMode=VM_ASYNC
+USB_DEVICE.IPParameters=VirtualMode-HID_FS,VirtualModeFS,USBD_HandleTypeDef-HID_FS,USBD_MAX_NUM_INTERFACES-HID_FS
 USB_DEVICE.USBD_HandleTypeDef-HID_FS=hUsbDeviceFS
+USB_DEVICE.USBD_MAX_NUM_INTERFACES-HID_FS=2
 USB_DEVICE.VirtualMode-HID_FS=Hid
 USB_DEVICE.VirtualModeFS=Hid_FS
-USB_HOST.IPParameters=VirtualModeHS,USBH_HandleTypeDef-MSC_HS
-USB_HOST.USBH_HandleTypeDef-MSC_HS=hUsbHostHS
-USB_HOST.VirtualModeHS=Msc
 USB_OTG_FS.IPParameters=VirtualMode
 USB_OTG_FS.VirtualMode=Device_Only
-USB_OTG_HS.IPParameters=VirtualMode-Host_FS
-USB_OTG_HS.VirtualMode-Host_FS=Host_FS
-VP_FATFS_VS_SDIO.Mode=SDIO
-VP_FATFS_VS_SDIO.Signal=FATFS_VS_SDIO
-VP_FATFS_VS_USB.Mode=USB
-VP_FATFS_VS_USB.Signal=FATFS_VS_USB
 VP_TIM4_VS_ControllerModeClock.Mode=Clock Mode
 VP_TIM4_VS_ControllerModeClock.Signal=TIM4_VS_ControllerModeClock
 VP_USB_DEVICE_VS_USB_DEVICE_HID_FS.Mode=HID_FS
 VP_USB_DEVICE_VS_USB_DEVICE_HID_FS.Signal=USB_DEVICE_VS_USB_DEVICE_HID_FS
-VP_USB_HOST_VS_USB_HOST_MSC_HS.Mode=MSC_HS
-VP_USB_HOST_VS_USB_HOST_MSC_HS.Signal=USB_HOST_VS_USB_HOST_MSC_HS
 board=SCSI2SD-V6
diff --git a/STM32CubeMX/SCSI2SD-V6/Src/bsp_driver_sd.c b/STM32CubeMX/SCSI2SD-V6/Src/bsp_driver_sd.c
deleted file mode 100755 (executable)
index 1a99016..0000000
+++ /dev/null
@@ -1,308 +0,0 @@
-/**
- ******************************************************************************
-  * @file    bsp_driver_sd.c (based on stm324x9i_eval_sd.c)
-  * @brief   This file includes a generic uSD card driver.
-  ******************************************************************************
-  *
-  * COPYRIGHT(c) 2016 STMicroelectronics
-  *
-  * Redistribution and use in source and binary forms, with or without modification,
-  * are permitted provided that the following conditions are met:
-  *   1. Redistributions of source code must retain the above copyright notice,
-  *      this list of conditions and the following disclaimer.
-  *   2. Redistributions in binary form must reproduce the above copyright notice,
-  *      this list of conditions and the following disclaimer in the documentation
-  *      and/or other materials provided with the distribution.
-  *   3. Neither the name of STMicroelectronics nor the names of its contributors
-  *      may be used to endorse or promote products derived from this software
-  *      without specific prior written permission.
-  *
-  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-  *
-  ******************************************************************************
-  */
-#define BUS_4BITS 1
-/* USER CODE BEGIN 0 */
-/* Includes ------------------------------------------------------------------*/
-#include "bsp_driver_sd.h"
-
-/* Extern variables ---------------------------------------------------------*/ 
-  
-extern SD_HandleTypeDef hsd;
-extern HAL_SD_CardInfoTypedef SDCardInfo; 
-
-/**
-  * @brief  Initializes the SD card device.
-  * @param  None
-  * @retval SD status
-  */
-uint8_t BSP_SD_Init(void)
-{
-  uint8_t SD_state = MSD_OK;
-  /* Check if the SD card is plugged in the slot */
-  if (BSP_SD_IsDetected() != SD_PRESENT)
-  {
-    return MSD_ERROR;
-  }
-  SD_state = HAL_SD_Init(&hsd, &SDCardInfo);
-#ifdef BUS_4BITS
-  if (SD_state == MSD_OK)
-  {
-    if (HAL_SD_WideBusOperation_Config(&hsd, SDIO_BUS_WIDE_4B) != SD_OK)
-    {
-      SD_state = MSD_ERROR;
-    }
-    else
-    {
-      SD_state = MSD_OK;
-    }
-  }
-#endif
-  return SD_state;
-}
-
-/**
-  * @brief  Configures Interrupt mode for SD detection pin.
-  * @param  None
-  * @retval Returns 0 in success otherwise 1. 
-  */
-uint8_t BSP_SD_ITConfig(void)
-{  
-  /* TBI: add user code here depending on the hardware configuration used */
-  
-  return 0;
-}
-
-/** @brief  SD detect IT treatment
-  * @param  None
-  * @retval None
-  */
-void BSP_SD_DetectIT(void)
-{
-  /* TBI: add user code here depending on the hardware configuration used */
-}
-
-/** @brief  SD detect IT detection callback
-  * @param  None
-  * @retval None
-  */
-__weak void BSP_SD_DetectCallback(void)
-{
-  /* NOTE: This function Should not be modified, when the callback is needed,
-  the SD_DetectCallback could be implemented in the user file
-  */ 
-  
-}
-
-/**
-  * @brief  Reads block(s) from a specified address in an SD card, in polling mode. 
-  * @param  pData: Pointer to the buffer that will contain the data to transmit
-  * @param  ReadAddr: Address from where data is to be read  
-  * @param  BlockSize: SD card data block size, that should be 512
-  * @param  NumOfBlocks: Number of SD blocks to read 
-  * @retval SD status
-  */
-uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks)
-{
-  if(HAL_SD_ReadBlocks_DMA(&hsd, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK)  
-  {
-    return MSD_ERROR;
-  }
-  else
-  {
-    return MSD_OK;
-  }
-}
-
-/**
-  * @brief  Writes block(s) to a specified address in an SD card, in polling mode. 
-  * @param  pData: Pointer to the buffer that will contain the data to transmit
-  * @param  WriteAddr: Address from where data is to be written  
-  * @param  BlockSize: SD card data block size, that should be 512
-  * @param  NumOfBlocks: Number of SD blocks to write
-  * @retval SD status
-  */
-uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks)
-{
-  if(HAL_SD_WriteBlocks_DMA(&hsd, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK)  
-  {
-    return MSD_ERROR;
-  }
-  else
-  {
-    return MSD_OK;
-  }
-}
-
-/**
-  * @brief  Reads block(s) from a specified address in an SD card, in DMA mode. 
-  * @param  pData: Pointer to the buffer that will contain the data to transmit
-  * @param  ReadAddr: Address from where data is to be read  
-  * @param  BlockSize: SD card data block size, that should be 512
-  * @param  NumOfBlocks: Number of SD blocks to read 
-  * @retval SD status
-  */
-uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks)
-{
-  uint8_t SD_state = MSD_OK;
-  
-  /* Read block(s) in DMA transfer mode */
-  if(HAL_SD_ReadBlocks_DMA(&hsd, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK)  
-  {
-    SD_state = MSD_ERROR;
-  }
-  
-  /* Wait until transfer is complete */
-  if(SD_state == MSD_OK)
-  {
-    if(HAL_SD_CheckReadOperation(&hsd, (uint32_t)SD_DATATIMEOUT) != SD_OK)  
-    {
-      SD_state = MSD_ERROR;
-    }
-    else
-    {
-      SD_state = MSD_OK;
-    }
-  }
-  
-  return SD_state; 
-}
-
-/**
-  * @brief  Writes block(s) to a specified address in an SD card, in DMA mode.  
-  * @param  pData: Pointer to the buffer that will contain the data to transmit
-  * @param  WriteAddr: Address from where data is to be written  
-  * @param  BlockSize: SD card data block size, that should be 512
-  * @param  NumOfBlocks: Number of SD blocks to write 
-  * @retval SD status
-  */
-uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks)
-{
-  uint8_t SD_state = SD_OK;
-  
-  /* Write block(s) in DMA transfer mode */
-  if(HAL_SD_WriteBlocks_DMA(&hsd, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK)  
-  {
-    SD_state = MSD_ERROR;
-  }
-  
-  /* Wait until transfer is complete */
-  if(SD_state == MSD_OK)
-  {
-    if(HAL_SD_CheckWriteOperation(&hsd, (uint32_t)SD_DATATIMEOUT) != SD_OK)  
-    {
-      SD_state = MSD_ERROR;
-    }
-    else
-    {
-      SD_state = MSD_OK;
-    }
-  }
-  
-  return SD_state; 
-}
-
-/**
-  * @brief  Erases the specified memory area of the given SD card. 
-  * @param  StartAddr: Start byte address
-  * @param  EndAddr: End byte address
-  * @retval SD status
-  */
-uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr)
-{
-  if(HAL_SD_Erase(&hsd, StartAddr, EndAddr) != SD_OK)  
-  {
-    return MSD_ERROR;
-  }
-  else
-  {
-    return MSD_OK;
-  }
-}
-
-/**
-  * @brief  Handles SD card interrupt request.
-  * @param  None
-  * @retval None
-  */
-void BSP_SD_IRQHandler(void)
-{
-  HAL_SD_IRQHandler(&hsd);
-}
-
-/**
-  * @brief  Handles SD DMA Tx transfer interrupt request.
-  * @param  None
-  * @retval None
-  */
-void BSP_SD_DMA_Tx_IRQHandler(void)
-{
-  HAL_DMA_IRQHandler(hsd.hdmatx); 
-}
-
-/**
-  * @brief  Handles SD DMA Rx transfer interrupt request.
-  * @param  None
-  * @retval None
-  */
-void BSP_SD_DMA_Rx_IRQHandler(void)
-{
-  HAL_DMA_IRQHandler(hsd.hdmarx);
-}
-
-/**
-  * @brief  Gets the current SD card data status.
-  * @param  None
-  * @retval Data transfer state.
-  *          This value can be one of the following values:
-  *            @arg  SD_TRANSFER_OK: No data transfer is acting
-  *            @arg  SD_TRANSFER_BUSY: Data transfer is acting
-  *            @arg  SD_TRANSFER_ERROR: Data transfer error 
-  */
-HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void)
-{
-  return(HAL_SD_GetStatus(&hsd));
-}
-
-/**
-  * @brief  Get SD information about specific SD card.
-  * @param  CardInfo: Pointer to HAL_SD_CardInfoTypedef structure
-  * @retval None 
-  */
-void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef* CardInfo)
-{
-  /* Get SD card Information */
-  HAL_SD_Get_CardInfo(&hsd, CardInfo);
-}
-/* USER CODE END 0 */
-
-/**
- * @brief  Detects if SD card is correctly plugged in the memory slot or not.
- * @param  None
- * @retval Returns if SD is detected or not
- */
-uint8_t BSP_SD_IsDetected(void)
-{
-  __IO uint8_t status = SD_PRESENT;
-
-  /* USER CODE BEGIN 1 */
-  /* user code can be inserted here */
-  /* USER CODE END 1 */    
-  
-  return status;
-}
-
-/* USER CODE BEGIN AdditionalCode */
-/* user code can be inserted here */
-/* USER CODE END AdditionalCode */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
index 5261aa928eff03424a2ae8ec29b017b0be323b2a..c257924341bb790efddb648fcfaa2f0bcf393574 100755 (executable)
@@ -5,7 +5,7 @@
   *                      of the FSMC peripheral.
   ******************************************************************************
   *
-  * COPYRIGHT(c) 2016 STMicroelectronics
+  * COPYRIGHT(c) 2019 STMicroelectronics
   *
   * Redistribution and use in source and binary forms, with or without modification,
   * are permitted provided that the following conditions are met:
@@ -66,28 +66,12 @@ void MX_FSMC_Init(void)
   hsram1.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE;
   hsram1.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE;
   /* Timing */
-
-  // 1 clock to read the address, + 1 for synchroniser skew
   Timing.AddressSetupTime = 2;
   Timing.AddressHoldTime = 1;
-
-  // Writes to device:
-  //   1 for synchroniser skew (dbx also delayed)
-  //   1 to skip hold time
-  //   1 to write data.
-
-  // Reads from device:
-  //   3 for syncroniser
-  //   1 to write back to fsmc bus.
   Timing.DataSetupTime = 4;
-
-  // Allow a clock for us to release signals
-  // Need to avoid both devices acting as outputs
-  // on the multiplexed lines at the same time.
   Timing.BusTurnAroundDuration = 1;
-
-  Timing.CLKDivision = 16; // Ignored for async
-  Timing.DataLatency = 17; // Ignored for async
+  Timing.CLKDivision = 16;
+  Timing.DataLatency = 17;
   Timing.AccessMode = FSMC_ACCESS_MODE_A;
   /* ExtTiming */
 
@@ -107,7 +91,7 @@ static void HAL_FSMC_MspInit(void){
   }
   FSMC_Initialized = 1;
   /* Peripheral clock enable */
-  __FSMC_CLK_ENABLE();
+  #__FSMC_CLK_ENABLE();
   
   /** FSMC GPIO Configuration  
   PE7   ------> FSMC_DA4
@@ -119,6 +103,9 @@ static void HAL_FSMC_MspInit(void){
   PE13   ------> FSMC_DA10
   PE14   ------> FSMC_DA11
   PE15   ------> FSMC_DA12
+  PD8   ------> FSMC_DA13
+  PD9   ------> FSMC_DA14
+  PD10   ------> FSMC_DA15
   PD14   ------> FSMC_DA0
   PD15   ------> FSMC_DA1
   PD0   ------> FSMC_DA2
@@ -126,31 +113,28 @@ static void HAL_FSMC_MspInit(void){
   PD4   ------> FSMC_NOE
   PD5   ------> FSMC_NWE
   PD7   ------> FSMC_NE1
-  PD8   ------> FSMC_DA13
-  PD9   ------> FSMC_DA14
-  PD10  ------> FSMC_DA15
   PB7   ------> FSMC_NL
   PE0   ------> FSMC_NBL0
   PE1   ------> FSMC_NBL1
   */
-  // MM: GPIO_SPEED_FREQ_MEDIUM is rated up to 50MHz, which is fine as all the
-  // fsmc timings are > 1 (ie. so clock speed / 2 is around 50MHz).
-
   /* GPIO_InitStruct */
-  GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
+  GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 
+                          |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 
+                          |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1;
   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
   GPIO_InitStruct.Pull = GPIO_NOPULL;
-  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; //HIGH;
+  GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
   GPIO_InitStruct.Alternate = GPIO_AF12_FSMC;
 
   HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
 
   /* GPIO_InitStruct */
-  GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1 
-                          |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10;
+  GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 
+                          |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4 
+                          |GPIO_PIN_5|GPIO_PIN_7;
   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
   GPIO_InitStruct.Pull = GPIO_NOPULL;
-  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; //HIGH;
+  GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
   GPIO_InitStruct.Alternate = GPIO_AF12_FSMC;
 
   HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
@@ -159,7 +143,7 @@ static void HAL_FSMC_MspInit(void){
   GPIO_InitStruct.Pin = GPIO_PIN_7;
   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
   GPIO_InitStruct.Pull = GPIO_NOPULL;
-  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;//HIGH;
+  GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
   GPIO_InitStruct.Alternate = GPIO_AF12_FSMC;
 
   HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
@@ -202,6 +186,9 @@ static void HAL_FSMC_MspDeInit(void){
   PE13   ------> FSMC_DA10
   PE14   ------> FSMC_DA11
   PE15   ------> FSMC_DA12
+  PD8   ------> FSMC_DA13
+  PD9   ------> FSMC_DA14
+  PD10   ------> FSMC_DA15
   PD14   ------> FSMC_DA0
   PD15   ------> FSMC_DA1
   PD0   ------> FSMC_DA2
@@ -209,18 +196,18 @@ static void HAL_FSMC_MspDeInit(void){
   PD4   ------> FSMC_NOE
   PD5   ------> FSMC_NWE
   PD7   ------> FSMC_NE1
-  PD8   ------> FSMC_DA13
-  PD9   ------> FSMC_DA14
-  PD10  ------> FSMC_DA15
   PB7   ------> FSMC_NL
   PE0   ------> FSMC_NBL0
   PE1   ------> FSMC_NBL1
   */
 
-  HAL_GPIO_DeInit(GPIOE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15);
+  HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 
+                          |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 
+                          |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1);
 
-  HAL_GPIO_DeInit(GPIOD, GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1 
-                          |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10);
+  HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 
+                          |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4 
+                          |GPIO_PIN_5|GPIO_PIN_7);
 
   HAL_GPIO_DeInit(GPIOB, GPIO_PIN_7);
 
index 5682f257887e36601d866a1bfce347668eed1be0..21529ffdf1cff5584a95d367892ccc51c2f7d000 100755 (executable)
@@ -5,7 +5,7 @@
   *                      of all used GPIO pins.
   ******************************************************************************
   *
-  * COPYRIGHT(c) 2016 STMicroelectronics
+  * COPYRIGHT(c) 2019 STMicroelectronics
   *
   * Redistribution and use in source and binary forms, with or without modification,
   * are permitted provided that the following conditions are met:
@@ -68,17 +68,17 @@ void MX_GPIO_Init(void)
   __GPIOB_CLK_ENABLE();
   __GPIOD_CLK_ENABLE();
 
-  /*Configure GPIO pins : PEPin PEPin PEPin PEPin */
+  /*Configure GPIO pins : PEPin PEPin PEPin */
   GPIO_InitStruct.Pin = FPGA_GPIO2_Pin|UNUSED_PE5_Pin|UNUSED_PE6_Pin;
   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
   GPIO_InitStruct.Pull = GPIO_PULLDOWN;
   HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
 
-  /*Configure GPIO pin : PE3 */
+  /*Configure GPIO pin : PtPin */
   GPIO_InitStruct.Pin = FPGA_GPIO3_Pin;
   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
   GPIO_InitStruct.Pull = GPIO_NOPULL;
-  HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
+  HAL_GPIO_Init(FPGA_GPIO3_GPIO_Port, &GPIO_InitStruct);
 
   /*Configure GPIO pin : PE4 */
   GPIO_InitStruct.Pin = GPIO_PIN_4;
@@ -96,8 +96,10 @@ void MX_GPIO_Init(void)
   GPIO_InitStruct.Pull = GPIO_PULLDOWN;
   HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
 
-  /*Configure GPIO pins : PAPin PAPin PAPin PAPin */
-  GPIO_InitStruct.Pin = UNUSED_PA0_Pin|UNUSED_PA1_Pin|UNUSED_PA2_Pin|UNUSED_PA3_Pin;
+  /*Configure GPIO pins : PAPin PAPin PAPin PAPin 
+                           PA10 */
+  GPIO_InitStruct.Pin = UNUSED_PA0_Pin|UNUSED_PA1_Pin|UNUSED_PA2_Pin|UNUSED_PA3_Pin 
+                          |GPIO_PIN_10;
   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
   GPIO_InitStruct.Pull = GPIO_PULLDOWN;
   HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
@@ -123,26 +125,14 @@ void MX_GPIO_Init(void)
   GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
   HAL_GPIO_Init(nTERM_EN_GPIO_Port, &GPIO_InitStruct);
 
-  /*Configure GPIO pins : PBPin PBPin PBPin */
-  GPIO_InitStruct.Pin = BOOT1_Pin|UNUSED_PB5_Pin|UNUSED_PB6_Pin;
-  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
-  GPIO_InitStruct.Pull = GPIO_PULLDOWN;
-  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
-
-  /*Configure GPIO pins : PBPin PBPin */
-  GPIO_InitStruct.Pin = UNUSED_PB12_Pin|UNUSED_PB13_Pin;
+  /*Configure GPIO pins : PBPin PBPin PBPin PB14 
+                           PB15 PBPin PBPin */
+  GPIO_InitStruct.Pin = BOOT1_Pin|UNUSED_PB12_Pin|UNUSED_PB13_Pin|GPIO_PIN_14 
+                          |GPIO_PIN_15|UNUSED_PB5_Pin|UNUSED_PB6_Pin;
   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
   GPIO_InitStruct.Pull = GPIO_PULLDOWN;
   HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 
-  /*Configure GPIO pins : PD6, PD12 */
-  // PD6: FSMC NWAIT, not used yet.PULLED UP in fpga pin config
-  // PD12: FPGA_GPIO1, not used.
-  GPIO_InitStruct.Pin = GPIO_PIN_6 | GPIO_PIN_12;
-  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
-  GPIO_InitStruct.Pull = GPIO_PULLUP;
-  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
-
   /*Configure GPIO pins : PDPin PDPin */
   GPIO_InitStruct.Pin = UNUSED_PD11_Pin|FSMC_UNUSED_CLK_Pin;
   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
@@ -170,18 +160,11 @@ void MX_GPIO_Init(void)
   GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
   HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 
-  /*Configure GPIO pin : PA10 */
-  // USB Host OTG ID pin
-  GPIO_InitStruct.Pin = GPIO_PIN_10;
-  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
-  GPIO_InitStruct.Pull = GPIO_PULLDOWN;
-  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
-  // USB Host pins, currently unused.
-  GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15;
-  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
-  GPIO_InitStruct.Pull = GPIO_PULLDOWN;
-  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+  /*Configure GPIO pin : PD6 */
+  GPIO_InitStruct.Pin = GPIO_PIN_6;
+  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
+  GPIO_InitStruct.Pull = GPIO_NOPULL;
+  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
 
   /*Configure GPIO pins : PBPin PBPin */
   GPIO_InitStruct.Pin = nSD_WP_Pin|nSD_CD_Pin;
index a80e07810867beb2f489387719bf975c8d95124a..48e1f9ab931ab459d3286b58e0f31f0f40081f41 100755 (executable)
@@ -4,7 +4,7 @@
   * Description        : Main program body
   ******************************************************************************
   *
-  * COPYRIGHT(c) 2016 STMicroelectronics
+  * COPYRIGHT(c) 2019 STMicroelectronics
   *
   * Redistribution and use in source and binary forms, with or without modification,
   * are permitted provided that the following conditions are met:
   */
 /* Includes ------------------------------------------------------------------*/
 #include "stm32f2xx_hal.h"
+#include "dma.h"
 #include "sdio.h"
 #include "spi.h"
+#include "tim.h"
 #include "usart.h"
 #include "usb_device.h"
-#include "usb_host.h"
 #include "gpio.h"
 #include "fsmc.h"
 
@@ -53,7 +54,6 @@
 
 /* Private function prototypes -----------------------------------------------*/
 void SystemClock_Config(void);
-void MX_USB_HOST_Process(void);
 
 /* USER CODE BEGIN PFP */
 /* Private function prototypes -----------------------------------------------*/
@@ -87,11 +87,14 @@ int main(void)
 
   /* Initialize all configured peripherals */
   MX_GPIO_Init();
+  MX_DMA_Init();
+  SystemClock_Config();
   MX_FSMC_Init();
   MX_SDIO_SD_Init();
   MX_SPI1_Init();
-  MX_USART3_UART_Init(); // Not used, but we don't want the pins floating.
-  // MX_USB_HOST_Init(); // Not used, pins set to GPIO
+  MX_TIM4_Init();
+  MX_USART3_UART_Init();
+  MX_USB_DEVICE_Init();
 
   /* USER CODE BEGIN 2 */
   mainInit();
@@ -103,7 +106,6 @@ int main(void)
   while (1)
   {
   /* USER CODE END WHILE */
-    //MX_USB_HOST_Process();
 
   /* USER CODE BEGIN 3 */
   mainLoop();
@@ -126,7 +128,6 @@ void SystemClock_Config(void)
   RCC_OscInitStruct.HSEState = RCC_HSE_ON;
   RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
   RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
-
   RCC_OscInitStruct.PLL.PLLM = 20;
   RCC_OscInitStruct.PLL.PLLN = 432;
   RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
index 0f9a34b12532157bb64f51a5d4533ea670e5267a..e8b2ad88c3d9d36fff838e0acd3e2da3c8105d7a 100755 (executable)
@@ -5,7 +5,7 @@
   *                      of the SDIO instances.
   ******************************************************************************
   *
-  * COPYRIGHT(c) 2016 STMicroelectronics
+  * COPYRIGHT(c) 2019 STMicroelectronics
   *
   * Redistribution and use in source and binary forms, with or without modification,
   * are permitted provided that the following conditions are met:
@@ -36,6 +36,7 @@
 #include "sdio.h"
 
 #include "gpio.h"
+#include "dma.h"
 
 /* USER CODE BEGIN 0 */
 
@@ -58,6 +59,9 @@ void MX_SDIO_SD_Init(void)
   hsd.Init.BusWide = SDIO_BUS_WIDE_1B;
   hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
   hsd.Init.ClockDiv = 0;
+  HAL_SD_Init(&hsd, &SDCardInfo);
+
+  HAL_SD_WideBusOperation_Config(&hsd, SDIO_BUS_WIDE_4B);
 
 }
 
@@ -83,12 +87,11 @@ void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
     */
     GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11;
     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
-    GPIO_InitStruct.Pull = GPIO_PULLUP; // MM
+    GPIO_InitStruct.Pull = GPIO_PULLUP;
     GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
     GPIO_InitStruct.Alternate = GPIO_AF12_SDIO;
     HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
 
-    // No pullup on CLK
     GPIO_InitStruct.Pin = GPIO_PIN_12;
     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
     GPIO_InitStruct.Pull = GPIO_NOPULL;
@@ -98,7 +101,7 @@ void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
 
     GPIO_InitStruct.Pin = GPIO_PIN_2;
     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
-    GPIO_InitStruct.Pull = GPIO_PULLUP; // MM
+    GPIO_InitStruct.Pull = GPIO_PULLUP;
     GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
     GPIO_InitStruct.Alternate = GPIO_AF12_SDIO;
     HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
@@ -112,8 +115,8 @@ void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
     hdma_sdio_tx.Init.MemInc = DMA_MINC_ENABLE;
     hdma_sdio_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
     hdma_sdio_tx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
-    hdma_sdio_tx.Init.Mode = DMA_PFCTRL; // TODO MM. This is necessary or SDIO doesn't work
-    hdma_sdio_tx.Init.Priority = DMA_PRIORITY_VERY_HIGH; // TODO MM Prevent underruns
+    hdma_sdio_tx.Init.Mode = DMA_PFCTRL;
+    hdma_sdio_tx.Init.Priority = DMA_PRIORITY_VERY_HIGH;
     hdma_sdio_tx.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
     hdma_sdio_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
     hdma_sdio_tx.Init.MemBurst = DMA_MBURST_INC4;
@@ -129,8 +132,8 @@ void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
     hdma_sdio_rx.Init.MemInc = DMA_MINC_ENABLE;
     hdma_sdio_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
     hdma_sdio_rx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
-    hdma_sdio_rx.Init.Mode = DMA_PFCTRL; // TODO MM. This is necessary or SDIO doesn't work
-    hdma_sdio_rx.Init.Priority = DMA_PRIORITY_VERY_HIGH; // TODO MM Prevent underruns
+    hdma_sdio_rx.Init.Mode = DMA_PFCTRL;
+    hdma_sdio_rx.Init.Priority = DMA_PRIORITY_VERY_HIGH;
     hdma_sdio_rx.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
     hdma_sdio_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
     hdma_sdio_rx.Init.MemBurst = DMA_MBURST_INC4;
@@ -140,7 +143,6 @@ void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
     __HAL_LINKDMA(hsd,hdmarx,hdma_sdio_rx);
 
     /* Peripheral interrupt init*/
-       HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
     HAL_NVIC_SetPriority(SDIO_IRQn, 0, 0);
     HAL_NVIC_EnableIRQ(SDIO_IRQn);
   /* USER CODE BEGIN SDIO_MspInit 1 */
index 25e0745e9a55c67fce80caa8a4ff012415d7e65f..cfb19ce2ad7797366c5d0203c7c695d4b53a97d4 100755 (executable)
@@ -5,7 +5,7 @@
   *                      of the SPI instances.
   ******************************************************************************
   *
-  * COPYRIGHT(c) 2016 STMicroelectronics
+  * COPYRIGHT(c) 2019 STMicroelectronics
   *
   * Redistribution and use in source and binary forms, with or without modification,
   * are permitted provided that the following conditions are met:
@@ -54,7 +54,6 @@ void MX_SPI1_Init(void)
   hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH;
   hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
   hspi1.Init.NSS = SPI_NSS_SOFT;
-  // (96MHz / 2) / 4 = 12MHz. FPGA device allows up to 25MHz write
   hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
   hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
   hspi1.Init.TIMode = SPI_TIMODE_DISABLED;
index b7ab0a3bc3a5b241fc2c5174e34c30fb108e927f..e6b778381f5cc1c5bd902c753760073a68d5d5d6 100755 (executable)
@@ -5,7 +5,7 @@
   *                      and de-Initialization codes.
   ******************************************************************************
   *
-  * COPYRIGHT(c) 2016 STMicroelectronics
+  * COPYRIGHT(c) 2019 STMicroelectronics
   *
   * Redistribution and use in source and binary forms, with or without modification,
   * are permitted provided that the following conditions are met:
@@ -50,6 +50,14 @@ void HAL_MspInit(void)
   HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
 
   /* System interrupt init*/
+  /* MemoryManagement_IRQn interrupt configuration */
+  HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0);
+  /* BusFault_IRQn interrupt configuration */
+  HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0);
+  /* UsageFault_IRQn interrupt configuration */
+  HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0);
+  /* DebugMonitor_IRQn interrupt configuration */
+  HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0);
   /* SysTick_IRQn interrupt configuration */
   HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
 
index efa2c5a59f68ae370313ffdbc07ca1d2ff69c057..d8a2ddfbdfe8998f50de1f7d784c01e0c282c12d 100755 (executable)
@@ -4,7 +4,7 @@
   * @brief   Interrupt Service Routines.
   ******************************************************************************
   *
-  * COPYRIGHT(c) 2016 STMicroelectronics
+  * COPYRIGHT(c) 2019 STMicroelectronics
   *
   * Redistribution and use in source and binary forms, with or without modification,
   * are permitted provided that the following conditions are met:
@@ -41,7 +41,6 @@
 
 /* External variables --------------------------------------------------------*/
 extern PCD_HandleTypeDef hpcd_USB_OTG_FS;
-extern HCD_HandleTypeDef hhcd_USB_OTG_HS;
 extern DMA_HandleTypeDef hdma_sdio_tx;
 extern DMA_HandleTypeDef hdma_sdio_rx;
 extern SD_HandleTypeDef hsd;
@@ -72,7 +71,6 @@ void SysTick_Handler(void)
 /* please refer to the startup file (startup_stm32f2xx.s).                    */
 /******************************************************************************/
 
-
 /**
 * @brief This function handles EXTI line4 interrupt.
 */
@@ -143,20 +141,6 @@ void DMA2_Stream6_IRQHandler(void)
   /* USER CODE END DMA2_Stream6_IRQn 1 */
 }
 
-/**
-* @brief This function handles USB On The Go HS global interrupt.
-*/
-void OTG_HS_IRQHandler(void)
-{
-  /* USER CODE BEGIN OTG_HS_IRQn 0 */
-
-  /* USER CODE END OTG_HS_IRQn 0 */
-  HAL_HCD_IRQHandler(&hhcd_USB_OTG_HS);
-  /* USER CODE BEGIN OTG_HS_IRQn 1 */
-
-  /* USER CODE END OTG_HS_IRQn 1 */
-}
-
 /* USER CODE BEGIN 1 */
 
 /* USER CODE END 1 */
index 07387caa3e2e788a0c5eb0dec3202d243336476f..272d38885dde98cfe05ccb958085f79a886d7d16 100755 (executable)
@@ -5,7 +5,7 @@
   * @brief          : This file implements the board support package for the USB device library
   ******************************************************************************
   *
-  * COPYRIGHT(c) 2016 STMicroelectronics
+  * COPYRIGHT(c) 2019 STMicroelectronics
   *
   * Redistribution and use in source and binary forms, with or without modification,
   * are permitted provided that the following conditions are met:
@@ -108,18 +108,7 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd)
     PA11     ------> USB_OTG_FS_DM
     PA12     ------> USB_OTG_FS_DP 
     */
-       // HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_12);
-       // MM: Don't let pins float.
-       GPIO_InitTypeDef GPIO_InitStruct;
-       GPIO_InitStruct.Pin = GPIO_PIN_9;
-       GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
-       GPIO_InitStruct.Pull = GPIO_PULLDOWN;
-       HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
-       GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
-       GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
-       GPIO_InitStruct.Pull = GPIO_PULLDOWN;
-       HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_12);
 
     /* Peripheral interrupt Deinit*/
     HAL_NVIC_DisableIRQ(OTG_FS_IRQn);
@@ -305,11 +294,9 @@ USBD_StatusTypeDef  USBD_LL_Init (USBD_HandleTypeDef *pdev)
   hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE;
   HAL_PCD_Init(&hpcd_USB_OTG_FS);
 
-  // Sum of all FIFOs must be <= 320.
   HAL_PCD_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80);
   HAL_PCD_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40);
-  HAL_PCD_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x40);
-  HAL_PCD_SetTxFiFo(&hpcd_USB_OTG_FS, 2, 0x40);
+  HAL_PCD_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80);
   }
   return USBD_OK;
 }
diff --git a/src/firmware/bsp_driver_sd.c b/src/firmware/bsp_driver_sd.c
new file mode 100755 (executable)
index 0000000..1a99016
--- /dev/null
@@ -0,0 +1,308 @@
+/**
+ ******************************************************************************
+  * @file    bsp_driver_sd.c (based on stm324x9i_eval_sd.c)
+  * @brief   This file includes a generic uSD card driver.
+  ******************************************************************************
+  *
+  * COPYRIGHT(c) 2016 STMicroelectronics
+  *
+  * Redistribution and use in source and binary forms, with or without modification,
+  * are permitted provided that the following conditions are met:
+  *   1. Redistributions of source code must retain the above copyright notice,
+  *      this list of conditions and the following disclaimer.
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
+  *      this list of conditions and the following disclaimer in the documentation
+  *      and/or other materials provided with the distribution.
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
+  *      may be used to endorse or promote products derived from this software
+  *      without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  *
+  ******************************************************************************
+  */
+#define BUS_4BITS 1
+/* USER CODE BEGIN 0 */
+/* Includes ------------------------------------------------------------------*/
+#include "bsp_driver_sd.h"
+
+/* Extern variables ---------------------------------------------------------*/ 
+  
+extern SD_HandleTypeDef hsd;
+extern HAL_SD_CardInfoTypedef SDCardInfo; 
+
+/**
+  * @brief  Initializes the SD card device.
+  * @param  None
+  * @retval SD status
+  */
+uint8_t BSP_SD_Init(void)
+{
+  uint8_t SD_state = MSD_OK;
+  /* Check if the SD card is plugged in the slot */
+  if (BSP_SD_IsDetected() != SD_PRESENT)
+  {
+    return MSD_ERROR;
+  }
+  SD_state = HAL_SD_Init(&hsd, &SDCardInfo);
+#ifdef BUS_4BITS
+  if (SD_state == MSD_OK)
+  {
+    if (HAL_SD_WideBusOperation_Config(&hsd, SDIO_BUS_WIDE_4B) != SD_OK)
+    {
+      SD_state = MSD_ERROR;
+    }
+    else
+    {
+      SD_state = MSD_OK;
+    }
+  }
+#endif
+  return SD_state;
+}
+
+/**
+  * @brief  Configures Interrupt mode for SD detection pin.
+  * @param  None
+  * @retval Returns 0 in success otherwise 1. 
+  */
+uint8_t BSP_SD_ITConfig(void)
+{  
+  /* TBI: add user code here depending on the hardware configuration used */
+  
+  return 0;
+}
+
+/** @brief  SD detect IT treatment
+  * @param  None
+  * @retval None
+  */
+void BSP_SD_DetectIT(void)
+{
+  /* TBI: add user code here depending on the hardware configuration used */
+}
+
+/** @brief  SD detect IT detection callback
+  * @param  None
+  * @retval None
+  */
+__weak void BSP_SD_DetectCallback(void)
+{
+  /* NOTE: This function Should not be modified, when the callback is needed,
+  the SD_DetectCallback could be implemented in the user file
+  */ 
+  
+}
+
+/**
+  * @brief  Reads block(s) from a specified address in an SD card, in polling mode. 
+  * @param  pData: Pointer to the buffer that will contain the data to transmit
+  * @param  ReadAddr: Address from where data is to be read  
+  * @param  BlockSize: SD card data block size, that should be 512
+  * @param  NumOfBlocks: Number of SD blocks to read 
+  * @retval SD status
+  */
+uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks)
+{
+  if(HAL_SD_ReadBlocks_DMA(&hsd, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK)  
+  {
+    return MSD_ERROR;
+  }
+  else
+  {
+    return MSD_OK;
+  }
+}
+
+/**
+  * @brief  Writes block(s) to a specified address in an SD card, in polling mode. 
+  * @param  pData: Pointer to the buffer that will contain the data to transmit
+  * @param  WriteAddr: Address from where data is to be written  
+  * @param  BlockSize: SD card data block size, that should be 512
+  * @param  NumOfBlocks: Number of SD blocks to write
+  * @retval SD status
+  */
+uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks)
+{
+  if(HAL_SD_WriteBlocks_DMA(&hsd, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK)  
+  {
+    return MSD_ERROR;
+  }
+  else
+  {
+    return MSD_OK;
+  }
+}
+
+/**
+  * @brief  Reads block(s) from a specified address in an SD card, in DMA mode. 
+  * @param  pData: Pointer to the buffer that will contain the data to transmit
+  * @param  ReadAddr: Address from where data is to be read  
+  * @param  BlockSize: SD card data block size, that should be 512
+  * @param  NumOfBlocks: Number of SD blocks to read 
+  * @retval SD status
+  */
+uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks)
+{
+  uint8_t SD_state = MSD_OK;
+  
+  /* Read block(s) in DMA transfer mode */
+  if(HAL_SD_ReadBlocks_DMA(&hsd, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK)  
+  {
+    SD_state = MSD_ERROR;
+  }
+  
+  /* Wait until transfer is complete */
+  if(SD_state == MSD_OK)
+  {
+    if(HAL_SD_CheckReadOperation(&hsd, (uint32_t)SD_DATATIMEOUT) != SD_OK)  
+    {
+      SD_state = MSD_ERROR;
+    }
+    else
+    {
+      SD_state = MSD_OK;
+    }
+  }
+  
+  return SD_state; 
+}
+
+/**
+  * @brief  Writes block(s) to a specified address in an SD card, in DMA mode.  
+  * @param  pData: Pointer to the buffer that will contain the data to transmit
+  * @param  WriteAddr: Address from where data is to be written  
+  * @param  BlockSize: SD card data block size, that should be 512
+  * @param  NumOfBlocks: Number of SD blocks to write 
+  * @retval SD status
+  */
+uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks)
+{
+  uint8_t SD_state = SD_OK;
+  
+  /* Write block(s) in DMA transfer mode */
+  if(HAL_SD_WriteBlocks_DMA(&hsd, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK)  
+  {
+    SD_state = MSD_ERROR;
+  }
+  
+  /* Wait until transfer is complete */
+  if(SD_state == MSD_OK)
+  {
+    if(HAL_SD_CheckWriteOperation(&hsd, (uint32_t)SD_DATATIMEOUT) != SD_OK)  
+    {
+      SD_state = MSD_ERROR;
+    }
+    else
+    {
+      SD_state = MSD_OK;
+    }
+  }
+  
+  return SD_state; 
+}
+
+/**
+  * @brief  Erases the specified memory area of the given SD card. 
+  * @param  StartAddr: Start byte address
+  * @param  EndAddr: End byte address
+  * @retval SD status
+  */
+uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr)
+{
+  if(HAL_SD_Erase(&hsd, StartAddr, EndAddr) != SD_OK)  
+  {
+    return MSD_ERROR;
+  }
+  else
+  {
+    return MSD_OK;
+  }
+}
+
+/**
+  * @brief  Handles SD card interrupt request.
+  * @param  None
+  * @retval None
+  */
+void BSP_SD_IRQHandler(void)
+{
+  HAL_SD_IRQHandler(&hsd);
+}
+
+/**
+  * @brief  Handles SD DMA Tx transfer interrupt request.
+  * @param  None
+  * @retval None
+  */
+void BSP_SD_DMA_Tx_IRQHandler(void)
+{
+  HAL_DMA_IRQHandler(hsd.hdmatx); 
+}
+
+/**
+  * @brief  Handles SD DMA Rx transfer interrupt request.
+  * @param  None
+  * @retval None
+  */
+void BSP_SD_DMA_Rx_IRQHandler(void)
+{
+  HAL_DMA_IRQHandler(hsd.hdmarx);
+}
+
+/**
+  * @brief  Gets the current SD card data status.
+  * @param  None
+  * @retval Data transfer state.
+  *          This value can be one of the following values:
+  *            @arg  SD_TRANSFER_OK: No data transfer is acting
+  *            @arg  SD_TRANSFER_BUSY: Data transfer is acting
+  *            @arg  SD_TRANSFER_ERROR: Data transfer error 
+  */
+HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void)
+{
+  return(HAL_SD_GetStatus(&hsd));
+}
+
+/**
+  * @brief  Get SD information about specific SD card.
+  * @param  CardInfo: Pointer to HAL_SD_CardInfoTypedef structure
+  * @retval None 
+  */
+void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef* CardInfo)
+{
+  /* Get SD card Information */
+  HAL_SD_Get_CardInfo(&hsd, CardInfo);
+}
+/* USER CODE END 0 */
+
+/**
+ * @brief  Detects if SD card is correctly plugged in the memory slot or not.
+ * @param  None
+ * @retval Returns if SD is detected or not
+ */
+uint8_t BSP_SD_IsDetected(void)
+{
+  __IO uint8_t status = SD_PRESENT;
+
+  /* USER CODE BEGIN 1 */
+  /* user code can be inserted here */
+  /* USER CODE END 1 */    
+  
+  return status;
+}
+
+/* USER CODE BEGIN AdditionalCode */
+/* user code can be inserted here */
+/* USER CODE END AdditionalCode */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/src/firmware/bsp_driver_sd.h b/src/firmware/bsp_driver_sd.h
new file mode 100755 (executable)
index 0000000..49a0a50
--- /dev/null
@@ -0,0 +1,104 @@
+/**
+ ******************************************************************************
+  * @file    bsp_driver_sd.h (based on stm324x9i_eval_sd.h)
+  * @brief   This file contains the common defines and functions prototypes for 
+  *          the bsp_driver_sd.c driver.
+  ******************************************************************************
+  *
+  * COPYRIGHT(c) 2016 STMicroelectronics
+  *
+  * Redistribution and use in source and binary forms, with or without modification,
+  * are permitted provided that the following conditions are met:
+  *   1. Redistributions of source code must retain the above copyright notice,
+  *      this list of conditions and the following disclaimer.
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
+  *      this list of conditions and the following disclaimer in the documentation
+  *      and/or other materials provided with the distribution.
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
+  *      may be used to endorse or promote products derived from this software
+  *      without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  *
+  ******************************************************************************
+  */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F2XX_SD_H
+#define __STM32F2XX_SD_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif 
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f2xx_hal.h"
+
+/* Exported constants --------------------------------------------------------*/ 
+
+/** 
+  * @brief  SD status structure definition  
+  */     
+#define   MSD_OK         0x00
+#define   MSD_ERROR      0x01
+#ifndef SD_CardInfo
+  #define SD_CardInfo HAL_SD_CardInfoTypedef
+#endif
+  
+/** @defgroup STM324x9I_EVAL_SD_Exported_Constants
+  * @{
+  */ 
+#define SD_DATATIMEOUT           ((uint32_t)0xFFFFFFFF)
+
+#define SD_PRESENT               ((uint8_t)0x01)
+#define SD_NOT_PRESENT           ((uint8_t)0x00)
+
+/* USER CODE BEGIN 0 */ 
+   
+/* DMA definitions for SD DMA transfer */
+/*
+#define __DMAx_TxRx_CLK_ENABLE            __DMA2_CLK_ENABLE
+#define SD_DMAx_Tx_CHANNEL                DMA_CHANNEL_4
+#define SD_DMAx_Rx_CHANNEL                DMA_CHANNEL_4
+#define SD_DMAx_Tx_STREAM                 DMA2_Stream6  
+#define SD_DMAx_Rx_STREAM                 DMA2_Stream3  
+#define SD_DMAx_Tx_IRQn                   DMA2_Stream6_IRQn
+#define SD_DMAx_Rx_IRQn                   DMA2_Stream3_IRQn
+#define SD_DMAx_Tx_IRQHandler             DMA2_Stream6_IRQHandler   
+#define SD_DMAx_Rx_IRQHandler             DMA2_Stream3_IRQHandler  
+*/
+
+/* Exported functions --------------------------------------------------------*/   
+uint8_t BSP_SD_Init(void);
+uint8_t BSP_SD_ITConfig(void);
+void BSP_SD_DetectIT(void);
+__weak void BSP_SD_DetectCallback(void);
+uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
+uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
+uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
+uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
+uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr);
+void BSP_SD_IRQHandler(void);
+void BSP_SD_DMA_Tx_IRQHandler(void);
+void BSP_SD_DMA_Rx_IRQHandler(void);
+HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void);
+void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo);
+uint8_t BSP_SD_IsDetected(void);
+/* USER CODE END 0 */ 
+   
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F2XX_SD_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/src/firmware/cubemx.patch b/src/firmware/cubemx.patch
new file mode 100644 (file)
index 0000000..e7c12d1
--- /dev/null
@@ -0,0 +1,589 @@
+diff --git b/STM32CubeMX/SCSI2SD-V6/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_sd.c a/STM32CubeMX/SCSI2SD-V6/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_sd.c
+index 4df41a0..7312d0e 100755
+--- b/STM32CubeMX/SCSI2SD-V6/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_sd.c
++++ a/STM32CubeMX/SCSI2SD-V6/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_sd.c
+@@ -178,7 +178,6 @@
+ /* Includes ------------------------------------------------------------------*/
+ #include "stm32f2xx_hal.h"
+-
+ #ifdef HAL_SD_MODULE_ENABLED
+ /** @addtogroup STM32F2xx_HAL_Driver
+@@ -893,7 +892,7 @@ HAL_SD_ErrorTypedef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pRead
+                                 SDIO_IT_STBITERR));
+   
+   /* Enable SDIO DMA transfer */
+-  __HAL_SD_SDIO_DMA_ENABLE();
++  // MM disabled, as this fails on fast cards. __HAL_SD_SDIO_DMA_ENABLE();
+   
+   /* Configure DMA user callbacks */
+   hsd->hdmarx->XferCpltCallback  = SD_DMA_RxCplt;
+@@ -902,26 +901,29 @@ HAL_SD_ErrorTypedef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pRead
+   /* Enable the DMA Stream */
+   HAL_DMA_Start_IT(hsd->hdmarx, (uint32_t)&hsd->Instance->FIFO, (uint32_t)pReadBuffer, (uint32_t)(BlockSize * NumberOfBlocks)/4);
+   
++  sdio_cmdinitstructure.Response         = SDIO_RESPONSE_SHORT;
++  sdio_cmdinitstructure.WaitForInterrupt = SDIO_WAIT_NO;
++  sdio_cmdinitstructure.CPSM             = SDIO_CPSM_ENABLE;
++  
+   if (hsd->CardType == HIGH_CAPACITY_SD_CARD)
+   {
+     BlockSize = 512;
+     ReadAddr /= 512;
+-  }
++  } else {
+   
+-  /* Set Block Size for Card */ 
+-  sdio_cmdinitstructure.Argument         = (uint32_t)BlockSize;
+-  sdio_cmdinitstructure.CmdIndex         = SD_CMD_SET_BLOCKLEN;
+-  sdio_cmdinitstructure.Response         = SDIO_RESPONSE_SHORT;
+-  sdio_cmdinitstructure.WaitForInterrupt = SDIO_WAIT_NO;
+-  sdio_cmdinitstructure.CPSM             = SDIO_CPSM_ENABLE;
+-  SDIO_SendCommand(hsd->Instance, &sdio_cmdinitstructure);
++    /* Set Block Size for Card */ 
++    sdio_cmdinitstructure.Argument         = (uint32_t)BlockSize;
++    sdio_cmdinitstructure.CmdIndex         = SD_CMD_SET_BLOCKLEN;
++
++    SDIO_SendCommand(hsd->Instance, &sdio_cmdinitstructure);
+   
+-  /* Check for error conditions */
+-  errorstate = SD_CmdResp1Error(hsd, SD_CMD_SET_BLOCKLEN);
++    /* Check for error conditions */
++    errorstate = SD_CmdResp1Error(hsd, SD_CMD_SET_BLOCKLEN);
+   
+-  if (errorstate != SD_OK)
+-  {
+-    return errorstate;
++    if (errorstate != SD_OK)
++    {
++      return errorstate;
++    }
+   }
+   
+   /* Configure the SD DPSM (Data Path State Machine) */ 
+@@ -931,6 +933,11 @@ HAL_SD_ErrorTypedef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pRead
+   sdio_datainitstructure.TransferDir   = SDIO_TRANSFER_DIR_TO_SDIO;
+   sdio_datainitstructure.TransferMode  = SDIO_TRANSFER_MODE_BLOCK;
+   sdio_datainitstructure.DPSM          = SDIO_DPSM_ENABLE;
++
++  // We cannot enable DMA too early on UHS-I class 3 SD cards, or else the
++  // data is just discarded before the dpsm is started.
++  __HAL_SD_SDIO_DMA_ENABLE();
++
+   SDIO_DataConfig(hsd->Instance, &sdio_datainitstructure);
+   
+   /* Check number of blocks command */
+@@ -1017,28 +1024,30 @@ HAL_SD_ErrorTypedef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pWri
+   HAL_DMA_Start_IT(hsd->hdmatx, (uint32_t)pWriteBuffer, (uint32_t)&hsd->Instance->FIFO, (uint32_t)(BlockSize * NumberOfBlocks)/4);
+   /* Enable SDIO DMA transfer */
+-  __HAL_SD_SDIO_DMA_ENABLE();
++  // MM disabled, as this fails on fast cards. __HAL_SD_SDIO_DMA_ENABLE();
++  
++  sdio_cmdinitstructure.Response         = SDIO_RESPONSE_SHORT;
++  sdio_cmdinitstructure.WaitForInterrupt = SDIO_WAIT_NO;
++  sdio_cmdinitstructure.CPSM             = SDIO_CPSM_ENABLE;
+   
+   if (hsd->CardType == HIGH_CAPACITY_SD_CARD)
+   {
+     BlockSize = 512;
+     WriteAddr /= 512;
+-  }
++  } else {
++      /* Set Block Size for Card */ 
++    sdio_cmdinitstructure.Argument         = (uint32_t)BlockSize;
++    sdio_cmdinitstructure.CmdIndex         = SD_CMD_SET_BLOCKLEN;
+-  /* Set Block Size for Card */ 
+-  sdio_cmdinitstructure.Argument         = (uint32_t)BlockSize;
+-  sdio_cmdinitstructure.CmdIndex         = SD_CMD_SET_BLOCKLEN;
+-  sdio_cmdinitstructure.Response         = SDIO_RESPONSE_SHORT;
+-  sdio_cmdinitstructure.WaitForInterrupt = SDIO_WAIT_NO;
+-  sdio_cmdinitstructure.CPSM             = SDIO_CPSM_ENABLE;
+-  SDIO_SendCommand(hsd->Instance, &sdio_cmdinitstructure);
++    SDIO_SendCommand(hsd->Instance, &sdio_cmdinitstructure);
+-  /* Check for error conditions */
+-  errorstate = SD_CmdResp1Error(hsd, SD_CMD_SET_BLOCKLEN);
++    /* Check for error conditions */
++    errorstate = SD_CmdResp1Error(hsd, SD_CMD_SET_BLOCKLEN);
+-  if (errorstate != SD_OK)
+-  {
+-    return errorstate;
++    if (errorstate != SD_OK)
++    {
++      return errorstate;
++    }
+   }
+   
+   /* Check number of blocks command */
+@@ -1049,13 +1058,34 @@ HAL_SD_ErrorTypedef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pWri
+   }
+   else
+   {
++    /* MM: Prepare for write */
++    sdio_cmdinitstructure.Argument         = (uint32_t)(hsd->RCA << 16);
++    sdio_cmdinitstructure.CmdIndex         = SD_CMD_APP_CMD;
++    SDIO_SendCommand(hsd->Instance, &sdio_cmdinitstructure);
++    errorstate = SD_CmdResp1Error(hsd, SD_CMD_APP_CMD);
++    if (errorstate != SD_OK)
++    {
++      return errorstate;
++    }
++    sdio_cmdinitstructure.Argument         = (uint32_t)NumberOfBlocks;
++    sdio_cmdinitstructure.CmdIndex         = SD_CMD_SET_BLOCK_COUNT;
++    SDIO_SendCommand(hsd->Instance, &sdio_cmdinitstructure);
++    errorstate = SD_CmdResp1Error(hsd, SD_CMD_SET_BLOCK_COUNT);
++    if (errorstate != SD_OK)
++    {
++      return errorstate;
++    }
++  
++    /* /MM */
++
+     /* Send CMD25 WRITE_MULT_BLOCK with argument data address */
+     sdio_cmdinitstructure.CmdIndex = SD_CMD_WRITE_MULT_BLOCK;
+   }
+-  
++
+   sdio_cmdinitstructure.Argument         = (uint32_t)WriteAddr;
+   SDIO_SendCommand(hsd->Instance, &sdio_cmdinitstructure);
++
+   /* Check for error conditions */
+   if(NumberOfBlocks > 1)
+   {
+@@ -1078,6 +1108,11 @@ HAL_SD_ErrorTypedef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, uint32_t *pWri
+   sdio_datainitstructure.TransferDir   = SDIO_TRANSFER_DIR_TO_CARD;
+   sdio_datainitstructure.TransferMode  = SDIO_TRANSFER_MODE_BLOCK;
+   sdio_datainitstructure.DPSM          = SDIO_DPSM_ENABLE;
++
++  // We cannot enable DMA too early on UHS-I class 3 SD cards, or else the
++  // data is just discarded before the dpsm is started.
++  __HAL_SD_SDIO_DMA_ENABLE();
++
+   SDIO_DataConfig(hsd->Instance, &sdio_datainitstructure);
+   
+   hsd->SdTransferErr = errorstate;
+@@ -1116,7 +1151,9 @@ HAL_SD_ErrorTypedef HAL_SD_CheckReadOperation(SD_HandleTypeDef *hsd, uint32_t Ti
+   
+   timeout = Timeout;
+   
+-  /* Wait until the Rx transfer is no longer active */
++  /* Wait until the Rx transfer is no longer active. IE. fifo is empty.
++Once FIFO is empty, the DMA will have finished and DmaTransferCplt should
++be true */
+   while((__HAL_SD_SDIO_GET_FLAG(hsd, SDIO_FLAG_RXACT)) && (timeout > 0))
+   {
+     timeout--;  
+@@ -1916,10 +1953,12 @@ HAL_SD_ErrorTypedef HAL_SD_HighSpeed (SD_HandleTypeDef *hsd)
+     __HAL_SD_SDIO_CLEAR_FLAG(hsd, SDIO_STATIC_FLAGS);
+     
+     /* Test if the switch mode HS is ok */
+-    if ((SD_hs[13]& 2) != 2)
+-    {
+-      errorstate = SD_UNSUPPORTED_FEATURE;
+-    } 
++    // MM: These bits (0 to 271) are reserved in the spec I'm looking at ???
++    // Should be safe to ignore the result.
++    //if ((SD_hs[13]& 2) != 2)
++    //{
++      //errorstate = SD_UNSUPPORTED_FEATURE;
++    //} 
+   }
+   
+   return errorstate;
+diff --git b/STM32CubeMX/SCSI2SD-V6/Inc/stm32f2xx_hal_conf.h a/STM32CubeMX/SCSI2SD-V6/Inc/stm32f2xx_hal_conf.h
+index ef23c94..c899300 100755
+--- b/STM32CubeMX/SCSI2SD-V6/Inc/stm32f2xx_hal_conf.h
++++ a/STM32CubeMX/SCSI2SD-V6/Inc/stm32f2xx_hal_conf.h
+@@ -76,7 +76,7 @@
+ //#define HAL_SMARTCARD_MODULE_ENABLED   
+ //#define HAL_WWDG_MODULE_ENABLED   
+ #define HAL_PCD_MODULE_ENABLED
+-//#define HAL_HCD_MODULE_ENABLED   
++#define HAL_HCD_MODULE_ENABLED
+ #define HAL_GPIO_MODULE_ENABLED
+ #define HAL_DMA_MODULE_ENABLED
+ #define HAL_RCC_MODULE_ENABLED
+diff --git b/STM32CubeMX/SCSI2SD-V6/Inc/stm32f2xx_it.h a/STM32CubeMX/SCSI2SD-V6/Inc/stm32f2xx_it.h
+index a2efe1f..4c7075a 100755
+--- b/STM32CubeMX/SCSI2SD-V6/Inc/stm32f2xx_it.h
++++ a/STM32CubeMX/SCSI2SD-V6/Inc/stm32f2xx_it.h
+@@ -46,11 +46,13 @@
+ /* Exported functions ------------------------------------------------------- */
+ void SysTick_Handler(void);
++void EXTI3_IRQHandler(void);
+ void EXTI4_IRQHandler(void);
+ void SDIO_IRQHandler(void);
+ void DMA2_Stream3_IRQHandler(void);
+ void OTG_FS_IRQHandler(void);
+ void DMA2_Stream6_IRQHandler(void);
+ #ifdef __cplusplus
+ }
+diff --git b/STM32CubeMX/SCSI2SD-V6/Src/fsmc.c a/STM32CubeMX/SCSI2SD-V6/Src/fsmc.c
+index c257924..5261aa9 100755
+--- b/STM32CubeMX/SCSI2SD-V6/Src/fsmc.c
++++ a/STM32CubeMX/SCSI2SD-V6/Src/fsmc.c
+@@ -66,12 +66,28 @@ void MX_FSMC_Init(void)
+   hsram1.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE;
+   hsram1.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE;
+   /* Timing */
++
++  // 1 clock to read the address, + 1 for synchroniser skew
+   Timing.AddressSetupTime = 2;
+   Timing.AddressHoldTime = 1;
++
++  // Writes to device:
++  //   1 for synchroniser skew (dbx also delayed)
++  //   1 to skip hold time
++  //   1 to write data.
++
++  // Reads from device:
++  //   3 for syncroniser
++  //   1 to write back to fsmc bus.
+   Timing.DataSetupTime = 4;
++
++  // Allow a clock for us to release signals
++  // Need to avoid both devices acting as outputs
++  // on the multiplexed lines at the same time.
+   Timing.BusTurnAroundDuration = 1;
+-  Timing.CLKDivision = 16;
+-  Timing.DataLatency = 17;
++
++  Timing.CLKDivision = 16; // Ignored for async
++  Timing.DataLatency = 17; // Ignored for async
+   Timing.AccessMode = FSMC_ACCESS_MODE_A;
+   /* ExtTiming */
+@@ -91,7 +107,7 @@ static void HAL_FSMC_MspInit(void){
+   }
+   FSMC_Initialized = 1;
+   /* Peripheral clock enable */
+-  #__FSMC_CLK_ENABLE();
++  __FSMC_CLK_ENABLE();
+   
+   /** FSMC GPIO Configuration  
+   PE7   ------> FSMC_DA4
+@@ -103,9 +119,6 @@ static void HAL_FSMC_MspInit(void){
+   PE13   ------> FSMC_DA10
+   PE14   ------> FSMC_DA11
+   PE15   ------> FSMC_DA12
+-  PD8   ------> FSMC_DA13
+-  PD9   ------> FSMC_DA14
+-  PD10   ------> FSMC_DA15
+   PD14   ------> FSMC_DA0
+   PD15   ------> FSMC_DA1
+   PD0   ------> FSMC_DA2
+@@ -113,28 +126,31 @@ static void HAL_FSMC_MspInit(void){
+   PD4   ------> FSMC_NOE
+   PD5   ------> FSMC_NWE
+   PD7   ------> FSMC_NE1
++  PD8   ------> FSMC_DA13
++  PD9   ------> FSMC_DA14
++  PD10  ------> FSMC_DA15
+   PB7   ------> FSMC_NL
+   PE0   ------> FSMC_NBL0
+   PE1   ------> FSMC_NBL1
+   */
++  // MM: GPIO_SPEED_FREQ_MEDIUM is rated up to 50MHz, which is fine as all the
++  // fsmc timings are > 1 (ie. so clock speed / 2 is around 50MHz).
++
+   /* GPIO_InitStruct */
+-  GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 
+-                          |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 
+-                          |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1;
++  GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
+   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+   GPIO_InitStruct.Pull = GPIO_NOPULL;
+-  GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
++  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; //HIGH;
+   GPIO_InitStruct.Alternate = GPIO_AF12_FSMC;
+   HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
+   /* GPIO_InitStruct */
+-  GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 
+-                          |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4 
+-                          |GPIO_PIN_5|GPIO_PIN_7;
++  GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1 
++                          |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10;
+   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+   GPIO_InitStruct.Pull = GPIO_NOPULL;
+-  GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
++  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; //HIGH;
+   GPIO_InitStruct.Alternate = GPIO_AF12_FSMC;
+   HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
+@@ -143,7 +159,7 @@ static void HAL_FSMC_MspInit(void){
+   GPIO_InitStruct.Pin = GPIO_PIN_7;
+   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+   GPIO_InitStruct.Pull = GPIO_NOPULL;
+-  GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
++  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;//HIGH;
+   GPIO_InitStruct.Alternate = GPIO_AF12_FSMC;
+   HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+@@ -186,9 +202,6 @@ static void HAL_FSMC_MspDeInit(void){
+   PE13   ------> FSMC_DA10
+   PE14   ------> FSMC_DA11
+   PE15   ------> FSMC_DA12
+-  PD8   ------> FSMC_DA13
+-  PD9   ------> FSMC_DA14
+-  PD10   ------> FSMC_DA15
+   PD14   ------> FSMC_DA0
+   PD15   ------> FSMC_DA1
+   PD0   ------> FSMC_DA2
+@@ -196,18 +209,18 @@ static void HAL_FSMC_MspDeInit(void){
+   PD4   ------> FSMC_NOE
+   PD5   ------> FSMC_NWE
+   PD7   ------> FSMC_NE1
++  PD8   ------> FSMC_DA13
++  PD9   ------> FSMC_DA14
++  PD10  ------> FSMC_DA15
+   PB7   ------> FSMC_NL
+   PE0   ------> FSMC_NBL0
+   PE1   ------> FSMC_NBL1
+   */
+-  HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10 
+-                          |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14 
+-                          |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1);
++  HAL_GPIO_DeInit(GPIOE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15);
+-  HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_14 
+-                          |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_4 
+-                          |GPIO_PIN_5|GPIO_PIN_7);
++  HAL_GPIO_DeInit(GPIOD, GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1 
++                          |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10);
+   HAL_GPIO_DeInit(GPIOB, GPIO_PIN_7);
+diff --git b/STM32CubeMX/SCSI2SD-V6/Src/gpio.c a/STM32CubeMX/SCSI2SD-V6/Src/gpio.c
+index 21529ff..5682f25 100755
+--- b/STM32CubeMX/SCSI2SD-V6/Src/gpio.c
++++ a/STM32CubeMX/SCSI2SD-V6/Src/gpio.c
+@@ -68,17 +68,17 @@ void MX_GPIO_Init(void)
+   __GPIOB_CLK_ENABLE();
+   __GPIOD_CLK_ENABLE();
+-  /*Configure GPIO pins : PEPin PEPin PEPin */
++  /*Configure GPIO pins : PEPin PEPin PEPin PEPin */
+   GPIO_InitStruct.Pin = FPGA_GPIO2_Pin|UNUSED_PE5_Pin|UNUSED_PE6_Pin;
+   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+   GPIO_InitStruct.Pull = GPIO_PULLDOWN;
+   HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
+-  /*Configure GPIO pin : PtPin */
++  /*Configure GPIO pin : PE3 */
+   GPIO_InitStruct.Pin = FPGA_GPIO3_Pin;
+   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+   GPIO_InitStruct.Pull = GPIO_NOPULL;
+-  HAL_GPIO_Init(FPGA_GPIO3_GPIO_Port, &GPIO_InitStruct);
++  HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
+   /*Configure GPIO pin : PE4 */
+   GPIO_InitStruct.Pin = GPIO_PIN_4;
+@@ -96,10 +96,8 @@ void MX_GPIO_Init(void)
+   GPIO_InitStruct.Pull = GPIO_PULLDOWN;
+   HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
+-  /*Configure GPIO pins : PAPin PAPin PAPin PAPin 
+-                           PA10 */
+-  GPIO_InitStruct.Pin = UNUSED_PA0_Pin|UNUSED_PA1_Pin|UNUSED_PA2_Pin|UNUSED_PA3_Pin 
+-                          |GPIO_PIN_10;
++  /*Configure GPIO pins : PAPin PAPin PAPin PAPin */
++  GPIO_InitStruct.Pin = UNUSED_PA0_Pin|UNUSED_PA1_Pin|UNUSED_PA2_Pin|UNUSED_PA3_Pin;
+   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+   GPIO_InitStruct.Pull = GPIO_PULLDOWN;
+   HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+@@ -125,14 +123,26 @@ void MX_GPIO_Init(void)
+   GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
+   HAL_GPIO_Init(nTERM_EN_GPIO_Port, &GPIO_InitStruct);
+-  /*Configure GPIO pins : PBPin PBPin PBPin PB14 
+-                           PB15 PBPin PBPin */
+-  GPIO_InitStruct.Pin = BOOT1_Pin|UNUSED_PB12_Pin|UNUSED_PB13_Pin|GPIO_PIN_14 
+-                          |GPIO_PIN_15|UNUSED_PB5_Pin|UNUSED_PB6_Pin;
++  /*Configure GPIO pins : PBPin PBPin PBPin */
++  GPIO_InitStruct.Pin = BOOT1_Pin|UNUSED_PB5_Pin|UNUSED_PB6_Pin;
++  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
++  GPIO_InitStruct.Pull = GPIO_PULLDOWN;
++  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
++
++  /*Configure GPIO pins : PBPin PBPin */
++  GPIO_InitStruct.Pin = UNUSED_PB12_Pin|UNUSED_PB13_Pin;
+   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+   GPIO_InitStruct.Pull = GPIO_PULLDOWN;
+   HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
++  /*Configure GPIO pins : PD6, PD12 */
++  // PD6: FSMC NWAIT, not used yet.PULLED UP in fpga pin config
++  // PD12: FPGA_GPIO1, not used.
++  GPIO_InitStruct.Pin = GPIO_PIN_6 | GPIO_PIN_12;
++  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
++  GPIO_InitStruct.Pull = GPIO_PULLUP;
++  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
++
+   /*Configure GPIO pins : PDPin PDPin */
+   GPIO_InitStruct.Pin = UNUSED_PD11_Pin|FSMC_UNUSED_CLK_Pin;
+   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+@@ -160,11 +170,18 @@ void MX_GPIO_Init(void)
+   GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
+   HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+-  /*Configure GPIO pin : PD6 */
+-  GPIO_InitStruct.Pin = GPIO_PIN_6;
+-  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
+-  GPIO_InitStruct.Pull = GPIO_NOPULL;
+-  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
++  /*Configure GPIO pin : PA10 */
++  // USB Host OTG ID pin
++  GPIO_InitStruct.Pin = GPIO_PIN_10;
++  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
++  GPIO_InitStruct.Pull = GPIO_PULLDOWN;
++  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
++
++  // USB Host pins, currently unused.
++  GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15;
++  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
++  GPIO_InitStruct.Pull = GPIO_PULLDOWN;
++  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+   /*Configure GPIO pins : PBPin PBPin */
+   GPIO_InitStruct.Pin = nSD_WP_Pin|nSD_CD_Pin;
+diff --git b/STM32CubeMX/SCSI2SD-V6/Src/main.c a/STM32CubeMX/SCSI2SD-V6/Src/main.c
+index 48e1f9a..a80e078 100755
+--- b/STM32CubeMX/SCSI2SD-V6/Src/main.c
++++ a/STM32CubeMX/SCSI2SD-V6/Src/main.c
+@@ -32,12 +32,11 @@
+   */
+ /* Includes ------------------------------------------------------------------*/
+ #include "stm32f2xx_hal.h"
+-#include "dma.h"
+ #include "sdio.h"
+ #include "spi.h"
+-#include "tim.h"
+ #include "usart.h"
+ #include "usb_device.h"
+ #include "gpio.h"
+ #include "fsmc.h"
+@@ -87,14 +87,11 @@ int main(void)
+   /* Initialize all configured peripherals */
+   MX_GPIO_Init();
+-  MX_DMA_Init();
+-  SystemClock_Config();
+   MX_FSMC_Init();
+   MX_SDIO_SD_Init();
+   MX_SPI1_Init();
+-  MX_TIM4_Init();
+-  MX_USART3_UART_Init();
+-  MX_USB_DEVICE_Init();
++  MX_USART3_UART_Init(); // Not used, but we don't want the pins floating.
+   /* USER CODE BEGIN 2 */
+   mainInit();
+diff --git b/STM32CubeMX/SCSI2SD-V6/Src/sdio.c a/STM32CubeMX/SCSI2SD-V6/Src/sdio.c
+index e8b2ad8..0f9a34b 100755
+--- b/STM32CubeMX/SCSI2SD-V6/Src/sdio.c
++++ a/STM32CubeMX/SCSI2SD-V6/Src/sdio.c
+@@ -36,7 +36,6 @@
+ #include "sdio.h"
+ #include "gpio.h"
+-#include "dma.h"
+ /* USER CODE BEGIN 0 */
+@@ -59,9 +58,6 @@ void MX_SDIO_SD_Init(void)
+   hsd.Init.BusWide = SDIO_BUS_WIDE_1B;
+   hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
+   hsd.Init.ClockDiv = 0;
+-  HAL_SD_Init(&hsd, &SDCardInfo);
+-
+-  HAL_SD_WideBusOperation_Config(&hsd, SDIO_BUS_WIDE_4B);
+ }
+@@ -143,6 +140,7 @@ void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
+     __HAL_LINKDMA(hsd,hdmarx,hdma_sdio_rx);
+     /* Peripheral interrupt init*/
++      HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
+     HAL_NVIC_SetPriority(SDIO_IRQn, 0, 0);
+     HAL_NVIC_EnableIRQ(SDIO_IRQn);
+   /* USER CODE BEGIN SDIO_MspInit 1 */
+diff --git b/STM32CubeMX/SCSI2SD-V6/Src/spi.c a/STM32CubeMX/SCSI2SD-V6/Src/spi.c
+index cfb19ce..25e0745 100755
+--- b/STM32CubeMX/SCSI2SD-V6/Src/spi.c
++++ a/STM32CubeMX/SCSI2SD-V6/Src/spi.c
+@@ -54,6 +54,7 @@ void MX_SPI1_Init(void)
+   hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH;
+   hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
+   hspi1.Init.NSS = SPI_NSS_SOFT;
++  // (96MHz / 2) / 4 = 12MHz. FPGA device allows up to 25MHz write
+   hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
+   hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
+   hspi1.Init.TIMode = SPI_TIMODE_DISABLED;
+diff --git b/STM32CubeMX/SCSI2SD-V6/Src/stm32f2xx_hal_msp.c a/STM32CubeMX/SCSI2SD-V6/Src/stm32f2xx_hal_msp.c
+index e6b7783..b7ab0a3 100755
+--- b/STM32CubeMX/SCSI2SD-V6/Src/stm32f2xx_hal_msp.c
++++ a/STM32CubeMX/SCSI2SD-V6/Src/stm32f2xx_hal_msp.c
+@@ -50,14 +50,6 @@ void HAL_MspInit(void)
+   HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
+   /* System interrupt init*/
+-  /* MemoryManagement_IRQn interrupt configuration */
+-  HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0);
+-  /* BusFault_IRQn interrupt configuration */
+-  HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0);
+-  /* UsageFault_IRQn interrupt configuration */
+-  HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0);
+-  /* DebugMonitor_IRQn interrupt configuration */
+-  HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0);
+   /* SysTick_IRQn interrupt configuration */
+   HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
+diff --git b/STM32CubeMX/SCSI2SD-V6/Src/usbd_conf.c a/STM32CubeMX/SCSI2SD-V6/Src/usbd_conf.c
+index 272d388..07387ca 100755
+--- b/STM32CubeMX/SCSI2SD-V6/Src/usbd_conf.c
++++ a/STM32CubeMX/SCSI2SD-V6/Src/usbd_conf.c
+@@ -108,7 +108,18 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd)
+     PA11     ------> USB_OTG_FS_DM
+     PA12     ------> USB_OTG_FS_DP 
+     */
+-    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_12);
++      // HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_12);
++      // MM: Don't let pins float.
++      GPIO_InitTypeDef GPIO_InitStruct;
++      GPIO_InitStruct.Pin = GPIO_PIN_9;
++      GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
++      GPIO_InitStruct.Pull = GPIO_PULLDOWN;
++      HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
++
++      GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
++      GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
++      GPIO_InitStruct.Pull = GPIO_PULLDOWN;
++      HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+     /* Peripheral interrupt Deinit*/
+     HAL_NVIC_DisableIRQ(OTG_FS_IRQn);
+@@ -294,9 +305,11 @@ USBD_StatusTypeDef  USBD_LL_Init (USBD_HandleTypeDef *pdev)
+   hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE;
+   HAL_PCD_Init(&hpcd_USB_OTG_FS);
++  // Sum of all FIFOs must be <= 320.
+   HAL_PCD_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80);
+   HAL_PCD_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40);
+-  HAL_PCD_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80);
++  HAL_PCD_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x40);
++  HAL_PCD_SetTxFiFo(&hpcd_USB_OTG_FS, 2, 0x40);
+   }
+   return USBD_OK;
+ }