diff --git a/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c b/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c index f4e7f66e7..66b4a4370 100644 --- a/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c +++ b/arch/cpu/cc26xx-cc13xx/rf-core/prop-mode.c @@ -45,6 +45,7 @@ #include "net/netstack.h" #include "sys/energest.h" #include "sys/clock.h" +#include "sys/critical.h" #include "sys/rtimer.h" #include "sys/cc.h" #include "lpm.h" @@ -766,6 +767,7 @@ send(const void *payload, unsigned short payload_len) static int read_frame(void *buf, unsigned short buf_len) { + int_master_status_t status; rfc_dataEntryGeneral_t *entry = (rfc_dataEntryGeneral_t *)rx_read_entry; uint8_t *data_ptr = &entry->data; int len = 0; @@ -795,6 +797,14 @@ read_frame(void *buf, unsigned short buf_len) entry->status = DATA_ENTRY_STATUS_PENDING; } + status = critical_enter(); + if(rx_is_full) { + rx_is_full = false; + PRINTF("RXQ was full, re-enabling radio!\n"); + rx_on_prop(); + } + critical_exit(status); + return len; } /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/cc26xx-cc13xx/rf-core/rf-core.c b/arch/cpu/cc26xx-cc13xx/rf-core/rf-core.c index 2baa883ad..23b78eab4 100644 --- a/arch/cpu/cc26xx-cc13xx/rf-core/rf-core.c +++ b/arch/cpu/cc26xx-cc13xx/rf-core/rf-core.c @@ -76,7 +76,7 @@ /*---------------------------------------------------------------------------*/ /* RF interrupts */ #define RX_FRAME_IRQ IRQ_RX_ENTRY_DONE -#define ERROR_IRQ IRQ_INTERNAL_ERROR +#define ERROR_IRQ (IRQ_INTERNAL_ERROR | IRQ_RX_BUF_FULL) #define RX_NOK_IRQ IRQ_RX_NOK /* Those IRQs are enabled all the time */ @@ -103,6 +103,9 @@ static const rf_core_primary_mode_t *primary_mode = NULL; int32_t rat_offset = 0; static bool rat_offset_known = false; /*---------------------------------------------------------------------------*/ +/* Buffer full flag */ +volatile bool rx_is_full = false; +/*---------------------------------------------------------------------------*/ PROCESS(rf_core_process, "CC13xx / CC26xx RF driver"); /*---------------------------------------------------------------------------*/ #define RF_CORE_CLOCKS_MASK (RFC_PWR_PWMCLKEN_RFC_M | RFC_PWR_PWMCLKEN_CPE_M \ @@ -574,6 +577,16 @@ cc26xx_rf_cpe1_isr(void) return; } } + + if(HWREG(RFC_DBELL_NONBUF_BASE + RFC_DBELL_O_RFCPEIFG) & IRQ_RX_BUF_FULL) { + PRINTF("\nRF: BUF_FULL\n\n"); + /* set a flag that the buffer is full*/ + rx_is_full = true; + /* make sure read_frame() will be called to make space in RX buffer */ + process_poll(&rf_core_process); + /* Clear the IRQ_RX_BUF_FULL interrupt flag by writing zero to bit */ + HWREG(RFC_DBELL_NONBUF_BASE + RFC_DBELL_O_RFCPEIFG) = ~(IRQ_RX_BUF_FULL); + } /* Clear INTERNAL_ERROR interrupt flag */ HWREG(RFC_DBELL_NONBUF_BASE + RFC_DBELL_O_RFCPEIFG) = 0x7FFFFFFF; diff --git a/arch/cpu/cc26xx-cc13xx/rf-core/rf-core.h b/arch/cpu/cc26xx-cc13xx/rf-core/rf-core.h index ac48bc52a..c97ab0f8a 100644 --- a/arch/cpu/cc26xx-cc13xx/rf-core/rf-core.h +++ b/arch/cpu/cc26xx-cc13xx/rf-core/rf-core.h @@ -263,6 +263,9 @@ typedef struct rf_core_primary_mode_s { /* Radio timer register */ #define RATCNT 0x00000004 /*---------------------------------------------------------------------------*/ +/* Buffer full flag */ +extern volatile bool rx_is_full; +/*---------------------------------------------------------------------------*/ /* Make the main driver process visible to mode drivers */ PROCESS_NAME(rf_core_process); /*---------------------------------------------------------------------------*/