添加按键高阻态、使飞控进入BOOT、擦除flash
This commit is contained in:
@@ -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 基本操作:设置使输出是否为有效的电平
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
/**
|
||||
* @brief 设置boot按键输出
|
||||
*/
|
||||
void boot_set(uint8_t value);
|
||||
/**
|
||||
* @brief 设置boot按键为高阻态
|
||||
*/
|
||||
void boot_set_high_z(void);
|
||||
Reference in New Issue
Block a user