Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using the nrf_drv_uart compatibility layer on a project using 2 serial ports.

Hi,

I am working on a custom board using an nRF52840 and developing with SDK5 (V17.02).

I have a serial communications channel to the device which must use UART as I need to inspect incoming characters on the fly (packet-based comms protocol with start and end sentinels). I have created a packet handler based on the app_uart_fifo module which works well.

I also required to send log output to a second comms channel. For this purpose I have modified nrf_log_backend_uart to use a UARTE rather than UART (as only 1 UART is available on the 52840).

The problem appears when I call various UART/UARTE abstracted functions from nrf_drv_uart via my modified app_uart_fifo and log_backend_uart modules as nrf_drv_uart seems to use the NRF_DRV_UART_USE_UARTE and NRF_DRV_UART_USE_UART switches exclusively.

e.g. from nrf_drv_uart.h

__STATIC_INLINE
void nrf_drv_uart_rx_enable(nrf_drv_uart_t const * p_instance)
{
    if (NRF_DRV_UART_USE_UARTE)
    {
        NRFX_ASSERT(false); // not supported
    }
    else if (NRF_DRV_UART_USE_UART)
    {
        nrfx_uart_rx_enable(&p_instance->uart);
    }
}

Am I correct in asserting that nrf_drv_uart does not support a project using UART and UARTE and that I need to drop nrf_drv_uart and modify my modules to use nrfx_uart and nrfx_uarte directly instead?

Thanks for any pointers you can give,

Carl Kamper.

Parents
  • Hi Carl,

    Yes. I have never come across this before, but your observations are correct. The nrf_drv driver globally enables UART or UARTE.

    One option could be to modify the nrf_drv driver, or alternatively use the nrfx driver at least with your code where you use the UART (I do not immediately see any problems with using UARTE with the logger using the nrf_drv API).

  • Thanks for verifying that Einar.

    I have modified both of my modules to use nrfx_uart/e as required. I suppose I could have used nrf_drv for the module that requires UARTE but I was annoyed enough at nrf_drv to remove it completely :-)

    Modifying nrf_drv feels like a sure-fire way to dependency hell and probably more work than just modifying my own  modules.

    Regards,

    Carl.

Reply
  • Thanks for verifying that Einar.

    I have modified both of my modules to use nrfx_uart/e as required. I suppose I could have used nrf_drv for the module that requires UARTE but I was annoyed enough at nrf_drv to remove it completely :-)

    Modifying nrf_drv feels like a sure-fire way to dependency hell and probably more work than just modifying my own  modules.

    Regards,

    Carl.

Children
No Data
Related