This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

UART / Serial APIs for single character tx/rx

I am working on developing a UART driver. I am looking for APIs that support this. I see 3 sets of implementation examples:

1. nrf_serial

2. nrf_drv_uart

3. nrfx_uart

Which is the best option for me to choose as my requirement is just 1 character Tx and Rx at a time

Also, is the serial_xxx old implementation?

Parents
  • Hi, 

    There are various UART drivers and libraries in the nRF SDK, e.g. app_uart ("old" lib), libuarte ("new" lib), nrf_drv_uart ("old" driver) and nrfx_uarte ("new" driver).

    They provide different abstraction and functionality of using the UART peripheral in an application.

    In general the nrfx* is the low level driver that give you full control over the peripheral, while the app*/lib* library give you more high level api where you don't need to think about the low level hardware registers.

    Which to use depends on your requirements, if you find that the app*/lib* provide the functionality you need then there is no need to use the nrfx* driver.

    I will suggest you take a look at the following examples and start from them 

    nRF5 SDK v15.3.0: UART Example

    nRF5 SDK v15.3.0: UART/Serial Port Emulation over BLE

    Best regards,

    Amanda

  • I donot see any example using new APIs. Is it possible to share one?

    Also, I understand the main difference between old/new lib/app/driver is EasyDMA implementation in new. Please correct me if I am wrong

  • Hi, 

    There is only a legacy API layer that connects legacy API to NRFX API. Please see this page for more details.

    The ble_app_uart example uses the new nRFX UARTE drivers and the UARTE hardware abstraction layer (UARTE HAL). 

    This is maybe more clear in the migration document for SDK 15.0.0. The drivers should be very similar expect the names, but have been splitted into two separate drivers for EasyDMA and non-EasyDMA.

    -Amanda

  • I am looking for IRQ based implementation without easy DMA.

    This QA suggests I use nrf_serial which used nrfx_uart instead of app_uart in UART example.

    Any suggestion on sequence of APIs nrfx_uart APIS that I must use in sequence? Does the below sequence do?

    1. nrfx_uart_init() -> with nrfx_uart_event_handler_t  event_handler for IRQ handling during Rx

    2. nrfx_uart_tx() -> whenever I want to transfer a byte

    3. Event handler will be called automatically on IRQ for RX

    Should I take care of anything more?

  • Hi, 

    nrfx_uart_rx must be called to setup a receive operation.

    Otherwise, it looks ok.

    -Amanda

  • nrfx_uart_rx must be called to setup a receive operation

    Once I call this function, the Rx will happen continuously over the backend(like a separate thread running continuously in an infinite loop) when interrupt arrives each time. It is non-blocking as I am providing event_handler in init.

    Am I right?

Reply
  • nrfx_uart_rx must be called to setup a receive operation

    Once I call this function, the Rx will happen continuously over the backend(like a separate thread running continuously in an infinite loop) when interrupt arrives each time. It is non-blocking as I am providing event_handler in init.

    Am I right?

Children
No Data