Microchip® Advanced Software Framework

at86rf215/src/tal_pib.c File Reference
#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)
 Applies channel settings by writing them to the transceiver. 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...
 
static retval_t check_valid_freq_range (trx_id_t trx_id)
 Check if freq spacing and frequency are in the supported range. 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...
 

static retval_t apply_channel_settings ( trx_id_t  trx_id)
static

Applies channel settings by writing them to the transceiver.

Parameters
trx_idTransceiver identifier
Returns
MAC_SUCCESS if channel setting is successful else FAILURE

References check_valid_freq_range(), 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_state, US_915, wait_for_freq_settling(), and WORLD_2450.

Referenced by config_phy().

static ch_pg_t calc_ch_page ( trx_id_t  trx_id)
static

Calculates the channel page based on trx_id and freq_band.

Parameters
trx_idTransceiver identifier
Returns
Channel page

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().

static retval_t check_valid_freq_range ( trx_id_t  trx_id)
static

Check if freq spacing and frequency are in the supported range.

Parameters
trx_idTransceiver identifier
Returns
MAC_SUCCESS if frequency spacing and frequency are supported else FAILURE

References FAILURE, MAC_SUCCESS, RF09, status, and tal_pib.

Referenced by apply_channel_settings().

retval_t config_phy ( trx_id_t  trx_id)

Configures the PHY.

This function configures the PHY related settings.

Parameters
trx_idTransceiver identifier
Returns
MAC_SUCCESS if the configuration was successful

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, and tal_pib.

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.

Parameters
trx_idTransceiver 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.

static retval_t set_channel ( trx_id_t  trx_id,
uint16_t  ch 
)
static

Sets the provided channel.

Parameters
trx_idTransceiver identifier
chChannel number
Returns
MAC_SUCCESS if setting was successful else MAC_INVALID_PARAMETER

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)
static retval_t set_phy_based_on_channel_page ( trx_id_t  trx_id,
ch_pg_t  pg 
)
static

Sets PHY based on provided channel page.

Parameters
trx_idTransceiver identifier
pgChannel page
Returns
MAC_SUCCESS if setting was successful else MAC_INVALID_PARAMETER

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 void set_tx_pwr ( trx_id_t  trx_id,
int8_t  tx_pwr 
)
static

Sets the transmit power.

Parameters
trx_idTransceiver identifier
tx_pwrTransmit power in dBm

References RF_BASE_ADDR_OFFSET, SR_RF09_PAC_TXPWR, and tal_pib.

Referenced by tal_pib_set().

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.

Parameters
trx_idTransceiver identifier
attributeTAL infobase attribute ID
valueTAL infobase attribute value to be set
Returns
  • MAC_UNSUPPORTED_ATTRIBUTE if the TAL info base attribute is not found
  • TAL_BUSY if the TAL is not in TAL_IDLE state. An exception is macBeaconTxTime which can be accepted by TAL even if TAL is not in TAL_IDLE state.
  • MAC_SUCCESS if the attempt to set the PIB attribute was successful
  • TAL_TRX_ASLEEP if trx is in SLEEP mode and access to trx is required

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, and trx_default_state.

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.

Parameters
attributeTAL infobase attribute ID
valueTAL infobase attribute value to be set
Returns
  • MAC_UNSUPPORTED_ATTRIBUTE if the TAL info base attribute is not found
  • TAL_BUSY if the TAL is not in TAL_IDLE state. An exception is macBeaconTxTime which can be accepted by TAL even if TAL is not in TAL_IDLE state.
  • MAC_SUCCESS if the attempt to set the PIB attribute was successful
  • TAL_TRX_ASLEEP if trx is in SLEEP mode and access to trx is required

References MAC_SUCCESS, NUM_TRX, status, and tal_pib_set().

static void wait_for_freq_settling ( trx_id_t  trx_id)
static

Waits for frequency settling.

Parameters
trx_idTransceiver 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, and start_time.

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.

Parameters
trx_idTransceiver 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, and tal_rx_enable().