nRF5 SDK v17.1.0
UART RAW protocol
This information applies to the following SoftDevices: S132, S140, S212, S332

The UART RAW protocol implements the Serialization PHY API using the UART interface.

UART RAW for serialization uses four standard UART lines: RX, TX, /CTS, and /RTS. Hardware flow control is enabled. The protocol supports full duplex communication. Every packet consists of a two-byte header followed by payload. The packet header contains the number of bytes of the payload. The header is transmitted with the least significant byte first.

UART RAW packet

Packets are transmitted in the following format:

TX_RAW_PACKET = [TX_HEADER][TX_PAYLOAD]
uart_460800.png
Reception and transmission of a packet
  1. First, on the RX line, the length is received as the header: [RX_HEADER]=[0x0004].
  2. It is then followed by the payload [RX_PAYLOAD]=[0x00 0x78 0x41 0x03].
  3. After the reception of a packet, transmission starts on the TX line. The packet format is the same as during reception: [TX_HEADER]=[0x0006], [TX_PAYLOAD]=[0x01 0x78 0x00 0x00 0x00 0x00].

UART driver

The UART RAW protocol for serialization is implemented in the ser_phy_uart.c file. It uses the UART driver as a low-level driver.

The implementation is event-driven. Events from the low-level driver are handled in a static uart_event_handler() function. Three types of nrf_drv_uart_event_t events are processed: NRF_DRV_UART_EVT_ERROR, NRF_DRV_UART_EVT_TX_DONE, and NRF_DRV_UART_EVT_RX_DONE.

The following ser_phy_evt_t events are sent to the upper layer:

Function ser_phy_open() initializes UART using the nrf_drv_uart_init() function and prepares reception of incoming packets. It also registers the ser_phy_evt_t event callback.

Function ser_phy_close() closes UART using the nrf_drv_uart_uninit() function. It also deregisters the ser_phy_evt_t event callback.


Documentation feedback | Developer Zone | Subscribe | Updated