Microchip® Advanced Software Framework

at86rf215/src/tal.c File Reference
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include "pal.h"
#include "return_val.h"
#include "tal.h"
#include "ieee_const.h"
#include "tal_pib.h"
#include "tal_config.h"
#include "stack_config.h"
#include "bmm.h"
#include "qmm.h"
#include "tal_internal.h"
#include "mac_build_config.h"

Macros

#define AGC_LEG_OQPSK_DEAF_PERIOD   300
 

Functions

void cancel_any_reception (trx_id_t trx_id)
 Cancel any ongoing receive transaction incl. More...
 
static void handle_trxerr (trx_id_t trx_id)
 Handles a transceiver error. More...
 
void start_rpc (trx_id_t trx_id)
 SW workaround for errata reference 4841. 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 tal_task (void)
 TAL task handling. More...
 
void wait_for_txprep (trx_id_t trx_id)
 Wait to reach TXPREP. More...
 

Variables

bool ack_transmitting [NUM_TRX]
 Flag indicating ongoing ACK transmission. More...
 
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...
 
uint32_t rxe_txe_tstamp [NUM_TRX]
 Timestamp for end of reception, i.e. More...
 
volatile bb_irq_t tal_bb_irqs [NUM_TRX] = {BB_IRQ_NO_IRQ, BB_IRQ_NO_IRQ}
 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...
 
tal_pib_t tal_pib [NUM_TRX]
 TAL PIBs. More...
 
volatile rf_irq_t tal_rf_irqs [NUM_TRX] = {RF_IRQ_NO_IRQ, RF_IRQ_NO_IRQ}
 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] = {RF09, RF24}
 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 AGC_LEG_OQPSK_DEAF_PERIOD   300

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

static void handle_trxerr ( trx_id_t  trx_id)
static

Handles a transceiver error.

This function handles a TRXERR interrupt.

Parameters
trx_idTransceiver identifier

References FAILURE, PHY_RX_ON, RF_BASE_ADDR_OFFSET, RF_RX, RF_TRXOFF, RG_RF09_CMD, stop_ed_scan(), stop_tal_timer(), TAL_ED_SCAN, TAL_IDLE, tal_rx_enable(), tal_state, TAL_TX, trx_default_state, trx_state, tx_done_handling(), TX_IDLE, and tx_state.

Referenced by tal_task().

void start_rpc ( trx_id_t  trx_id)
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 wait_for_txprep ( trx_id_t  trx_id)

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

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.

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] = {BB_IRQ_NO_IRQ, BB_IRQ_NO_IRQ}

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.

tal_pib_t tal_pib[NUM_TRX]

TAL PIBs.

volatile rf_irq_t tal_rf_irqs[NUM_TRX] = {RF_IRQ_NO_IRQ, RF_IRQ_NO_IRQ}

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] = {RF09, RF24}

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