Skip to content

Commit 0c72444

Browse files
committed
cpu/cc2538: mask length byte before checking CRC
1 parent 2adb404 commit 0c72444

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

cpu/cc2538/include/cc2538_rf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ extern "C" {
4141
#define CC2538_AUTOCRC_LEN (2)
4242
#define CC2538_RF_FIFO_SIZE (128)
4343
#define CC2538_PACKET_LENGTH_SIZE (1)
44+
#define CC2538_LENGTH_BYTE_MASK (0x7F) /**< Mask for the length byte in the packet */
4445

4546
#define CC2538_RF_MAX_DATA_LEN (CC2538_RF_FIFO_SIZE - CC2538_PACKET_LENGTH_SIZE)
4647

cpu/cc2538/radio/cc2538_rf_radio_ops.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,11 @@ void cc2538_irq_handler(void)
412412

413413
if (flags_f0 & RXPKTDONE) {
414414
handled_f0 |= RXPKTDONE;
415-
/* CRC_OK bit is in the last byte in the RX FIFO */
416-
uint8_t crc_loc = RFCORE_XREG_RXFIFOCNT - 1;
417-
if (rfcore_peek_rx_fifo(crc_loc) & CC2538_CRC_BIT_MASK) {
415+
/* CRC_OK bit is located in the last byte of the packet.
416+
* The radio masks the length byte before filling the FIFO with the
417+
* corresponding number of bytes. */
418+
uint8_t pkt_len = (rfcore_peek_rx_fifo(0) & CC2538_LENGTH_BYTE_MASK);
419+
if (rfcore_peek_rx_fifo(pkt_len) & CC2538_CRC_BIT_MASK) {
418420
/* Disable RX while the frame has not been processed */
419421
_disable_rx();
420422
/* If AUTOACK is disabled or the ACK request bit is not set */

0 commit comments

Comments
 (0)