Contiki-NG
Loading...
Searching...
No Matches

Files

file  cc2538-rf.c
 Implementation of the cc2538 RF driver.
 
file  cc2538-rf.h
 Header file for the cc2538 RF driver.
 

Macros

#define CC2538_RF_CSP_ISRXON()    do { REG(RFCORE_SFR_RFST) = CC2538_RF_CSP_OP_ISRXON; } while(0)
 Send an RX ON command strobe to the CSP.
 
#define CC2538_RF_CSP_ISTXON()    do { REG(RFCORE_SFR_RFST) = CC2538_RF_CSP_OP_ISTXON; } while(0)
 Send a TX ON command strobe to the CSP.
 
#define CC2538_RF_CSP_ISRFOFF()    do { REG(RFCORE_SFR_RFST) = CC2538_RF_CSP_OP_ISRFOFF; } while(0)
 Send a RF OFF command strobe to the CSP.
 
#define CC2538_RF_CSP_ISFLUSHRX()
 Flush the RX FIFO.
 
#define CC2538_RF_CSP_ISFLUSHTX()
 Flush the TX FIFO.
 

Functions

static uint8_t get_channel ()
 Get the current operating channel.
 
static void set_channel (uint8_t channel)
 Set the current operating channel.
 
static radio_value_t get_rssi (void)
 Reads the current signal strength (RSSI)
 
static void get_iq_lsbs (radio_value_t *value)
 Reads the current I/Q data of the received signal.
 
static int init (void)
 
 PROCESS_THREAD (cc2538_rf_process, ev, data)
 Implementation of the cc2538 RF driver process.
 
void cc2538_rf_rx_tx_isr (void)
 The cc2538 RF RX/TX ISR.
 
void cc2538_rf_err_isr (void)
 The cc2538 RF Error ISR.
 
void cc2538_rf_set_addr (uint16_t pan)
 Sets addresses and PAN identifier to the relevant RF hardware registers.
 

Variables

const struct radio_driver cc2538_rf_driver
 The NETSTACK data structure for the cc2538 RF driver.
 
const struct radio_driver cc2538_rf_driver
 The NETSTACK data structure for the cc2538 RF driver.
 

Detailed Description

Driver implementation for the cc2538 RF transceiver

Function Documentation

◆ cc2538_rf_err_isr()

void cc2538_rf_err_isr ( void )

The cc2538 RF Error ISR.

   This is the interrupt service routine for all RF errors. We
   acknowledge every error type and instead of trying to be smart and
   act differently depending on error condition, we simply reset the
   transceiver. RX FIFO overflow is an exception, we ignore this error
   since read() handles it anyway.

   However, we don't want to reset within this ISR. If the error occurs
   while we are reading a frame out of the FIFO, trashing the FIFO in
   the middle of read(), would result in further errors (RX underflows).

   Instead, we set a flag and poll the driver process. The process will
   reset the transceiver without any undesirable consequences.

Definition at line 1228 of file cc2538-rf.c.

References process_poll(), RFCORE_SFR_RFERRF, and RFCORE_SFR_RFERRF_RXOVERF.

◆ cc2538_rf_rx_tx_isr()

void cc2538_rf_rx_tx_isr ( void )

The cc2538 RF RX/TX ISR.

   This is the interrupt service routine for all RF interrupts relating
   to RX and TX. Error conditions are handled by cc2538_rf_err_isr().
   Currently, we only acknowledge the FIFOP interrupt source.

Definition at line 1201 of file cc2538-rf.c.

References process_poll(), and RFCORE_SFR_RFIRQF0.

◆ cc2538_rf_set_addr()

void cc2538_rf_set_addr ( uint16_t pan)

Sets addresses and PAN identifier to the relevant RF hardware registers.

Parameters
panThe PAN Identifier

Values for short and extended addresses are not needed as parameters since they exist in the linkaddr buffer in the contiki core. They are thus simply copied over from there.

◆ get_channel()

static uint8_t get_channel ( void )
static

Get the current operating channel.

Returns
Returns a value in [11,26] representing the current channel

Definition at line 166 of file cc2538-rf.c.

◆ get_iq_lsbs()

static void get_iq_lsbs ( radio_value_t * value)
static

Reads the current I/Q data of the received signal.

Parameters
valueThe least significant bit (LSB) of the I coordinate and the LSB of the Q coordinate are concatenated and stored here.

If not done already, this function first enables the RX mode and waits for the RSSI_VALID bit to go high. Hence, this function should only be called at start up or by the MAC protocol to avoid conflicts.

Definition at line 269 of file cc2538-rf.c.

References RFCORE_XREG_FSMSTAT0, RFCORE_XREG_FSMSTAT0_FSM_FFCTRL_STATE, RFCORE_XREG_RFRND, RFCORE_XREG_RFRND_IRND, RFCORE_XREG_RFRND_QRND, RFCORE_XREG_RSSISTAT, and RFCORE_XREG_RSSISTAT_RSSI_VALID.

◆ get_rssi()

static radio_value_t get_rssi ( void )
static

Reads the current signal strength (RSSI)

Returns
The current RSSI in dBm

This function reads the current RSSI on the currently configured channel.

Definition at line 234 of file cc2538-rf.c.

References RFCORE_XREG_FSMSTAT0, RFCORE_XREG_FSMSTAT0_FSM_FFCTRL_STATE, and RFCORE_XREG_RSSI.

◆ init()

◆ PROCESS_THREAD()

PROCESS_THREAD ( cc2538_rf_process ,
ev ,
data  )

Implementation of the cc2538 RF driver process.

   This process is started by init(). It simply sits there waiting for
   an event. Upon frame reception, the RX ISR will poll this process.
   Subsequently, the contiki core will generate an event which will
   call this process so that the received frame can be picked up from
   the RF RX FIFO

Definition at line 1151 of file cc2538-rf.c.

References init(), mac_driver::input, radio_driver::off, radio_driver::on, packetbuf_clear(), packetbuf_dataptr(), packetbuf_set_datalen(), PACKETBUF_SIZE, PROCESS_BEGIN, PROCESS_END, PROCESS_YIELD_UNTIL, radio_driver::read, RFCORE_XREG_FSMSTAT0, and RFCORE_XREG_FSMSTAT0_FSM_FFCTRL_STATE.

◆ set_channel()

static void set_channel ( uint8_t channel)
static

Set the current operating channel.

Parameters
channelThe desired channel as a value in [11,26]

Definition at line 176 of file cc2538-rf.c.

References RFCORE_XREG_FREQCTRL, RFCORE_XREG_FSMSTAT0, and RFCORE_XREG_FSMSTAT0_FSM_FFCTRL_STATE.

Referenced by init().