Microchip® Advanced Software Framework

at86rf215/inc/tal_internal.h File Reference
#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 = 0,
  TAL_TX_AUTO = 1,
  TAL_TX_DONE = 2,
  TAL_SLOTTED_CSMA = 3,
  TAL_IDLE = 0,
  TAL_TX_AUTO = 1,
  TAL_TX_DONE = 2,
  TAL_SLOTTED_CSMA = 3,
  TAL_IDLE = 0,
  TAL_TX_AUTO = 1,
  TAL_TX_DONE = 2,
  TAL_SLOTTED_CSMA = 3,
  TAL_IDLE,
  TAL_SLEEP,
  TAL_RESET,
  TAL_WAKING_UP,
  TAL_TX,
  TAL_ED_SCAN,
  TAL_TFA_CW_RX,
  TAL_TFA_CW,
  TAL_TFA_CCA,
  TAL_IDLE = 0,
  TAL_TX_AUTO = 1,
  TAL_TX_DONE = 2,
  TAL_SLOTTED_CSMA = 3,
  TAL_IDLE = 0,
  TAL_TX_AUTO = 1,
  TAL_TX_DONE = 2,
  TAL_SLOTTED_CSMA = 3
}
 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)
 The peak_ed_level is the maximum ED value received from the transceiver for the specified Scan Duration. 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)
 
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 trx_irq_timestamp_handler_cb (void)
 
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]
 
uint32_t fs_tstamp [NUM_TRX]
 Frame start time stamp During Tx transaction it stores the time when the frame is actually send, i.e. More...
 
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_t * tal_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 \
float32_t var
Definition: arm_class_marks_example_f32.c:150
#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_TX_AUTO 
TAL_TX_DONE 
TAL_SLOTTED_CSMA 
TAL_IDLE 
TAL_TX_AUTO 
TAL_TX_DONE 
TAL_SLOTTED_CSMA 
TAL_IDLE 
TAL_TX_AUTO 
TAL_TX_DONE 
TAL_SLOTTED_CSMA 
TAL_IDLE 
TAL_SLEEP 
TAL_RESET 
TAL_WAKING_UP 
TAL_TX 
TAL_ED_SCAN 
TAL_TFA_CW_RX 
TAL_TFA_CW 
TAL_TFA_CCA 
TAL_IDLE 
TAL_TX_AUTO 
TAL_TX_DONE 
TAL_SLOTTED_CSMA 
TAL_IDLE 
TAL_TX_AUTO 
TAL_TX_DONE 
TAL_SLOTTED_CSMA 

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

Referenced by transmit_frame().

void cca_done_handling ( trx_id_t  trx_id)

Referenced by handle_ed_end_irq(), and tal_task().

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

void complete_rx_transaction ( trx_id_t  trx_id)

Completes Rx transaction.

Parameters
trx_idTransceiver identifier

References frame_info_tag::mpdu, NULL, RF_BASE_ADDR_OFFSET, RG_RF09_EDV, tal_incoming_frame_queue, tal_pib, and tal_rx_buffer.

Referenced by ack_transmission_done(), handle_incoming_frame(), and handle_rx_end_irq().

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(), status, stop_rpc(), switch_to_rx(), switch_to_txprep(), tal_pib, 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 
)

Configures reduced power consumption for FSK.

Parameters
trx_idTransceiver identifier
sym_rateSymbol rate

References FSK_SYM_RATE_100, FSK_SYM_RATE_150, FSK_SYM_RATE_200, FSK_SYM_RATE_300, FSK_SYM_RATE_400, FSK_SYM_RATE_50, RF_BASE_ADDR_OFFSET, RG_BBC0_FSKPLL, RG_BBC0_FSKRPC, SR_BBC0_FSKC1_FSKPLH, SR_BBC0_FSKC2_PDTM, SR_BBC0_FSKRPC_EN, and tal_pib.

Referenced by conf_fsk(), and tal_pib_set().

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 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(), handle_tx_end_irq(), and tal_task().

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, status, tal_pib, 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, status, 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  )

Referenced by tal_task().

void handle_ed_end_irq ( trx_id_t  trx_id)

The peak_ed_level is the maximum ED value received from the transceiver for the specified Scan Duration.

Starts ED Scan

This function starts an ED Scan for the scan duration specified by the MAC layer. The result is returned from the TAL by calling tal_ed_end_cb().

Parameters
trx_idTransceiver identifier
scan_durationSpecifies the ED scan duration in superframe duration
Returns
MAC_SUCCESS - ED scan duration timer started successfully TAL_BUSY - TAL is busy servicing the previous request from MAC TAL_TRX_ASLEEP - Transceiver is currently sleeping FAILURE otherwise Handles ED scan end interrupt

This function handles an ED done interrupt from the transceiver.

Parameters
trx_idTransceiver identifier

References cca_done_handling(), RF_BASE_ADDR_OFFSET, RF_EDAUTO, RF_RX, RF_TRXOFF, RG_RF09_CMD, RG_RF09_EDV, set_ed_sample_duration(), SR_BBC0_PC_BBEN, SR_RF09_EDC_EDM, SR_RF09_IRQM_EDC, switch_to_rx(), tal_current_ed_val, tal_ed_end_cb(), TAL_ED_SCAN, TAL_IDLE, tal_pib, tal_state, trx_default_state, and tx_state.

Referenced by tal_task().

void handle_rx_end_irq ( trx_id_t  trx_id)

Handle received frame interrupt.

This function handles transceiver interrupts for received frames.

Parameters
trx_idTransceiver identifier

References complete_rx_transaction(), FSK, handle_incoming_frame(), RF_BASE_ADDR_OFFSET, RF_RX, RG_RF09_CMD, SR_BBC0_AMCS_AACK, SR_BBC0_AMCS_AACKFT, SR_BBC0_FSKPHRRX_FCST, SR_BBC0_FSKPHRRX_MS, start_rpc(), stop_rpc(), stop_tal_timer(), switch_to_rx(), TAL_IDLE, tal_pib, tal_state, trx_state, TX_BACKOFF, TX_DEFER, tx_state, and upload_frame().

Referenced by tal_task().

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.

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 frame_info_tag::buffer_header, frame_info_tag::mpdu, scale_ed_value(), tal_pib, and tal_rx_frame_cb().

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

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

void set_fsk_pibs ( trx_id_t  trx_id)
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, and tal_pib.

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)

Starts the timer to wait for an ACK reception.

Parameters
trx_idId of the corresponding trx

References ACK_FRAME_TYPE_ONLY, ack_timout_cb(), Assert, FUNC_PTR, MAC_SUCCESS, pal_timer_start(), RF09, RF_BASE_ADDR_OFFSET, RF_RX, RF_TRXOFF, RG_BBC0_AFFTM, RG_RF09_CMD, status, tal_pib, TAL_T_0, TAL_T_1, trx_state, tx_done_handling(), tx_state, and TX_WAITING_FOR_ACK.

Referenced by handle_tx_end_irq().

void start_rpc ( trx_id_t  trx_id)
void stop_ed_scan ( trx_id_t  trx_id)

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

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 NULL, RF_BASE_ADDR_OFFSET, RF_RX, RG_RF09_CMD, start_rpc(), switch_to_txprep(), tal_buf_shortage, tal_rx_buffer, 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(), 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, 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_generate_rand_seed(), and tal_rx_enable().

void transmit_frame ( trx_id_t  trx_id,
cca_use_t  cca 
)

Transmits frame.

Parameters
trx_idTransceiver identifier
ccaIf WITH_CCA CCA is enforced, else no CCA is applied before transmission.

References ACK_FRAME_TYPE_ONLY, ack_requested, AMCS_CCATX_MASK, AMCS_TX2RX_MASK, BB_IRQ_TXFE, BB_TX_FRM_BUF_OFFSET, cancel_any_reception(), FAILURE, frame_buf_filled, fs_tstamp, last_txframe_length, mac_frame_ptr, pal_get_current_time(), pal_timer_delay, PC_BBEN_MASK, PC_TXAFCS_MASK, RF_BASE_ADDR_OFFSET, RF_EDSINGLE, RF_IRQ_EDC, RF_IRQ_TRXERR, RF_IRQ_TRXRDY, RF_RX, RF_TRXOFF, RF_TX, RG_BBC0_AFFTM, RG_BBC0_AMCS, RG_BBC0_FBTXS, RG_BBC0_PC, RG_BBC0_TXFLL, RG_RF09_CMD, RG_RF09_EDC, RG_RF09_STATE, SR_BBC0_PC_BBEN, SR_BBC0_PC_TXAFCS, SR_BBC0_PS_TXUR, TAL_BB_IRQ_CLR, tal_pib, TAL_RF_IRQ_CLR, trx_state, TX_CCATX, tx_done_handling(), tx_state, TX_TX, and WITH_CCA.

Referenced by cca_start(), continue_deferred_transmission(), csma_start(), handle_gts_data_req(), mac_tx_gts_data(), mcps_data_request(), mlme_gts_request(), process_deallocate_data_q(), range_test_frame_tx(), send_disconnect_command(), send_identify_command(), send_parameters_changed(), send_peer_conf(), send_peer_info_req(), send_peer_info_rsp(), send_peer_req(), send_peer_rsp(), send_per_test_start_cmd(), send_range_test_marker_cmd(), send_range_test_marker_rsp(), send_range_test_rsp(), send_range_test_start_cmd(), send_range_test_stop_cmd(), send_remote_cmd(), send_remote_reply_cmd(), send_result_req(), send_result_rsp(), send_set_default_config_command(), tal_tx_frame(), and tx_done_handling().

void trx_config ( trx_id_t  trx_id)
void trx_irq_timestamp_handler_cb ( void  )
void tx_done_handling ( trx_id_t  trx_id,
retval_t  status 
)

Implements the handling of the transmission end.

This function handles the callback for the transmission end.

Parameters
trx_idTransceiver identifier
statusStatus of the transmission: MAC_SUCCESS, MAC_NO_ACK, CHANNEL_ACCESS_FAILURE, FAILURE

References ack_requested, AMCS_AACK_MASK, csma_start(), CSMA_UNSLOTTED, fs_tstamp, global_csma_mode, handle_ifs(), INVALID_TOF_VALUE, LEG_OQPSK, mac_frame_ptr, MAC_NO_ACK, MAC_SUCCESS, NO_CCA, NO_CSMA_WITH_IFS, number_of_tx_retries, RF_BASE_ADDR_OFFSET, RF_RX, RF_TRXOFF, RG_BBC0_AMCS, RG_RF09_CMD, start_rpc(), switch_to_rx(), TAL_IDLE, tal_pib, tal_state, tal_tx_frame_done_cb(), frame_info_tag::time_stamp, transmit_frame(), trx_default_state, trx_state, TX_IDLE, and tx_state.

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

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

uint32_t fs_tstamp[NUM_TRX]

Frame start time stamp During Tx transaction it stores the time when the frame is actually send, i.e.

frame start. During Rx transaction it stores the time when the frame is actually received, i.e. frame end - RXFE.

Referenced by handle_tx_end_irq(), transmit_frame(), trx_irq_handler_cb(), tx_done_handling(), and upload_frame().

frame_info_t* mac_frame_ptr[NUM_TRX]

Frame pointer for the frame structure provided by the MCL.

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

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.

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.

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.

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_pib_set(), tal_rx_enable(), and tx_done_handling().

uint8_t txc[NUM_TRX][2]

TX calibration values.

Referenced by switch_to_txprep().