Help understanding RX / TX

I have this main code:

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/uart.h>
#include <string.h>

#define MSG_SIZE 32
K_MSGQ_DEFINE(uart_msgq, MSG_SIZE, 10, 4);

static char rx_buf[MSG_SIZE];
static int rx_buf_pos;

#define UART_DEVICE_NODE DT_NODELABEL(uart1)
static const struct device *const uart_dev = DEVICE_DT_GET(UART_DEVICE_NODE);

void serial_cb(const struct device *dev, void *user_data)
{
    uint8_t c;
    if (!uart_irq_update(uart_dev) || !uart_irq_rx_ready(uart_dev)) {
		printk("UART IRQ not ready\r\n");
		return;
	}

	printk("reading datar\r\n");
    while (uart_fifo_read(uart_dev, &c, 1) == 1) {
		printk("RX: %c\n", c);
        if ((c == '\n' || c == '\r') && rx_buf_pos > 0) {
            rx_buf[rx_buf_pos] = '\0';
            k_msgq_put(&uart_msgq, &rx_buf, K_NO_WAIT);
            rx_buf_pos = 0;
        } else if (rx_buf_pos < (sizeof(rx_buf) - 1)) {
            rx_buf[rx_buf_pos++] = c;
        }
    }
}

void print_uart(char *buf)
{
    for (int i = 0; buf[i] != '\0'; i++) {
        uart_poll_out(uart_dev, buf[i]);
        k_busy_wait(100);
    }
}

int main(void)
{
    printk("UART Echo Started\n");

    if (!device_is_ready(uart_dev)) {
        printk("UART device not ready\n");
        return 0;
    }

    uart_irq_callback_user_data_set(uart_dev, serial_cb, NULL);
    uart_irq_rx_enable(uart_dev);

    print_uart("Hello from echo bot\r\n");
	printk("Hello sent\r\n");

	while(true) {
		print_uart("Echo: ");
		print_uart(" is one wild");
		print_uart("\r\n");
		//Sleep for a second
		k_sleep(K_SECONDS(1));
		printk("Sending data to TX\r\n");
    }

    return 0;
}

With this overlay:

&uart1 {
    status = "okay";
    current-speed = <115200>;
    pinctrl-0 = <&uart1_default>;
    pinctrl-1 = <&uart1_sleep>;
    pinctrl-names = "default", "sleep";
};

&pinctrl {
    uart1_default: uart1_default {
        group1 {
            psels = <NRF_PSEL(UART_TX, 0, 9)>,
                    <NRF_PSEL(UART_RX, 0, 10)>;
        };
    };

    uart1_sleep: uart1_sleep {
        group1 {
            psels = <NRF_PSEL(UART_TX, 0, 9)>,
                    <NRF_PSEL(UART_RX, 0, 10)>;
            low-power-enable;
        };
    };
};

and this configuration:

CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_CONSOLE=n

CONFIG_USE_SEGGER_RTT=y
CONFIG_RTT_CONSOLE=y
CONFIG_LOG=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_PRINTK=y

I am using a nrf52840 dev board and have connected P0.06 and P0.08.

Why does it not trigger TX and write to JRTTLinkEXE the data sent in the main loop?

Related