[bsp][stm32][f469-disco]Fix the BUG of SD card hot plug detection

Signed-off-by: Willian Chan <chentingwei@rt-thread.com>
This commit is contained in:
Willian Chan 2019-06-15 09:51:34 +08:00
parent d4ad48d893
commit 6e7baa7fd5
3 changed files with 7 additions and 6 deletions

View File

@ -24,7 +24,7 @@ CONFIG_RT_USING_TIMER_SOFT=y
CONFIG_RT_TIMER_THREAD_PRIO=4
CONFIG_RT_TIMER_THREAD_STACK_SIZE=512
CONFIG_RT_DEBUG=y
# CONFIG_RT_DEBUG_COLOR is not set
CONFIG_RT_DEBUG_COLOR=y
# CONFIG_RT_DEBUG_INIT_CONFIG is not set
# CONFIG_RT_DEBUG_THREAD_CONFIG is not set
# CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set

View File

@ -64,20 +64,20 @@ static void _sdcard_unmount(void)
static void sd_mount(void *parameter)
{
rt_uint8_t re_sd_check = 1;
rt_uint8_t re_sd_check_pin = 1;
while (1)
{
rt_thread_mdelay(200);
if(re_sd_check && !rt_pin_read(SD_CHECK_PIN))
if(re_sd_check_pin && (re_sd_check_pin = rt_pin_read(SD_CHECK_PIN)) == 0)
{
_sdcard_mount();
}
if (!re_sd_check && rt_pin_read(SD_CHECK_PIN))
if (!re_sd_check_pin && (re_sd_check_pin = rt_pin_read(SD_CHECK_PIN)) != 0)
{
_sdcard_unmount();
}
re_sd_check = rt_pin_read(SD_CHECK_PIN);
}
}
@ -88,7 +88,7 @@ int stm32_sdcard_mount(void)
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 - 1, 20);
1024, RT_THREAD_PRIORITY_MAX - 2, 20);
if (tid != RT_NULL)
{
rt_thread_startup(tid);

View File

@ -20,6 +20,7 @@
#define RT_TIMER_THREAD_PRIO 4
#define RT_TIMER_THREAD_STACK_SIZE 512
#define RT_DEBUG
#define RT_DEBUG_COLOR
/* Inter-Thread communication */