From 473d51992685cd6f9400774a1b46b9a98ba17f98 Mon Sep 17 00:00:00 2001 From: Adam Dunkels Date: Fri, 22 Nov 2013 15:49:05 +0100 Subject: [PATCH 1/4] Added a way to obtain the RSSI from the CC2538 RF core --- cpu/cc2538/dev/cc2538-rf.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cpu/cc2538/dev/cc2538-rf.c b/cpu/cc2538/dev/cc2538-rf.c index 625a41f6a..fb78cb2c9 100644 --- a/cpu/cc2538/dev/cc2538-rf.c +++ b/cpu/cc2538/dev/cc2538-rf.c @@ -186,6 +186,31 @@ cc2538_rf_set_addr(uint16_t pan) 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 */ /*---------------------------------------------------------------------------*/ static int From 76f2a10c9a3bae2d9208cc71b6308ffa5fe231aa Mon Sep 17 00:00:00 2001 From: Adam Dunkels Date: Fri, 22 Nov 2013 18:04:23 +0100 Subject: [PATCH 2/4] Added a function for setting promiscous mode on the CC2538 RF core --- cpu/cc2538/dev/cc2538-rf.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cpu/cc2538/dev/cc2538-rf.c b/cpu/cc2538/dev/cc2538-rf.c index fb78cb2c9..226d8be9f 100644 --- a/cpu/cc2538/dev/cc2538-rf.c +++ b/cpu/cc2538/dev/cc2538-rf.c @@ -745,5 +745,14 @@ cc2538_rf_err_isr(void) ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ - +void +cc2538_rf_set_promiscous_mode(char p) +{ + if(p) { + REG(RFCORE_XREG_FRMFILT0) &= ~RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN; + } else { + REG(RFCORE_XREG_FRMFILT0) |= RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN; + } +} +/*---------------------------------------------------------------------------*/ /** @} */ From e95236b64282ef1e6200c57a40292537363361ca Mon Sep 17 00:00:00 2001 From: Adam Dunkels Date: Sat, 23 Nov 2013 15:04:35 +0100 Subject: [PATCH 3/4] Added header declarations for cc2538_rf_read_rssi() and cc2538_rf_set_promiscous_mode() --- cpu/cc2538/dev/cc2538-rf.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cpu/cc2538/dev/cc2538-rf.h b/cpu/cc2538/dev/cc2538-rf.h index e6f420fe6..b7dd5f6ad 100644 --- a/cpu/cc2538/dev/cc2538-rf.h +++ b/cpu/cc2538/dev/cc2538-rf.h @@ -167,6 +167,27 @@ uint8_t cc2538_rf_power_set(uint8_t new_power); * are thus simply copied over from there. */ void cc2538_rf_set_addr(uint16_t pan); + +/** + * \brief Reads the current signal strength (RSSI) + * \return The current RSSI + * + * This function reads the current RSSI on the currently configured + * channel. + */ +int cc2538_rf_read_rssi(void); + +/** + * \brief Turn promiscous mode on or off + * \param p If promiscous mode should be on (1) or off (0) + * + * This function turns promiscous mode on or off. In promiscous mode, + * every received frame is returned from the RF core. In + * non-promiscous mode, only broadcast frames or frames with our + * address as the receive address are returned from the RF core. + */ +void cc2538_rf_set_promiscous_mode(char p); + /*---------------------------------------------------------------------------*/ #endif /* CC2538_RF_H__ */ From 1ab28e4668991a5a542a0444b8487956286b2b23 Mon Sep 17 00:00:00 2001 From: Adam Dunkels Date: Sat, 23 Nov 2013 15:04:46 +0100 Subject: [PATCH 4/4] Added missing argument declaration --- cpu/cc2538/dev/cc2538-rf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/cc2538/dev/cc2538-rf.h b/cpu/cc2538/dev/cc2538-rf.h index b7dd5f6ad..75b4ca3e4 100644 --- a/cpu/cc2538/dev/cc2538-rf.h +++ b/cpu/cc2538/dev/cc2538-rf.h @@ -144,7 +144,7 @@ int8_t cc2538_rf_channel_set(uint8_t channel); * \brief Get the current operating channel * \return Returns a value in [11,26] representing the current channel */ -uint8_t cc2538_rf_channel_get(); +uint8_t cc2538_rf_channel_get(void); /** * \brief Sets RF TX power