未验证 提交 a6a01da3 编写于 作者: B Bernard Xiong 提交者: GitHub

Merge pull request #2779 from willianchanlovegithub/469

[bsp][stm32][f469-disco]Fix the BUG of SD card hot plug detection
......@@ -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
......
......@@ -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);
......
......@@ -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 */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册