Merge pull request #458 from adamdunkels/push/cc2538-rf

CC2538 RF core additions
This commit is contained in:
George Oikonomou 2013-11-23 07:13:06 -08:00
commit f3f1b8c90d
2 changed files with 57 additions and 2 deletions

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
@ -720,5 +745,14 @@ cc2538_rf_err_isr(void)
ENERGEST_OFF(ENERGEST_TYPE_IRQ); 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;
}
}
/*---------------------------------------------------------------------------*/
/** @} */ /** @} */

View file

@ -144,7 +144,7 @@ int8_t cc2538_rf_channel_set(uint8_t channel);
* \brief Get the current operating channel * \brief Get the current operating channel
* \return Returns a value in [11,26] representing the current 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 * \brief Sets RF TX power
@ -167,6 +167,27 @@ uint8_t cc2538_rf_power_set(uint8_t new_power);
* are thus simply copied over from there. * are thus simply copied over from there.
*/ */
void cc2538_rf_set_addr(uint16_t pan); 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__ */ #endif /* CC2538_RF_H__ */