RF230 interface
[Wireless]

Files

file  radio.c
 

This file contains radio driver code.


file  radio.h
 

This file contains radio driver code.


file  rf230bb.h
 

This file contains radio driver code.


Defines

#define RADIO_CCA_DONE_MASK   (1 << 7)
 Mask used to check the CCA_DONE bit.
#define RADIO_CCA_IDLE_MASK   (1 << 6)
 Mask used to check the CCA_STATUS bit.
#define RADIO_START_CCA   (1)
 Value in the CCA_REQUEST subregister that initiate a cca.
#define RF230_MAX_TX_FRAME_LENGTH   ( 127 )
 127 Byte PSDU.
#define RADIO_STATUS_START_VALUE   ( 0x40 )
 This macro defines the start value for the RADIO_* status constants.
#define RF230_MAX_TX_FRAME_LENGTH   ( 127 )
 127 Byte PSDU.
#define RADIO_STATUS_START_VALUE   ( 0x40 )
 This macro defines the start value for the RADIO_* status constants.

Enumerations

enum  radio_trx_timing_t {
  TIME_TO_ENTER_P_ON = 510, TIME_P_ON_TO_TRX_OFF = 510, TIME_SLEEP_TO_TRX_OFF = 880, TIME_RESET = 6,
  TIME_ED_MEASUREMENT = 140, TIME_CCA = 140, TIME_PLL_LOCK = 150, TIME_FTN_TUNING = 25,
  TIME_NOCLK_TO_WAKE = 6, TIME_CMD_FORCE_TRX_OFF = 1, TIME_TRX_OFF_TO_PLL_ACTIVE = 180, TIME_STATE_TRANSITION_PLL_ACTIVE = 1,
  TIME_TO_ENTER_P_ON = 510, TIME_P_ON_TO_TRX_OFF = 510, TIME_SLEEP_TO_TRX_OFF = 880, TIME_RESET = 6,
  TIME_ED_MEASUREMENT = 140, TIME_CCA = 140, TIME_PLL_LOCK = 150, TIME_FTN_TUNING = 25,
  TIME_NOCLK_TO_WAKE = 6, TIME_CMD_FORCE_TRX_OFF = 1, TIME_TRX_OFF_TO_PLL_ACTIVE = 180, TIME_STATE_TRANSITION_PLL_ACTIVE = 1,
  TIME_TO_ENTER_P_ON = 510, TIME_P_ON_TO_TRX_OFF = 510, TIME_SLEEP_TO_TRX_OFF = 880, TIME_RESET = 6,
  TIME_ED_MEASUREMENT = 140, TIME_CCA = 140, TIME_PLL_LOCK = 150, TIME_FTN_TUNING = 25,
  TIME_NOCLK_TO_WAKE = 6, TIME_CMD_FORCE_TRX_OFF = 1, TIME_TRX_OFF_TO_PLL_ACTIVE = 180, TIME_STATE_TRANSITION_PLL_ACTIVE = 1
}
 

This enumeration defines the necessary timing information for the AT86RF230 radio transceiver.

More...
enum  radio_status_t {
  RADIO_SUCCESS = RADIO_STATUS_START_VALUE, RADIO_UNSUPPORTED_DEVICE, RADIO_INVALID_ARGUMENT, RADIO_TIMED_OUT,
  RADIO_WRONG_STATE, RADIO_BUSY_STATE, RADIO_STATE_TRANSITION_FAILED, RADIO_CCA_IDLE,
  RADIO_CCA_BUSY, RADIO_TRX_BUSY, RADIO_BAT_LOW, RADIO_BAT_OK,
  RADIO_CRC_FAILED, RADIO_CHANNEL_ACCESS_FAILURE, RADIO_NO_ACK, RADIO_SUCCESS = RADIO_STATUS_START_VALUE,
  RADIO_UNSUPPORTED_DEVICE, RADIO_INVALID_ARGUMENT, RADIO_TIMED_OUT, RADIO_WRONG_STATE,
  RADIO_BUSY_STATE, RADIO_STATE_TRANSITION_FAILED, RADIO_CCA_IDLE, RADIO_CCA_BUSY,
  RADIO_TRX_BUSY, RADIO_BAT_LOW, RADIO_BAT_OK, RADIO_CRC_FAILED,
  RADIO_CHANNEL_ACCESS_FAILURE, RADIO_NO_ACK
}
 

This enumeration defines the possible return values for the TAT API functions.

More...
enum  radio_cca_mode_t {
  CCA_ED = 0, CCA_CARRIER_SENSE = 1, CCA_CARRIER_SENSE_WITH_ED = 2, CCA_ENERGY_DETECT = 0,
  CCA_CARRIER_SENSE = 1, CCA_CARRIER_SENSE_WITH_ED = 2
}
 

This enumeration defines the possible modes available for the Clear Channel Assessment algorithm.

More...
enum  radio_clkm_speed_t
 

This enumeration defines the possible CLKM speeds.

More...
enum  radio_status_t {
  RADIO_SUCCESS = RADIO_STATUS_START_VALUE, RADIO_UNSUPPORTED_DEVICE, RADIO_INVALID_ARGUMENT, RADIO_TIMED_OUT,
  RADIO_WRONG_STATE, RADIO_BUSY_STATE, RADIO_STATE_TRANSITION_FAILED, RADIO_CCA_IDLE,
  RADIO_CCA_BUSY, RADIO_TRX_BUSY, RADIO_BAT_LOW, RADIO_BAT_OK,
  RADIO_CRC_FAILED, RADIO_CHANNEL_ACCESS_FAILURE, RADIO_NO_ACK, RADIO_SUCCESS = RADIO_STATUS_START_VALUE,
  RADIO_UNSUPPORTED_DEVICE, RADIO_INVALID_ARGUMENT, RADIO_TIMED_OUT, RADIO_WRONG_STATE,
  RADIO_BUSY_STATE, RADIO_STATE_TRANSITION_FAILED, RADIO_CCA_IDLE, RADIO_CCA_BUSY,
  RADIO_TRX_BUSY, RADIO_BAT_LOW, RADIO_BAT_OK, RADIO_CRC_FAILED,
  RADIO_CHANNEL_ACCESS_FAILURE, RADIO_NO_ACK
}
 

This enumeration defines the possible return values for the TAT API functions.

More...
enum  radio_cca_mode_t {
  CCA_ED = 0, CCA_CARRIER_SENSE = 1, CCA_CARRIER_SENSE_WITH_ED = 2, CCA_ENERGY_DETECT = 0,
  CCA_CARRIER_SENSE = 1, CCA_CARRIER_SENSE_WITH_ED = 2
}
 

This enumeration defines the possible modes available for the Clear Channel Assessment algorithm.

More...
enum  radio_clkm_speed_t
 

This enumeration defines the possible CLKM speeds.

More...

Functions

bool radio_is_sleeping (void)
 This function checks if the radio transceiver is sleeping.
radio_status_t radio_init (bool cal_rc_osc, hal_rx_start_isr_event_handler_t rx_event, hal_trx_end_isr_event_handler_t trx_end_event, radio_rx_callback rx_callback)
 Initialize the Transceiver Access Toolbox and lower layers.
uint8_t radio_get_operating_channel (void)
 This function will return the channel used by the radio transceiver.
radio_status_t radio_set_operating_channel (uint8_t channel)
 This function will change the operating channel.
uint8_t radio_get_tx_power_level (void)
 This function will read and return the output power level.
radio_status_t radio_set_tx_power_level (uint8_t power_level)
 This function will change the output power level.
uint8_t radio_get_cca_mode (void)
 This function returns the current CCA mode used.
uint8_t radio_get_ed_threshold (void)
 This function returns the current ED threshold used by the CCA algorithm.
radio_status_t radio_set_cca_mode (uint8_t mode, uint8_t ed_threshold)
 This function will configure the Clear Channel Assessment algorithm.
radio_status_t radio_get_rssi_value (uint8_t *rssi)
 This function returns the Received Signal Strength Indication.
uint8_t radio_batmon_get_voltage_threshold (void)
 This function returns the current threshold volatge used by the battery monitor (BATMON_VTH).
uint8_t radio_batmon_get_voltage_range (void)
 This function returns if high or low voltage range is used.
radio_status_t radio_batmon_configure (bool range, uint8_t voltage_threshold)
 This function is used to configure the battery monitor module.
radio_status_t radio_batmon_get_status (void)
 This function returns the status of the Battery Monitor module.
uint8_t radio_get_clock_speed (void)
 This function returns the current clock setting for the CLKM pin.
radio_status_t radio_set_clock_speed (bool direct, uint8_t clock_speed)
 This function changes the prescaler on the CLKM pin.
radio_status_t radio_calibrate_filter (void)
 This function calibrates the Single Side Band Filter.
radio_status_t radio_calibrate_pll (void)
 This function calibrates the PLL.
uint8_t radio_get_trx_state (void)
 This function return the Radio Transceivers current state.
radio_status_t radio_set_trx_state (uint8_t new_state)
 This function will change the current state of the radio transceiver's internal state machine.
radio_status_t radio_enter_sleep_mode (void)
 This function will put the radio transceiver to sleep.
radio_status_t radio_leave_sleep_mode (void)
 This function will take the radio transceiver from sleep mode and put it into the TRX_OFF state.
void radio_reset_state_machine (void)
 This function will reset the state machine (to TRX_OFF) from any of its states, except for the SLEEP state.
void radio_reset_trx (void)
 This function will reset all the registers and the state machine of the radio transceiver.
void radio_use_auto_tx_crc (bool auto_crc_on)
 This function will enable or disable automatic CRC during frame transmission.
radio_status_t radio_send_data (uint8_t data_length, uint8_t *data)
 This function will download a frame to the radio transceiver's transmit buffer and send it.
uint8_t radio_get_device_role (void)
 This function will read the I_AM_COORD sub register.
void radio_set_device_role (bool i_am_coordinator)
 This function will set the I_AM_COORD sub register.
uint16_t radio_get_pan_id (void)
 This function will return the PANID used by the address filter.
void radio_set_pan_id (uint16_t new_pan_id)
 This function will set the PANID used by the address filter.
uint16_t radio_get_short_address (void)
 This function will return the current short address used by the address filter.
void radio_set_short_address (uint16_t new_short_address)
 This function will set the short address used by the address filter.
void radio_get_extended_address (uint8_t *extended_address)
 This function will read the extended address used by the address filter.
void radio_set_extended_address (uint8_t *extended_address)
 This function will set a new extended address to be used by the address filter.
radio_status_t radio_configure_csma (uint8_t seed0, uint8_t be_csma_seed1)
 This function will configure the CSMA algorithm used by the radio transceiver when transmitting data from TX_ARET_ON state.
bool calibrate_rc_osc_clkm (void)
 Calibrate the internal RC oscillator.
void calibrate_rc_osc_32k (void)
 Calibrate the internal RC oscillator.

Transaction status codes



#define TRAC_SUCCESS   0
#define TRAC_SUCCESS_DATA_PENDING   1
#define TRAC_SUCCESS_WAIT_FOR_ACK   2
#define TRAC_CHANNEL_ACCESS_FAILURE   3
#define TRAC_NO_ACK   5
#define TRAC_INVALID   7

Transaction status codes



#define TRAC_SUCCESS   0
#define TRAC_SUCCESS_DATA_PENDING   1
#define TRAC_SUCCESS_WAIT_FOR_ACK   2
#define TRAC_CHANNEL_ACCESS_FAILURE   3
#define TRAC_NO_ACK   5
#define TRAC_INVALID   7

Define Documentation

#define RADIO_CCA_DONE_MASK   (1 << 7)

Mask used to check the CCA_DONE bit.

Definition at line 78 of file radio.c.

#define RADIO_CCA_IDLE_MASK   (1 << 6)

Mask used to check the CCA_STATUS bit.

Definition at line 79 of file radio.c.

#define RADIO_START_CCA   (1)

Value in the CCA_REQUEST subregister that initiate a cca.

Definition at line 81 of file radio.c.

#define RADIO_STATUS_START_VALUE   ( 0x40 )

This macro defines the start value for the RADIO_* status constants.

It was chosen to have this macro so that the user can define where the status returned from the TAT starts. This can be useful in a system where numerous drivers are used, and some range of status codes are occupied.

See also:
radio_status_t

Definition at line 115 of file rf230bb.h.

#define RADIO_STATUS_START_VALUE   ( 0x40 )

This macro defines the start value for the RADIO_* status constants.

It was chosen to have this macro so that the user can define where the status returned from the TAT starts. This can be useful in a system where numerous drivers are used, and some range of status codes are occupied.

See also:
radio_status_t

Definition at line 97 of file radio.h.

#define RF230_MAX_TX_FRAME_LENGTH   ( 127 )

127 Byte PSDU.

Definition at line 78 of file rf230bb.h.

#define RF230_MAX_TX_FRAME_LENGTH   ( 127 )

127 Byte PSDU.

Definition at line 70 of file radio.h.


Enumeration Type Documentation

This enumeration defines the possible modes available for the Clear Channel Assessment algorithm.

These constants are extracted from the datasheet.

Enumerator:
CCA_ED 

Use energy detection above threshold mode.

CCA_CARRIER_SENSE 

Use carrier sense mode.

CCA_CARRIER_SENSE_WITH_ED 

Use a combination of both energy detection and carrier sense.

CCA_ENERGY_DETECT 

Use energy detection above threshold mode.

CCA_CARRIER_SENSE 

Use carrier sense mode.

CCA_CARRIER_SENSE_WITH_ED 

Use a combination of both energy detection and carrier sense.

Definition at line 162 of file rf230bb.h.

This enumeration defines the possible modes available for the Clear Channel Assessment algorithm.

These constants are extracted from the datasheet.

Enumerator:
CCA_ED 

Use energy detection above threshold mode.

CCA_CARRIER_SENSE 

Use carrier sense mode.

CCA_CARRIER_SENSE_WITH_ED 

Use a combination of both energy detection and carrier sense.

CCA_ENERGY_DETECT 

Use energy detection above threshold mode.

CCA_CARRIER_SENSE 

Use carrier sense mode.

CCA_CARRIER_SENSE_WITH_ED 

Use a combination of both energy detection and carrier sense.

Definition at line 144 of file radio.h.

This enumeration defines the possible CLKM speeds.

These constants are extracted from the RF230 datasheet.

Definition at line 175 of file rf230bb.h.

This enumeration defines the possible CLKM speeds.

These constants are extracted from the RF230 datasheet.

Definition at line 156 of file radio.h.

This enumeration defines the possible return values for the TAT API functions.

These values are defined so that they should not collide with the return/status codes defined in the IEEE 802.15.4 standard.

Enumerator:
RADIO_SUCCESS 

The requested service was performed successfully.

RADIO_UNSUPPORTED_DEVICE 

The connected device is not an Atmel AT86RF230.

RADIO_INVALID_ARGUMENT 

One or more of the supplied function arguments are invalid.

RADIO_TIMED_OUT 

The requested service timed out.

RADIO_WRONG_STATE 

The end-user tried to do an invalid state transition.

RADIO_BUSY_STATE 

The radio transceiver is busy receiving or transmitting.

RADIO_STATE_TRANSITION_FAILED 

The requested state transition could not be completed.

RADIO_CCA_IDLE 

Channel is clear, available to transmit a new frame.

RADIO_CCA_BUSY 

Channel busy.

RADIO_TRX_BUSY 

Transceiver is busy receiving or transmitting data.

RADIO_BAT_LOW 

Measured battery voltage is lower than voltage threshold.

RADIO_BAT_OK 

Measured battery voltage is above the voltage threshold.

RADIO_CRC_FAILED 

The CRC failed for the actual frame.

RADIO_CHANNEL_ACCESS_FAILURE 

The channel access failed during the auto mode.

RADIO_NO_ACK 

No acknowledge frame was received.

RADIO_SUCCESS 

The requested service was performed successfully.

RADIO_UNSUPPORTED_DEVICE 

The connected device is not an Atmel AT86RF230.

RADIO_INVALID_ARGUMENT 

One or more of the supplied function arguments are invalid.

RADIO_TIMED_OUT 

The requested service timed out.

RADIO_WRONG_STATE 

The end-user tried to do an invalid state transition.

RADIO_BUSY_STATE 

The radio transceiver is busy receiving or transmitting.

RADIO_STATE_TRANSITION_FAILED 

The requested state transition could not be completed.

RADIO_CCA_IDLE 

Channel is clear, available to transmit a new frame.

RADIO_CCA_BUSY 

Channel busy.

RADIO_TRX_BUSY 

Transceiver is busy receiving or transmitting data.

RADIO_BAT_LOW 

Measured battery voltage is lower than voltage threshold.

RADIO_BAT_OK 

Measured battery voltage is above the voltage threshold.

RADIO_CRC_FAILED 

The CRC failed for the actual frame.

RADIO_CHANNEL_ACCESS_FAILURE 

The channel access failed during the auto mode.

RADIO_NO_ACK 

No acknowledge frame was received.

Definition at line 124 of file rf230bb.h.

This enumeration defines the possible return values for the TAT API functions.

These values are defined so that they should not collide with the return/status codes defined in the IEEE 802.15.4 standard.

Enumerator:
RADIO_SUCCESS 

The requested service was performed successfully.

RADIO_UNSUPPORTED_DEVICE 

The connected device is not an Atmel AT86RF230.

RADIO_INVALID_ARGUMENT 

One or more of the supplied function arguments are invalid.

RADIO_TIMED_OUT 

The requested service timed out.

RADIO_WRONG_STATE 

The end-user tried to do an invalid state transition.

RADIO_BUSY_STATE 

The radio transceiver is busy receiving or transmitting.

RADIO_STATE_TRANSITION_FAILED 

The requested state transition could not be completed.

RADIO_CCA_IDLE 

Channel is clear, available to transmit a new frame.

RADIO_CCA_BUSY 

Channel busy.

RADIO_TRX_BUSY 

Transceiver is busy receiving or transmitting data.

RADIO_BAT_LOW 

Measured battery voltage is lower than voltage threshold.

RADIO_BAT_OK 

Measured battery voltage is above the voltage threshold.

RADIO_CRC_FAILED 

The CRC failed for the actual frame.

RADIO_CHANNEL_ACCESS_FAILURE 

The channel access failed during the auto mode.

RADIO_NO_ACK 

No acknowledge frame was received.

RADIO_SUCCESS 

The requested service was performed successfully.

RADIO_UNSUPPORTED_DEVICE 

The connected device is not an Atmel AT86RF230.

RADIO_INVALID_ARGUMENT 

One or more of the supplied function arguments are invalid.

RADIO_TIMED_OUT 

The requested service timed out.

RADIO_WRONG_STATE 

The end-user tried to do an invalid state transition.

RADIO_BUSY_STATE 

The radio transceiver is busy receiving or transmitting.

RADIO_STATE_TRANSITION_FAILED 

The requested state transition could not be completed.

RADIO_CCA_IDLE 

Channel is clear, available to transmit a new frame.

RADIO_CCA_BUSY 

Channel busy.

RADIO_TRX_BUSY 

Transceiver is busy receiving or transmitting data.

RADIO_BAT_LOW 

Measured battery voltage is lower than voltage threshold.

RADIO_BAT_OK 

Measured battery voltage is above the voltage threshold.

RADIO_CRC_FAILED 

The CRC failed for the actual frame.

RADIO_CHANNEL_ACCESS_FAILURE 

The channel access failed during the auto mode.

RADIO_NO_ACK 

No acknowledge frame was received.

Definition at line 106 of file radio.h.

This enumeration defines the necessary timing information for the AT86RF230 radio transceiver.

All times are in microseconds.

These constants are extracted from the datasheet.

Enumerator:
TIME_TO_ENTER_P_ON 

Transition time from VCC is applied to P_ON.

TIME_P_ON_TO_TRX_OFF 

Transition time from P_ON to TRX_OFF.

TIME_SLEEP_TO_TRX_OFF 

Transition time from SLEEP to TRX_OFF.

TIME_RESET 

Time to hold the RST pin low during reset.

TIME_ED_MEASUREMENT 

Time it takes to do a ED measurement.

TIME_CCA 

Time it takes to do a CCA.

TIME_PLL_LOCK 

Maximum time it should take for the PLL to lock.

TIME_FTN_TUNING 

Maximum time it should take to do the filter tuning.

TIME_NOCLK_TO_WAKE 

Transition time from *_NOCLK to being awake.

TIME_CMD_FORCE_TRX_OFF 

Time it takes to execute the FORCE_TRX_OFF command.

TIME_TRX_OFF_TO_PLL_ACTIVE 

Transition time from TRX_OFF to: RX_ON, PLL_ON, TX_ARET_ON and RX_AACK_ON.

TIME_STATE_TRANSITION_PLL_ACTIVE 

Transition time from PLL active state to another.

TIME_TO_ENTER_P_ON 

Transition time from VCC is applied to P_ON - most favorable case!

TIME_P_ON_TO_TRX_OFF 

Transition time from P_ON to TRX_OFF.

TIME_SLEEP_TO_TRX_OFF 

Transition time from SLEEP to TRX_OFF.

TIME_RESET 

Time to hold the RST pin low during reset.

TIME_ED_MEASUREMENT 

Time it takes to do a ED measurement.

TIME_CCA 

Time it takes to do a CCA.

TIME_PLL_LOCK 

Maximum time it should take for the PLL to lock.

TIME_FTN_TUNING 

Maximum time it should take to do the filter tuning.

TIME_NOCLK_TO_WAKE 

Transition time from *_NOCLK to being awake.

TIME_CMD_FORCE_TRX_OFF 

Time it takes to execute the FORCE_TRX_OFF command.

TIME_TRX_OFF_TO_PLL_ACTIVE 

Transition time from TRX_OFF to: RX_ON, PLL_ON, TX_ARET_ON and RX_AACK_ON.

TIME_STATE_TRANSITION_PLL_ACTIVE 

Transition time from PLL active state to another.

TIME_TO_ENTER_P_ON 

Transition time from VCC is applied to P_ON - most favorable case!

TIME_P_ON_TO_TRX_OFF 

Transition time from P_ON to TRX_OFF.

TIME_SLEEP_TO_TRX_OFF 

Transition time from SLEEP to TRX_OFF.

TIME_RESET 

Time to hold the RST pin low during reset.

TIME_ED_MEASUREMENT 

Time it takes to do a ED measurement.

TIME_CCA 

Time it takes to do a CCA.

TIME_PLL_LOCK 

Maximum time it should take for the PLL to lock.

TIME_FTN_TUNING 

Maximum time it should take to do the filter tuning.

TIME_NOCLK_TO_WAKE 

Transition time from *_NOCLK to being awake.

TIME_CMD_FORCE_TRX_OFF 

Time it takes to execute the FORCE_TRX_OFF command.

TIME_TRX_OFF_TO_PLL_ACTIVE 

Transition time from TRX_OFF to: RX_ON, PLL_ON, TX_ARET_ON and RX_AACK_ON.

TIME_STATE_TRANSITION_PLL_ACTIVE 

Transition time from PLL active state to another.

Definition at line 93 of file radio.c.


Function Documentation

void calibrate_rc_osc_32k ( void   ) 

Calibrate the internal RC oscillator.

This function calibrates the internal RC oscillator, based on an external 32KHz crystal connected to TIMER2. In order to verify the calibration result you can program the CKOUT fuse and monitor the CPU clock on an I/O pin.

bool calibrate_rc_osc_clkm ( void   ) 

Calibrate the internal RC oscillator.

This function calibrates the internal RC oscillator, based on the 1 MHz clock supplied by the AT86RF2xx. In order to verify the calibration result you can program the CKOUT fuse and monitor the CPU clock on an I/O pin.

Returns:
TRUE if calibrate passed; FALSE if calibrate failed.
radio_status_t radio_batmon_configure ( bool  range,
uint8_t  voltage_threshold 
)

This function is used to configure the battery monitor module.

Parameters:
range True means high voltage range and false low voltage range.
voltage_threshold The datasheet defines 16 voltage levels for both low and high range.
Return values:
RADIO_SUCCESS Battery monitor configured
RADIO_WRONG_STATE The device is sleeping.
RADIO_INVALID_ARGUMENT The voltage_threshold parameter is out of bounds (Not within [0 - 15]).
radio_status_t radio_batmon_get_status ( void   ) 

This function returns the status of the Battery Monitor module.

Note:
This function can not be called from P_ON or SLEEP. This is ensured by reading the device state before calling this function.
Return values:
RADIO_BAT_LOW Battery voltage is below the programmed threshold.
RADIO_BAT_OK Battery voltage is above the programmed threshold.
uint8_t radio_batmon_get_voltage_range ( void   ) 

This function returns if high or low voltage range is used.

Note:
This function can not be called from P_ON or SLEEP. This is ensured by reading the device state before calling this function.
Return values:
0 Low voltage range selected.
1 High voltage range selected.
uint8_t radio_batmon_get_voltage_threshold ( void   ) 

This function returns the current threshold volatge used by the battery monitor (BATMON_VTH).

Note:
This function can not be called from P_ON or SLEEP. This is ensured by reading the device state before calling this function.
Returns:
Current threshold voltage, 0 to 15.
radio_status_t radio_calibrate_filter ( void   ) 

This function calibrates the Single Side Band Filter.

Return values:
RADIO_SUCCESS Filter is calibrated.
RADIO_TIMED_OUT The calibration could not be completed within time.
RADIO_WRONG_STATE This function can only be called from TRX_OFF or PLL_ON.
radio_status_t radio_calibrate_pll ( void   ) 

This function calibrates the PLL.

Return values:
RADIO_SUCCESS PLL Center Frequency and Delay Cell is calibrated.
RADIO_TIMED_OUT The calibration could not be completed within time.
RADIO_WRONG_STATE This function can only be called from PLL_ON.
radio_status_t radio_configure_csma ( uint8_t  seed0,
uint8_t  be_csma_seed1 
)

This function will configure the CSMA algorithm used by the radio transceiver when transmitting data from TX_ARET_ON state.

Parameters:
seed0 Lower 8 bits of the seed used for the random number generator in the CSMA algorithm. Value range: 0 to 255.
be_csma_seed1 Is a combined argument of the MIN_BE, MAX_CSMA_RETRIES and SEED1 variables:

  1. MIN_BE: Bit[7:6] Minimum back-off exponent in the CSMA/CA algorithm.
  2. MAX_CSMA_RETRIES: Bit[5:3] Number of retries in TX_ARET_ON mode to repeat the CSMA/CA procedures before the ARET procedure gives up.
  3. SEED1: Bits[2:0] Higher 3 bits of CSMA_SEED, bits[10:8] Seed for the random number generator in the CSMA/CA algorithm.
Return values:
RADIO_SUCCESS The CSMA algorithm was configured successfully.
RADIO_WRONG_STATE This function should not be called in the SLEEP state.
radio_status_t radio_enter_sleep_mode ( void   ) 

This function will put the radio transceiver to sleep.

Return values:
RADIO_SUCCESS Sleep mode entered successfully.
RADIO_TIMED_OUT The transition to TRX_OFF took too long.
uint8_t radio_get_cca_mode ( void   ) 

This function returns the current CCA mode used.

Returns:
CCA mode currently used, 0 to 3.
uint8_t radio_get_clock_speed ( void   ) 

This function returns the current clock setting for the CLKM pin.

Return values:
CLKM_DISABLED CLKM pin is disabled.
CLKM_1MHZ CLKM pin is prescaled to 1 MHz.
CLKM_2MHZ CLKM pin is prescaled to 2 MHz.
CLKM_4MHZ CLKM pin is prescaled to 4 MHz.
CLKM_8MHZ CLKM pin is prescaled to 8 MHz.
CLKM_16MHZ CLKM pin is not prescaled. Output is 16 MHz.
uint8_t radio_get_device_role ( void   ) 

This function will read the I_AM_COORD sub register.

Return values:
0 Not coordinator.
1 Coordinator role enabled.
uint8_t radio_get_ed_threshold ( void   ) 

This function returns the current ED threshold used by the CCA algorithm.

Returns:
Current ED threshold, 0 to 15.
void radio_get_extended_address ( uint8_t *  extended_address  ) 

This function will read the extended address used by the address filter.

Note:
In this function a pointer is used to convey the 64-bit result, since it is very inefficient to use the stack for this.
Returns:
Extended Address, any 64-bit value.
uint8_t radio_get_operating_channel ( void   ) 

This function will return the channel used by the radio transceiver.

Returns:
Current channel, 11 to 26.

Referenced by menu_process().

uint16_t radio_get_pan_id ( void   ) 

This function will return the PANID used by the address filter.

Return values:
Any value from 0 to 0xFFFF.
radio_status_t radio_get_rssi_value ( uint8_t *  rssi  ) 

This function returns the Received Signal Strength Indication.

Note:
This function should only be called from the: RX_ON and BUSY_RX. This can be ensured by reading the current state of the radio transceiver before executing this function!
Parameters:
rssi Pointer to memory location where RSSI value should be written.
Return values:
RADIO_SUCCESS The RSSI measurement was successful.
RADIO_WRONG_STATE The radio transceiver is not in RX_ON or BUSY_RX.

Referenced by menu_process().

uint16_t radio_get_short_address ( void   ) 

This function will return the current short address used by the address filter.

Return values:
Any value from 0x0000 to 0xFFFF
uint8_t radio_get_trx_state ( void   ) 

This function return the Radio Transceivers current state.

Return values:
P_ON When the external supply voltage (VDD) is first supplied to the transceiver IC, the system is in the P_ON (Poweron) mode.
BUSY_RX The radio transceiver is busy receiving a frame.
BUSY_TX The radio transceiver is busy transmitting a frame.
RX_ON The RX_ON mode enables the analog and digital receiver blocks and the PLL frequency synthesizer.
TRX_OFF In this mode, the SPI module and crystal oscillator are active.
PLL_ON Entering the PLL_ON mode from TRX_OFF will first enable the analog voltage regulator. The transceiver is ready to transmit a frame.
BUSY_RX_AACK The radio was in RX_AACK_ON mode and received the Start of Frame Delimiter (SFD). State transition to BUSY_RX_AACK is done if the SFD is valid.
BUSY_TX_ARET The radio transceiver is busy handling the auto retry mechanism.
RX_AACK_ON The auto acknowledge mode of the radio is enabled and it is waiting for an incomming frame.
TX_ARET_ON The auto retry mechanism is enabled and the radio transceiver is waiting for the user to send the TX_START command.
RX_ON_NOCLK The radio transceiver is listening for incomming frames, but the CLKM is disabled so that the controller could be sleeping. However, this is only true if the controller is run from the clock output of the radio.
RX_AACK_ON_NOCLK Same as the RX_ON_NOCLK state, but with the auto acknowledge module turned on.
BUSY_RX_AACK_NOCLK Same as BUSY_RX_AACK, but the controller could be sleeping since the CLKM pin is disabled.
STATE_TRANSITION The radio transceiver's state machine is in transition between two states.
uint8_t radio_get_tx_power_level ( void   ) 

This function will read and return the output power level.

Returns:
0 to 15 Current output power in "TX power settings" as defined in the radio transceiver's datasheet

Referenced by menu_process().

radio_status_t radio_init ( bool  cal_rc_osc,
hal_rx_start_isr_event_handler_t  rx_event,
hal_trx_end_isr_event_handler_t  trx_end_event,
radio_rx_callback  rx_callback 
)

Initialize the Transceiver Access Toolbox and lower layers.

If the initialization is successful the radio transceiver will be in TRX_OFF state.

Note:
This function must be called prior to any of the other functions in this file! Can be called from any transceiver state.
Parameters:
cal_rc_osc If true, the radio's accurate clock is used to calibrate the CPU's internal RC oscillator.
rx_event Optional pointer to a user-defined function to be called on an RX_START interrupt. Use NULL for no handler.
trx_end_event Optional pointer to a user-defined function to be called on an TRX_END interrupt. Use NULL for no handler.
rx_callback Optional pointer to a user-defined function that receives a frame from the radio one byte at a time. If the index parameter to this callback is 0xff, then the function should reset its state and prepare for a frame from the radio, with one call per byte.
Return values:
RADIO_SUCCESS The radio transceiver was successfully initialized and put into the TRX_OFF state.
RADIO_UNSUPPORTED_DEVICE The connected device is not an Atmel AT86RF230 radio transceiver.
RADIO_TIMED_OUT The radio transceiver was not able to initialize and enter TRX_OFF state within the specified time.

Referenced by PROCESS_THREAD().

bool radio_is_sleeping ( void   ) 

This function checks if the radio transceiver is sleeping.

Return values:
true The radio transceiver is in SLEEP or one of the *_NOCLK states.
false The radio transceiver is not sleeping.

Definition at line 777 of file radio.c.

References hal_get_slptr.

radio_status_t radio_leave_sleep_mode ( void   ) 

This function will take the radio transceiver from sleep mode and put it into the TRX_OFF state.

Return values:
RADIO_SUCCESS Left sleep mode and entered TRX_OFF state.
RADIO_TIMED_OUT Transition to TRX_OFF state timed out.
radio_status_t radio_send_data ( uint8_t  data_length,
uint8_t *  data 
)

This function will download a frame to the radio transceiver's transmit buffer and send it.

Parameters:
data_length Length of the frame to be transmitted. 1 to 128 bytes are the valid lengths.
*data Pointer to the data to transmit
Return values:
RADIO_SUCCESS Frame downloaded and sent successfully.
RADIO_INVALID_ARGUMENT If the dataLength is 0 byte or more than 127 bytes the frame will not be sent.
RADIO_WRONG_STATE It is only possible to use this function in the PLL_ON and TX_ARET_ON state. If any other state is detected this error message will be returned.

Referenced by sicslowmac_dataRequest().

radio_status_t radio_set_cca_mode ( uint8_t  mode,
uint8_t  ed_threshold 
)

This function will configure the Clear Channel Assessment algorithm.

Parameters:
mode Three modes are available: Energy above threshold, carrier sense only and carrier sense with energy above threshold.
ed_threshold Above this energy threshold the channel is assumed to be busy. The threshold is given in positive dBm values. Ex. -91 dBm gives a csThreshold of 91. Value range for the variable is [61 to 91]. Only valid for the CCA_ED and CCA_CARRIER_SENSE_ED modes.
Return values:
RADIO_SUCCESS Mode and its parameters successfully changed.
RADIO_WRONG_STATE This function cannot be called in the SLEEP state.
RADIO_INVALID_ARGUMENT If one of the three function arguments are out of bounds.
radio_status_t radio_set_clock_speed ( bool  direct,
uint8_t  clock_speed 
)

This function changes the prescaler on the CLKM pin.

Parameters:
direct This boolean variable is used to determine if the frequency of the CLKM pin shall be changed directly or not. If direct equals true, the frequency will be changed directly. This is fine if the CLKM signal is used to drive a timer etc. on the connected microcontroller. However, the CLKM signal can also be used to clock the microcontroller itself. In this situation it is possible to change the CLKM frequency indirectly (direct == false). When the direct argument equlas false, the CLKM frequency will be changed first after the radio transceiver has been taken to SLEEP and awaken again.
clock_speed This parameter can be one of the following constants: CLKM_DISABLED, CLKM_1MHZ, CLKM_2MHZ, CLKM_4MHZ, CLKM_8MHZ or CLKM_16MHZ.
Return values:
RADIO_SUCCESS Clock speed updated. New state is TRX_OFF.
RADIO_INVALID_ARGUMENT Requested clock speed is out of bounds.
void radio_set_device_role ( bool  i_am_coordinator  ) 

This function will set the I_AM_COORD sub register.

Parameters:
[in] i_am_coordinator If this parameter is true, the associated coordinator role will be enabled in the radio transceiver's address filter. False disables the same feature.
void radio_set_extended_address ( uint8_t *  extended_address  ) 

This function will set a new extended address to be used by the address filter.

Parameters:
extended_address Extended address to be used by the address filter.
radio_status_t radio_set_operating_channel ( uint8_t  channel  ) 

This function will change the operating channel.

Parameters:
channel New channel to operate on. Must be between 11 and 26.
Return values:
RADIO_SUCCESS New channel set.
RADIO_WRONG_STATE Transceiver is in a state where the channel cannot be changed (SLEEP).
RADIO_INVALID_ARGUMENT Channel argument is out of bounds.
RADIO_TIMED_OUT The PLL did not lock within the specified time.

Referenced by menu_process(), and PROCESS_THREAD().

void radio_set_pan_id ( uint16_t  new_pan_id  ) 

This function will set the PANID used by the address filter.

Parameters:
new_pan_id Desired PANID. Can be any value from 0x0000 to 0xFFFF
void radio_set_short_address ( uint16_t  new_short_address  ) 

This function will set the short address used by the address filter.

Parameters:
new_short_address Short address to be used by the address filter.
radio_status_t radio_set_trx_state ( uint8_t  new_state  ) 

This function will change the current state of the radio transceiver's internal state machine.

Parameters:
new_state Here is a list of possible states:

  • RX_ON Requested transition to RX_ON state.
  • TRX_OFF Requested transition to TRX_OFF state.
  • PLL_ON Requested transition to PLL_ON state.
  • RX_AACK_ON Requested transition to RX_AACK_ON state.
  • TX_ARET_ON Requested transition to TX_ARET_ON state.
Return values:
RADIO_SUCCESS Requested state transition completed successfully.
RADIO_INVALID_ARGUMENT Supplied function parameter out of bounds.
RADIO_WRONG_STATE Illegal state to do transition from.
RADIO_BUSY_STATE The radio transceiver is busy.
RADIO_TIMED_OUT The state transition could not be completed within resonable time.

Referenced by menu_process(), and PROCESS_THREAD().

radio_status_t radio_set_tx_power_level ( uint8_t  power_level  ) 

This function will change the output power level.

Parameters:
power_level New output power level in the "TX power settings" as defined in the radio transceiver's datasheet.
Return values:
RADIO_SUCCESS New output power set successfully.
RADIO_INVALID_ARGUMENT The supplied function argument is out of bounds.
RADIO_WRONG_STATE It is not possible to change the TX power when the device is sleeping.

Referenced by menu_process().

void radio_use_auto_tx_crc ( bool  auto_crc_on  ) 

This function will enable or disable automatic CRC during frame transmission.

Parameters:
auto_crc_on If this parameter equals true auto CRC will be used for all frames to be transmitted. The framelength must be increased by two bytes (16 bit CRC). If the parameter equals false, the automatic CRC will be disabled.

Referenced by PROCESS_THREAD().


Generated on Mon Apr 11 14:23:55 2011 for Contiki 2.5 by  doxygen 1.6.1