Merge pull request #2779 from willianchanlovegithub/469

[bsp][stm32][f469-disco]Fix the BUG of SD card hot plug detection
This commit is contained in:
Bernard Xiong 2019-06-15 18:13:30 +08:00 committed by GitHub
commit a6a01da3be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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_PRIO=4
CONFIG_RT_TIMER_THREAD_STACK_SIZE=512 CONFIG_RT_TIMER_THREAD_STACK_SIZE=512
CONFIG_RT_DEBUG=y 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_INIT_CONFIG is not set
# CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set
# CONFIG_RT_DEBUG_SCHEDULER_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) static void sd_mount(void *parameter)
{ {
rt_uint8_t re_sd_check = 1; rt_uint8_t re_sd_check_pin = 1;
while (1) while (1)
{ {
rt_thread_mdelay(200); 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(); _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(); _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); rt_pin_mode(SD_CHECK_PIN, PIN_MODE_INPUT_PULLUP);
tid = rt_thread_create("sd_mount", sd_mount, RT_NULL, 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) if (tid != RT_NULL)
{ {
rt_thread_startup(tid); rt_thread_startup(tid);

View File

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