The UART SCB Components are used to physically generate signals.
The software CRC-16 calculation is applied to every sent/received byte (except STX and the CRC itself). To detect an unsuccessful packet transaction, the timer is used.
Three interrupts implemented in this project provide a fully interrupt-driven background process:
1) The transmit interrupt in the UART is configured for a FIFO not-full event to take the new data from the RAM and place it into the TX buffer, and for a transmit complete event to start or stop the CRC calculation.
2) The receive interrupt in the UART is configured for a FIFO not-empty event to analyze the received data, calculate the CRC, and store the received data into RAM.
3) The timer interrupt is used to detect the end of an unsuccessful transmission.
Protocol description Master(A) slave(B) communication:
Packet format:
1)
a) STX - 0x02 starts the packet marker. The unique byte of the start packet. b) ADDR - The device address. c) DL - The data length in bytes [1..255]. d) CRCH - MSB of CRC-16 calculated from ADDR to the last data byte. e) CRCL - LSB of CRC-16 calculated from ADDR to the last data byte.
2) If there is a byte
that equals STX, then it is exchanged with the two-byte sequence
3) If there is a byte
that equals ESC, then it is exchanged with the two-byte sequence
API Reference | |
| Master | |
| Slave | |