Skip to content

Commit

Permalink
cpu/cc2538: mask length byte before checking CRC
Browse files Browse the repository at this point in the history
  • Loading branch information
HavingaThijs committed Nov 18, 2024
1 parent 2adb404 commit 0c72444
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 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
8 changes: 5 additions & 3 deletions cpu/cc2538/radio/cc2538_rf_radio_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,11 @@ void cc2538_irq_handler(void)

if (flags_f0 & RXPKTDONE) {
handled_f0 |= RXPKTDONE;
/* CRC_OK bit is in the last byte in the RX FIFO */
uint8_t crc_loc = RFCORE_XREG_RXFIFOCNT - 1;
if (rfcore_peek_rx_fifo(crc_loc) & CC2538_CRC_BIT_MASK) {
/* 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();
/* If AUTOACK is disabled or the ACK request bit is not set */
Expand Down

0 comments on commit 0c72444

Please sign in to comment.