CC2420 radio driver

Detailed Description

Files

file  cc2420_internal.h
 Definitions and settings for the cc2420.
 
file  cc2420_netdev.h
 Netdev interface for the CC2420.
 
file  cc2420_registers.h
 Register and command definitions for CC2420.
 
file  cc2420.h
 Interface definition for the CC2420 driver.
 

Data Structures

struct  cc2420_params
 Struct holding all parameters needed for device initialization. More...
 
struct  cc2420_t
 Device descriptor for CC2420 radio devices. More...
 

Macros

#define CC2420_PKT_MAXLEN   (IEEE802154_FRAME_LEN_MAX)
 Maximum possible packet size in byte.
 
#define CC2420_PANID_DEFAULT   (IEEE802154_DEFAULT_PANID)
 PAN ID configuration.
 
#define CC2420_RSSI_OFFSET   (-45)
 RSSI offset.
 

Typedefs

typedef struct cc2420_params cc2420_params_t
 Struct holding all parameters needed for device initialization.
 

Enumerations

enum  { CC2420_RET_CHAN_OK = 2 }
 A couple of return values used in this driver.
 

Functions

void cc2420_setup (cc2420_t *dev, const cc2420_params_t *params)
 Setup the device descriptor for the given device. More...
 
int cc2420_init (cc2420_t *dev)
 Initialize a given CC2420 device. More...
 
int cc2420_reset (cc2420_t *dev)
 Trigger a hardware reset and configure radio with default values. More...
 
bool cc2420_cca (cc2420_t *dev)
 Trigger a clear channel assessment. More...
 
void cc2420_get_addr_short (cc2420_t *dev, uint8_t *addr)
 Get the short address of the given device. More...
 
void cc2420_set_addr_short (cc2420_t *dev, const uint8_t *addr)
 Set the short address of the given device. More...
 
void cc2420_get_addr_long (cc2420_t *dev, uint8_t *addr_long)
 Get the configured long address of the given device. More...
 
void cc2420_set_addr_long (cc2420_t *dev, const uint8_t *addr_long)
 Set the long address of the given device. More...
 
uint16_t cc2420_get_pan (cc2420_t *dev)
 Get the configured PAN ID of the given device. More...
 
void cc2420_set_pan (cc2420_t *dev, uint16_t pan)
 Set the PAN ID of the given device. More...
 
uint16_t cc2420_get_chan (cc2420_t *dev)
 Get the configured channel of the given device. More...
 
int cc2420_set_chan (cc2420_t *dev, uint16_t chan)
 Set the channel of the given device. More...
 
int16_t cc2420_get_txpower (cc2420_t *dev)
 Get the configured transmission power of the given device [in dBm]. More...
 
void cc2420_set_txpower (cc2420_t *dev, int16_t txpower)
 Set the transmission power of the given device [in dBm]. More...
 
int cc2420_set_option (cc2420_t *dev, uint16_t option, bool state)
 Enable or disable driver specific options. More...
 
int cc2420_set_state (cc2420_t *dev, netopt_state_t state)
 Set the state of the given device (trigger a state change) More...
 
netopt_state_t cc2420_get_state (cc2420_t *dev)
 Get the state of the given device. More...
 
size_t cc2420_send (cc2420_t *dev, const struct iovec *data, unsigned count)
 Convenience function for simply sending data. More...
 
size_t cc2420_tx_prepare (cc2420_t *dev, const struct iovec *data, unsigned count)
 Prepare for sending of data. More...
 
void cc2420_tx_exec (cc2420_t *dev)
 Trigger sending of data previously loaded into transmit buffer. More...
 
int cc2420_rx (cc2420_t *dev, uint8_t *buf, size_t max_len, void *info)
 Read a chunk of data from the receive buffer of the given device. More...
 

Channel configuration

#define CC2420_CHAN_MIN   (IEEE802154_CHANNEL_MIN)
 
#define CC2420_CHAN_MAX   (IEEE802154_CHANNEL_MAX)
 
#define CC2420_CHAN_DEFAULT   (IEEE802154_DEFAULT_CHANNEL)
 

Default TX power configuration [in dBm]

#define CC2420_TXPOWER_MIN   (-25)
 
#define CC2420_TXPOWER_MAX   (0)
 
#define CC2420_TXPOWER_DEFAULT   (IEEE802154_DEFAULT_TXPOWER)
 

Function Documentation

◆ cc2420_cca()

bool cc2420_cca ( cc2420_t dev)

Trigger a clear channel assessment.

Parameters
[in]devdevice to use
Returns
true if channel is clear
false if channel is busy

◆ cc2420_get_addr_long()

void cc2420_get_addr_long ( cc2420_t dev,
uint8_t *  addr_long 
)

Get the configured long address of the given device.

Parameters
[in]devdevice to read from
[out]addr_longbuffer to save the read address
Returns
the currently set (8-byte) long address

◆ cc2420_get_addr_short()

void cc2420_get_addr_short ( cc2420_t dev,
uint8_t *  addr 
)

Get the short address of the given device.

Parameters
[in]devdevice to read from
[out]addrmemory to write the 2 byte address into

◆ cc2420_get_chan()

uint16_t cc2420_get_chan ( cc2420_t dev)

Get the configured channel of the given device.

Parameters
[in]devdevice to read from
Returns
the currently set channel

◆ cc2420_get_pan()

uint16_t cc2420_get_pan ( cc2420_t dev)

Get the configured PAN ID of the given device.

Parameters
[in]devdevice to read from
Returns
the currently set PAN ID

◆ cc2420_get_state()

netopt_state_t cc2420_get_state ( cc2420_t dev)

Get the state of the given device.

Parameters
[in]devdevice to change state of
Returns
the device's current state

◆ cc2420_get_txpower()

int16_t cc2420_get_txpower ( cc2420_t dev)

Get the configured transmission power of the given device [in dBm].

Parameters
[in]devdevice to read from
Returns
configured transmission power in dBm

◆ cc2420_init()

int cc2420_init ( cc2420_t dev)

Initialize a given CC2420 device.

Parameters
[out]devdevice descriptor
Returns
0 on success
<0 on error

◆ cc2420_reset()

int cc2420_reset ( cc2420_t dev)

Trigger a hardware reset and configure radio with default values.

Parameters
[in]devdevice to reset
Returns
TODO

◆ cc2420_rx()

int cc2420_rx ( cc2420_t dev,
uint8_t *  buf,
size_t  max_len,
void *  info 
)

Read a chunk of data from the receive buffer of the given device.

Parameters
[in]devdevice to read from
[out]bufbuffer to write data to
[in]max_lennumber of bytes to read from device
[in]infoto be removed
Returns
the number of bytes in the Rx FIFO
the number of bytes written to buf if present

◆ cc2420_send()

size_t cc2420_send ( cc2420_t dev,
const struct iovec data,
unsigned  count 
)

Convenience function for simply sending data.

Note
This function ignores the PRELOADING option
Parameters
[in]devdevice to use for sending
[in]datadata to send (must include IEEE802.15.4 header)
[in]countlength of data
Returns
number of bytes that were actually send
0 on error

◆ cc2420_set_addr_long()

void cc2420_set_addr_long ( cc2420_t dev,
const uint8_t *  addr_long 
)

Set the long address of the given device.

Parameters
[in]devdevice to write to
[in]addr_long(8-byte) long address to set

◆ cc2420_set_addr_short()

void cc2420_set_addr_short ( cc2420_t dev,
const uint8_t *  addr 
)

Set the short address of the given device.

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

◆ cc2420_set_chan()

int cc2420_set_chan ( cc2420_t dev,
uint16_t  chan 
)

Set the channel of the given device.

Parameters
[in]devdevice to write to
[in]chanchannel to set

◆ cc2420_set_option()

int cc2420_set_option ( cc2420_t dev,
uint16_t  option,
bool  state 
)

Enable or disable driver specific options.

Parameters
[in]devdevice to set/clear option flag for
[in]optionoption to enable/disable
[in]statetrue for enable, false for disable

◆ cc2420_set_pan()

void cc2420_set_pan ( cc2420_t dev,
uint16_t  pan 
)

Set the PAN ID of the given device.

Parameters
[in]devdevice to write to
[in]panPAN ID to set

◆ cc2420_set_state()

int cc2420_set_state ( cc2420_t dev,
netopt_state_t  state 
)

Set the state of the given device (trigger a state change)

Parameters
[in]devdevice to change state of
[in]statethe targeted new state

◆ cc2420_set_txpower()

void cc2420_set_txpower ( cc2420_t dev,
int16_t  txpower 
)

Set the transmission power of the given device [in dBm].

If the device does not support the exact dBm value given, it will set a value as close as possible to the given value. If the given value is larger or lower then the maximal or minimal possible value, the min or max value is set, respectively.

Parameters
[in]devdevice to write to
[in]txpowertransmission power in dBm

◆ cc2420_setup()

void cc2420_setup ( cc2420_t dev,
const cc2420_params_t params 
)

Setup the device descriptor for the given device.

Parameters
[out]devdevice descriptor
[in]paramsdevice parameters
Returns
0 on success
-1 on error

◆ cc2420_tx_exec()

void cc2420_tx_exec ( cc2420_t dev)

Trigger sending of data previously loaded into transmit buffer.

Parameters
[in]devdevice to trigger

◆ cc2420_tx_prepare()

size_t cc2420_tx_prepare ( cc2420_t dev,
const struct iovec data,
unsigned  count 
)

Prepare for sending of data.

This function puts the given device into the TX state, so no receiving of data is possible after it was called.

Parameters
[in]devdevice to prepare for sending
[in]datadata to prepare (must include IEEE802.15.4 header)
[in]countlength of data