From 793817d00e6f39567b92b9642d02bc55eb4eb4f3 Mon Sep 17 00:00:00 2001 From: OPTOC <9159397+optoc@user.noreply.gitee.com> Date: Tue, 21 Oct 2025 16:18:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8C=89=E9=94=AE=E9=AB=98?= =?UTF-8?q?=E9=98=BB=E6=80=81=E3=80=81=E4=BD=BF=E9=A3=9E=E6=8E=A7=E8=BF=9B?= =?UTF-8?q?=E5=85=A5BOOT=E3=80=81=E6=93=A6=E9=99=A4flash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/drivers/pin_io/pin_io.c | 14 ++++++++++++++ app/drivers/pin_io/pin_io.h | 2 ++ app/drivers/sertrf/device.c | 2 +- app/drivers/sertrf/key.c | 19 +++++++++++++------ app/drivers/sertrf/key.h | 12 +++++++++++- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/app/drivers/pin_io/pin_io.c b/app/drivers/pin_io/pin_io.c index e2592c9..73e0e7c 100644 --- a/app/drivers/pin_io/pin_io.c +++ b/app/drivers/pin_io/pin_io.c @@ -83,6 +83,20 @@ void pin_cfg_output(const cfg_board_pin_io_t *pin) gpio_config(&io_conf); } + + +void gpio_to_high_z(const cfg_board_pin_io_t *pin) +{ + gpio_config_t io = { + .pin_bit_mask = 1ULL << pin->pin, + .mode = GPIO_MODE_DISABLE, // 或 GPIO_MODE_INPUT(都不会驱动外部) + .pull_up_en = GPIO_PULLUP_DISABLE, + .pull_down_en = GPIO_PULLDOWN_DISABLE, + .intr_type = GPIO_INTR_DISABLE, + }; + gpio_config(&io); +} + /** * @brief IO 基本操作:设置使输出是否为有效的电平 * diff --git a/app/drivers/pin_io/pin_io.h b/app/drivers/pin_io/pin_io.h index 913a614..039a755 100644 --- a/app/drivers/pin_io/pin_io.h +++ b/app/drivers/pin_io/pin_io.h @@ -17,6 +17,8 @@ void pin_cfg_input(const cfg_board_pin_io_t *pin); bool pin_get_valid(const cfg_board_pin_io_t *pin); + +void gpio_to_high_z(const cfg_board_pin_io_t *pin); void pin_cfg_output(const cfg_board_pin_io_t *pin); void pin_set_valid(const cfg_board_pin_io_t *pin, bool en); diff --git a/app/drivers/sertrf/device.c b/app/drivers/sertrf/device.c index 0f5b4f3..014b6df 100644 --- a/app/drivers/sertrf/device.c +++ b/app/drivers/sertrf/device.c @@ -67,7 +67,7 @@ uint8_t device_init(device_t *port) uint8_t uart_init(init_device_t *port) { // port->uart_port = sb_uart_port_bind(g_cfg_board->uart_fc.id, g_cfg_board->uart_fc.br, g_cfg_board->uart_fc.pin_txd.pin, g_cfg_board->uart_fc.pin_rxd.pin, g_cfg_board->uart_fc.irq_prior, 1024, 0, NULL); - port->uart_port = sb_uart_port_bind(1, 115200, 21, 20, 21, 1024, 0, NULL); + port->uart_port = sb_uart_port_bind(1, 115200, 21, 20, 21, 2048, 0, NULL); if(port->uart_port == NULL) { diff --git a/app/drivers/sertrf/key.c b/app/drivers/sertrf/key.c index ba3261f..f1aa6d6 100644 --- a/app/drivers/sertrf/key.c +++ b/app/drivers/sertrf/key.c @@ -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); +} \ No newline at end of file diff --git a/app/drivers/sertrf/key.h b/app/drivers/sertrf/key.h index 9539658..c536414 100644 --- a/app/drivers/sertrf/key.h +++ b/app/drivers/sertrf/key.h @@ -47,5 +47,15 @@ typedef struct { extern bool key_single_click,key_press_down,key_press_up; void _work_button(void *arg); +/** + * @brief 初始化按键 + */ void button_work_init(); -void boot_set(uint8_t value); \ No newline at end of file +/** + * @brief 设置boot按键输出 + */ +void boot_set(uint8_t value); +/** + * @brief 设置boot按键为高阻态 + */ +void boot_set_high_z(void); \ No newline at end of file