Seal
A colleague wrote firmware to receive binary packets over UART1 (115200 baud, 8N1) and validate their integrity using CRC32 before processing. The protocol is used on a sensor bus where corrupted packets must be rejected.
Packet format: STX (0x02) | LEN (1 byte) | PAYLOAD (LEN bytes) | CRC32 (4 bytes, little-endian)
CRC32 is computed over the LEN byte and all PAYLOAD bytes using the standard CRC-32 algorithm (polynomial 0xEDB88320, init 0xFFFFFFFF, final XOR 0xFFFFFFFF).
On valid packet: transmit "ACK:" followed by each payload byte as two uppercase hex chars, then "\n". Example: payload [0x48, 0x45, 0x4C, 0x4F] -> "ACK:48454C4F\n"
On invalid CRC: transmit "NAK\n" and wait for the next packet.
The starter code provides the CRC32 lookup table and computation function, plus UART register definitions. You need to implement the packet reception state machine, CRC validation, and response logic.