diff --git a/bsp/stm32/stm32f103-dofly-M3S/board/Kconfig b/bsp/stm32/stm32f103-dofly-M3S/board/Kconfig index 8ea2fa2093..282a6fda5f 100644 --- a/bsp/stm32/stm32f103-dofly-M3S/board/Kconfig +++ b/bsp/stm32/stm32f103-dofly-M3S/board/Kconfig @@ -7,7 +7,7 @@ config SOC_STM32F103ZE menu "Onboard Peripheral Drivers" - config BSP_USING_SDCARD + config BSP_USING_SDIO_SDCARD bool "Enable SDCARD (sdio)" select BSP_USING_SDIO select RT_USING_DFS @@ -15,6 +15,15 @@ menu "Onboard Peripheral Drivers" select RT_USING_PIN default n + config BSP_USING_SPI_SDCARD + bool "Enable SDCARD (spi2)" + select BSP_USING_SPI + select BSP_USING_SPI2 + select RT_USING_SPI_MSD + select RT_USING_DFS + select RT_USING_DFS_ELMFAT + default n + config BSP_USING_SPI_FLASH bool "Enable SPI FLASH (W25Q64 spi2)" select BSP_USING_SPI diff --git a/bsp/stm32/stm32f103-dofly-M3S/board/SConscript b/bsp/stm32/stm32f103-dofly-M3S/board/SConscript index c1cc4eef45..cd34843ab6 100644 --- a/bsp/stm32/stm32f103-dofly-M3S/board/SConscript +++ b/bsp/stm32/stm32f103-dofly-M3S/board/SConscript @@ -12,7 +12,10 @@ board.c CubeMX_Config/Src/stm32f1xx_hal_msp.c ''') -if GetDepend(['BSP_USING_SDCARD']): +if GetDepend(['BSP_USING_SDIO_SDCARD']): + src += Glob('ports/drv_sdcard.c') + +if GetDepend(['BSP_USING_SPI_SDCARD']): src += Glob('ports/drv_sdcard.c') if GetDepend(['BSP_USING_SPI_FLASH']): diff --git a/bsp/stm32/stm32f103-dofly-M3S/board/ports/drv_sdcard.c b/bsp/stm32/stm32f103-dofly-M3S/board/ports/drv_sdcard.c index ef539c46e4..5ffa50ba1d 100644 --- a/bsp/stm32/stm32f103-dofly-M3S/board/ports/drv_sdcard.c +++ b/bsp/stm32/stm32f103-dofly-M3S/board/ports/drv_sdcard.c @@ -6,12 +6,12 @@ * Change Logs: * Date Author Notes * 2018-12-13 balanceTWK add sdcard port file + * 2019-08-23 WillianChan add spi sdcard port code */ #include -#ifdef BSP_USING_SDCARD - +#if defined BSP_USING_SDIO_SDCARD || defined BSP_USING_SPI_SDCARD #include #include #include @@ -58,5 +58,16 @@ int stm32_sdcard_mount(void) return RT_EOK; } INIT_APP_EXPORT(stm32_sdcard_mount); +#endif /* BSP_USING_SDIO_SDCARD || BSP_USING_SPI_SDCARD */ -#endif /* BSP_USING_SDCARD */ +#ifdef BSP_USING_SPI_SDCARD +#include "drv_spi.h" +#include "spi_msd.h" +static int rt_hw_spi2_tfcard(void) +{ + __HAL_RCC_GPIOC_CLK_ENABLE(); + rt_hw_spi_device_attach("spi2", "spi20", GPIOD, GPIO_PIN_2); + return msd_init("sd0", "spi20"); +} +INIT_DEVICE_EXPORT(rt_hw_spi2_tfcard); +#endif /* BSP_USING_SPI_SDCARD */