Hello,
I am using UART_1 in my program to comminicate with other sensor. So the data is read from UART_1 and print to UART_0. Now I want to communicate with other sensor simultaneously. So I am using UART_2 for that purpose. When I connect both sensors to UART_1 and UART_2, only the data from UART_1 is read and it is printed on the terminal. But the data from UART_2 is not read and printed. So how to read and print the data from both UART on the terminal at the same time.
The Code is:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <zephyr.h>
#include <misc/printk.h>
#include <uart.h>
static u8_t uart_buf[1024];
static u8_t uart_buf1[1024];
void uart_cb(struct device *x)
{
uart_irq_update(x);
int data_length = 0;
if (uart_irq_rx_ready(x)) {
data_length = uart_fifo_read(x, uart_buf, sizeof(uart_buf));
uart_buf[data_length] = 0;
}
printk("%s", uart_buf);
}
void uart_cb1(struct device *x1)
Is this code correct or is there any other way to use 2 UARTS simultaneously?