AVR Z-LINKŪ | |||||
Defines | |
#define | TAT_STATUS_START_VALUE ( 0x40 ) |
This macro defines the start value for the TAT_* status constants. | |
Enumerations | |
enum | tat_cca_mode_t { 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 | tat_clkm_speed_t { CLKM_DISABLED = 0, CLKM_1MHZ = 1, CLKM_2MHZ = 2, CLKM_4MHZ = 3, CLKM_8MHZ = 4, CLKM_16MHZ = 5 } |
This enumeration defines the possible CLKM speeds. More... | |
enum | tat_status_t { TAT_SUCCESS = TAT_STATUS_START_VALUE, TAT_UNSUPPORTED_DEVICE, TAT_INVALID_ARGUMENT, TAT_TIMED_OUT, TAT_WRONG_STATE, TAT_BUSY_STATE, TAT_STATE_TRANSITION_FAILED, TAT_CCA_IDLE, TAT_CCA_BUSY, TAT_TRX_BUSY, TAT_BAT_LOW, TAT_BAT_OK, TAT_CRC_FAILED, TAT_CHANNEL_ACCESS_FAILURE, TAT_NO_ACK } |
This enumeration defines the possible return values for the TAT API functions. More... | |
enum | tat_trx_timing_t { 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. All times are in microseconds. More... | |
Functions | |
static bool | is_sleeping (void) |
This function checks if the radio transceiver is sleeping. | |
tat_status_t | tat_batmon_configure (bool range, uint8_t voltage_threshold) |
This function is used to configure the battery monitor module. | |
tat_status_t | tat_batmon_get_status (void) |
This function returns the status of the Battery Monitor module. | |
uint8_t | tat_batmon_get_voltage_range (void) |
This function returns if high or low voltage range is used. | |
uint8_t | tat_batmon_get_voltage_threshold (void) |
This function returns the current threshold volatge used by the battery monitor (BATMON_VTH). | |
tat_status_t | tat_calibrate_filter (void) |
This function calibrates the Single Side Band Filter. | |
tat_status_t | tat_calibrate_pll (void) |
This function calibrates the PLL. | |
tat_status_t | tat_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. | |
tat_status_t | tat_do_cca (void) |
This function will perform a Clear Channel Assessment. | |
tat_status_t | tat_do_ed_scan (uint8_t *ed_level) |
This function will measure the amount of energy sensed on the antenna pins. | |
tat_status_t | tat_enter_sleep_mode (void) |
This function will put the radio transceiver to sleep. | |
uint8_t | tat_get_cca_mode (void) |
This function returns the current CCA mode used. | |
uint8_t | tat_get_clock_speed (void) |
This function returns the current clock setting for the CLKM pin. | |
uint8_t | tat_get_ed_threshold (void) |
This function returns the current ED threshold used by the CCA algorithm. | |
uint64_t | tat_get_extended_address (void) |
This function will read the extended address used by the address filter. | |
uint8_t | tat_get_operating_channel (void) |
This function will return the channel used by the radio transceiver. | |
uint16_t | tat_get_pan_id (void) |
This function will return the PANID used by the address filter. | |
tat_status_t | tat_get_rssi_value (uint8_t *rssi) |
This function returns the Received Signal Strength Indication. | |
uint16_t | tat_get_short_address (void) |
This function will return the current short address used by the address filter. | |
uint8_t | tat_get_trx_state (void) |
This function return the Radio Transceivers current state. | |
uint8_t | tat_get_tx_power_level (void) |
This function will read and return the output power level. | |
tat_status_t | tat_init (void) |
Initialize the Transceiver Access Toolbox and lower layers. | |
tat_status_t | tat_leave_sleep_mode (void) |
This function will take the radio transceiver from sleep mode and put it into the TRX_OFF state. | |
void | tat_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 | tat_reset_trx (void) |
This function will reset all the registers and the state machine of the radio transceiver. | |
tat_status_t | tat_send_data (uint8_t *data, uint8_t data_length) |
This function will download a frame to the radio transceiver's transmit buffer and send it. | |
tat_status_t | tat_send_data_with_retry (uint8_t frame_length, uint8_t *frame, uint8_t retries) |
This function uses the . | |
tat_status_t | tat_set_cca_mode (uint8_t mode, uint8_t ed_threshold) |
This function will configure the Clear Channel Assessment algorithm. | |
tat_status_t | tat_set_clock_speed (bool direct, uint8_t clock_speed) |
This function changes the prescaler on the CLKM pin. | |
void | tat_set_extended_address (uint64_t new_extended_address) |
This function will set a new extended address to be used by the address filter. | |
tat_status_t | tat_set_operating_channel (uint8_t channel) |
This function will change the operating channel. | |
void | tat_set_pan_id (uint16_t new_pan_id) |
This function will set the PANID used by the address filter. | |
void | tat_set_short_address (uint16_t new_short_address) |
This function will set the short address used by the address filter. | |
tat_status_t | tat_set_trx_state (uint8_t new_state) |
This function will change the current state of the radio transceiver's internal state machine. | |
tat_status_t | tat_set_tx_power_level (uint8_t power_level) |
This function will change the output power level. | |
void | tat_use_auto_tx_crc (bool auto_crc_on) |
This function will enable or disable automatic CRC during frame transmission. |
#define TAT_STATUS_START_VALUE ( 0x40 ) |
This macro defines the start value for the TAT_* 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.
enum tat_cca_mode_t |
This enumeration defines the possible modes available for the Clear Channel Assessment algorithm.
These constants are extracted from the datasheet.
CCA_ED | Use energy detection above threshold mode. Use carrier sense mode. |
CCA_CARRIER_SENSE | Use a combination of both energy detection and carrier sense. |
CCA_CARRIER_SENSE_WITH_ED |
Definition at line 187 of file tat.h.
00187 { 00189 CCA_ED = 0, 00191 CCA_CARRIER_SENSE = 1, 00193 CCA_CARRIER_SENSE_WITH_ED = 2 00194 }tat_cca_mode_t;
enum tat_clkm_speed_t |
This enumeration defines the possible CLKM speeds.
These constants are extracted from the datasheet.
Definition at line 202 of file tat.h.
00202 { 00203 00204 CLKM_DISABLED = 0, 00205 CLKM_1MHZ = 1, 00206 CLKM_2MHZ = 2, 00207 CLKM_4MHZ = 3, 00208 CLKM_8MHZ = 4, 00209 CLKM_16MHZ = 5 00210 }tat_clkm_speed_t;
enum tat_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.
Definition at line 147 of file tat.h.
00147 { 00149 TAT_SUCCESS = TAT_STATUS_START_VALUE, 00151 TAT_UNSUPPORTED_DEVICE, 00153 TAT_INVALID_ARGUMENT, 00155 TAT_TIMED_OUT, 00157 TAT_WRONG_STATE, 00159 TAT_BUSY_STATE, 00161 TAT_STATE_TRANSITION_FAILED, 00163 TAT_CCA_IDLE, 00165 TAT_CCA_BUSY, 00167 TAT_TRX_BUSY, 00169 TAT_BAT_LOW, 00171 TAT_BAT_OK, 00173 TAT_CRC_FAILED, 00175 TAT_CHANNEL_ACCESS_FAILURE, 00177 TAT_NO_ACK, 00178 }tat_status_t;
enum tat_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.
Definition at line 75 of file tat.c.
00075 { 00076 00077 TIME_P_ON_TO_TRX_OFF = 510, 00078 TIME_SLEEP_TO_TRX_OFF = 880, 00079 TIME_RESET = 6, 00080 TIME_ED_MEASUREMENT = 140, 00081 TIME_CCA = 140, 00082 TIME_PLL_LOCK = 150, 00083 TIME_FTN_TUNING = 25, 00084 TIME_NOCLK_TO_WAKE = 6, 00085 TIME_CMD_FORCE_TRX_OFF = 1, 00086 TIME_TRX_OFF_TO_PLL_ACTIVE = 180, 00087 TIME_STATE_TRANSITION_PLL_ACTIVE = 1, 00088 }tat_trx_timing_t;
static bool is_sleeping | ( | void | ) | [static] |
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 654 of file tat.c.
References hal_get_slptr.
Referenced by tat_batmon_configure(), tat_configure_csma(), tat_enter_sleep_mode(), tat_leave_sleep_mode(), tat_set_cca_mode(), tat_set_operating_channel(), tat_set_trx_state(), and tat_set_tx_power_level().
00654 { 00655 00656 bool sleeping = false; 00657 00658 //The radio transceiver will be at SLEEP or one of the *_NOCLK states only if 00659 //the SLP_TR pin is high. 00660 if (hal_get_slptr( ) != 0) { 00661 sleeping = true; 00662 } 00663 00664 return sleeping; 00665 }
tat_status_t tat_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. |
TAT_SUCCESS | Battery monitor configured | |
TAT_WRONG_STATE | The device is sleeping. | |
TAT_INVALID_ARGUMENT | The voltage_threshold parameter is out of bounds (Not within [0 - 15]). |
Definition at line 434 of file tat.c.
References BATTERY_MONITOR_HIGH_VOLTAGE, BATTERY_MONITOR_HIGHEST_VOLTAGE, BATTERY_MONITOR_LOW_VOLTAGE, hal_subregister_write(), is_sleeping(), SR_BATMON_HR, SR_BATMON_VTH, TAT_INVALID_ARGUMENT, TAT_SUCCESS, and TAT_WRONG_STATE.
00434 { 00435 00436 /*Check function parameters and state.*/ 00437 if (voltage_threshold > BATTERY_MONITOR_HIGHEST_VOLTAGE) { 00438 return TAT_INVALID_ARGUMENT; 00439 } 00440 00441 if (is_sleeping( ) == true) { return TAT_WRONG_STATE; } 00442 00443 /*Write new voltage range and voltage level.*/ 00444 if (range == true) { 00445 hal_subregister_write( SR_BATMON_HR, BATTERY_MONITOR_HIGH_VOLTAGE ); 00446 } else { 00447 hal_subregister_write( SR_BATMON_HR, BATTERY_MONITOR_LOW_VOLTAGE ); 00448 } // end: if (range == true) ... 00449 00450 hal_subregister_write( SR_BATMON_VTH, voltage_threshold ); 00451 00452 return TAT_SUCCESS; 00453 }
Here is the call graph for this function:
tat_status_t tat_batmon_get_status | ( | void | ) |
This function returns the status of the Battery Monitor module.
TAT_BAT_LOW | Battery voltage is below the programmed threshold. | |
TAT_BAT_OK | Battery voltage is above the programmed threshold. |
Definition at line 465 of file tat.c.
References BATTERY_MONITOR_VOLTAGE_UNDER_THRESHOLD, hal_subregister_read(), SR_BATMON_OK, TAT_BAT_LOW, and TAT_BAT_OK.
00465 { 00466 00467 tat_status_t batmon_status = TAT_BAT_LOW; 00468 00469 if (hal_subregister_read( SR_BATMON_OK ) != 00470 BATTERY_MONITOR_VOLTAGE_UNDER_THRESHOLD) { 00471 batmon_status = TAT_BAT_OK; 00472 } 00473 00474 return batmon_status; 00475 }
Here is the call graph for this function:
uint8_t tat_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 419 of file tat.c.
References hal_subregister_read(), and SR_BATMON_HR.
00419 { 00420 return hal_subregister_read( SR_BATMON_HR ); 00421 }
Here is the call graph for this function:
uint8_t tat_batmon_get_voltage_threshold | ( | void | ) |
This function returns the current threshold volatge used by the battery monitor (BATMON_VTH).
Definition at line 405 of file tat.c.
References hal_subregister_read(), and SR_BATMON_VTH.
00405 { 00406 return hal_subregister_read( SR_BATMON_VTH ); 00407 }
Here is the call graph for this function:
tat_status_t tat_calibrate_filter | ( | void | ) |
This function calibrates the Single Side Band Filter.
TAT_SUCCESS | Filter is calibrated. | |
TAT_TIMED_OUT | The calibration could not be completed within time. | |
TAT_WRONG_STATE | This function can only be called from TRX_OFF or PLL_ON. |
Definition at line 541 of file tat.c.
References FTN_CALIBRATION_DONE, hal_subregister_read(), hal_subregister_write(), PLL_ON, SR_FTN_START, tat_get_trx_state(), TAT_SUCCESS, TAT_TIMED_OUT, TAT_WRONG_STATE, TIME_FTN_TUNING, and TRX_OFF.
00541 { 00542 00543 /*Check current state. Only possible to do filter calibration from TRX_OFF or PLL_ON.*/ 00544 uint8_t trx_state = tat_get_trx_state( ); 00545 00546 if ((trx_state != TRX_OFF ) && (trx_state != PLL_ON)) { return TAT_WRONG_STATE; } 00547 00548 //Start the tuning algorithm by writing one to the FTN_START subregister. 00549 hal_subregister_write( SR_FTN_START, 1 ); 00550 delay_us( TIME_FTN_TUNING ); //Wait for the calibration to finish. 00551 00552 tat_status_t filter_calibration_status = TAT_TIMED_OUT; 00553 00554 //Verify the calibration result. 00555 if (hal_subregister_read( SR_FTN_START ) == FTN_CALIBRATION_DONE) { 00556 filter_calibration_status = TAT_SUCCESS; 00557 } 00558 00559 return filter_calibration_status; 00560 }
Here is the call graph for this function:
tat_status_t tat_calibrate_pll | ( | void | ) |
This function calibrates the PLL.
TAT_SUCCESS | PLL Center Frequency and Delay Cell is calibrated. | |
TAT_TIMED_OUT | The calibration could not be completed within time. | |
TAT_WRONG_STATE | This function can only be called from PLL_ON. |
Definition at line 570 of file tat.c.
References hal_clear_pll_lock_flag(), hal_get_pll_lock_flag(), hal_subregister_read(), hal_subregister_write(), PLL_CF_CALIBRATION_DONE, PLL_DCU_CALIBRATION_DONE, PLL_ON, SR_PLL_CF_START, SR_PLL_DCU_START, tat_get_trx_state(), TAT_SUCCESS, TAT_TIMED_OUT, TAT_WRONG_STATE, and TIME_PLL_LOCK.
00570 { 00571 00572 /*Check current state. Only possible to calibrate PLL from PLL_ON state*/ 00573 if (tat_get_trx_state( ) != PLL_ON) { return TAT_WRONG_STATE; } 00574 00575 //Initiate the DCU and CF calibration loops. 00576 hal_subregister_write( SR_PLL_DCU_START, 1 ); 00577 hal_subregister_write( SR_PLL_CF_START, 1 ); 00578 00579 //Wait maximum 150 us for the PLL to lock. 00580 hal_clear_pll_lock_flag( ); 00581 delay_us( TIME_PLL_LOCK ); 00582 00583 tat_status_t pll_calibration_status = TAT_TIMED_OUT; 00584 00585 if (hal_get_pll_lock_flag( ) > 0) { 00586 00587 if (hal_subregister_read( SR_PLL_DCU_START ) == PLL_DCU_CALIBRATION_DONE) { 00588 00589 if (hal_subregister_read( SR_PLL_CF_START ) == PLL_CF_CALIBRATION_DONE) { 00590 pll_calibration_status = TAT_SUCCESS; 00591 } // end: if (hal_subregister_read( SR_PLL_CF_START ) ... 00592 } // end: if (hal_subregister_read( SR_PLL_DCU_START ) ... 00593 } // end: if ((hal_get_pll_lock_flag( ) ... 00594 00595 return pll_calibration_status; 00596 }
Here is the call graph for this function:
tat_status_t tat_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:
|
TAT_SUCCESS | The CSMA algorithm was configured successfully. | |
TAT_WRONG_STATE | This function should not be called in the SLEEP state. |
Definition at line 1042 of file tat.c.
References hal_subregister_write(), is_sleeping(), SR_CSMA_SEED_0, SR_CSMA_SEED_1, SR_MAX_CSMA_RETRIES, SR_MAX_FRAME_RETRIES, SR_MIN_BE, TAT_SUCCESS, and TAT_WRONG_STATE.
01042 { 01043 01044 /*Check state.*/ 01045 if (is_sleeping( ) == true) { return TAT_WRONG_STATE; } 01046 01047 /*Extract parameters, and configure the CSMA-CA algorithm.*/ 01048 uint8_t back_off_exponent = ( be_csma_seed1 & 0xC0 ) >> 6; 01049 uint8_t csma_retries = ( be_csma_seed1 & 0x38 ) >> 3; 01050 uint8_t seed1 = ( be_csma_seed1 & 0x07 ); 01051 01052 hal_subregister_write( SR_MAX_FRAME_RETRIES, 0 ); //AT86RF230 rev A errata. 01053 hal_subregister_write( SR_MAX_CSMA_RETRIES, csma_retries ); 01054 hal_subregister_write( SR_MIN_BE, back_off_exponent ); 01055 hal_subregister_write( SR_CSMA_SEED_0, seed0 ); 01056 hal_subregister_write( SR_CSMA_SEED_1, seed1 ); 01057 01058 return TAT_SUCCESS; 01059 }
Here is the call graph for this function:
tat_status_t tat_do_cca | ( | void | ) |
This function will perform a Clear Channel Assessment.
TAT_CCA_IDLE | Channel is ready for transmission. | |
TAT_CCA_BUSY | Channel is not ready for transmission. | |
TAT_WRONG_STATE | CCA can only be done in PLL_ON. | |
TAT_TIMED_OUT | CCA algorithm timed out. |
Definition at line 336 of file tat.c.
References hal_register_read(), hal_subregister_write(), PLL_ON, RG_TRX_STATUS, RX_ON, SR_CCA_REQUEST, TAT_CCA_BUSY, TAT_CCA_DONE_MASK, TAT_CCA_IDLE, TAT_CCA_IDLE_MASK, tat_get_trx_state(), tat_set_trx_state(), TAT_START_CCA, TAT_SUCCESS, TAT_TIMED_OUT, TAT_WRONG_STATE, and TIME_CCA.
00336 { 00337 00338 /*Check state. CCA measurement only possible form PLL_ON state.*/ 00339 if (tat_get_trx_state( ) != PLL_ON) { return TAT_WRONG_STATE; } 00340 00341 /*Ensure that it is possible to enter RX_ON*/ 00342 if (tat_set_trx_state( RX_ON ) != TAT_SUCCESS) { return TAT_TIMED_OUT; } 00343 00344 //The CCA is initiated by writing 1 to the CCA_REQUEST subregister. 00345 hal_subregister_write( SR_CCA_REQUEST, TAT_START_CCA ); 00346 00347 //The CCA is measured over 128 us + 12 us computation time. 00348 delay_us( TIME_CCA ); 00349 00350 uint8_t status = hal_register_read( RG_TRX_STATUS ); //Read cca status. 00351 tat_status_t cca_status = TAT_CCA_BUSY; //Return variable. 00352 00353 //Check if the algorithm finished -> CCA_DONE == 1. 00354 if ((status & TAT_CCA_DONE_MASK) != TAT_CCA_DONE_MASK) { 00355 cca_status = TAT_TIMED_OUT; 00356 } else { 00357 00358 //CCA done, but check if the channel is busy or not. 00359 if ((status & TAT_CCA_IDLE_MASK) != TAT_CCA_IDLE_MASK) { 00360 cca_status = TAT_CCA_BUSY; 00361 } else { 00362 cca_status = TAT_CCA_IDLE; 00363 } // end: if ((status & TAT_CCA_IDLE_MASK) ... 00364 } // end: if ((status & TAT_CCA_DONE_MASK) ... 00365 00366 return cca_status; 00367 }
Here is the call graph for this function:
tat_status_t tat_do_ed_scan | ( | uint8_t * | ed_level | ) |
This function will measure the amount of energy sensed on the antenna pins.
ed_level | This is a pointer used to return the measured energy. The value is only written if the function returns with TAT_SUCCESS. The written value is 0 to 84. |
TAT_SUCCESS | The detection was successful. | |
TAT_WRONG_STATE | The energy detection can only be done if the radio transceiver's state is RX_ON or BUSY_RX. |
Definition at line 249 of file tat.c.
References BUSY_RX, hal_register_read(), hal_register_write(), RG_PHY_ED_LEVEL, RX_ON, tat_get_trx_state(), TAT_SUCCESS, TAT_WRONG_STATE, and TIME_ED_MEASUREMENT.
00249 { 00250 00251 uint8_t current_state = tat_get_trx_state( ); 00252 00253 /*Check state. Only possible to do ed measurement from RX_ON or BUSY_RX.*/ 00254 if ((current_state != RX_ON ) && (current_state != BUSY_RX)) { 00255 return TAT_WRONG_STATE; 00256 } 00257 00258 /*Do ED measurement.*/ 00259 //Initiate the measurement by writing to the PHY_ED_LEVEL register. 00260 hal_register_write( RG_PHY_ED_LEVEL, 0 ); 00261 delay_us( TIME_ED_MEASUREMENT ); //Wait 128 us + 12 us computation time. 00262 *ed_level = hal_register_read( RG_PHY_ED_LEVEL ); //Write ED level to pointer. 00263 00264 return TAT_SUCCESS; 00265 }
Here is the call graph for this function:
tat_status_t tat_enter_sleep_mode | ( | void | ) |
This function will put the radio transceiver to sleep.
TAT_SUCCESS | Sleep mode entered successfully. | |
TAT_TIMED_OUT | The transition to TRX_OFF took too long. |
Definition at line 759 of file tat.c.
References hal_set_slptr_high, is_sleeping(), tat_get_trx_state(), tat_reset_state_machine(), TAT_SUCCESS, TAT_TIMED_OUT, and TRX_OFF.
00759 { 00760 00761 if (is_sleeping( ) == true) { return TAT_SUCCESS; } 00762 00763 tat_reset_state_machine( ); //Force the device into TRX_OFF. 00764 00765 tat_status_t enter_sleep_status = TAT_TIMED_OUT; 00766 00767 if (tat_get_trx_state( ) == TRX_OFF) { 00768 00769 //Enter Sleep. 00770 hal_set_slptr_high( ); 00771 enter_sleep_status = TAT_SUCCESS; 00772 } 00773 00774 return enter_sleep_status; 00775 }
Here is the call graph for this function:
uint8_t tat_get_cca_mode | ( | void | ) |
This function returns the current CCA mode used.
Definition at line 273 of file tat.c.
References hal_subregister_read(), and SR_CCA_MODE.
00273 { 00274 return hal_subregister_read( SR_CCA_MODE ); 00275 }
Here is the call graph for this function:
uint8_t tat_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 488 of file tat.c.
References hal_subregister_read(), and SR_CLKM_CTRL.
Referenced by tat_set_clock_speed().
00488 { 00489 return hal_subregister_read( SR_CLKM_CTRL ); 00490 }
Here is the call graph for this function:
uint8_t tat_get_ed_threshold | ( | void | ) |
This function returns the current ED threshold used by the CCA algorithm.
Definition at line 283 of file tat.c.
References hal_subregister_read(), and SR_CCA_ED_THRES.
00283 { 00284 return hal_subregister_read( SR_CCA_ED_THRES ); 00285 }
Here is the call graph for this function:
uint64_t tat_get_extended_address | ( | void | ) |
This function will read the extended address used by the address filter.
Definition at line 972 of file tat.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.
00972 { 00973 00974 //This union is used for the data convertion purposes. 00975 union{ 00976 00977 uint64_t u64; 00978 uint8_t u8[ 8 ]; 00979 }extended_address; 00980 00981 extended_address.u8[ 0 ] = hal_register_read( RG_IEEE_ADDR_7 ); 00982 extended_address.u8[ 1 ] = hal_register_read( RG_IEEE_ADDR_6 ); 00983 extended_address.u8[ 2 ] = hal_register_read( RG_IEEE_ADDR_5 ); 00984 extended_address.u8[ 3 ] = hal_register_read( RG_IEEE_ADDR_4 ); 00985 extended_address.u8[ 4 ] = hal_register_read( RG_IEEE_ADDR_3 ); 00986 extended_address.u8[ 5 ] = hal_register_read( RG_IEEE_ADDR_2 ); 00987 extended_address.u8[ 6 ] = hal_register_read( RG_IEEE_ADDR_1 ); 00988 extended_address.u8[ 7 ] = hal_register_read( RG_IEEE_ADDR_0 ); 00989 00990 return extended_address.u64; 00991 }
Here is the call graph for this function:
uint8_t tat_get_operating_channel | ( | void | ) |
This function will return the channel used by the radio transceiver.
Definition at line 153 of file tat.c.
References hal_subregister_read(), and SR_CHANNEL.
Referenced by tat_set_operating_channel().
00153 { 00154 return hal_subregister_read( SR_CHANNEL ); 00155 }
Here is the call graph for this function:
uint16_t tat_get_pan_id | ( | void | ) |
This function will return the PANID used by the address filter.
Any | value from 0 to 0xFFFF. |
Definition at line 886 of file tat.c.
References hal_register_read(), RG_PAN_ID_0, and RG_PAN_ID_1.
00886 { 00887 00888 //This union is used for the data convertion purposes. 00889 union{ 00890 00891 uint16_t u16; 00892 uint8_t u8[ 2 ]; 00893 }pan_id; 00894 00895 pan_id.u8[ 0 ] = hal_register_read( RG_PAN_ID_1 ); 00896 pan_id.u8[ 1 ] = hal_register_read( RG_PAN_ID_0 ); 00897 00898 return pan_id.u16; 00899 }
Here is the call graph for this function:
tat_status_t tat_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. |
TAT_SUCCESS | The RSSI measurement was successful. | |
TAT_WRONG_STATE | The radio transceiver is not in RX_ON or BUSY_RX. |
Definition at line 380 of file tat.c.
References BUSY_RX, hal_subregister_read(), RX_ON, SR_RSSI, tat_get_trx_state(), TAT_SUCCESS, and TAT_WRONG_STATE.
00380 { 00381 00382 uint8_t current_state = tat_get_trx_state( ); 00383 tat_status_t retval = TAT_WRONG_STATE; 00384 00385 /*The RSSI measurement should only be done in RX_ON or BUSY_RX.*/ 00386 if ((current_state == RX_ON) || (current_state == BUSY_RX)) { 00387 00388 *rssi = hal_subregister_read( SR_RSSI ); 00389 retval = TAT_SUCCESS; 00390 } 00391 00392 return retval; 00393 }
Here is the call graph for this function:
uint16_t tat_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 929 of file tat.c.
References hal_register_read(), RG_SHORT_ADDR_0, and RG_SHORT_ADDR_1.
00929 { 00930 00931 //This union is used for the data convertion purposes. 00932 union{ 00933 00934 uint16_t u16; 00935 uint8_t u8[ 2 ]; 00936 }short_address; 00937 00938 short_address.u8[ 0 ] = hal_register_read( RG_SHORT_ADDR_1 ); 00939 short_address.u8[ 1 ] = hal_register_read( RG_SHORT_ADDR_0 ); 00940 00941 return short_address.u16; 00942 }
Here is the call graph for this function:
uint8_t tat_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 642 of file tat.c.
References hal_subregister_read(), and SR_TRX_STATUS.
Referenced by tat_calibrate_filter(), tat_calibrate_pll(), tat_do_cca(), tat_do_ed_scan(), tat_enter_sleep_mode(), tat_get_rssi_value(), tat_init(), tat_leave_sleep_mode(), tat_send_data(), tat_send_data_with_retry(), tat_set_operating_channel(), and tat_set_trx_state().
00642 { 00643 return hal_subregister_read( SR_TRX_STATUS ); 00644 }
Here is the call graph for this function:
uint8_t tat_get_tx_power_level | ( | void | ) |
This function will read and return the output power level.
Definition at line 208 of file tat.c.
References hal_subregister_read(), and SR_TX_PWR.
00208 { 00209 return hal_subregister_read( SR_TX_PWR ); 00210 }
Here is the call graph for this function:
tat_status_t tat_init | ( | void | ) |
Initialize the Transceiver Access Toolbox and lower layers.
If the initialization is successful the radio transceiver will be in TRX_OFF state.
TAT_SUCCESS | The radio transceiver was successfully initialized and put into the TRX_OFF state. | |
TAT_UNSUPPORTED_DEVICE | The connected device is not an Atmel AT86RF230 radio transceiver. | |
TAT_TIMED_OUT | The radio transceiver was not able to initialize and enter TRX_OFF state within the specified time. |
Definition at line 110 of file tat.c.
References CLKM_DISABLED, CMD_FORCE_TRX_OFF, hal_init(), hal_register_read(), hal_register_write(), hal_subregister_write(), RF230_REVA, RF230_REVB, RF230_SUPPORTED_INTERRUPT_MASK, RG_IRQ_MASK, RG_MAN_ID_0, RG_VERSION_NUM, SR_CLKM_CTRL, SR_TRX_CMD, SUPPORTED_MANUFACTURER_ID, tat_get_trx_state(), tat_reset_trx(), TAT_SUCCESS, TAT_TIMED_OUT, TAT_UNSUPPORTED_DEVICE, TIME_P_ON_TO_TRX_OFF, and TRX_OFF.
00110 { 00111 00112 tat_status_t init_status = TAT_SUCCESS; 00113 00114 //Initialize Hardware Abstraction Layer. 00115 hal_init( ); 00116 sei( ); //Enable global interrupts. 00117 00118 tat_reset_trx( ); //Do HW reset of radio transeiver. 00119 00120 //Force transition to TRX_OFF. 00121 hal_subregister_write( SR_TRX_CMD, CMD_FORCE_TRX_OFF ); 00122 delay_us( TIME_P_ON_TO_TRX_OFF ); //Wait for the transition to be complete. 00123 00124 if (tat_get_trx_state( ) != TRX_OFF) { 00125 init_status = TAT_TIMED_OUT; 00126 } else { 00127 00128 //Read Version Number 00129 uint8_t version_number = hal_register_read( RG_VERSION_NUM ); 00130 00131 if ((version_number != RF230_REVA ) && (version_number != RF230_REVB)) { 00132 init_status = TAT_UNSUPPORTED_DEVICE; 00133 } else { 00134 00135 if (hal_register_read( RG_MAN_ID_0 ) != SUPPORTED_MANUFACTURER_ID) { 00136 init_status = TAT_UNSUPPORTED_DEVICE; 00137 } else { 00138 hal_register_write( RG_IRQ_MASK, RF230_SUPPORTED_INTERRUPT_MASK ); 00139 hal_subregister_write( SR_CLKM_CTRL, CLKM_DISABLED ); 00140 } // end: if (hal_register_read( RG_MAN_ID_0 ) != ... 00141 } // end: if ((version_number != RF230_REVA ) ... 00142 } // end: if (tat_get_trx_state( ) ... 00143 00144 return init_status; 00145 }
Here is the call graph for this function:
tat_status_t tat_leave_sleep_mode | ( | void | ) |
This function will take the radio transceiver from sleep mode and put it into the TRX_OFF state.
TAT_SUCCESS | Left sleep mode and entered TRX_OFF state. | |
TAT_TIMED_OUT | Transition to TRX_OFF state timed out. |
Definition at line 785 of file tat.c.
References hal_set_slptr_low, is_sleeping(), tat_get_trx_state(), TAT_SUCCESS, TAT_TIMED_OUT, TIME_SLEEP_TO_TRX_OFF, and TRX_OFF.
00785 { 00786 00787 //Check if the radio transceiver is actually sleeping. 00788 if (is_sleeping( ) == false) { return TAT_SUCCESS; } 00789 00790 hal_set_slptr_low( ); 00791 delay_us( TIME_SLEEP_TO_TRX_OFF ); 00792 00793 tat_status_t leave_sleep_status = TAT_TIMED_OUT; 00794 00795 //Ensure that the radio transceiver is in the TRX_OFF state. 00796 if (tat_get_trx_state( ) == TRX_OFF) { 00797 leave_sleep_status = TAT_SUCCESS; 00798 } 00799 00800 return leave_sleep_status; 00801 }
Here is the call graph for this function:
void tat_reset_state_machine | ( | void | ) |
This function will reset the state machine (to TRX_OFF) from any of its states, except for the SLEEP state.
Definition at line 808 of file tat.c.
References CMD_FORCE_TRX_OFF, hal_set_slptr_low, hal_subregister_write(), SR_TRX_CMD, TIME_CMD_FORCE_TRX_OFF, and TIME_NOCLK_TO_WAKE.
Referenced by tat_enter_sleep_mode(), and tat_set_trx_state().
00808 { 00809 00810 hal_set_slptr_low( ); 00811 delay_us( TIME_NOCLK_TO_WAKE ); 00812 hal_subregister_write( SR_TRX_CMD, CMD_FORCE_TRX_OFF ); 00813 delay_us( TIME_CMD_FORCE_TRX_OFF ); 00814 }
Here is the call graph for this function:
void tat_reset_trx | ( | void | ) |
This function will reset all the registers and the state machine of the radio transceiver.
Definition at line 821 of file tat.c.
References hal_set_rst_high, hal_set_rst_low, hal_set_slptr_low, and TIME_RESET.
Referenced by tat_init().
00821 { 00822 00823 hal_set_rst_low( ); 00824 hal_set_slptr_low( ); 00825 delay_us( TIME_RESET ); 00826 hal_set_rst_high( ); 00827 }
tat_status_t tat_send_data | ( | uint8_t * | data, | |
uint8_t | data_length | |||
) |
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 |
TAT_SUCCESS | Frame downloaded and sent successfully. | |
TAT_INVALID_ARGUMENT | If the dataLength is 0 byte or more than 127 bytes the frame will not be sent. | |
TAT_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 863 of file tat.c.
References hal_frame_write(), hal_set_slptr_high, hal_set_slptr_low, PLL_ON, RF230_MAX_TX_FRAME_LENGTH, tat_get_trx_state(), TAT_INVALID_ARGUMENT, TAT_SUCCESS, and TAT_WRONG_STATE.
00863 { 00864 00865 /*Check function parameters and current state.*/ 00866 if (data_length > RF230_MAX_TX_FRAME_LENGTH) { return TAT_INVALID_ARGUMENT; } 00867 00868 if ((tat_get_trx_state( ) != PLL_ON)) { return TAT_WRONG_STATE; } 00869 00870 /*Do frame transmission.*/ 00871 //Toggle the SLP_TR pin to initiate the frame transmission. 00872 hal_set_slptr_high( ); 00873 hal_set_slptr_low( ); 00874 00875 hal_frame_write( data, data_length ); //Then write data to the frame buffer. 00876 00877 return TAT_SUCCESS; 00878 }
Here is the call graph for this function:
tat_status_t tat_send_data_with_retry | ( | uint8_t | frame_length, | |
uint8_t * | frame, | |||
uint8_t | retries | |||
) |
This function uses the .
This function can only send valid IEEE 802.15.4 Frames.
frame_length | Length of frame to transmit. | |
frame | Pointer to the frame to transmit. | |
retries | Number of times to retry frame transmission (Zero means that the frame will be sent once.). |
TAT_SUCCESS | if the frame was sent successfully within the defined number of retries. | |
TAT_CHANNEL_ACCESS_FAILURE | if the channel was found to be busy on the last retry. | |
TAT_NO_ACK | if an IEEE 802.15.4 acknowledge was not received in time. | |
TAT_INVALID_ARGUMENT | if the frame_length is too long. | |
TAT_WRONG_STATE | if the radio transceiver is not in TX_ARET_ON. |
Definition at line 1081 of file tat.c.
References hal_clear_trx_end_flag(), hal_frame_write(), hal_get_trx_end_flag(), hal_set_slptr_high, hal_set_slptr_low, hal_subregister_read(), RF230_MAX_TX_FRAME_LENGTH, SR_TRAC_STATUS, TAT_BUSY_CHANNEL, TAT_CHANNEL_ACCESS_FAILURE, tat_get_trx_state(), TAT_INVALID_ARGUMENT, TAT_MIN_IEEE_FRAME_LENGTH, TAT_NO_ACK, TAT_SUCCESS, TAT_TRANSMISSION_SUCCESS, TAT_WRONG_STATE, and TX_ARET_ON.
01082 { 01083 01084 tat_status_t task_status = TAT_CHANNEL_ACCESS_FAILURE; 01085 01086 /*Do sanity check on function parameters and current state.*/ 01087 if ((frame_length > RF230_MAX_TX_FRAME_LENGTH) || 01088 (frame_length < TAT_MIN_IEEE_FRAME_LENGTH)) { 01089 return TAT_INVALID_ARGUMENT; 01090 } 01091 01092 if (tat_get_trx_state( ) != TX_ARET_ON) { return TAT_WRONG_STATE; } 01093 01094 hal_clear_trx_end_flag( ); 01095 01096 /*Do initial frame transmission.*/ 01097 hal_set_slptr_high( ); 01098 hal_set_slptr_low( ); 01099 hal_frame_write( frame, frame_length ); //Then write data to the frame buffer. 01100 01101 bool retry = false; // Variable used to control the retry loop. 01102 01103 /*Do retry if requested.*/ 01104 do{ 01105 01106 //Wait for TRX_END interrupt. 01107 while (hal_get_trx_end_flag( ) == 0) {;} 01108 01109 //Check status. 01110 uint8_t transaction_status = hal_subregister_read( SR_TRAC_STATUS ); 01111 01112 //Check for failure. 01113 if ((transaction_status != TAT_TRANSMISSION_SUCCESS)) { 01114 01115 if (transaction_status == TAT_BUSY_CHANNEL) { 01116 task_status = TAT_CHANNEL_ACCESS_FAILURE; 01117 } else { 01118 task_status = TAT_NO_ACK; 01119 } 01120 01121 if ((retries--) > 0) { 01122 01123 retry = true; 01124 01125 //Wait for the TRX to go back to TX_ARET_ON. 01126 while (tat_get_trx_state() != TX_ARET_ON) {;} 01127 01128 hal_clear_trx_end_flag( ); 01129 hal_set_slptr_high( ); 01130 hal_set_slptr_low( ); 01131 } else { 01132 retry = false; 01133 } 01134 } else{ 01135 01136 task_status = TAT_SUCCESS; 01137 retry = false; 01138 } // end: if ((transaction_status != TAT_TRANSMISSION_SUCCESS)) ... 01139 } while (retry == true); 01140 01141 return task_status; 01142 }
Here is the call graph for this function:
tat_status_t tat_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. |
TAT_SUCCESS | Mode and its parameters successfully changed. | |
TAT_WRONG_STATE | This function cannot be called in the SLEEP state. | |
TAT_INVALID_ARGUMENT | If one of the three function arguments are out of bounds. |
Definition at line 304 of file tat.c.
References CCA_CARRIER_SENSE, CCA_CARRIER_SENSE_WITH_ED, CCA_ED, hal_subregister_write(), is_sleeping(), RF230_MAX_ED_THRESHOLD, SR_CCA_ED_THRES, SR_CCA_MODE, TAT_INVALID_ARGUMENT, TAT_SUCCESS, and TAT_WRONG_STATE.
00304 { 00305 00306 /*Check function parameters and state.*/ 00307 if ((mode != CCA_ED) && (mode != CCA_CARRIER_SENSE) && 00308 (mode != CCA_CARRIER_SENSE_WITH_ED)) { 00309 return TAT_INVALID_ARGUMENT; 00310 } 00311 00312 //Ensure that the ED threshold is within bounds. 00313 if (ed_threshold > RF230_MAX_ED_THRESHOLD) { return TAT_INVALID_ARGUMENT; } 00314 00315 //Ensure that the radio transceiver is not sleeping. 00316 if (is_sleeping( ) == true) { return TAT_WRONG_STATE; } 00317 00318 /*Change cca mode and ed threshold.*/ 00319 hal_subregister_write( SR_CCA_MODE, mode ); 00320 hal_subregister_write( SR_CCA_ED_THRES, ed_threshold ); 00321 00322 return TAT_SUCCESS; 00323 }
Here is the call graph for this function:
tat_status_t tat_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. |
TAT_SUCCESS | Clock speed updated. New state is TRX_OFF. | |
TAT_INVALID_ARGUMENT | Requested clock speed is out of bounds. |
Definition at line 513 of file tat.c.
References CLKM_16MHZ, hal_subregister_write(), SR_CLKM_CTRL, SR_CLKM_SHA_SEL, tat_get_clock_speed(), TAT_INVALID_ARGUMENT, and TAT_SUCCESS.
00513 { 00514 00515 /*Check function parameter and current clock speed.*/ 00516 if (clock_speed > CLKM_16MHZ) { return TAT_INVALID_ARGUMENT; } 00517 00518 if (tat_get_clock_speed( ) == clock_speed) { return TAT_SUCCESS; } 00519 00520 /*Select to change the CLKM frequency directly or after returning from SLEEP.*/ 00521 if (direct == false) { 00522 hal_subregister_write( SR_CLKM_SHA_SEL, 1 ); 00523 } else { 00524 hal_subregister_write( SR_CLKM_SHA_SEL, 0 ); 00525 } // end: if (direct == false) ... 00526 00527 hal_subregister_write( SR_CLKM_CTRL, clock_speed ); 00528 00529 return TAT_SUCCESS; 00530 }
Here is the call graph for this function:
void tat_set_extended_address | ( | uint64_t | new_extended_address | ) |
This function will set a new extended address to be used by the address filter.
new_extended_address | Extended address to be used by the address filter. |
Definition at line 1000 of file tat.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.
01000 { 01001 01002 //This union is used for the data convertion purposes. 01003 union{ 01004 01005 uint64_t u64; 01006 uint8_t u8[ 8 ]; 01007 }extended_address; 01008 01009 extended_address.u64 = new_extended_address; 01010 01011 hal_register_write( RG_IEEE_ADDR_7, extended_address.u8[ 0 ] ); 01012 hal_register_write( RG_IEEE_ADDR_6, extended_address.u8[ 1 ] ); 01013 hal_register_write( RG_IEEE_ADDR_5, extended_address.u8[ 2 ] ); 01014 hal_register_write( RG_IEEE_ADDR_4, extended_address.u8[ 3 ] ); 01015 hal_register_write( RG_IEEE_ADDR_3, extended_address.u8[ 4 ] ); 01016 hal_register_write( RG_IEEE_ADDR_2, extended_address.u8[ 5 ] ); 01017 hal_register_write( RG_IEEE_ADDR_1, extended_address.u8[ 6 ] ); 01018 hal_register_write( RG_IEEE_ADDR_0, extended_address.u8[ 7 ] ); 01019 }
Here is the call graph for this function:
tat_status_t tat_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. |
TAT_SUCCESS | New channel set. | |
TAT_WRONG_STATE | Transceiver is in a state where the channel cannot be changed (SLEEP). | |
TAT_INVALID_ARGUMENT | Channel argument is out of bounds. | |
TAT_TIMED_OUT | The PLL did not lock within the specified time. |
Definition at line 169 of file tat.c.
References hal_subregister_write(), is_sleeping(), PLL_ON, RF230_MAX_CHANNEL, RF230_MIN_CHANNEL, RX_ON, SR_CHANNEL, tat_get_operating_channel(), tat_get_trx_state(), TAT_INVALID_ARGUMENT, TAT_SUCCESS, TAT_TIMED_OUT, TAT_WRONG_STATE, and TIME_PLL_LOCK.
00169 { 00170 00171 /*Do function parameter and state check.*/ 00172 if ((channel < RF230_MIN_CHANNEL) || (channel > RF230_MAX_CHANNEL)) { 00173 return TAT_INVALID_ARGUMENT; 00174 } 00175 00176 if (is_sleeping( ) == true) { return TAT_WRONG_STATE; } 00177 00178 if (tat_get_operating_channel( ) == channel) { return TAT_SUCCESS; } 00179 00180 /*Set new operating channel.*/ 00181 hal_subregister_write( SR_CHANNEL, channel ); 00182 00183 //Read current state and wait for the PLL_LOCK interrupt if the 00184 //radio transceiver is in either RX_ON or PLL_ON. 00185 uint8_t trx_state = tat_get_trx_state( ); 00186 00187 if ((trx_state == RX_ON) || (trx_state == PLL_ON)) { 00188 delay_us( TIME_PLL_LOCK ); 00189 } 00190 00191 tat_status_t channel_set_status = TAT_TIMED_OUT; 00192 00193 //Check that the channel was set properly. 00194 if (tat_get_operating_channel( ) == channel) { 00195 channel_set_status = TAT_SUCCESS; 00196 } 00197 00198 return channel_set_status; 00199 }
Here is the call graph for this function:
void tat_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 907 of file tat.c.
References hal_register_write(), RG_PAN_ID_0, and RG_PAN_ID_1.
00907 { 00908 00909 //This union is used for the data convertion purposes. 00910 union{ 00911 00912 uint16_t u16; 00913 uint8_t u8[ 2 ]; 00914 }pan_id; 00915 00916 pan_id.u16 = new_pan_id; 00917 00918 hal_register_write( RG_PAN_ID_1, pan_id.u8[ 0 ] ); 00919 hal_register_write( RG_PAN_ID_0, pan_id.u8[ 1 ] ); 00920 }
Here is the call graph for this function:
void tat_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 950 of file tat.c.
References hal_register_write(), RG_SHORT_ADDR_0, and RG_SHORT_ADDR_1.
00950 { 00951 00952 //This union is used for the data convertion purposes. 00953 union{ 00954 00955 uint16_t u16; 00956 uint8_t u8[ 2 ]; 00957 }short_address; 00958 00959 short_address.u16 = new_short_address; 00960 00961 hal_register_write( RG_SHORT_ADDR_1, short_address.u8[ 0 ] ); 00962 hal_register_write( RG_SHORT_ADDR_0, short_address.u8[ 1 ] ); 00963 }
Here is the call graph for this function:
tat_status_t tat_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:
|
TAT_SUCCESS | Requested state transition completed successfully. | |
TAT_INVALID_ARGUMENT | Supplied function parameter out of bounds. | |
TAT_WRONG_STATE | Illegal state to do transition from. | |
TAT_BUSY_STATE | The radio transceiver is busy. | |
TAT_TIMED_OUT | The state transition could not be completed within resonable time. |
Definition at line 687 of file tat.c.
References BUSY_RX, BUSY_RX_AACK, BUSY_TX, BUSY_TX_ARET, hal_subregister_write(), is_sleeping(), PLL_ON, RX_AACK_ON, RX_ON, SR_TRX_CMD, TAT_BUSY_STATE, tat_get_trx_state(), TAT_INVALID_ARGUMENT, tat_reset_state_machine(), TAT_SUCCESS, TAT_TIMED_OUT, TAT_WRONG_STATE, TIME_STATE_TRANSITION_PLL_ACTIVE, TIME_TRX_OFF_TO_PLL_ACTIVE, TRX_OFF, and TX_ARET_ON.
Referenced by tat_do_cca().
00687 { 00688 00689 /*Check function paramter and current state of the radio transceiver.*/ 00690 if (!((new_state == TRX_OFF ) || (new_state == RX_ON) || (new_state == PLL_ON) || 00691 (new_state == RX_AACK_ON ) || (new_state == TX_ARET_ON ))) { 00692 00693 return TAT_INVALID_ARGUMENT; 00694 } 00695 00696 if (is_sleeping( ) == true) { return TAT_WRONG_STATE; } 00697 00698 uint8_t original_state = tat_get_trx_state( ); 00699 00700 if ((original_state == BUSY_RX ) || (original_state == BUSY_TX) || 00701 (original_state == BUSY_RX_AACK) || (original_state == BUSY_TX_ARET)) { 00702 return TAT_BUSY_STATE; 00703 } 00704 00705 if (new_state == original_state) { return TAT_SUCCESS; } 00706 00707 //At this point it is clear that the requested new_state is: 00708 //TRX_OFF, RX_ON, PLL_ON, RX_AACK_ON or TX_ARET_ON. 00709 00710 //The radio transceiver can be in one of the following states: 00711 //TRX_OFF, RX_ON, PLL_ON, RX_AACK_ON, TX_ARET_ON. 00712 if( new_state == TRX_OFF ){ 00713 tat_reset_state_machine( ); //Go to TRX_OFF from any state. 00714 } else { 00715 00716 //It is not allowed to go from RX_AACK_ON or TX_AACK_ON and directly to 00717 //TX_AACK_ON or RX_AACK_ON respectively. Need to go via RX_ON or PLL_ON. 00718 if ((new_state == TX_ARET_ON) && (original_state == RX_AACK_ON)) { 00719 00720 //First do intermediate state transition to PLL_ON, then to TX_ARET_ON. 00721 //The final state transition to TX_ARET_ON is handled after the if-else if. 00722 hal_subregister_write( SR_TRX_CMD, PLL_ON ); 00723 delay_us( TIME_STATE_TRANSITION_PLL_ACTIVE ); 00724 } else if ((new_state == RX_AACK_ON) && (original_state == TX_ARET_ON)) { 00725 00726 //First do intermediate state transition to RX_ON, then to RX_AACK_ON. 00727 //The final state transition to RX_AACK_ON is handled after the if-else if. 00728 hal_subregister_write( SR_TRX_CMD, RX_ON ); 00729 delay_us( TIME_STATE_TRANSITION_PLL_ACTIVE ); 00730 } 00731 00732 //Any other state transition can be done directly. 00733 hal_subregister_write( SR_TRX_CMD, new_state ); 00734 00735 //When the PLL is active most states can be reached in 1us. However, from 00736 //TRX_OFF the PLL needs time to activate. 00737 if (original_state == TRX_OFF) { 00738 delay_us( TIME_TRX_OFF_TO_PLL_ACTIVE ); 00739 } else { 00740 delay_us( TIME_STATE_TRANSITION_PLL_ACTIVE ); 00741 } // end: if (original_state == TRX_OFF) ... 00742 } // end: if( new_state == TRX_OFF ) ... 00743 00744 /*Verify state transition.*/ 00745 tat_status_t set_state_status = TAT_TIMED_OUT; 00746 00747 if( tat_get_trx_state( ) == new_state ){ set_state_status = TAT_SUCCESS; } 00748 00749 return set_state_status; 00750 }
Here is the call graph for this function:
tat_status_t tat_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. |
TAT_SUCCESS | New output power set successfully. | |
TAT_INVALID_ARGUMENT | The supplied function argument is out of bounds. | |
TAT_WRONG_STATE | It is not possible to change the TX power when the device is sleeping. |
Definition at line 224 of file tat.c.
References hal_subregister_write(), is_sleeping(), SR_TX_PWR, TAT_INVALID_ARGUMENT, TAT_SUCCESS, TAT_WRONG_STATE, and TX_PWR_17_2DBM.
00224 { 00225 00226 /*Check function parameter and state.*/ 00227 if (power_level > TX_PWR_17_2DBM) { return TAT_INVALID_ARGUMENT; } 00228 00229 if (is_sleeping( ) == true) { return TAT_WRONG_STATE; } 00230 00231 /*Set new power level*/ 00232 hal_subregister_write( SR_TX_PWR, power_level ); 00233 00234 return TAT_SUCCESS; 00235 }
Here is the call graph for this function:
void tat_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 839 of file tat.c.
References hal_subregister_write(), and SR_TX_AUTO_CRC_ON.
00839 { 00840 00841 if (auto_crc_on == true) { 00842 hal_subregister_write( SR_TX_AUTO_CRC_ON, 1 ); 00843 } else { 00844 hal_subregister_write( SR_TX_AUTO_CRC_ON, 0 ); 00845 } // end: if (auto_crc_on == true) ... 00846 }
Here is the call graph for this function:
Generated on Wed Jul 11 18:16:32 2007 for AVR2001 AT86RF230 Software Programmer's Manual by ![]() |