#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_t * | mac_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
trx_id | Transceiver 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, temp, trx_reg_read(), and trx_state.
Referenced by transmit_frame().
|
static |
Handles a transceiver error.
This function handles a TRXERR interrupt.
trx_id | Transceiver 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_reg_write(), trx_state, tx_done_handling(), TX_IDLE, and tx_state.
Referenced by tal_task().
void start_rpc | ( | trx_id_t | trx_id | ) |
SW workaround for errata reference 4841.
trx_id | Transceiver identifier |
References else, FSK, OQPSK, RF_BASE_ADDR_OFFSET, RG_BBC0_FSKPLL, RG_RF09_PLL, SR_BBC0_FSKC1_FSKPLH, SR_BBC0_FSKRPC_EN, SR_BBC0_OQPSKC2_RPC, SUPPORT_FSK, SUPPORT_OQPSK, tal_pib, trx_bit_write(), and trx_reg_write().
Referenced by conf_trx_modulation(), handle_rx_end_irq(), set_channel(), switch_to_rx(), tal_rx_enable(), and tx_done_handling().
void stop_rpc | ( | trx_id_t | trx_id | ) |
Stops RPC; SW workaround for errata reference 4841.
trx_id | Transceiver 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.
trx_id | Transceiver 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.
trx_id | Transceiver identifier |
References NULL, RF_BASE_ADDR_OFFSET, RF_RX, RG_RF09_CMD, start_rpc(), switch_to_txprep(), tal_buf_shortage, tal_rx_buffer, 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(), 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.
trx_id | Transceiver identifier |
References RF_BASE_ADDR_OFFSET, RF_TXPREP, RG_RF09_CMD, trx_reg_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_generate_rand_seed(), and tal_rx_enable().
void tal_task | ( | void | ) |
TAL task handling.
This function
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, ENTER_CRITICAL_REGION, handle_batmon_irq(), handle_ed_end_irq(), handle_rx_end_irq(), handle_trxerr(), handle_tx_end_irq(), LEAVE_CRITICAL_REGION, NULL, NUM_TRX, process_incoming_frame(), RF_IRQ_BATLOW, RF_IRQ_EDC, RF_IRQ_IQIFSF, RF_IRQ_TRXERR, RF_IRQ_TRXRDY, RF_IRQ_WAKEUP, switch_to_rx(), TAL_BB_IRQ_CLR, tal_bb_irqs, tal_buf_shortage, TAL_IDLE, tal_incoming_frame_queue, TAL_RF_IRQ_CLR, tal_rf_irqs, tal_rx_buffer, TAL_SLEEP, tal_state, TX_CCATX, and tx_state.
void wait_for_txprep | ( | trx_id_t | trx_id | ) |
Wait to reach TXPREP.
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, RF_TXPREP, RG_RF09_PLL, RG_RF09_STATE, start_time, state, trx_reg_read(), trx_reg_write(), and trx_state.
Referenced by switch_to_txprep().
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().
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] = {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.
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().
rf_cmd_state_t trx_state[NUM_TRX] |
Current trx state.
Referenced by apply_channel_settings(), cancel_any_reception(), cca_start(), conf_trx_modulation(), handle_incoming_frame(), handle_rx_end_irq(), handle_trxerr(), handle_tx_end_irq(), perf_get_req(), set_channel(), set_transceiver_state(), set_trx_state(), start_ack_wait_timer(), start_backoff(), switch_to_rx(), tal_generate_rand_seed(), tal_reset(), tal_rx_enable(), tal_trx_sleep(), tal_trx_wakeup(), transmit_frame(), trx_reset(), tx_done_handling(), and wait_for_txprep().
tx_state_t tx_state[NUM_TRX] |
Current state of the TX state machine.
Referenced by ack_transmission_done(), handle_ed_end_irq(), handle_incoming_frame(), handle_rx_end_irq(), handle_trxerr(), handle_tx_end_irq(), start_ack_wait_timer(), start_backoff(), tal_init(), tal_reset(), tal_task(), transmit_frame(), and tx_done_handling().
uint8_t txc[NUM_TRX][2] |
TX calibration values.
Referenced by switch_to_txprep().