Added a way to obtain the RSSI from the CC2538 RF core

This commit is contained in:
Adam Dunkels 2013-11-22 15:49:05 +01:00
parent 6265219775
commit 473d519926

View File

@ -186,6 +186,31 @@ cc2538_rf_set_addr(uint16_t pan)
REG(RFCORE_FFSM_SHORT_ADDR1) = rimeaddr_node_addr.u8[RIMEADDR_SIZE - 2]; REG(RFCORE_FFSM_SHORT_ADDR1) = rimeaddr_node_addr.u8[RIMEADDR_SIZE - 2];
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int
cc2538_rf_read_rssi(void)
{
int rssi;
/* If we are off, turn on first */
if((REG(RFCORE_XREG_FSMSTAT0) & RFCORE_XREG_FSMSTAT0_FSM_FFCTRL_STATE) == 0) {
rf_flags |= WAS_OFF;
on();
}
/* Wait on RSSI_VALID */
while((REG(RFCORE_XREG_RSSISTAT) & RFCORE_XREG_RSSISTAT_RSSI_VALID) == 0);
rssi = ((int8_t)REG(RFCORE_XREG_RSSI)) - RSSI_OFFSET;
/* If we were off, turn back off */
if((rf_flags & WAS_OFF) == WAS_OFF) {
rf_flags &= ~WAS_OFF;
off();
}
return rssi;
}
/*---------------------------------------------------------------------------*/
/* Netstack API radio driver functions */ /* Netstack API radio driver functions */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int