修复按键与BOOT冲突
This commit is contained in:
@@ -14,7 +14,7 @@ cfg_board_pin_io_t boot_switch = {
|
|||||||
|
|
||||||
bool key_single_click = 0,key_press_down = 0,key_press_up = 0;
|
bool key_single_click = 0,key_press_down = 0,key_press_up = 0;
|
||||||
|
|
||||||
|
static os_work_t work_handler_button;
|
||||||
// 用户在此处理按键事件
|
// 用户在此处理按键事件
|
||||||
static void my_button_handler(button_event_t evt) {
|
static void my_button_handler(button_event_t evt) {
|
||||||
switch (evt) {
|
switch (evt) {
|
||||||
@@ -35,6 +35,8 @@ static void my_button_handler(button_event_t evt) {
|
|||||||
case EVT_DOUBLE_CLICK: //双击
|
case EVT_DOUBLE_CLICK: //双击
|
||||||
// SYS_LOG_INF("[Event] DOUBLE_CLICK");
|
// SYS_LOG_INF("[Event] DOUBLE_CLICK");
|
||||||
// sertrf_rf_switch(1);
|
// sertrf_rf_switch(1);
|
||||||
|
// aes_test();
|
||||||
|
key_test();
|
||||||
break;
|
break;
|
||||||
case EVT_LONG_PRESS: //长按
|
case EVT_LONG_PRESS: //长按
|
||||||
SYS_LOG_INF("[Event] LONG_PRESS");
|
SYS_LOG_INF("[Event] LONG_PRESS");
|
||||||
@@ -44,7 +46,7 @@ static void my_button_handler(button_event_t evt) {
|
|||||||
break;
|
break;
|
||||||
case EVT_SINGLE_LONG_PRESS: //单击后长按
|
case EVT_SINGLE_LONG_PRESS: //单击后长按
|
||||||
rgb_Indicator_light_off(0);
|
rgb_Indicator_light_off(0);
|
||||||
// wifi_mode_switch(NULL);
|
wifi_mode_switch(NULL);
|
||||||
SYS_LOG_INF("[Event] SINGLE_LONG_PRESS");
|
SYS_LOG_INF("[Event] SINGLE_LONG_PRESS");
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
@@ -176,13 +178,16 @@ void button_work_init() {
|
|||||||
|
|
||||||
button_init(&btn, read_button_pin, my_button_handler);
|
button_init(&btn, read_button_pin, my_button_handler);
|
||||||
|
|
||||||
static os_work_t work_handler_button;
|
|
||||||
os_work_create(&work_handler_button, "work-button", _work_button, NULL, OS_PRIORITY_NORMAL);
|
os_work_create(&work_handler_button, "work-button", _work_button, NULL, OS_PRIORITY_NORMAL);
|
||||||
os_work_submit(default_os_work_q_hdl, &work_handler_button, 10);
|
os_work_submit(default_os_work_q_hdl, &work_handler_button, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void boot_set(uint8_t value)
|
void boot_set(uint8_t value)
|
||||||
{
|
{
|
||||||
|
// 设置按键为高阻态,防止冲突
|
||||||
|
gpio_to_high_z(&key_switch);
|
||||||
|
os_work_suspend(&work_handler_button);
|
||||||
|
|
||||||
pin_cfg_output(&boot_switch);
|
pin_cfg_output(&boot_switch);
|
||||||
pin_set_valid(&boot_switch, value);
|
pin_set_valid(&boot_switch, value);
|
||||||
}
|
}
|
||||||
@@ -190,4 +195,17 @@ void boot_set(uint8_t value)
|
|||||||
void boot_set_high_z(void)
|
void boot_set_high_z(void)
|
||||||
{
|
{
|
||||||
gpio_to_high_z(&boot_switch);
|
gpio_to_high_z(&boot_switch);
|
||||||
|
//重新初始化按键
|
||||||
|
pin_cfg_input(&key_switch);
|
||||||
|
os_work_resume(&work_handler_button,10);
|
||||||
|
// os_work_later(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
void key_test(void)
|
||||||
|
{
|
||||||
|
boot_set(0);
|
||||||
|
|
||||||
|
os_thread_sleep(5000);
|
||||||
|
|
||||||
|
boot_set_high_z();
|
||||||
}
|
}
|
||||||
@@ -58,4 +58,6 @@ void boot_set(uint8_t value);
|
|||||||
/**
|
/**
|
||||||
* @brief 设置boot按键为高阻态
|
* @brief 设置boot按键为高阻态
|
||||||
*/
|
*/
|
||||||
void boot_set_high_z(void);
|
void boot_set_high_z(void);
|
||||||
|
|
||||||
|
void key_test(void);
|
||||||
Reference in New Issue
Block a user