platform: platform_uart_setup handles null ptr

This commit is contained in:
Joo Aun Saw 2022-08-29 16:36:35 +10:00 committed by Johny Mattsson
parent 01b94f31dc
commit ca0a2b3f47
1 changed files with 5 additions and 3 deletions

View File

@ -209,9 +209,11 @@ static void task_uart( void *pvParameters ){
uint32_t platform_uart_setup( unsigned id, uint32_t baud, int databits, int parity, int stopbits, uart_pins_t* pins )
{
int flow_control = UART_HW_FLOWCTRL_DISABLE;
if(pins->flow_control & PLATFORM_UART_FLOW_CTS) flow_control |= UART_HW_FLOWCTRL_CTS;
if(pins->flow_control & PLATFORM_UART_FLOW_RTS) flow_control |= UART_HW_FLOWCTRL_RTS;
if (pins != NULL) {
if(pins->flow_control & PLATFORM_UART_FLOW_CTS) flow_control |= UART_HW_FLOWCTRL_CTS;
if(pins->flow_control & PLATFORM_UART_FLOW_RTS) flow_control |= UART_HW_FLOWCTRL_RTS;
}
uart_config_t cfg = {
.baud_rate = baud,
.flow_ctrl = flow_control,