Multiple UART`s for AT commands

ferrero
Posts: 12
Joined: Tue Nov 05, 2024 3:11 am

Multiple UART`s for AT commands

Postby ferrero » Fri Nov 08, 2024 6:06 am

Is it possible to configure several UARTs to work with AT commands? The point is, that at one moment of time you can work only with one specific UART, but physically there can be several of them, when commands arrive to another UART, the program switches to it. Is there any library that implements this or does it need to be changed in uart/interface files manualy?

ferrero
Posts: 12
Joined: Tue Nov 05, 2024 3:11 am

Re: Multiple UART`s for AT commands

Postby ferrero » Wed Nov 27, 2024 5:31 am

Solved.
In the at_uart_task file, I created additional variables s_at_uart0_queue and s_at_uart1_queue for uart queues. Statically declared pin parameters for each of the uarts g_uart0_port_pin and g_uart1_port_pin through the at_uart_port_pins_t structure.
I created the variables g_at_cmd_port and g_uart_port_pin to select which specific uart to work with at a given time. In the at_uart_init function, I initialized the second uart like the first. I created a second similar freetos task for the second uart. I passed the g_uartX_port_pin.number variable to the tasks as a parameter.
In the task handler at_uart_task I assign s_at_uart_queue to that queue depending on what uart the handler was called for. In events, I check if g_at_cmd_port is not equal to the uart on which the handler was called, then I assign this uart to the g_at_cmd_port variable and also set a new value for g_uart_port_pin.
Thus, the uart changes depending on where the data comes, they work asynchronously, not in parallel

Who is online

Users browsing this forum: No registered users and 22 guests