This file implements functions for initializing TAL and reset.
Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include "return_val.h"
#include "tal.h"
#include "ieee_const.h"
#include "tal_pib.h"
#include "stack_config.h"
#include "bmm.h"
#include "qmm.h"
#include "pal.h"
#include "tal_internal.h"
#include "tal_config.h"
#include "tfa.h"
#include "mac_build_config.h"
Functions | |
static void | cleanup_tal (trx_id_t trx_id) |
Stops all initialized TAL timers. More... | |
retval_t | tal_init (void) |
Initializes the TAL. More... | |
retval_t | tal_reset (trx_id_t trx_id, bool set_default_pib) |
Resets TAL state machine and sets the default PIB values if requested. More... | |
static retval_t | tal_timer_init (void) |
Initializes all timers used by the TAL module by assigning id's to each of them. More... | |
void | trx_config (trx_id_t trx_id) |
Configures the transceiver. More... | |
static void | trx_init (void) |
Initializes the transceiver. More... | |
retval_t | trx_reset (trx_id_t trx_id) |
Resets transceiver(s) More... | |
Variables | |
uint8_t | TAL_T_0 |
uint8_t | TAL_T_1 |
|
static |
Stops all initialized TAL timers.
Cleanup TAL.
trx_id | Transceiver identifier |
References bmm_buffer_alloc(), bmm_buffer_free(), BMM_BUFFER_POINTER, ENTER_CRITICAL_REGION, LARGE_BUFFER_SIZE, LEAVE_CRITICAL_REGION, qmm_queue_remove(), stop_tal_timer(), tal_buf_shortage, tal_incoming_frame_queue, tal_rx_buffer, and frame_info_tag::trx_id.
Referenced by tal_reset().
retval_t tal_init | ( | void | ) |
Initializes the TAL.
This function is called to initialize the TAL. The transceiver is initialized, the TAL PIBs are set to their default values, and the TAL state machine is set to TAL_IDLE state.
References bmm_buffer_alloc(), bmm_buffer_init(), BMM_BUFFER_POINTER, calculate_pib_values(), config_phy(), FAILURE, FUNC_PTR, init_tal_pib(), LARGE_BUFFER_SIZE, MAC_SUCCESS, NUM_TRX, pal_init(), pal_trx_irq_en, pal_trx_irq_flag_clr, qmm_queue_init(), RFBOTH, RG_RF_PN, RG_RF_VN, tal_generate_rand_seed(), TAL_IDLE, tal_incoming_frame_queue, tal_pib, tal_rx_buffer, tal_state, tal_timer_init(), trx_config(), frame_info_tag::trx_id, trx_init(), trx_irq_handler_cb(), trx_irq_init(), trx_reg_read(), trx_reset(), TX_IDLE, tx_state, and write_all_tal_pib_to_trx().
Referenced by init_state_init().
Resets TAL state machine and sets the default PIB values if requested.
trx_id | Transceiver identifier |
set_default_pib | Defines whether PIB values need to be set to its default values |
References calculate_pib_values(), cleanup_tal(), config_phy(), FAILURE, FUNC_PTR, init_tal_pib(), MAC_SUCCESS, NUM_TRX, pal_trx_irq_en, RF09, RF24, RF_SLEEP, RFBOTH, TAL_IDLE, tal_state, trx_config(), trx_init(), trx_irq_handler_cb(), trx_irq_init(), trx_reset(), trx_state, TX_IDLE, tx_state, and write_all_tal_pib_to_trx().
Referenced by set_transceiver_state().
|
static |
Initializes all timers used by the TAL module by assigning id's to each of them.
References FAILURE, MAC_SUCCESS, pal_timer_get_id(), TAL_T_0, and TAL_T_1.
Referenced by tal_init().
void trx_config | ( | trx_id_t | trx_id | ) |
Configures the transceiver.
This function is called to configure a certain transceiver (RF09 or RF24) after trx sleep or reset or power on.
trx_id | Transceiver identifier |
References AMCS_AACK_MASK, BB_IRQ_AGCH, BB_IRQ_AGCR, BB_IRQ_NO_IRQ, BB_IRQ_RXFE, BB_IRQ_RXFS, BB_IRQ_TXFE, CNTC_CAPRXS_MASK, CNTC_EN_MASK, CNTC_RSTRXS_MASK, CNTC_RSTTXS_MASK, RF_BASE_ADDR_OFFSET, RF_IRQ_BATLOW, RF_IRQ_EDC, RF_IRQ_IQIFSF, RF_IRQ_NO_IRQ, RF_IRQ_TRXERR, RF_IRQ_WAKEUP, RG_BBC0_AMAACKPD, RG_BBC0_AMCS, RG_BBC0_CNTC, RG_BBC0_IRQM, RG_RF09_AGCC, RG_RF09_IRQM, SR_BBC0_AFC0_AFEN0, SR_BBC0_FSKC4_RAWRBIT, SR_RF09_AUXS_AVEN, SR_RF_IQIFC0_EEC, SR_RF_IQIFC1_CHPM, trx_bit_write(), trx_reg_read(), and trx_reg_write().
Referenced by init_after_disconnect(), tal_init(), tal_reset(), and tal_trx_wakeup().
|
static |
Initializes the transceiver.
This function is called to initialize the general transceiver functionality after power or IC reset.
References SR_RF_CFG_IRQP, SR_RF_CLKO_OS, trx_bit_write(), and TRX_CLOCK_OUTPUT_SELECTION.
Referenced by tal_init(), and tal_reset().
Resets transceiver(s)
trx_id | Transceiver identifier |
References ENTER_TRX_REGION, FAILURE, HIGH, LEAVE_TRX_REGION, MAC_SUCCESS, NUM_TRX, pal_get_current_time(), pal_sub_time_us(), pal_trx_irq_flag_clr, PAL_WAIT_1_US, RF09, RF24, RF_BASE_ADDR_OFFSET, RF_IRQ_WAKEUP, RF_RESET, RF_TRXOFF, RFBOTH, RG_RF09_CMD, RG_RF09_STATE, RST_HIGH, RST_LOW, start_time, TAL_RESET, TAL_RF_IRQ_CLR, TAL_RF_IRQ_CLR_ALL, tal_state, TRX_IRQ_GET, trx_irq_handler_cb(), trx_reg_read(), trx_reg_write(), and trx_state.
Referenced by init_after_disconnect(), tal_init(), and tal_reset().
uint8_t TAL_T_0 |
Referenced by start_ack_wait_timer(), start_backoff(), stop_tal_timer(), and tal_timer_init().
uint8_t TAL_T_1 |
Referenced by start_ack_wait_timer(), start_backoff(), stop_tal_timer(), and tal_timer_init().