From 78cd967c489760d8e5035e2ac06f20ac14402167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=A9=AC=5F666?= <13089258+pony-six-hundred-and-sixty-six@user.noreply.gitee.com> Date: Fri, 24 Jan 2025 09:43:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E4=B8=8A=E7=94=B5?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=8F=91=E9=80=81=E4=B8=8D=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E6=97=B6,=E4=BB=8D=E7=84=B6=E5=8F=91=E9=80=81=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E4=BA=8B=E4=BB=B6=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- applications/user_sys.h | 2 +- bsp/inc/bsp_button.h | 2 +- bsp/src/bsp_button.c | 49 +++++++++++++++-------------------------- bsp/src/bsp_nt26k.c | 8 ++++++- 4 files changed, 27 insertions(+), 34 deletions(-) diff --git a/applications/user_sys.h b/applications/user_sys.h index d45319b..5a582a8 100644 --- a/applications/user_sys.h +++ b/applications/user_sys.h @@ -35,7 +35,7 @@ // 定义宏来打印编译时间和日期 #define COMPILE_TIME \ do { \ - rt_kprintf("Compiled on: %s at %s\n", __DATE__, __TIME__); \ + rt_kprintf("Compiled at: %s\n", __TIMESTAMP__); \ } while (0) typedef enum diff --git a/bsp/inc/bsp_button.h b/bsp/inc/bsp_button.h index 1864172..b24bdb7 100644 --- a/bsp/inc/bsp_button.h +++ b/bsp/inc/bsp_button.h @@ -9,7 +9,7 @@ #endif // 不然就是用 timer 实现按键扫描处理 -// #define BUTTON_USE_THREAD +#define BUTTON_USE_THREAD #ifdef BUTTON_USE_THREAD #define BUTTON_THREAD_PRIORITY 5 // 优先级拉高,这时按键响应快点 diff --git a/bsp/src/bsp_button.c b/bsp/src/bsp_button.c index a47fd8a..b9f2a59 100644 --- a/bsp/src/bsp_button.c +++ b/bsp/src/bsp_button.c @@ -105,44 +105,31 @@ int BSP_BUTTON_Init(void) flex_button_register(&user_button[i]); } #ifdef BUTTON_USE_THREAD - // ret = rt_thread_init(&button_thread, - // "button_thread", - // _BUTTON_Process, - // RT_NULL, - // &button_thread_stack[0], - // sizeof(button_thread_stack), - // BUTTON_THREAD_PRIORITY, - // BUTTON_THREAD_TICKS); + ret = rt_thread_init(&button_thread, + "button_thread", + _BUTTON_Process, + RT_NULL, + &button_thread_stack[0], + sizeof(button_thread_stack), + BUTTON_THREAD_PRIORITY, + BUTTON_THREAD_TICKS); - // if (ret == RT_EOK) - // { - // rt_thread_startup(&button_thread); - // return RT_EOK; - // } - // else - // { - // LOG_E("button_thread create failed"); - // return -RT_ERROR; - // } + if (ret == RT_EOK) + { + rt_thread_startup(&button_thread); + return RT_EOK; + } + else + { + LOG_E("button_thread create failed"); + return -RT_ERROR; + } #else // TODO:这里改的静态 rt_timer_init(&button_timer1, "button_timer", _BUTTON_Process, RT_NULL, 20, RT_TIMER_FLAG_PERIODIC); rt_timer_start(&button_timer1); - - // button_timer = rt_timer_create("button_timer", _BUTTON_Process, - // RT_NULL, 20, - // RT_TIMER_FLAG_PERIODIC); - // if (button_timer != RT_NULL) - // { - // rt_timer_start(button_timer); - // } - // else - // { - // LOG_E("create button_timer fail"); - // return -RT_ERROR; - // } #endif // !BUTTON_USE_THREAD LOG_I("BSP_BUTTON_Init!"); diff --git a/bsp/src/bsp_nt26k.c b/bsp/src/bsp_nt26k.c index a36e083..ec4efaa 100644 --- a/bsp/src/bsp_nt26k.c +++ b/bsp/src/bsp_nt26k.c @@ -171,7 +171,13 @@ void Nt26k_Send_Event(Nt26kEvent event_type) nt26k_event_index.current_event = event_type; if (nt26k_event_initialized == RT_TRUE) { - rt_event_send(&at_device_event, Nt26k_Get_Event_Flag(event_type)); + if (nt26k_event_index.current_event != kNt26kPowerOnEvent) + { + if(power_on_send_flag) + { + rt_event_send(&at_device_event, Nt26k_Get_Event_Flag(event_type)); + } + } } else {