Microchip® Advanced Software Framework

tal_internal.h File Reference

This header file contains types and variable definition that are used within the TAL only.

Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.

#include "tal_config.h"
#include "bmm.h"
#include "qmm.h"
#include "mac_build_config.h"
#include "tal.h"
#include "tal_rf215.h"

Macros

#define ACK_FRAME_TYPE_ONLY   (1 << FCF_FRAMETYPE_ACK)
 
#define CALC_REG_OFFSET(var)
 Defines to handle register offset. More...
 
#define DEFAULT_FRAME_TYPES
 
#define DEFAULT_TX_PWR_REG   20
 Register value for default transmit power. More...
 
#define GET_REG_ADDR   (reg)offset + reg
 
#define INVALID_TOF_VALUE   (0xFFFFFFFF)
 
#define MAX_PLL_LOCK_DURATION   200
 
#define PLL_FRZ_SETTLING_DURATION   20
 
#define POLL_TIME_GAP   10
 
#define TOF_PROC_DELAY_OFFSET_2_4_GHZ_NS   (573537)
 
#define TOF_PROC_DELAY_OFFSET_SUB_GHZ_NS   (583158)
 

Typedefs

typedef enum cca_use_tag cca_use_t
 Enumeration use as parameter for function transmit_frame() More...
 
typedef enum tal_state_tag tal_state_t
 Enumeration for tal_state. More...
 
typedef enum tx_state_tag tx_state_t
 Enumeration for tx_state. More...
 

Enumerations

enum  cca_use_tag {
  NO_CCA,
  WITH_CCA
}
 Enumeration use as parameter for function transmit_frame() More...
 
enum  tal_state_tag {
  TAL_IDLE,
  TAL_SLEEP,
  TAL_RESET,
  TAL_WAKING_UP,
  TAL_TX,
  TAL_ED_SCAN,
  TAL_TFA_CW_RX,
  TAL_TFA_CW,
  TAL_TFA_CCA
}
 Enumeration for tal_state. More...
 
enum  tx_state_tag {
  TX_IDLE,
  TX_BACKOFF,
  TX_CCATX,
  TX_TX,
  TX_WAITING_FOR_ACK,
  TX_DEFER
}
 Enumeration for tx_state. More...
 

Functions

void ack_transmission_done (trx_id_t trx_id)
 Handles end of ACK transmission. More...
 
uint16_t calculate_cca_duration_us (trx_id_t trx_id)
 Gets CCA duration. More...
 
void calculate_pib_values (trx_id_t trx_id)
 Calculates PIB values that depend on the current PHY configuration. More...
 
void cancel_any_reception (trx_id_t trx_id)
 Cancel any ongoing receive transaction incl. More...
 
void cca_done_handling (trx_id_t trx_id)
 
uint16_t ceiling_sym (trx_id_t trx_id, uint16_t duration_us)
 Implements the ceiling function for symbols. More...
 
void complete_rx_transaction (trx_id_t trx_id)
 Completes Rx transaction. More...
 
retval_t conf_fsk_data_rate (trx_id_t trx_id, fsk_sym_rate_t rate)
 
retval_t conf_trx_modulation (trx_id_t trx_id)
 Configure the transceiver w.r.t. More...
 
void config_fsk_rpc (trx_id_t trx_id, fsk_sym_rate_t sym_rate)
 Configures reduced power consumption for FSK. More...
 
retval_t config_phy (trx_id_t trx_id)
 Configures the PHY. More...
 
void continue_deferred_transmission (trx_id_t trx_id)
 Confinues with a deferred transmission. More...
 
void csma_continue (trx_id_t trx_id)
 Continues CSMA; handles next CSMA retry. More...
 
void csma_start (trx_id_t trx_id)
 Starts software-controlled CSMA. More...
 
retval_t fsk_rfcfg (fsk_mod_type_t mod_type, fsk_sym_rate_t srate, mod_idx_t mod_idx, trx_id_t trx_id)
 Configures RF according FSK. More...
 
uint16_t get_AckTiming_us (trx_id_t trx_id)
 Gets the ACK timing in us. More...
 
uint16_t get_AckWaitDuration_us (trx_id_t trx_id)
 Gets the AckWaitDuration in us. More...
 
uint16_t get_cca_duration_us (trx_id_t trx_id)
 Gets the CCA duration in us. More...
 
int8_t get_cca_thres (trx_id_t trx_id)
 Gets the CCA threshold. More...
 
void get_ch_freq0_spacing (trx_id_t trx_id, uint32_t *freq, uint32_t *spacing)
 
float get_data_rate (trx_id_t trx_id)
 Gets PSDU data rate. More...
 
retval_t get_supported_channels_tuple (trx_id_t trx_id, uint32_t *value)
 Gets ACK duration. More...
 
void handle_batmon_irq (void)
 
void handle_ed_end_irq (trx_id_t trx_id)
 Handles ED scan end interrupt. More...
 
void handle_rx_end_irq (trx_id_t trx_id)
 Handle received frame interrupt. More...
 
void handle_tx_end_irq (trx_id_t trx_id)
 Handles interrupts issued due to end of transmission. More...
 
void init_tal_pib (trx_id_t trx_id)
 Initialize the TAL PIB. More...
 
bool is_ack_valid (trx_id_t trx_id)
 Checks if received ACK is an valid ACK frame. More...
 
bool is_frame_an_ack (trx_id_t trx_id)
 Checks if received frame is an ACK frame. More...
 
retval_t ofdm_rfcfg (ofdm_option_t ofdm_opt, trx_id_t trx_id)
 Configures RF according MR-OFDM. More...
 
retval_t oqpsk_rfcfg (oqpsk_chip_rate_t chip_rate, trx_id_t trx_id)
 Configures RF according MR-OQPSK. More...
 
uint8_t phr_duration_sym (trx_id_t trx_id)
 Gets the PHR duration. More...
 
void process_incoming_frame (trx_id_t trx_id, buffer_t *buf)
 Parses received frame and create the frame_info_t structure. More...
 
uint8_t scale_ed_value (int8_t ed)
 Scale ED value. More...
 
void set_ed_sample_duration (trx_id_t trx_id, uint16_t sample_duration_us)
 Sets the energy measurement duration. More...
 
void set_fsk_pibs (trx_id_t trx_id)
 Sets FSK related PIBs. More...
 
void set_sfd (trx_id_t trx_id)
 Configures SFDs. More...
 
uint8_t shr_duration_sym (trx_id_t trx_id)
 Gets the SHR duration. More...
 
void start_ack_wait_timer (trx_id_t trx_id)
 Starts the timer to wait for an ACK reception. More...
 
void start_rpc (trx_id_t trx_id)
 SW workaround for errata reference 4841. More...
 
void stop_ed_scan (trx_id_t trx_id)
 Stops ED Scan. More...
 
void stop_rpc (trx_id_t trx_id)
 Stops RPC; SW workaround for errata reference 4841. More...
 
void stop_tal_timer (trx_id_t trx_id)
 Stops TAL timer. More...
 
void switch_to_rx (trx_id_t trx_id)
 Switches the transceiver to Rx. More...
 
void switch_to_txprep (trx_id_t trx_id)
 Switches the transceiver to TxPREP. More...
 
void transmit_frame (trx_id_t trx_id, cca_use_t cca)
 Transmits frame. More...
 
void trx_config (trx_id_t trx_id)
 Configures the transceiver. More...
 
void trx_irq_handler_cb (void)
 Transceiver interrupt handler. More...
 
void tx_done_handling (trx_id_t trx_id, retval_t status)
 Implements the handling of the transmission end. More...
 
void wait_for_txprep (trx_id_t trx_id)
 Wait to reach TXPREP. More...
 
void write_all_tal_pib_to_trx (trx_id_t trx_id)
 Write all shadow PIB variables to the transceiver. More...
 

Variables

bool ack_transmitting [NUM_TRX]
 Flag indicating ongoing ACK transmission. More...
 
bool frame_buf_filled [NUM_TRX]
 
frame_info_tmac_frame_ptr [NUM_TRX]
 Frame pointer for the frame structure provided by the MCL. More...
 
frame_info_trx_frm_info [NUM_TRX]
 
uint32_t rxe_txe_tstamp [NUM_TRX]
 Timestamp for end of reception, i.e. More...
 
volatile bb_irq_t tal_bb_irqs [NUM_TRX]
 Shadow variable for BB IRQS; variable is filled during TRX ISR, see trx_irq_handler_cb() in tal_irq_handler.c. More...
 
bool tal_buf_shortage [NUM_TRX]
 Indicates if a buffer shortage issue needs to handled by tal_task(). More...
 
int8_t tal_current_ed_val [NUM_TRX]
 Last retrieved energy value; variable is filled by handle_ed_end_irq() in tal_ed.c. More...
 
uint8_t * tal_frame_to_tx [NUM_TRX]
 Pointer to the 15.4 frame created by the TAL to be handed over to the transceiver. More...
 
queue_t tal_incoming_frame_queue [NUM_TRX]
 Queue that contains all frames that are uploaded from the trx, but have not be processed by the MCL yet. More...
 
volatile rf_irq_t tal_rf_irqs [NUM_TRX]
 Shadow variable for RF IRQS; variable is filled during TRX ISR, see trx_irq_handler_cb() in tal_irq_handler.c. More...
 
buffer_ttal_rx_buffer [NUM_TRX]
 Pointer to receive buffer that can be used to upload a frame from the trx. More...
 
tal_state_t tal_state [NUM_TRX]
 Current state of the TAL state machine. More...
 
const uint8_t timer_cb_parameter [NUM_TRX]
 Parameter to handle timer callback functions. More...
 
rf_cmd_state_t trx_default_state [NUM_TRX]
 Default/Previous trx state while entering a transaction. More...
 
rf_cmd_state_t trx_state [NUM_TRX]
 Current trx state. More...
 
tx_state_t tx_state [NUM_TRX]
 Current state of the TX state machine. More...
 
uint8_t txc [NUM_TRX][2]
 TX calibration values. More...
 

#define ACK_FRAME_TYPE_ONLY   (1 << FCF_FRAMETYPE_ACK)
#define CALC_REG_OFFSET (   var)
Value:
uint16_t offset \
#define RF_BASE_ADDR_OFFSET
Register offset between RF09 and TRX24.
Definition: tal_rf215.h:103

Defines to handle register offset.

#define DEFAULT_FRAME_TYPES
Value:
#define FCF_FRAMETYPE_MAC_CMD
Define the command frame type.
Definition: ieee_const.h:1053
#define FCF_FRAMETYPE_BEACON
Defines the beacon frame type.
Definition: ieee_const.h:1038
#define FCF_FRAMETYPE_DATA
Define the data frame type.
Definition: ieee_const.h:1043

Referenced by ack_timout_cb(), and handle_incoming_frame().

#define DEFAULT_TX_PWR_REG   20

Register value for default transmit power.

Referenced by conf_trx_modulation(), fsk_rfcfg(), ofdm_rfcfg(), and oqpsk_rfcfg().

#define GET_REG_ADDR   (reg)offset + reg
#define INVALID_TOF_VALUE   (0xFFFFFFFF)

Referenced by tx_done_handling().

#define MAX_PLL_LOCK_DURATION   200
#define PLL_FRZ_SETTLING_DURATION   20
#define POLL_TIME_GAP   10
#define TOF_PROC_DELAY_OFFSET_2_4_GHZ_NS   (573537)
#define TOF_PROC_DELAY_OFFSET_SUB_GHZ_NS   (583158)

typedef enum cca_use_tag cca_use_t

Enumeration use as parameter for function transmit_frame()

typedef enum tal_state_tag tal_state_t

Enumeration for tal_state.

typedef enum tx_state_tag tx_state_t

Enumeration for tx_state.

Enumeration use as parameter for function transmit_frame()

Enumerator
NO_CCA 
WITH_CCA 

Enumeration for tal_state.

Enumerator
TAL_IDLE 
TAL_SLEEP 
TAL_RESET 
TAL_WAKING_UP 
TAL_TX 
TAL_ED_SCAN 
TAL_TFA_CW_RX 
TAL_TFA_CW 
TAL_TFA_CCA 

Enumeration for tx_state.

Enumerator
TX_IDLE 
TX_BACKOFF 
TX_CCATX 
TX_TX 
TX_WAITING_FOR_ACK 
TX_DEFER 

void ack_transmission_done ( trx_id_t  trx_id)

Handles end of ACK transmission.

This function is called with the TXFE IRQ. It handles further processing after an ACK has been transmitted.

Parameters
trx_idId of the corresponding trx

References ack_transmitting, Assert, complete_rx_transaction(), continue_deferred_transmission(), FSK, RF_BASE_ADDR_OFFSET, RG_BBC0_FSKPLL, SR_BBC0_FSKC1_FSKPLH, switch_to_rx(), tal_pib, trx_bit_write(), trx_reg_write(), TX_DEFER, TX_IDLE, and tx_state.

Referenced by handle_tx_end_irq().

uint16_t calculate_cca_duration_us ( trx_id_t  trx_id)

Gets CCA duration.

Parameters
trx_idTransceiver identifier
Returns
CCA duration in us

References tal_pib.

Referenced by get_cca_duration_us(), and tal_pib_set().

void cancel_any_reception ( trx_id_t  trx_id)

Cancel any ongoing receive transaction incl.

ACK transmission

Parameters
trx_idTransceiver identifier

References ack_transmitting, Assert, ENTER_TRX_REGION, LEAVE_TRX_REGION, NUM_TRX, RF09, RF_TXPREP, RG_BBC0_IRQS, RG_BBC1_IRQS, RG_RF09_IRQS, RG_RF24_IRQS, stop_rpc(), switch_to_txprep(), TAL_BB_IRQ_CLR_ALL, TAL_RF_IRQ_CLR_ALL, trx_reg_read(), and trx_state.

Referenced by transmit_frame().

void cca_done_handling ( trx_id_t  trx_id)

Referenced by handle_ed_end_irq().

uint16_t ceiling_sym ( trx_id_t  trx_id,
uint16_t  duration_us 
)

Implements the ceiling function for symbols.

Returns the smallest integer value in symbols greater or equal to its argument value see section 9.2, pg. 43

Parameters
trx_idTransceiver identifier
duration_usSymbol duration in us
Returns
Number of symbols

References tal_pib.

Referenced by get_AckTiming_us(), and get_AckWaitDuration_us().

retval_t conf_fsk_data_rate ( trx_id_t  trx_id,
fsk_sym_rate_t  rate 
)
retval_t conf_trx_modulation ( trx_id_t  trx_id)

Configure the transceiver w.r.t.

modulation

Parameters
trx_idTransceiver identifier
Returns
MAC_SUCCESS if setting could be executed, else MAC_INVALID_PARAMETER

References BB_IRQ_AGCH, BB_IRQ_AGCR, BB_IRQ_RXFS, conf_fsk(), conf_leg_oqpsk(), conf_ofdm(), conf_oqpsk(), DEFAULT_TX_PWR_REG, FSK, LEG_OQPSK, MAC_INVALID_PARAMETER, OFDM, OQPSK, RF_BASE_ADDR_OFFSET, RF_RX, RF_TRXOFF, RF_TXPREP, RG_BBC0_IRQM, RG_RF09_CMD, RG_RF09_STATE, start_rpc(), stop_rpc(), switch_to_rx(), switch_to_txprep(), tal_pib, trx_reg_read(), trx_reg_write(), and trx_state.

Referenced by config_phy(), and tal_pib_set().

void config_fsk_rpc ( trx_id_t  trx_id,
fsk_sym_rate_t  sym_rate 
)
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, tal_pib, trx_bit_write(), trx_reg_write(), and trx_write().

Referenced by set_phy_based_on_channel_page(), tal_init(), tal_pib_set(), tal_reset(), and tal_trx_wakeup().

void continue_deferred_transmission ( trx_id_t  trx_id)

Confinues with a deferred transmission.

Parameters
trx_idTransceiver identifier

References Assert, csma_start(), CSMA_UNSLOTTED, global_csma_mode, MAC_CHANNEL_ACCESS_FAILURE, NO_CCA, NUM_TRX, tal_pib, transmit_frame(), and tx_done_handling().

Referenced by ack_transmission_done().

void csma_continue ( trx_id_t  trx_id)

Continues CSMA; handles next CSMA retry.

Parameters
trx_idTransceiver identifier

References BE, MAC_CHANNEL_ACCESS_FAILURE, NB, start_backoff(), tal_pib, and tx_done_handling().

Referenced by cca_start(), and handle_tx_end_irq().

void csma_start ( trx_id_t  trx_id)

Starts software-controlled CSMA.

Parameters
trx_idTransceiver identifier

References BE, NB, NO_CCA, start_backoff(), tal_pib, and transmit_frame().

Referenced by continue_deferred_transmission(), tal_tx_frame(), and tx_done_handling().

retval_t fsk_rfcfg ( fsk_mod_type_t  mod_type,
fsk_sym_rate_t  srate,
mod_idx_t  mod_idx,
trx_id_t  trx_id 
)

Configures RF according FSK.

Parameters
mod_typeModulation order / type; i.e. F2FSK or F4FSK
srateSymbol rate
mod_idxModulation index
trx_idTransceiver identifier

References AGCC_AGCI_MASK, AGCC_AGCI_SHIFT, AGCC_AVGS_MASK, AGCC_AVGS_SHIFT, bb_blk_write, DEFAULT_TX_PWR_REG, FSKDM_EN_SHIFT, FSKDM_PE_SHIFT, get_agc_settling_period(), MAC_SUCCESS, PAC_PACUR_SHIFT, PAC_TXPWR_SHIFT, PGM_READ_BLOCK, PGM_READ_BYTE, RF09, RF_BASE_ADDR_OFFSET, rf_blk_write, RG_BBC0_FSKDM, RG_RF09_AGCC, RG_RF09_PAC, RG_RF09_RXBWC, RG_RF09_TXCUTC, RXDFE_SR_MASK, tal_pib, trx_reg_write(), and TXDFE_DM_SHIFT.

Referenced by conf_fsk().

uint16_t get_AckTiming_us ( trx_id_t  trx_id)

Gets the ACK timing in us.

Parameters
trx_idTransceiver identifier
Returns
ACK timing in us

References aMinTurnaroundTimeSUNPHY, aTurnaroundTime, ceiling_sym(), FSK, LEG_OQPSK, OFDM, OQPSK, PGM_READ_BYTE, and tal_pib.

Referenced by calculate_pib_values().

uint16_t get_AckWaitDuration_us ( trx_id_t  trx_id)

Gets the AckWaitDuration in us.

Parameters
trx_idTransceiver identifier
Returns
AckWaitDuration in us

References aMinTurnaroundTimeSUNPHY, ceiling_sym(), F4FSK, FSK, LEG_OQPSK, OFDM, OQPSK, oqpsk_ack_psdu_duration_sym(), phr_duration_sym(), shr_duration_sym(), and tal_pib.

Referenced by calculate_pib_values().

uint16_t get_cca_duration_us ( trx_id_t  trx_id)

Gets the CCA duration in us.

Parameters
trx_idTransceiver identifier
Returns
CCA duration in us

References calculate_cca_duration_us(), FSK, JAPAN_920, LEG_OQPSK, OFDM, OQPSK, PGM_READ_BYTE, and tal_pib.

Referenced by calculate_pib_values().

int8_t get_cca_thres ( trx_id_t  trx_id)

Gets the CCA threshold.

Parameters
trx_idTransceiver identifier
Returns
CCA threshold in dBm

References FK_CCA_THRES_FEC_OFFSET, FSK, LEG_OQPSK, OFDM, OQPSK, OQPSK_CCA_THRES, PGM_READ_BYTE, and tal_pib.

Referenced by calculate_pib_values().

void get_ch_freq0_spacing ( trx_id_t  trx_id,
uint32_t *  freq,
uint32_t *  spacing 
)
float get_data_rate ( trx_id_t  trx_id)

Gets PSDU data rate.

Parameters
trx_idTransceiver identifier
Returns
data rate in kbit/s

References CHIP_RATE_1000, F4FSK, FSK, LEG_OQPSK, OFDM, OQPSK, oqpsk_get_chip_rate(), oqpsk_spreading(), PGM_READ_BYTE, PGM_READ_WORD, and tal_pib.

Referenced by calculate_pib_values().

retval_t get_supported_channels_tuple ( trx_id_t  trx_id,
uint32_t *  value 
)

Gets ACK duration.

Parameters
trx_idTransceiver identifier
Returns
ACK duration in symbols Gets the supported channels

The lowest 16bits contain the lowest supported channel number and the highest 16bits contains the highest supported channel number.

Parameters
[in]trx_idTransceiver identifier
[out]valuePointer to tuple (32bits) storage location
Returns
MAC_SUCCESS, MAC_UNSUPPORTED_ATTRIBUTE, MAC_INVALID_PARAMETER

References CHINA_470, CHINA_780, FSK, LEG_OQPSK, MAC_INVALID_PARAMETER, MAC_SUCCESS, MAC_UNSUPPORTED_ATTRIBUTE, OFDM, OQPSK, RF09, tal_pib, and US_915.

Referenced by calculate_pib_values(), init_tal_pib(), set_phy_based_on_channel_page(), and tal_pib_set().

void handle_batmon_irq ( void  )

References irq_hdl_batmon.

Referenced by tal_task().

void handle_ed_end_irq ( trx_id_t  trx_id)
void handle_rx_end_irq ( trx_id_t  trx_id)
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.

Referenced by tal_init(), and tal_reset().

bool is_ack_valid ( trx_id_t  trx_id)

Checks if received ACK is an valid ACK frame.

Parameters
trx_idTransceiver identifier
Returns
true if ACK frame is valid, else false

References mac_frame_ptr, and rx_frm_info.

Referenced by handle_incoming_frame().

bool is_frame_an_ack ( trx_id_t  trx_id)

Checks if received frame is an ACK frame.

Parameters
trx_idTransceiver identifier
Returns
true if frame is an ACK frame, else false

References FCF1_FV_SHIFT, FCF_FRAME_VERSION_2006, FCF_FRAMETYPE_ACK, and rx_frm_info.

Referenced by handle_incoming_frame().

uint8_t phr_duration_sym ( trx_id_t  trx_id)

Gets the PHR duration.

see pg. 46

Parameters
trx_idTransceiver identifier
Returns
PHR duration in symbols

References FSK, LEG_OQPSK, OFDM, OFDM_OPT_1, OFDM_OPT_2, OQPSK, and tal_pib.

Referenced by get_AckWaitDuration_us().

void process_incoming_frame ( trx_id_t  trx_id,
buffer_t buf_ptr 
)

Parses received frame and create the frame_info_t structure.

This function parses the received frame and creates the frame_info_t structure to be sent to the MAC as a parameter of tal_rx_frame_cb().

Parameters
trx_idTransceiver identifier
buf_ptrPointer to the buffer containing the received frame

References BMM_BUFFER_POINTER, frame_info_tag::buffer_header, frame_info_tag::len_no_crc, frame_info_tag::mpdu, scale_ed_value(), tal_pib, and tal_rx_frame_cb().

Referenced by tal_task().

uint8_t scale_ed_value ( int8_t  ed)

Scale ED value.

This function scales the trx ED value to the range 0x00 - 0xFF.

Parameters
edRF215 register value EDV.
Returns
Scaled ED value

References LOWER_ED_LIMIT, and UPPER_ED_LIMIT.

Referenced by process_incoming_frame().

void set_ed_sample_duration ( trx_id_t  trx_id,
uint16_t  sample_duration_us 
)

Sets the energy measurement duration.

Parameters
trx_idTransceiver identifier
sample_duration_usSample duration in us

References RF_BASE_ADDR_OFFSET, RG_RF09_EDD, and trx_reg_write().

Referenced by config_phy(), handle_ed_end_irq(), tal_ed_start(), and tal_pib_set().

void set_sfd ( trx_id_t  trx_id)

Configures SFDs.

Parameters
trx_idTransceiver identifier

References F2FSK_SFD_0_CODED, F2FSK_SFD_0_UNCODED, F2FSK_SFD_1_CODED, F2FSK_SFD_1_UNCODED, RF_BASE_ADDR_OFFSET, RG_BBC0_FSKSFD0L, tal_pib, and trx_write().

Referenced by conf_fsk(), and tal_pib_set().

uint8_t shr_duration_sym ( trx_id_t  trx_id)

Gets the SHR duration.

Parameters
trx_idTransceiver identifier
Returns
SHR duration in symbols

References FSK, LEG_OQPSK, OFDM, OQPSK, PGM_READ_BYTE, and tal_pib.

Referenced by get_AckWaitDuration_us().

void start_ack_wait_timer ( trx_id_t  trx_id)
void stop_ed_scan ( trx_id_t  trx_id)

Stops ED Scan.

This function stops an ED Scan and completes it by calling tal_ed_end_cb().

Parameters
trx_idTransceiver identifier

References handle_ed_end_irq(), RF_BASE_ADDR_OFFSET, RF_EDAUTO, RF_IRQ_EDC, sampler_counter, SR_RF09_EDC_EDM, TAL_RF_IRQ_CLR, and trx_bit_write().

Referenced by handle_trxerr().

void stop_rpc ( trx_id_t  trx_id)

Stops RPC; SW workaround for errata reference 4841.

Parameters
trx_idTransceiver identifier

References FSK, OQPSK, RF_BASE_ADDR_OFFSET, RG_BBC0_FSKPLL, RG_RF09_PLL, SR_BBC0_FSKC1_FSKPLH, SR_BBC0_FSKRPC_EN, SR_BBC0_OQPSKC2_RPC, tal_pib, trx_bit_write(), and trx_reg_write().

Referenced by cancel_any_reception(), conf_trx_modulation(), handle_rx_end_irq(), set_channel(), and tal_rx_enable().

void stop_tal_timer ( trx_id_t  trx_id)

Stops TAL timer.

Parameters
trx_idTransceiver identifier

References pal_timer_stop(), RF09, TAL_T_0, and TAL_T_1.

Referenced by cleanup_tal(), handle_incoming_frame(), handle_rx_end_irq(), and handle_trxerr().

void switch_to_rx ( trx_id_t  trx_id)

Switches the transceiver to Rx.

This function tries to switch the transceiver to Rx. It checks if a Rx buffer is available. Only if a buffer is available, the receiver is actually switched on. If no buffer is available, the tal_buf_shortage flag is set. This buffer shortage issue is tried to solve within tal_task() again.

Parameters
trx_idTransceiver identifier

References RF_BASE_ADDR_OFFSET, RF_RX, RG_RF09_CMD, start_rpc(), switch_to_txprep(), tal_buf_shortage, trx_reg_write(), and trx_state.

Referenced by ack_transmission_done(), conf_trx_modulation(), handle_ed_end_irq(), handle_incoming_frame(), handle_rx_end_irq(), handle_tx_end_irq(), set_channel(), tal_rx_enable(), tal_task(), tfa_cca_perform(), tfa_continuous_tx_stop(), and tx_done_handling().

void switch_to_txprep ( trx_id_t  trx_id)

Switches the transceiver to TxPREP.

This function switches the transceiver to TxPREP and waits until it has has reached this state. Do not call this function within an ISR.

Parameters
trx_idTransceiver identifier

References RF_BASE_ADDR_OFFSET, RF_TXPREP, RG_RF09_CMD, trx_reg_write(), trx_write(), txc, and wait_for_txprep().

Referenced by ack_timout_cb(), cancel_any_reception(), conf_trx_modulation(), handle_tx_end_irq(), set_channel(), set_transceiver_state(), start_backoff(), switch_to_rx(), tal_ed_start(), tal_generate_rand_seed(), tal_rx_enable(), tfa_cca_perform(), tfa_continuous_tx_start(), and tfa_continuous_tx_stop().

void trx_irq_handler_cb ( void  )

Transceiver interrupt handler.

This function handles the transceiver interrupt. It reads all IRQs from the transceivers and stores them to a variable. If a transceiver is currently sleeping, then the IRQs are not handled. The actual processing of the IRQs is triggered from tal_task().

References BB_IRQ_AGCH, BB_IRQ_AGCR, BB_IRQ_NO_IRQ, BB_IRQ_RXAM, BB_IRQ_RXEM, BB_IRQ_RXFE, BB_IRQ_RXFS, BB_IRQ_TXFE, BB_RX_FRM_BUF_OFFSET, FCF_ACK_REQUEST, NUM_TRX, pal_get_current_time(), RF_BASE_ADDR_OFFSET, RF_IRQ_BATLOW, RF_IRQ_EDC, RF_IRQ_IQIFSF, RF_IRQ_NO_IRQ, RF_IRQ_TRXERR, RF_IRQ_TRXRDY, RF_IRQ_WAKEUP, RG_BBC0_FBRXS, RG_RF09_IRQS, rxe_txe_tstamp, SR_BBC0_AMCS_AACK, tal_bb_irqs, tal_rf_irqs, TAL_SLEEP, tal_state, trx_bit_write(), trx_read(), and trx_reg_read().

Referenced by tal_init(), tal_reset(), and trx_reset().

void tx_done_handling ( trx_id_t  trx_id,
retval_t  status 
)
void wait_for_txprep ( trx_id_t  trx_id)
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, tal_rx_enable(), trx_bit_write(), and trx_write().

Referenced by tal_init(), tal_reset(), and tal_trx_wakeup().

bool ack_transmitting[NUM_TRX]

Flag indicating ongoing ACK transmission.

Referenced by ack_transmission_done(), cancel_any_reception(), cca_start(), handle_incoming_frame(), and handle_tx_end_irq().

bool frame_buf_filled[NUM_TRX]

Referenced by tal_tx_frame(), and transmit_frame().

frame_info_t* mac_frame_ptr[NUM_TRX]

Frame pointer for the frame structure provided by the MCL.

Referenced by is_ack_valid(), tal_tx_frame(), transmit_frame(), and tx_done_handling().

frame_info_t* rx_frm_info[NUM_TRX]

Referenced by is_ack_valid(), and is_frame_an_ack().

uint32_t rxe_txe_tstamp[NUM_TRX]

Timestamp for end of reception, i.e.

RXFE IRQ; used during Rx transaction to calculate ACK transmission time. Timestamp for end of transmission; used during Tx transaction to calculate ACK timeout. Both scenarios use the same variable

Referenced by handle_ifs(), handle_tx_end_irq(), and trx_irq_handler_cb().

volatile bb_irq_t tal_bb_irqs[NUM_TRX]

Shadow variable for BB IRQS; variable is filled during TRX ISR, see trx_irq_handler_cb() in tal_irq_handler.c.

Referenced by tal_task(), and trx_irq_handler_cb().

bool tal_buf_shortage[NUM_TRX]

Indicates if a buffer shortage issue needs to handled by tal_task().

Referenced by cleanup_tal(), switch_to_rx(), tal_rx_enable(), tal_task(), and tal_trx_sleep().

int8_t tal_current_ed_val[NUM_TRX]

Last retrieved energy value; variable is filled by handle_ed_end_irq() in tal_ed.c.

Referenced by handle_ed_end_irq(), and tfa_cca_perform().

uint8_t* tal_frame_to_tx[NUM_TRX]

Pointer to the 15.4 frame created by the TAL to be handed over to the transceiver.

Referenced by tal_tx_frame().

queue_t tal_incoming_frame_queue[NUM_TRX]

Queue that contains all frames that are uploaded from the trx, but have not be processed by the MCL yet.

Referenced by cleanup_tal(), complete_rx_transaction(), init_after_disconnect(), and tal_init().

volatile rf_irq_t tal_rf_irqs[NUM_TRX]

Shadow variable for RF IRQS; variable is filled during TRX ISR, see trx_irq_handler_cb() in tal_irq_handler.c.

Referenced by tal_task(), and trx_irq_handler_cb().

buffer_t* tal_rx_buffer[NUM_TRX]

Pointer to receive buffer that can be used to upload a frame from the trx.

Referenced by cleanup_tal(), complete_rx_transaction(), init_after_disconnect(), tal_init(), tal_trx_sleep(), tal_trx_wakeup(), and upload_frame().

const uint8_t timer_cb_parameter[NUM_TRX]

Parameter to handle timer callback functions.

rf_cmd_state_t trx_default_state[NUM_TRX]

Default/Previous trx state while entering a transaction.

Referenced by handle_ed_end_irq(), handle_trxerr(), start_backoff(), tal_ed_start(), tal_pib_set(), tal_rx_enable(), and tx_done_handling().

uint8_t txc[NUM_TRX][2]

TX calibration values.

Referenced by switch_to_txprep().