I am unable to use UART 1 with a very simple use case.
All I need to do is enable an interrupt callback when there is data to receive from the UART. I know that UART0 is in use, so I figure UART1 can be used. In any case, I have had no success.
This is my overlay file:
&uart1 {
compatible = "nordic,nrf-uarte";
status = "okay";
tx-pin = < 12 >;
rx-pin = < 13 >;
};
This is my prj.conf: (As you can see I have tried several combinations of configurations to no avail)
## UART ######################### CONFIG_SERIAL=y CONFIG_UART_ASYNC_API=y CONFIG_UART_NRFX=y CONFIG_TRUSTED_EXECUTION_NONSECURE=y # CONFIG_UART_1_NRF_UARTE=y # CONFIG_UART_1_INTERRUPT_DRIVEN=y # CONFIG_UART_NRFX=y # CONFIG_UART_1_ASYNC=y # CONFIG_UART_1_NRF_HW_ASYNC=y # CONFIG_UART_INTERRUPT_DRIVEN=y # CONFIG_UART_NRFX=y # CONFIG_NRF_SW_LPUART=y # CONFIG_UART_1_ASYNC=y # CONFIG_UART_1_INTERRUPT_DRIVEN=n # CONFIG_UART_1_NRF_HW_ASYNC=y # CONFIG_UART_1_NRF_HW_ASYNC_TIMER=2 # CONFIG_NRFX_TIMER2=y
And here is my source code that I am writing to use the bus:
// Retreive device from DeviceTree
uart0_dev = device_get_binding(UART1);
if (uart0_dev == NULL) {
LOG_ERR("UART1 Device not found");
return;
}
// Configure the UART serial bus
struct uart_config uart_cfg = {
.baudrate = 115200,
.data_bits = UART_CFG_DATA_BITS_8,
.flow_ctrl = UART_CFG_FLOW_CTRL_NONE,
.parity = UART_CFG_PARITY_NONE,
.stop_bits = UART_CFG_STOP_BITS_1
};
int ret = 0;
ret = uart_configure(uart0_dev, &uart_cfg);
LOG_ERR_AND_RETURN(ret, "uart_configure()");
bool user_data = true;
ret = uart_callback_set(uart0_dev, uart_on_rx_cb, &user_data);
LOG_ERR_AND_RETURN(ret, "uart_callback_set()");
The error I see is from the function uart_callback_set(), which returns -ENOTSUP (-134). Digging through the drivers, there is a missing field to one of the structs (the .async field?) and this should be set assuming that the CONFIG_UART_1_NRF_UARTE configuration is set, however I cannot seem to turn this symbol to 'y' because it is not allowed for user space use.
Where might I be going wrong? I assume this should rather simple.
Thanks