Contiki 2.6
|
Files | |
file | rf230bb.h |
This file contains radio driver code. | |
file | radio.c |
This file contains radio driver code. | |
file | radio.h |
This file contains radio driver code. | |
Defines | |
#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 | 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. | |
Enumerations | |
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_ENERGY_DETECT = 0, CCA_CARRIER_SENSE = 1, CCA_CARRIER_SENSE_WITH_ED = 2, CCA_ED = 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_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 } |
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_ENERGY_DETECT = 0, CCA_CARRIER_SENSE = 1, CCA_CARRIER_SENSE_WITH_ED = 2, CCA_ED = 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 RADIO_CCA_DONE_MASK (1 << 7) |
#define RADIO_CCA_IDLE_MASK (1 << 6) |
#define RADIO_START_CCA (1) |
#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.
#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.
#define RF230_MAX_TX_FRAME_LENGTH ( 127 ) |
enum radio_cca_mode_t |
This enumeration defines the possible modes available for the Clear Channel Assessment algorithm.
These constants are extracted from the datasheet.
enum radio_cca_mode_t |
This enumeration defines the possible modes available for the Clear Channel Assessment algorithm.
These constants are extracted from the datasheet.
enum radio_clkm_speed_t |
enum radio_clkm_speed_t |
enum radio_status_t |
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.
enum radio_status_t |
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.
enum radio_trx_timing_t |
This enumeration defines the necessary timing information for the AT86RF230 radio transceiver.
All times are in microseconds.
These constants are extracted from the datasheet.
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.
Definition at line 1333 of file radio.c.
References AVR_ENTER_CRITICAL_REGION, and AVR_LEAVE_CRITICAL_REGION.
Referenced by radio_init().
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.
Definition at line 1239 of file radio.c.
References CLKM_1MHz, and radio_set_clock_speed().
radio_status_t radio_batmon_configure | ( | bool | range, |
uint8_t | voltage_threshold | ||
) |
This function is used to configure the battery monitor module.
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. |
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]). |
Definition at line 544 of file radio.c.
References hal_subregister_write(), RADIO_INVALID_ARGUMENT, radio_is_sleeping(), RADIO_SUCCESS, RADIO_WRONG_STATE, SR_BATMON_HR, and SR_BATMON_VTH.
radio_status_t radio_batmon_get_status | ( | void | ) |
This function returns the status of the Battery Monitor module.
RADIO_BAT_LOW | Battery voltage is below the programmed threshold. |
RADIO_BAT_OK | Battery voltage is above the programmed threshold. |
Definition at line 578 of file radio.c.
References hal_subregister_read(), RADIO_BAT_LOW, RADIO_BAT_OK, and SR_BATMON_OK.
uint8_t radio_batmon_get_voltage_range | ( | void | ) |
This function returns if high or low voltage range is used.
0 | Low voltage range selected. |
1 | High voltage range selected. |
Definition at line 527 of file radio.c.
References hal_subregister_read(), and SR_BATMON_HR.
uint8_t radio_batmon_get_voltage_threshold | ( | void | ) |
This function returns the current threshold volatge used by the battery monitor (BATMON_VTH).
Definition at line 512 of file radio.c.
References hal_subregister_read(), and SR_BATMON_VTH.
radio_status_t radio_calibrate_filter | ( | void | ) |
This function calibrates the Single Side Band Filter.
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. |
Definition at line 660 of file radio.c.
References hal_subregister_read(), hal_subregister_write(), PLL_ON, radio_get_trx_state(), RADIO_SUCCESS, RADIO_TIMED_OUT, RADIO_WRONG_STATE, SR_FTN_START, TIME_FTN_TUNING, and TRX_OFF.
radio_status_t radio_calibrate_pll | ( | void | ) |
This function calibrates the PLL.
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. |
Definition at line 692 of file radio.c.
References hal_clear_pll_lock_flag(), hal_get_pll_lock_flag(), hal_subregister_read(), hal_subregister_write(), PLL_ON, radio_get_trx_state(), RADIO_SUCCESS, RADIO_TIMED_OUT, RADIO_WRONG_STATE, SR_PLL_CF_START, SR_PLL_DCU_START, and TIME_PLL_LOCK.
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.
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:
|
RADIO_SUCCESS | The CSMA algorithm was configured successfully. |
RADIO_WRONG_STATE | This function should not be called in the SLEEP state. |
Definition at line 1205 of file radio.c.
References hal_register_write(), hal_subregister_write(), radio_is_sleeping(), RADIO_SUCCESS, RADIO_WRONG_STATE, RG_CSMA_SEED_0, SR_CSMA_SEED_1, SR_MAX_CSMA_RETRIES, SR_MAX_FRAME_RETRIES, and SR_MIN_BE.
radio_status_t radio_enter_sleep_mode | ( | void | ) |
This function will put the radio transceiver to sleep.
RADIO_SUCCESS | Sleep mode entered successfully. |
RADIO_TIMED_OUT | The transition to TRX_OFF took too long. |
Definition at line 903 of file radio.c.
References hal_set_slptr_high, radio_get_trx_state(), radio_is_sleeping(), radio_reset_state_machine(), RADIO_SUCCESS, RADIO_TIMED_OUT, and TRX_OFF.
uint8_t radio_get_cca_mode | ( | void | ) |
This function returns the current CCA mode used.
Definition at line 416 of file radio.c.
References hal_subregister_read(), and SR_CCA_MODE.
uint8_t radio_get_clock_speed | ( | void | ) |
This function returns the current clock setting for the CLKM pin.
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. |
Definition at line 602 of file radio.c.
References hal_subregister_read(), and SR_CLKM_CTRL.
Referenced by radio_set_clock_speed().
uint8_t radio_get_device_role | ( | void | ) |
This function will read the I_AM_COORD sub register.
0 | Not coordinator. |
1 | Coordinator role enabled. |
Definition at line 1057 of file radio.c.
References hal_subregister_read(), and SR_I_AM_COORD.
uint8_t radio_get_ed_threshold | ( | void | ) |
This function returns the current ED threshold used by the CCA algorithm.
Definition at line 427 of file radio.c.
References hal_subregister_read(), and SR_CCA_ED_THRES.
void radio_get_extended_address | ( | uint8_t * | extended_address | ) |
This function will read the extended address used by the address filter.
Definition at line 1153 of file radio.c.
References hal_register_read(), RG_IEEE_ADDR_0, RG_IEEE_ADDR_1, RG_IEEE_ADDR_2, RG_IEEE_ADDR_3, RG_IEEE_ADDR_4, RG_IEEE_ADDR_5, RG_IEEE_ADDR_6, and RG_IEEE_ADDR_7.
uint8_t radio_get_operating_channel | ( | void | ) |
This function will return the channel used by the radio transceiver.
Definition at line 314 of file radio.c.
References hal_subregister_read(), and SR_CHANNEL.
Referenced by menu_process(), and radio_set_operating_channel().
uint16_t radio_get_pan_id | ( | void | ) |
This function will return the PANID used by the address filter.
Any | value from 0 to 0xFFFF. |
Definition at line 1082 of file radio.c.
References hal_register_read(), RG_PAN_ID_0, and RG_PAN_ID_1.
radio_status_t radio_get_rssi_value | ( | uint8_t * | rssi | ) |
This function returns the Received Signal Strength Indication.
rssi | Pointer to memory location where RSSI value should be written. |
RADIO_SUCCESS | The RSSI measurement was successful. |
RADIO_WRONG_STATE | The radio transceiver is not in RX_ON or BUSY_RX. |
Definition at line 486 of file radio.c.
References BUSY_RX, hal_subregister_read(), radio_get_trx_state(), RADIO_SUCCESS, RADIO_WRONG_STATE, RX_ON, and SR_RSSI.
Referenced by menu_process().
uint16_t radio_get_short_address | ( | void | ) |
This function will return the current short address used by the address filter.
Any | value from 0x0000 to 0xFFFF |
Definition at line 1116 of file radio.c.
References hal_register_read(), and RG_SHORT_ADDR_1.
uint8_t radio_get_trx_state | ( | void | ) |
This function return the Radio Transceivers current state.
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. |
Definition at line 765 of file radio.c.
References hal_subregister_read(), and SR_TRX_STATUS.
Referenced by radio_calibrate_filter(), radio_calibrate_pll(), radio_enter_sleep_mode(), radio_get_rssi_value(), radio_init(), radio_leave_sleep_mode(), radio_send_data(), radio_set_operating_channel(), and radio_set_trx_state().
uint8_t radio_get_tx_power_level | ( | void | ) |
This function will read and return the output power level.
Definition at line 375 of file radio.c.
References hal_subregister_read(), and SR_TX_PWR.
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.
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. |
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. |
Definition at line 161 of file radio.c.
References calibrate_rc_osc_32k(), CMD_FORCE_TRX_OFF, hal_init(), hal_register_read(), hal_register_write(), hal_set_rx_start_event_handler(), hal_set_trx_end_event_handler(), hal_subregister_write(), radio_get_trx_state(), radio_reset_trx(), RADIO_SUCCESS, RADIO_TIMED_OUT, RADIO_UNSUPPORTED_DEVICE, RG_IRQ_MASK, RG_MAN_ID_0, RG_VERSION_NUM, SR_TRX_CMD, TIME_P_ON_TO_TRX_OFF, TIME_TO_ENTER_P_ON, and TRX_OFF.
Referenced by PROCESS_THREAD().
bool radio_is_sleeping | ( | void | ) |
This function checks if the radio transceiver is sleeping.
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.
Referenced by radio_batmon_configure(), radio_configure_csma(), radio_enter_sleep_mode(), radio_leave_sleep_mode(), radio_set_cca_mode(), radio_set_operating_channel(), radio_set_trx_state(), and radio_set_tx_power_level().
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.
RADIO_SUCCESS | Left sleep mode and entered TRX_OFF state. |
RADIO_TIMED_OUT | Transition to TRX_OFF state timed out. |
Definition at line 933 of file radio.c.
References hal_set_slptr_low, radio_get_trx_state(), radio_is_sleeping(), RADIO_SUCCESS, RADIO_TIMED_OUT, TIME_SLEEP_TO_TRX_OFF, and TRX_OFF.
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.
data_length | Length of the frame to be transmitted. 1 to 128 bytes are the valid lengths. |
*data | Pointer to the data to transmit |
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. |
Definition at line 1016 of file radio.c.
References BUSY_TX, BUSY_TX_ARET, hal_frame_write(), hal_set_slptr_high, hal_set_slptr_low, radio_get_trx_state(), RADIO_INVALID_ARGUMENT, radio_set_trx_state(), RADIO_SUCCESS, RADIO_WRONG_STATE, RF230_MAX_TX_FRAME_LENGTH, TRX_OFF, and TX_ARET_ON.
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.
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. |
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. |
Definition at line 449 of file radio.c.
References CCA_CARRIER_SENSE, CCA_CARRIER_SENSE_WITH_ED, CCA_ED, hal_subregister_write(), RADIO_INVALID_ARGUMENT, radio_is_sleeping(), RADIO_SUCCESS, RADIO_WRONG_STATE, SR_CCA_ED_THRES, and SR_CCA_MODE.
radio_status_t radio_set_clock_speed | ( | bool | direct, |
uint8_t | clock_speed | ||
) |
This function changes the prescaler on the CLKM pin.
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. |
RADIO_SUCCESS | Clock speed updated. New state is TRX_OFF. |
RADIO_INVALID_ARGUMENT | Requested clock speed is out of bounds. |
Definition at line 628 of file radio.c.
References hal_subregister_write(), radio_get_clock_speed(), RADIO_INVALID_ARGUMENT, RADIO_SUCCESS, SR_CLKM_CTRL, and SR_CLKM_SHA_SEL.
Referenced by calibrate_rc_osc_clkm().
void radio_set_device_role | ( | bool | i_am_coordinator | ) |
This function will set the I_AM_COORD sub register.
[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. |
Definition at line 1071 of file radio.c.
References hal_subregister_write(), and SR_I_AM_COORD.
void radio_set_extended_address | ( | uint8_t * | extended_address | ) |
This function will set a new extended address to be used by the address filter.
extended_address | Extended address to be used by the address filter. |
Definition at line 1172 of file radio.c.
References hal_register_write(), RG_IEEE_ADDR_0, RG_IEEE_ADDR_1, RG_IEEE_ADDR_2, RG_IEEE_ADDR_3, RG_IEEE_ADDR_4, RG_IEEE_ADDR_5, RG_IEEE_ADDR_6, and RG_IEEE_ADDR_7.
Referenced by mac_init().
radio_status_t radio_set_operating_channel | ( | uint8_t | channel | ) |
This function will change the operating channel.
channel | New channel to operate on. Must be between 11 and 26. |
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. |
Definition at line 330 of file radio.c.
References hal_subregister_write(), PLL_ON, radio_get_operating_channel(), radio_get_trx_state(), RADIO_INVALID_ARGUMENT, radio_is_sleeping(), RADIO_SUCCESS, RADIO_TIMED_OUT, RADIO_WRONG_STATE, RX_ON, SR_CHANNEL, and TIME_PLL_LOCK.
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.
new_pan_id | Desired PANID. Can be any value from 0x0000 to 0xFFFF |
Definition at line 1099 of file radio.c.
References hal_register_write(), RG_PAN_ID_0, and RG_PAN_ID_1.
Referenced by mac_init().
void radio_set_short_address | ( | uint16_t | new_short_address | ) |
This function will set the short address used by the address filter.
new_short_address | Short address to be used by the address filter. |
Definition at line 1133 of file radio.c.
References hal_register_write(), RG_SHORT_ADDR_0, and RG_SHORT_ADDR_1.
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.
new_state | Here is a list of possible states:
|
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. |
Definition at line 810 of file radio.c.
References BUSY_RX, BUSY_RX_AACK, BUSY_TX, BUSY_TX_ARET, hal_subregister_write(), PLL_ON, radio_get_trx_state(), RADIO_INVALID_ARGUMENT, radio_is_sleeping(), radio_reset_state_machine(), RADIO_SUCCESS, RADIO_TIMED_OUT, RADIO_WRONG_STATE, RX_AACK_ON, RX_ON, SR_TRX_CMD, TIME_STATE_TRANSITION_PLL_ACTIVE, TIME_TRX_OFF_TO_PLL_ACTIVE, TRX_OFF, and TX_ARET_ON.
Referenced by menu_process(), PROCESS_THREAD(), and radio_send_data().
radio_status_t radio_set_tx_power_level | ( | uint8_t | power_level | ) |
This function will change the output power level.
power_level | New output power level in the "TX power settings" as defined in the radio transceiver's datasheet. |
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. |
Definition at line 392 of file radio.c.
References hal_subregister_write(), RADIO_INVALID_ARGUMENT, radio_is_sleeping(), RADIO_SUCCESS, RADIO_WRONG_STATE, and SR_TX_PWR.
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.
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. |
Definition at line 992 of file radio.c.
References hal_subregister_write(), and SR_TX_AUTO_CRC_ON.
Referenced by PROCESS_THREAD().