#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include "pal.h"
#include "return_val.h"
#include "tal.h"
#include "ieee_const.h"
#include "tal_config.h"
#include "tal_pib.h"
#include "tal_internal.h"
#include "ieee_154g.h"
Functions | |
static retval_t | apply_channel_settings (trx_id_t trx_id) |
Check if freq spacing and frequency are in the supported range. More... | |
static ch_pg_t | calc_ch_page (trx_id_t trx_id) |
Calculates the channel page based on trx_id and freq_band. More... | |
void | calculate_pib_values (trx_id_t trx_id) |
Calculates PIB values that depend on the current PHY configuration. More... | |
retval_t | config_phy (trx_id_t trx_id) |
Configures the PHY. More... | |
void | init_tal_pib (trx_id_t trx_id) |
Initialize the TAL PIB. More... | |
static retval_t | set_channel (trx_id_t trx_id, uint16_t ch) |
Sets the provided channel. More... | |
void | set_fsk_pibs (trx_id_t trx_id) |
Sets FSK related PIBs. More... | |
static retval_t | set_phy_based_on_channel_page (trx_id_t trx_id, ch_pg_t pg) |
Sets PHY based on provided channel page. More... | |
static void | set_tx_pwr (trx_id_t trx_id, int8_t tx_pwr) |
Sets the transmit power. More... | |
retval_t | tal_pib_get (trx_id_t trx_id, uint8_t attribute, uint8_t *value) |
Gets a TAL PIB attribute. More... | |
retval_t | tal_pib_set (trx_id_t trx_id, uint8_t attribute, pib_value_t *value) |
Sets a TAL PIB attribute. More... | |
retval_t | tal_pib_set_all (uint8_t attribute, pib_value_t *value) |
Sets a TAL PIB attribute for all existing trx Ids for this device. More... | |
static void | wait_for_freq_settling (trx_id_t trx_id) |
Waits for frequency settling. More... | |
void | write_all_tal_pib_to_trx (trx_id_t trx_id) |
Write all shadow PIB variables to the transceiver. More... | |
Check if freq spacing and frequency are in the supported range.
trx_id | Transceiver identifier |
trx_id | Transceiver identifier |
References CHINA_780, EU_863, get_sun_max_ch_no(), LEG_OQPSK, MAC_SUCCESS, OQPSK, RF24, RF_BASE_ADDR_OFFSET, RF_TXPREP, RG_RF09_CCF0L, RG_RF09_CNL, RG_RF09_CS, status, tal_pib, trx_reg_write(), trx_state, US_915, wait_for_freq_settling(), and WORLD_2450.
Referenced by config_phy().
Calculates the channel page based on trx_id and freq_band.
trx_id | Transceiver identifier |
References CH_PG_2003, CH_PG_2006, CH_PG_CHINA, CH_PG_INVALID, CH_PG_SUN, CHINA_780, LEG_OQPSK, RF09, tal_pib, and US_915.
Referenced by calculate_pib_values().
void calculate_pib_values | ( | trx_id_t | trx_id | ) |
Calculates PIB values that depend on the current PHY configuration.
trx_id | Transceiver identifier |
References aMaxPHYPacketSize, aMaxPHYPacketSize_4g, calc_ch_page(), FCS_TYPE_2_OCTETS, FCS_TYPE_4_OCTETS, get_AckTiming_us(), get_AckWaitDuration_us(), get_cca_duration_us(), get_cca_thres(), get_data_rate(), get_supported_channels_tuple(), LEG_OQPSK, MAC_SUCCESS, tal_get_symbol_duration_us(), and tal_pib.
Referenced by set_phy_based_on_channel_page(), tal_init(), tal_pib_set(), and tal_reset().
Configures the PHY.
This function configures the PHY related settings.
trx_id | Transceiver identifier |
References apply_channel_settings(), conf_trx_modulation(), MAC_SUCCESS, RF_BASE_ADDR_OFFSET, RG_BBC0_AMAACKTL, RG_BBC0_AMEDT, set_ed_sample_duration(), SR_BBC0_PC_FCST, status, tal_pib, trx_bit_write(), and trx_reg_write().
Referenced by set_phy_based_on_channel_page(), tal_init(), tal_pib_set(), tal_reset(), and tal_trx_wakeup().
void init_tal_pib | ( | trx_id_t | trx_id | ) |
Initialize the TAL PIB.
This function initializes the TAL information base attributes to their default values.
trx_id | Transceiver identifier |
References aMaxPHYPacketSize_4g, FSK, get_supported_channels_tuple(), LEG_OQPSK, MAC_SUCCESS, OFDM, OQPSK, RF09, RF24, TAL_PANID_BC_DEF, tal_pib, TAL_RF09_ADAPT_DATA_RATE_FOR_ACK, TAL_RF09_FCS_TYPE_DEFAULT, TAL_RF09_FRAME_VERSIONS, TAL_RF09_FRAMES_TYPES, TAL_RF09_FSK_CH_SPACING_DEF, TAL_RF09_FSK_CURRENT_CHANNEL_DEF, TAL_RF09_FSK_DATA_RATE_DEF, TAL_RF09_FSK_FEC_ENABLE, TAL_RF09_FSK_FEC_INTERLEAVING_RSC, TAL_RF09_FSK_FEC_SCHEME, TAL_RF09_FSK_FRQ_BAND_DEF, TAL_RF09_FSK_FRQ_F0_DEF, TAL_RF09_FSK_MOD_IDX_DEF, TAL_RF09_FSK_OP_DEF, TAL_RF09_FSK_PREAMBLE_LEN, TAL_RF09_FSK_RAW_MODE_ENABLED, TAL_RF09_FSK_SCRAMBLE_PSDU, TAL_RF09_FSK_SFD, TAL_RF09_FSK_TYPE_DEF, TAL_RF09_LEG_OQPSK_CH_SPACING_DEF, TAL_RF09_LEG_OQPSK_CURRENT_CHANNEL_DEF, TAL_RF09_LEG_OQPSK_FRQ_BAND_DEF, TAL_RF09_LEG_OQPSK_FRQ_F0_DEF, TAL_RF09_LEG_OQPSK_RATE, TAL_RF09_MAX_CSMA_BACKOFFS_DEF, TAL_RF09_MAX_FRAMES_DURING_BACKOFF_DEF, TAL_RF09_MAXBE_DEF, TAL_RF09_MAXFRAMERETRIES_DEF, TAL_RF09_MINBE_DEF, TAL_RF09_MODE_SWITCH_DURATION, TAL_RF09_MODE_SWITCH_ENABLE, TAL_RF09_MODE_SWITCH_SETTLING_DELAY, TAL_RF09_NEW_MODE_FEC_ENABLED, TAL_RF09_NEW_MODE_MODULATION, TAL_RF09_NEW_MODE_OPTION, TAL_RF09_OFDM_CH_SPACING_DEF, TAL_RF09_OFDM_CURRENT_CHANNEL_DEF, TAL_RF09_OFDM_FRQ_BAND_DEF, TAL_RF09_OFDM_FRQ_F0_DEF, TAL_RF09_OFDM_INTERL_DEF, TAL_RF09_OFDM_MCS_VAL_DEF, TAL_RF09_OFDM_OPT_DEF, TAL_RF09_OQPSK_CH_SPACING_DEF, TAL_RF09_OQPSK_CURRENT_CHANNEL_DEF, TAL_RF09_OQPSK_FRQ_BAND_DEF, TAL_RF09_OQPSK_FRQ_F0_DEF, TAL_RF09_OQPSK_RATE, TAL_RF09_PAN_COORDINATOR_DEF, TAL_RF09_RPC_DEF, TAL_RF24_ADAPT_DATA_RATE_FOR_ACK, TAL_RF24_FCS_TYPE_DEFAULT, TAL_RF24_FRAME_VERSIONS, TAL_RF24_FRAMES_TYPES, TAL_RF24_FSK_CH_SPACING_DEF, TAL_RF24_FSK_CURRENT_CHANNEL_DEF, TAL_RF24_FSK_DATA_RATE_DEF, TAL_RF24_FSK_FEC_ENABLE, TAL_RF24_FSK_FEC_INTERLEAVING_RSC, TAL_RF24_FSK_FEC_SCHEME, TAL_RF24_FSK_FRQ_BAND_DEF, TAL_RF24_FSK_FRQ_F0_DEF, TAL_RF24_FSK_MOD_IDX_DEF, TAL_RF24_FSK_OP_DEF, TAL_RF24_FSK_PREAMBLE_LEN, TAL_RF24_FSK_RAW_MODE_ENABLED, TAL_RF24_FSK_SCRAMBLE_PSDU, TAL_RF24_FSK_SFD, TAL_RF24_FSK_TYPE_DEF, TAL_RF24_LEG_OQPSK_CH_SPACING_DEF, TAL_RF24_LEG_OQPSK_CURRENT_CHANNEL_DEF, TAL_RF24_LEG_OQPSK_FRQ_BAND_DEF, TAL_RF24_LEG_OQPSK_FRQ_F0_DEF, TAL_RF24_LEG_OQPSK_RATE, TAL_RF24_MAX_CSMA_BACKOFFS_DEF, TAL_RF24_MAX_FRAMES_DURING_BACKOFF_DEF, TAL_RF24_MAXBE_DEF, TAL_RF24_MAXFRAMERETRIES_DEF, TAL_RF24_MINBE_DEF, TAL_RF24_MODE_SWITCH_DURATION, TAL_RF24_MODE_SWITCH_ENABLE, TAL_RF24_MODE_SWITCH_SETTLING_DELAY, TAL_RF24_NEW_MODE_FEC_ENABLED, TAL_RF24_NEW_MODE_MODULATION, TAL_RF24_NEW_MODE_OPTION, TAL_RF24_OFDM_CH_SPACING_DEF, TAL_RF24_OFDM_CURRENT_CHANNEL_DEF, TAL_RF24_OFDM_FRQ_BAND_DEF, TAL_RF24_OFDM_FRQ_F0_DEF, TAL_RF24_OFDM_INTERL_DEF, TAL_RF24_OFDM_MCS_VAL_DEF, TAL_RF24_OFDM_OPT_DEF, TAL_RF24_OQPSK_CH_SPACING_DEF, TAL_RF24_OQPSK_CURRENT_CHANNEL_DEF, TAL_RF24_OQPSK_FRQ_BAND_DEF, TAL_RF24_OQPSK_FRQ_F0_DEF, TAL_RF24_OQPSK_RATE, TAL_RF24_PAN_COORDINATOR_DEF, TAL_RF24_RPC_DEF, and TAL_SHORT_ADDRESS_DEF.
Sets the provided channel.
trx_id | Transceiver identifier |
ch | Channel number |
References CHINA_780, LEG_OQPSK, MAC_INVALID_PARAMETER, MAC_SUCCESS, RF24, RF_BASE_ADDR_OFFSET, RF_RX, RF_TXPREP, RG_RF09_CNL, start_rpc(), stop_rpc(), switch_to_rx(), switch_to_txprep(), tal_pib, trx_state, US_915, and wait_for_freq_settling().
Referenced by tal_pib_set().
void set_fsk_pibs | ( | trx_id_t | trx_id | ) |
Sets FSK related PIBs.
trx_id | Transceiver identifier |
References RF_BASE_ADDR_OFFSET, RG_BBC0_FSKPLL, RG_BBC0_FSKRRXFLL, SR_BBC0_FSKC1_FSKPLH, SR_BBC0_FSKC2_FECIE, SR_BBC0_FSKC2_FECS, SR_BBC0_FSKC2_MSE, SR_BBC0_FSKPHRTX_DW, SR_BBC0_FSKPHRTX_SFD, tal_pib, trx_bit_write(), and trx_reg_write().
Referenced by write_all_tal_pib_to_trx().
Sets PHY based on provided channel page.
trx_id | Transceiver identifier |
pg | Channel page |
References calculate_pib_values(), CH_PG_16, CH_PG_18, CH_PG_2003, CH_PG_2006, CH_PG_CHINA, CH_PG_INVALID, CHINA_780, CHIP_RATE_1000, CHIP_RATE_2000, config_phy(), get_supported_channels_tuple(), LEG_2450_CH_SPAC, LEG_2450_F0, LEG_780_F0, LEG_915_CH_SPAC, LEG_915_F0, LEG_OQPSK, MAC_INVALID_PARAMETER, MAC_SUCCESS, phyHighRateEnabled, RF09, RF24, tal_pib, tal_pib_set(), US_915, and WORLD_2450.
Referenced by tal_pib_set().
|
static |
Sets the transmit power.
trx_id | Transceiver identifier |
tx_pwr | Transmit power in dBm |
References RF_BASE_ADDR_OFFSET, SR_RF09_PAC_TXPWR, tal_pib, and trx_bit_write().
Referenced by tal_pib_set().
Gets a TAL PIB attribute.
This function is called to retrieve the transceiver information base attributes.
[in] | trx_id | Transceiver identifier |
[in] | attribute | TAL infobase attribute ID |
[out] | value | TAL infobase attribute value |
References Assert, LEG_OQPSK, mac_i_pan_coordinator, MAC_SUCCESS, MAC_UNSUPPORTED_ATTRIBUTE, macACKTiming, macAckWaitDuration, macAdaptDataRateForACK, macFCSType, macFrameFilterFrameTypes, macFrameFilterFrameVersions, macIeeeAddress, macMaxBE, macMaxCSMABackoffs, macMaxFrameRetries, macMaxNumRxFramesDuringBackoff, macMinBE, macPANId, macPromiscuousMode, macShortAddress, NUM_TRX, phyCCADuration, phyCCAMode, phyCCAThreshold, phyCCATimeMethod, phyChannelsSupported, phyCurrentChannel, phyCurrentPage, phyCurrentSUNPageEntry, phyFSKFECEnabled, phyFSKFECInterleavingRSC, phyFSKFECScheme, phyFSKModeSwitchEnabled, phyFSKPreambleLength, phyFSKRawModeEnabled, phyFSKRawModeRxLength, phyFSKScramblePSDU, phyHighRateEnabled, phyMaxFrameDuration, phyModeSwitchDuration, phyModeSwitchNewMode, phyModeSwitchSettlingDelay, phyMRFSKSFD, phyOFDMInterleaving, phyOFDMMCS, phyOnAirDuration, phyOQPSKRateMode, phyRPCEnabled, phySetting, phySymbolsPerOctet, phyTransmitPower, status, and tal_pib.
retval_t tal_pib_set | ( | trx_id_t | trx_id, |
uint8_t | attribute, | ||
pib_value_t * | value | ||
) |
Sets a TAL PIB attribute.
This function is called to set the transceiver information base attributes.
trx_id | Transceiver identifier |
attribute | TAL infobase attribute ID |
value | TAL infobase attribute value to be set |
References Assert, calculate_cca_duration_us(), calculate_pib_values(), CCA_MODE_1_ED, conf_trx_modulation(), config_fsk_rpc(), config_phy(), FCS_TYPE_4_OCTETS, FSK, get_supported_channels_tuple(), LEG_OQPSK, mac_i_pan_coordinator, MAC_INVALID_PARAMETER, MAC_SUCCESS, MAC_UNSUPPORTED_ATTRIBUTE, macACKTiming, macAckWaitDuration, macAdaptDataRateForACK, macFCSType, macFrameFilterFrameTypes, macFrameFilterFrameVersions, macIeeeAddress, macMaxBE, macMaxCSMABackoffs, macMaxFrameRetries, macMaxNumRxFramesDuringBackoff, macMinBE, macPANId, macPromiscuousMode, macShortAddress, NUM_TRX, OFDM, OQPSK, PHY_RX_ON, PHY_TRX_OFF, phyCCADuration, phyCCAMode, phyCCAThreshold, phyCCATimeMethod, phyCurrentChannel, phyCurrentPage, phyFSKFECEnabled, phyFSKFECInterleavingRSC, phyFSKFECScheme, phyFSKModeSwitchEnabled, phyFSKPreambleLength, phyFSKRawModeEnabled, phyFSKRawModeRxLength, phyFSKScramblePSDU, phyHighRateEnabled, phyModeSwitchDuration, phyModeSwitchNewMode, phyModeSwitchSettlingDelay, phyMRFSKSFD, phyOFDMInterleaving, phyOFDMMCS, phyOnAirDuration, phyOQPSKRateMode, phyRPCEnabled, phySetting, phyTransmitPower, pib_value_t::pib_value_16bit, pib_value_t::pib_value_32bit, pib_value_t::pib_value_64bit, pib_value_t::pib_value_8bit, pib_value_t::pib_value_bool, RF_BASE_ADDR_OFFSET, RF_RX, RG_BBC0_AFFTM, RG_BBC0_AMEDT, RG_BBC0_FSKRRXFLL, RG_BBC0_MACEA0, RG_BBC0_MACPID0F0, RG_BBC0_MACSHA0F0, set_channel(), set_ed_sample_duration(), set_phy_based_on_channel_page(), set_sfd(), set_tx_pwr(), SR_BBC0_AFC0_PM, SR_BBC0_AFC1_PANC0, SR_BBC0_AFFVM_AFFVM, SR_BBC0_AMCS_AACK, SR_BBC0_AMCS_AACKDR, SR_BBC0_FSKC2_FECIE, SR_BBC0_FSKC2_FECS, SR_BBC0_FSKC2_MSE, SR_BBC0_FSKPHRTX_DW, SR_BBC0_FSKPHRTX_SFD, SR_BBC0_OFDMC_POI, SR_BBC0_OFDMPHRTX_MCS, SR_BBC0_OQPSKC2_RPC, SR_BBC0_OQPSKC3_HRLEG, SR_BBC0_OQPSKPHRTX_MOD, SR_BBC0_PC_FCST, status, TAL_BUSY, TAL_IDLE, tal_pib, tal_rx_enable(), TAL_SLEEP, tal_state, TAL_TRX_ASLEEP, trx_bit_write(), trx_default_state, and trx_reg_write().
retval_t tal_pib_set_all | ( | uint8_t | attribute, |
pib_value_t * | value | ||
) |
Sets a TAL PIB attribute for all existing trx Ids for this device.
This function is called to set the transceiver information base attributes for all transceivers on this device. This function simply calls function tal_pib_set() for all existing trx Ids.
attribute | TAL infobase attribute ID |
value | TAL infobase attribute value to be set |
References MAC_SUCCESS, NUM_TRX, status, and tal_pib_set().
|
static |
Waits for frequency settling.
trx_id | Transceiver identifier |
References MAX_PLL_LOCK_DURATION, pal_get_current_time(), pal_timer_delay, PLL_FRZ_SETTLING_DURATION, POLL_TIME_GAP, RF_BASE_ADDR_OFFSET, RG_RF09_PLL, SR_RF09_PLL_LS, start_time, trx_bit_read(), and trx_reg_write().
Referenced by apply_channel_settings(), and set_channel().
void write_all_tal_pib_to_trx | ( | trx_id_t | trx_id | ) |
Write all shadow PIB variables to the transceiver.
This function writes all shadow PIB variables to the transceiver. It is assumed that the radio does not sleep and has gone through a reset.
trx_id | Transceiver identifier |
References FCS_TYPE_4_OCTETS, PHY_RX_ON, RF_BASE_ADDR_OFFSET, RG_BBC0_AFFTM, RG_BBC0_MACEA0, RG_BBC0_MACPID0F0, RG_BBC0_MACSHA0F0, set_fsk_pibs(), SR_BBC0_AFC0_PM, SR_BBC0_AFC1_PANC0, SR_BBC0_AMCS_AACKDR, SR_BBC0_OFDMC_POI, SR_BBC0_OFDMPHRTX_MCS, SR_BBC0_OQPSKPHRTX_MOD, SR_BBC0_PC_FCST, tal_pib, tal_rx_enable(), temp, and trx_bit_write().