diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_sdio.c b/bsp/stm32/libraries/HAL_Drivers/drv_sdio.c index 335b97da1c..61387f24ef 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_sdio.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_sdio.c @@ -7,6 +7,7 @@ * Date Author Notes * 2018-06-22 tyx first * 2018-12-12 balanceTWK first version + * 2019-06-11 WillianChan Add SD card hot plug detection */ #include "board.h" @@ -878,4 +879,9 @@ int rt_hw_sdio_init(void) } INIT_DEVICE_EXPORT(rt_hw_sdio_init); +void stm32_mmcsd_change(void) +{ + mmcsd_change(host); +} + #endif diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_sdio.h b/bsp/stm32/libraries/HAL_Drivers/drv_sdio.h index 1040dae24e..0d25c3310e 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_sdio.h +++ b/bsp/stm32/libraries/HAL_Drivers/drv_sdio.h @@ -6,6 +6,7 @@ * Change Logs: * Date Author Notes * 2018-12-13 BalanceTWK first version + * 2019-06-11 WillianChan Add SD card hot plug detection */ #ifndef _DRV_SDIO_H @@ -187,4 +188,6 @@ struct stm32_sdio_class } dma; }; +extern void stm32_mmcsd_change(void); + #endif diff --git a/bsp/stm32/stm32f469-st-disco/.config b/bsp/stm32/stm32f469-st-disco/.config index 7dfe488641..8bd3069cd8 100644 --- a/bsp/stm32/stm32f469-st-disco/.config +++ b/bsp/stm32/stm32f469-st-disco/.config @@ -66,8 +66,9 @@ CONFIG_RT_USING_DEVICE=y CONFIG_RT_USING_CONSOLE=y CONFIG_RT_CONSOLEBUF_SIZE=128 CONFIG_RT_CONSOLE_DEVICE_NAME="uart3" -CONFIG_RT_VER_NUM=0x40001 +CONFIG_RT_VER_NUM=0x40002 CONFIG_ARCH_ARM=y +CONFIG_RT_USING_CPU_FFS=y CONFIG_ARCH_ARM_CORTEX_M=y CONFIG_ARCH_ARM_CORTEX_M4=y # CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set @@ -169,6 +170,11 @@ CONFIG_RT_MMCSD_MAX_PARTITION=16 # CONFIG_RT_USING_AUDIO is not set # CONFIG_RT_USING_SENSOR is not set +# +# Using Hardware Crypto drivers +# +# CONFIG_RT_USING_HWCRYPTO is not set + # # Using WiFi # @@ -385,6 +391,35 @@ CONFIG_RT_USING_POSIX=y # CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set # CONFIG_PKG_USING_HELLO is not set # CONFIG_PKG_USING_VI is not set + +# +# Privated Packages of RealThread +# +# CONFIG_PKG_USING_CODEC is not set +# CONFIG_PKG_USING_PLAYER is not set +# CONFIG_PKG_USING_MPLAYER is not set +# CONFIG_PKG_USING_PERSIMMON_SRC is not set +# CONFIG_PKG_USING_JS_PERSIMMON is not set +# CONFIG_PKG_USING_JERRYSCRIPT_WIN32 is not set +# CONFIG_PKG_USING_LIBRWS is not set + +# +# Network Utilities +# +# CONFIG_PKG_USING_WICED is not set +# CONFIG_PKG_USING_CLOUDSDK is not set +# CONFIG_PKG_USING_COREMARK is not set +# CONFIG_PKG_USING_POWER_MANAGER is not set +# CONFIG_PKG_USING_RT_OTA is not set +# CONFIG_PKG_USING_RDBD_SRC is not set +# CONFIG_PKG_USING_RTINSIGHT is not set +# CONFIG_PKG_USING_SMARTCONFIG is not set +# CONFIG_PKG_USING_RTX is not set +# CONFIG_RT_USING_TESTCASE is not set +# CONFIG_PKG_USING_NGHTTP2 is not set +# CONFIG_PKG_USING_AVS is not set +# CONFIG_PKG_USING_STS is not set +# CONFIG_PKG_USING_DLMS is not set CONFIG_SOC_FAMILY_STM32=y CONFIG_SOC_SERIES_STM32F4=y @@ -397,6 +432,7 @@ CONFIG_SOC_STM32F469NI=y # Onboard Peripheral Drivers # # CONFIG_BSP_USING_SDRAM is not set +# CONFIG_BSP_USING_LCD_MIPI is not set # CONFIG_BSP_USING_LCD_OTM8009A is not set # CONFIG_BSP_USING_QSPI_FLASH is not set # CONFIG_BSP_USING_SDCARD is not set diff --git a/bsp/stm32/stm32f469-st-disco/README.md b/bsp/stm32/stm32f469-st-disco/README.md index 72cb52cba1..5f62930e92 100644 --- a/bsp/stm32/stm32f469-st-disco/README.md +++ b/bsp/stm32/stm32f469-st-disco/README.md @@ -43,7 +43,7 @@ STM32F469-ST-DISCO 是 ST 推出的一款基于 ARM Cortex-M4 内核的开发板 | :-----: | :-----: | :-----: | | SDRAM | 支持 | 16MB | | LCD | 支持 | MIPI屏,otm8009a | -| SDCARD | 支持 | | +| SDCARD | 支持 | 支持热插拔,插拔检测间隔为200ms | | TOUCH | 支持 | ft6206 | | **片上外设** | **支持情况** | **备注** | | GPIO | 支持 | | diff --git a/bsp/stm32/stm32f469-st-disco/board/ports/drv_sdcard.c b/bsp/stm32/stm32f469-st-disco/board/ports/drv_sdcard.c index ef539c46e4..0092949702 100644 --- a/bsp/stm32/stm32f469-st-disco/board/ports/drv_sdcard.c +++ b/bsp/stm32/stm32f469-st-disco/board/ports/drv_sdcard.c @@ -6,6 +6,7 @@ * Change Logs: * Date Author Notes * 2018-12-13 balanceTWK add sdcard port file + * 2019-06-11 WillianChan Add SD card hot plug detection */ #include @@ -16,37 +17,80 @@ #include #include #include "drv_gpio.h" +#include "drv_sdio.h" #define DBG_TAG "app.card" #define DBG_LVL DBG_INFO #include +/* SD Card hot plug detection pin */ +#define SD_CHECK_PIN GET_PIN(G, 2) + +void __mount(void) +{ + rt_device_t device; + + device = rt_device_find("sd0"); + if (device == NULL) + { + mmcsd_wait_cd_changed(0); + stm32_mmcsd_change(); + mmcsd_wait_cd_changed(RT_WAITING_FOREVER); + device = rt_device_find("sd0"); + } + + if (device != RT_NULL) + { + if (dfs_mount("sd0", "/", "elm", 0, 0) == RT_EOK) + { + LOG_I("sd card mount to '/'"); + } + else + { + LOG_W("sd card mount to '/' failed!"); + } + } +} + +void __unmount(void) +{ + rt_thread_mdelay(200); + dfs_unmount("/"); + LOG_I("Unmount \"/\""); + + mmcsd_wait_cd_changed(0); + stm32_mmcsd_change(); + mmcsd_wait_cd_changed(RT_WAITING_FOREVER); + +} + void sd_mount(void *parameter) { + rt_uint8_t re_sd_check = 1; + while (1) { - rt_thread_mdelay(500); - if(rt_device_find("sd0") != RT_NULL) + rt_thread_mdelay(200); + if(re_sd_check && !rt_pin_read(SD_CHECK_PIN)) { - if (dfs_mount("sd0", "/", "elm", 0, 0) == RT_EOK) - { - LOG_I("sd card mount to '/'"); - break; - } - else - { - LOG_W("sd card mount to '/' failed!"); - } + __mount(); } + if (!re_sd_check && rt_pin_read(SD_CHECK_PIN)) + { + __unmount(); + } + re_sd_check = rt_pin_read(SD_CHECK_PIN); } } int stm32_sdcard_mount(void) { rt_thread_t tid; + + rt_pin_mode(SD_CHECK_PIN, PIN_MODE_INPUT_PULLUP); tid = rt_thread_create("sd_mount", sd_mount, RT_NULL, - 1024, RT_THREAD_PRIORITY_MAX - 2, 20); + 1024, RT_THREAD_PRIORITY_MAX - 1, 20); if (tid != RT_NULL) { rt_thread_startup(tid); diff --git a/bsp/stm32/stm32f469-st-disco/rtconfig.h b/bsp/stm32/stm32f469-st-disco/rtconfig.h index c1dd72b873..7292221d2f 100644 --- a/bsp/stm32/stm32f469-st-disco/rtconfig.h +++ b/bsp/stm32/stm32f469-st-disco/rtconfig.h @@ -42,8 +42,9 @@ #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLE_DEVICE_NAME "uart3" -#define RT_VER_NUM 0x40001 +#define RT_VER_NUM 0x40002 #define ARCH_ARM +#define RT_USING_CPU_FFS #define ARCH_ARM_CORTEX_M #define ARCH_ARM_CORTEX_M4 @@ -109,6 +110,9 @@ #define RT_MMCSD_THREAD_PREORITY 22 #define RT_MMCSD_MAX_PARTITION 16 +/* Using Hardware Crypto drivers */ + + /* Using WiFi */ @@ -184,6 +188,12 @@ /* samples: kernel and components samples */ + +/* Privated Packages of RealThread */ + + +/* Network Utilities */ + #define SOC_FAMILY_STM32 #define SOC_SERIES_STM32F4