![]() |
nRF5 SDK
v12.1.0
|
Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API |
The UART HCI protocol implements the Serialization PHY API using the UART interface.
UART HCI for serialization uses four standard UART lines: RX, TX, /CTS, and /RTS. Hardware flow control is enabled. The protocol supports full duplex communication. Serialization version of the HCI protocol has similar feature set as the stand-alone version provided in HCI transport library. However, implementation details are different due to API, signalling, and memory management required by the Serialization PHY API.
Packet format complies with the standard. However, because of memory shortage in the Connectivity Chip, the current implementation limits the packet size to 384 bytes. Every payload packet consists of a four-byte header followed by payload and CRC field.
Packet header contains SEQ, ACK numbers, data integrity check (DIP), reliable packet (RP) flags, LEN - numbers of bytes in the payload, and HCS - header checksum. Payload packets use TYPE=0xE
- a vendor-specific type. Acknowledgement packets use TYPE=0x0, SEQ=0, DIP=0, RP=0, LEN=0
.
The basic communication flow implemented in the HCI layer is shown in the figure below:
The driver is split into two layers - HCI and SLIP.
The HCI layer is implemented as two event-driven state machines with separated micro schedulers for events coming from SER_PHY, SLIP layers, and timer.
The operation of receiver and transmitter state machines is shown in the following UML state diagram:
Packets are transmitted in the following format:
, where both TX_PACKET_START
and TX_PACKET_END
are a 0xC0
byte.
[RX_PACKET]=[0xC0 0xE8 0x3E 0x00 0xDA 0x41 0x42 0xDB 0xDC 0x78 0x8D 0xC0]
At the beginning and the end of the packet, there are 0xC0
bytes that indicate packet start and packet end.0xC0
symbols, the content of the packet is received. It includes higher level (HCI) header, CRC, and payload. There is also a SLIP escape sequence present: [0xDB 0xDC]
, which is an encoded 0xC0 character.The UART HCI SLIP protocol for serialization is implemented in the ser_phy_uart_hci_slip.c
file. It uses app_uart.c
as a low-level UART driver.
The implementation is event driven. Events from the low-level driver are handled in a static ser_phy_uart_evt_callback()
function. Three types of app_uart_evt_t events are processed: APP_UART_COMMUNICATION_ERROR, APP_UART_TX_EMPTY, and APP_UART_DATA.
ser_phy_hci_tx_byte()
. ser_phy_hci_tx_byte()
function is called for the first time in the ser_phy_hci_slip_tx_pkt_send()
function. Later it is only called in the app_uart_evt_t event callback.ser_phi_hci_rx_byte()
is called, with the received byte as a parameter. The received byte is taken from the app_uart_evt_t structure.Following ser_phy_hci_slip_evt_type_t, the events are sent to the upper layer:
Function ser_phy_hci_slip_open()
initializes UART using the APP_UART_INIT
macro with configuration structure of type app_uart_comm_params_t
as input. It also registers the SER_PHY_HCI_SLIP
event callback.
Function ser_phy_hci_slip_close()
closes UART using the app_uart_close()
function. It also deregisters the SER_PHY_HCI_SLIP
event callback.