添加按键高阻态、使飞控进入BOOT、擦除flash

This commit is contained in:
OPTOC
2025-10-21 16:18:57 +08:00
parent 88dadb4f0e
commit 793817d00e
5 changed files with 41 additions and 8 deletions

View File

@@ -6,7 +6,7 @@ cfg_board_pin_io_t key_switch = {
.pin = 9,
.en_lev = 0,};
cfg_board_pin_io_t boot_switch = {
.pin = ~0,
.pin = 18,
.en_lev = 0,};
// 新增事件类型
// EVT_DOUBLE_CLICK: 双击
@@ -34,17 +34,17 @@ static void my_button_handler(button_event_t evt) {
break;
case EVT_DOUBLE_CLICK: //双击
// SYS_LOG_INF("[Event] DOUBLE_CLICK");
sertrf_rf_switch(1);
// sertrf_rf_switch(1);
break;
case EVT_LONG_PRESS: //长按
SYS_LOG_INF("[Event] LONG_PRESS");
// Examples_run();
Examples_run();
rgb_Indicator_light_off(0); //如果处理有变色,需要该函数先调用
sertrf_rf_switch(0);
// sertrf_rf_switch(0);
break;
case EVT_SINGLE_LONG_PRESS: //单击后长按
rgb_Indicator_light_off(0);
wifi_mode_switch(NULL);
// wifi_mode_switch(NULL);
SYS_LOG_INF("[Event] SINGLE_LONG_PRESS");
break;
default: break;
@@ -171,7 +171,8 @@ void _work_button(void *arg) {
void button_work_init() {
pin_cfg_input(&key_switch);
pin_cfg_output(&boot_switch);
// pin_cfg_output(&boot_switch);
gpio_to_high_z(&boot_switch);
button_init(&btn, read_button_pin, my_button_handler);
@@ -182,5 +183,11 @@ void button_work_init() {
void boot_set(uint8_t value)
{
pin_cfg_output(&boot_switch);
pin_set_valid(&boot_switch, value);
}
void boot_set_high_z(void)
{
gpio_to_high_z(&boot_switch);
}