Skip to content

Commit 1b61216

Browse files
authored
Merge pull request #21038 from maribu/backport/2024.10/cc2538_crc_bit
cpu/cc2538: mask length byte before checking CRC [backport 2024.10]
2 parents 0e82225 + 1278388 commit 1b61216

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,10 @@ void cc2538_irq_handler(void)
412412

413413
if (flags_f0 & RXPKTDONE) {
414414
handled_f0 |= RXPKTDONE;
415-
/* CRC check */
416-
uint8_t pkt_len = rfcore_peek_rx_fifo(0);
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);
417419
if (rfcore_peek_rx_fifo(pkt_len) & CC2538_CRC_BIT_MASK) {
418420
/* Disable RX while the frame has not been processed */
419421
_disable_rx();

0 commit comments

Comments
 (0)