添加BOOT键、飞控复位控制、串口校验位设置

This commit is contained in:
OPTOC
2025-10-14 10:17:40 +08:00
parent 0336a20472
commit e7989c7444
6 changed files with 87 additions and 2 deletions

View File

@@ -494,3 +494,18 @@ void sb_uart_port_unbind(sb_data_port_t *port)
port->data = NULL;
}
}
void uart_set_parity_switch(sb_data_port_t *port, uint8_t parity)
{
__uart_data_t *uart_data = port->data;
uart_wait_tx_done(uart_data->uart_num, pdMS_TO_TICKS(100)); // 等待已发完
uart_flush_input(uart_data->uart_num); // 清空接收FIFO避免半帧造成校验错
//清除缓存数据
os_pipe_clr(&uart_data->rx_pipe);
int size = _uart_port_get_rx_length(port);
printf("size: %d\n", size);
uart_set_parity(uart_data->uart_num, parity); // 切换为偶校验
}

View File

@@ -26,3 +26,6 @@ sb_data_port_t *sb_uart_port_bind(int uartNum,
os_work_t *rx_resume_work);
void sb_uart_port_unbind(sb_data_port_t *port);
//切换校验方式
void uart_set_parity_switch(sb_data_port_t *port, uint8_t parity);