Skip to content

Commit

Permalink
Merge pull request #21038 from maribu/backport/2024.10/cc2538_crc_bit
Browse files Browse the repository at this point in the history
cpu/cc2538: mask length byte before checking CRC [backport 2024.10]
  • Loading branch information
maribu authored Nov 25, 2024
2 parents 0e82225 + 1278388 commit 1b61216
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions cpu/cc2538/include/cc2538_rf.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ extern "C" {
#define CC2538_AUTOCRC_LEN (2)
#define CC2538_RF_FIFO_SIZE (128)
#define CC2538_PACKET_LENGTH_SIZE (1)
#define CC2538_LENGTH_BYTE_MASK (0x7F) /**< Mask for the length byte in the packet */

#define CC2538_RF_MAX_DATA_LEN (CC2538_RF_FIFO_SIZE - CC2538_PACKET_LENGTH_SIZE)

Expand Down
6 changes: 4 additions & 2 deletions cpu/cc2538/radio/cc2538_rf_radio_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,10 @@ void cc2538_irq_handler(void)

if (flags_f0 & RXPKTDONE) {
handled_f0 |= RXPKTDONE;
/* CRC check */
uint8_t pkt_len = rfcore_peek_rx_fifo(0);
/* CRC_OK bit is located in the last byte of the packet.
* The radio masks the length byte before filling the FIFO with the
* corresponding number of bytes. */
uint8_t pkt_len = (rfcore_peek_rx_fifo(0) & CC2538_LENGTH_BYTE_MASK);
if (rfcore_peek_rx_fifo(pkt_len) & CC2538_CRC_BIT_MASK) {
/* Disable RX while the frame has not been processed */
_disable_rx();
Expand Down

0 comments on commit 1b61216

Please sign in to comment.