cc2538_rf.h File Reference

Low-level radio driver for the CC2538. More...

Detailed Description

Low-level radio driver for the CC2538.

Author
Aaron Sowry aaron.nosp@m.@mut.nosp@m.ex.nz
Ian Martin ian@l.nosp@m.ocic.nosp@m.ontro.nosp@m.ls.c.nosp@m.om

Definition in file cc2538_rf.h.

#include <stdbool.h>
#include "net/ieee802154.h"
#include "net/netdev.h"
#include "net/netdev/ieee802154.h"
+ Include dependency graph for cc2538_rf.h:

Go to the source code of this file.

Data Structures

struct  cc2538_rf_t
 Device descriptor for CC2538 transceiver. More...
 
#define CC2538_AUTOCRC_LEN   (2)
 
#define CC2538_RF_FIFO_SIZE   (128)
 
#define CC2538_PACKET_LENGTH_SIZE   (1)
 
#define CC2538_RF_MAX_DATA_LEN   (CC2538_RF_FIFO_SIZE - CC2538_PACKET_LENGTH_SIZE)
 
#define CC2538_EUI64_LOCATION_PRI   (0x00280028)
 Primary EUI-64 address location.
 
#define CC2538_EUI64_LOCATION_SEC   (0x0027FFCC)
 Secondary EUI-64 address location.
 
#define IEEE802154_MIN_FREQ   (2405)
 Min. More...
 
#define IEEE802154_MAX_FREQ   (2480)
 Max. More...
 
#define IEEE802154_CHANNEL_SPACING   (5)
 Channel spacing in MHz.
 
#define IEEE802154_CHAN2FREQ(chan)   ( IEEE802154_MIN_FREQ + ((chan) - IEEE802154_CHANNEL_MIN) * IEEE802154_CHANNEL_SPACING )
 
#define IEEE802154_FREQ2CHAN(freq)   ( IEEE802154_CHANNEL_MIN + ((freq) - IEEE802154_MIN_FREQ) / IEEE802154_CHANNEL_SPACING )
 
#define CC2538_MIN_FREQ   (2394)
 
#define CC2538_MAX_FREQ   (2507)
 
#define CC2538_RF_POWER_DEFAULT   (IEEE802154_DEFAULT_TXPOWER)
 Default output power in dBm.
 
#define CC2538_RF_CHANNEL_DEFAULT   (IEEE802154_DEFAULT_CHANNEL)
 
#define CC2538_RF_PANID_DEFAULT   (IEEE802154_DEFAULT_PANID)
 
#define OUTPUT_POWER_MIN   (-24)
 Min output power in dBm.
 
#define OUTPUT_POWER_MAX   (7)
 Max output power in dBm.
 
#define NUM_POWER_LEVELS   ( OUTPUT_POWER_MAX - OUTPUT_POWER_MIN + 1 )
 
#define CC2538_CORR_VAL_MIN   (50U)
 
#define CC2538_CORR_VAL_MAX   (110U)
 
#define CC2538_CORR_VAL_MASK   (0x7F)
 
#define CC2538_RSSI_OFFSET   (-73)
 Signal strength offset value.
 
#define CC2538_RF_SENSITIVITY   (-97)
 dBm typical, normal conditions
 
#define RFCORE_ASSERT(expr)   (void)( (expr) || RFCORE_ASSERT_failure(#expr, __FUNCTION__, __LINE__) )
 
#define RFCORE_WAIT_UNTIL(expr)
 
#define RFCORE_FLUSH_RECEIVE_FIFO()   rfcore_strobe(ISFLUSHRX)
 
#define ABS_DIFF(x, y)   ( ((x) < (y))? ((y) - (x)) : ((x) - (y)) )
 
#define BOOLEAN(x)   ( (x) != 0 )
 
#define NOT(x)   ( (x) == 0 )
 
#define GET_BYTE(buffer, index)   ( (unsigned char*)(buffer) )[index]
 
#define BIT(n)   ( 1 << (n) )
 
#define OBSSEL_EN   BIT(7)
 
enum  { FSM_STATE_IDLE = 0, FSM_STATE_RX_CALIBRATION = 2, FSM_STATE_TX_CALIBRATION = 32 }
 
enum  {
  STROBE_ERR = BIT(6), TXUNDERF = BIT(5), TXOVERF = BIT(4), RXUNDERF = BIT(3),
  RXOVERF = BIT(2), RXABO = BIT(1), NLOCK = BIT(0)
}
 
enum  { ENERGY_SCAN = BIT(4), AUTOACK = BIT(5), AUTOCRC = BIT(6), APPEND_DATA_MODE = BIT(7) }
 
enum  {
  ACT_UNUSED = BIT(0), SFD = BIT(1), FIFOP = BIT(2), SRC_MATCH_DONE = BIT(3),
  SRC_MATCH_FOUND = BIT(4), FRAME_ACCEPTED = BIT(5), RXPKTDONE = BIT(6), RXMASKZERO = BIT(7)
}
 
enum  { rfc_obs_sig0 = 0, rfc_obs_sig1 = 1, rfc_obs_sig2 = 2 }
 
enum  {
  constant_value_0 = 0x00, constant_value_1 = 0x01, rfc_sniff_data = 0x08, rfc_sniff_clk = 0x09,
  rssi_valid = 0x0c, demod_cca = 0x0d, sampled_cca = 0x0e, sfd_sync = 0x0f,
  tx_active = 0x10, rx_active = 0x11, ffctrl_fifo = 0x12, ffctrl_fifop = 0x13,
  packet_done = 0x14, rfc_xor_rand_i_q = 0x16, rfc_rand_q = 0x17, rfc_rand_i = 0x18,
  lock_status = 0x19, pa_pd = 0x20, lna_pd = 0x2a
}
 
void _irq_handler (void)
 IRQ handler for RF events. More...
 
bool cc2538_channel_clear (void)
 Trigger a clear channel assessment. More...
 
uint64_t cc2538_get_addr_long (void)
 Get the configured long address of the device. More...
 
uint16_t cc2538_get_addr_short (void)
 Get the configured short address of the device. More...
 
uint64_t cc2538_get_eui64_primary (void)
 Get the primary (burned-in) EUI-64 of the device. More...
 
unsigned int cc2538_get_chan (void)
 Get the configured channel number of the device. More...
 
bool cc2538_get_monitor (void)
 Check if device is in monitor (promiscuous) mode. More...
 
uint16_t cc2538_get_pan (void)
 Get the configured PAN ID of the device. More...
 
int cc2538_get_tx_power (void)
 Get the configured transmission power of the device. More...
 
void cc2538_init (void)
 Initialise the CC2538 radio hardware. More...
 
bool cc2538_is_on (void)
 Check if device is active. More...
 
void cc2538_off (void)
 Deactivate the CC2538 radio device. More...
 
bool cc2538_on (void)
 Activate the CC2538 radio device. More...
 
void cc2538_setup (cc2538_rf_t *dev)
 Setup a CC2538 radio device for use with netdev. More...
 
void cc2538_set_addr_short (uint16_t addr)
 Set the short address of the device. More...
 
void cc2538_set_addr_long (uint64_t addr)
 Set the long address of the device. More...
 
void cc2538_set_chan (unsigned int chan)
 Set the channel number of the device. More...
 
void cc2538_set_freq (unsigned int MHz)
 Set the frequency of the device. More...
 
void cc2538_set_monitor (bool mode)
 Enable/disable monitor (promiscuous) mode for the device. More...
 
void cc2538_set_pan (uint16_t pan)
 Set the PAN ID of the device. More...
 
void cc2538_set_state (cc2538_rf_t *dev, netopt_state_t state)
 Set the state of the device. More...
 
void cc2538_set_tx_power (int dBm)
 Set the transmission power for the device. More...
 

Macro Definition Documentation

◆ IEEE802154_MAX_FREQ

#define IEEE802154_MAX_FREQ   (2480)

Max.

frequency (2480 MHz)

Definition at line 47 of file cc2538_rf.h.

◆ IEEE802154_MIN_FREQ

#define IEEE802154_MIN_FREQ   (2405)

Min.

frequency (2405 MHz)

Definition at line 46 of file cc2538_rf.h.

◆ RFCORE_WAIT_UNTIL

#define RFCORE_WAIT_UNTIL (   expr)
Value:
while (!(expr)) { \
DEBUG("RFCORE_WAIT_UNTIL(%s) at line %u in %s()\n", #expr, __LINE__, __FUNCTION__); \
thread_yield(); \
}

Definition at line 76 of file cc2538_rf.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SFD 

Start of frame event.

RXPKTDONE 

End of frame event.

Definition at line 125 of file cc2538_rf.h.

Function Documentation

◆ _irq_handler()

void _irq_handler ( void  )

IRQ handler for RF events.

◆ cc2538_channel_clear()

bool cc2538_channel_clear ( void  )

Trigger a clear channel assessment.

Returns
True if channel is clear
False if channel is busy

◆ cc2538_get_addr_long()

uint64_t cc2538_get_addr_long ( void  )

Get the configured long address of the device.

Returns
The currently set (8-byte) long address

◆ cc2538_get_addr_short()

uint16_t cc2538_get_addr_short ( void  )

Get the configured short address of the device.

Returns
The currently set (2-byte) short address

◆ cc2538_get_chan()

unsigned int cc2538_get_chan ( void  )

Get the configured channel number of the device.

Returns
The currently set channel number

◆ cc2538_get_eui64_primary()

uint64_t cc2538_get_eui64_primary ( void  )

Get the primary (burned-in) EUI-64 of the device.

Returns
The primary EUI-64 of the device

◆ cc2538_get_monitor()

bool cc2538_get_monitor ( void  )

Check if device is in monitor (promiscuous) mode.

Returns
True if device is in monitor mode
False if device is not in monitor mode

◆ cc2538_get_pan()

uint16_t cc2538_get_pan ( void  )

Get the configured PAN ID of the device.

Returns
The currently set PAN ID

◆ cc2538_get_tx_power()

int cc2538_get_tx_power ( void  )

Get the configured transmission power of the device.

Returns
The currently configured transmission power in dBm

◆ cc2538_init()

void cc2538_init ( void  )

Initialise the CC2538 radio hardware.

◆ cc2538_is_on()

bool cc2538_is_on ( void  )

Check if device is active.

Returns
True if device is active
False if device is not active

◆ cc2538_off()

void cc2538_off ( void  )

Deactivate the CC2538 radio device.

◆ cc2538_on()

bool cc2538_on ( void  )

Activate the CC2538 radio device.

◆ cc2538_set_addr_long()

void cc2538_set_addr_long ( uint64_t  addr)

Set the long address of the device.

Parameters
[in]addr(8-byte) short address to set

◆ cc2538_set_addr_short()

void cc2538_set_addr_short ( uint16_t  addr)

Set the short address of the device.

Parameters
[in]addr(2-byte) short address to set

◆ cc2538_set_chan()

void cc2538_set_chan ( unsigned int  chan)

Set the channel number of the device.

Parameters
[in]chanChannel number to set

◆ cc2538_set_freq()

void cc2538_set_freq ( unsigned int  MHz)

Set the frequency of the device.

Parameters
[in]MHzFrequency to set in MHz

◆ cc2538_set_monitor()

void cc2538_set_monitor ( bool  mode)

Enable/disable monitor (promiscuous) mode for the device.

Parameters
[in]modeTrue for enable, false for disable

◆ cc2538_set_pan()

void cc2538_set_pan ( uint16_t  pan)

Set the PAN ID of the device.

Parameters
[in]panPAN ID to set

◆ cc2538_set_state()

void cc2538_set_state ( cc2538_rf_t dev,
netopt_state_t  state 
)

Set the state of the device.

Parameters
[out]devDevice descriptor
[in]stateState to set device to

◆ cc2538_set_tx_power()

void cc2538_set_tx_power ( int  dBm)

Set the transmission power for the device.

Parameters
[in]dBmTransmission power to set in dBm

◆ cc2538_setup()

void cc2538_setup ( cc2538_rf_t dev)

Setup a CC2538 radio device for use with netdev.

Parameters
[out]devDevice descriptor