Driver for AT86RF212 transceiver.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
Functions | |
static void | generate_rand_seed (void) |
Generates a 16-bit random number used as initial seed for srand() More... | |
static void | handle_received_frame_irq (void) |
Handle received frame interrupt. More... | |
void | handle_tal_state (void) |
Handles the transceiver state. More... | |
static void | handle_tx_end_irq (void) |
Handles interrupts issued due to end of transmission. More... | |
static trx_retval_t | internal_tal_reset (void) |
Internal TAL reset function. More... | |
static tal_trx_status_t | set_trx_state (trx_cmd_t trx_cmd) |
Sets transceiver state. More... | |
static void | switch_pll_on (void) |
Switches the PLL on. More... | |
trx_retval_t | tal_init (void) |
Initializes the TAL. More... | |
static void | trx_config (void) |
Configures the transceiver. More... | |
static trx_retval_t | trx_init (void) |
Initializes the transceiver. More... | |
void | trx_irq_handler_cb (void) |
Transceiver interrupt handler. More... | |
static trx_retval_t | trx_reset (void) |
Reset transceiver. More... | |
static void | tx_end_handling (void) |
Implements the handling of the transmission end. More... | |
void | tx_frame_config (void) |
Configures the transceiver for frame transmission. More... | |
Variables | |
static tal_state_t | tal_state |
Current state of the TAL state machine. More... | |
static tal_trx_status_t | tal_trx_status |
Current state of the transceiver. More... | |
static trx_trac_status_t | trx_trac_status |
Keep track of transceiver status. More... | |
|
static |
Generates a 16-bit random number used as initial seed for srand()
This function generates a 16-bit random number by means of using the Random Number Generator from the transceiver. The Random Number Generator generates 2-bit random values. These 2-bit random values are concatenated to the required 16-bit random seed. For further information please check the SWPM AT86RF212.
The generated random 16-bit number is feed into function srand() as initial seed.
The transceiver state is initially set to RX_ON. After the completion of the random seed generation, the transceiver is set to TRX_OFF.
As a prerequisite the Preamble Detector must not be disabled. Since this function is called right after trx_reset(), the Preamble Detector has its original value, i.e. it is enabled. In case this function is used at a different point of time, having the proper value set must be checked additionally.
Also in case the function is called from a different state than TRX_OFF, additional trx state handling is required, such as reading the original value and restoring this state after finishing the sequence. Since in our case the function is called from TRX_OFF, this is not required here.
References CLEAR_TRX_IRQ, CMD_FORCE_TRX_OFF, CMD_RX_ON, ENTER_TRX_REGION, LEAVE_TRX_REGION, pal_trx_bit_read(), pal_trx_reg_read(), RG_IRQ_STATUS, set_trx_state(), and SR_RND_VALUE.
Referenced by internal_tal_reset().
|
static |
Handle received frame interrupt.
This function handles transceiver interrupts for received frames and uploads the frames from the trx.
References at86rfx_frame_rx, at86rfx_rx_buffer, CMD_RX_ON, CRC16_NOT_VALID, LENGTH_FIELD_LEN, pal_trx_bit_read(), pal_trx_frame_read(), PHY_MAX_LENGTH, set_trx_state(), and SR_RX_CRC_VALID.
Referenced by trx_irq_handler_cb().
|
static |
Handles interrupts issued due to end of transmission.
References CMD_RX_ON, set_trx_state(), tal_state, and TAL_TX_END.
Referenced by trx_irq_handler_cb().
|
static |
Internal TAL reset function.
References generate_rand_seed(), TAL_IDLE, tal_state, trx_config(), TRX_FAILURE, trx_reset(), and TRX_SUCCESS.
Referenced by tal_init().
|
static |
Sets transceiver state.
trx_cmd | needs to be one of the trx commands |
References Assert, CMD_FORCE_TRX_OFF, CMD_PLL_ON, CMD_RX_ON, pal_trx_bit_read(), pal_trx_reg_write(), PAL_WAIT_1_US, PLL_ON, RG_TRX_STATE, RX_ON, SR_TRX_STATUS, STATE_TRANSITION_IN_PROGRESS, switch_pll_on(), tal_trx_status, and TRX_OFF.
Referenced by generate_rand_seed(), handle_received_frame_irq(), handle_tx_end_irq(), and tx_frame_config().
|
static |
Switches the PLL on.
References Assert, CMD_PLL_ON, DELAY_US, pal_trx_bit_read(), pal_trx_reg_read(), pal_trx_reg_write(), PLL_LOCK_ATTEMPTS, RG_IRQ_STATUS, RG_TRX_STATE, SR_TRX_STATUS, TRX_IRQ_PLL_LOCK, TRX_OFF, and TRX_OFF_TO_PLL_ON_TIME_US.
Referenced by set_trx_state().
|
static |
Configures the transceiver.
This function is called to configure the transceiver after reset.
References CLKM_1MHZ, CLKM_SHA_DISABLE, IRQ_MASK_MODE_ON, PAD_CLKM_2_MA, pal_trx_bit_write(), pal_trx_reg_write(), RG_IRQ_MASK, RX_SAFE_MODE_ENABLE, SET_PD, SR_AACK_SET_PD, SR_CLKM_CTRL, SR_CLKM_SHA_SEL, SR_IRQ_MASK_MODE, SR_PAD_IO_CLKM, SR_RX_SAFE_MODE, and TRX_IRQ_DEFAULT.
Referenced by internal_tal_reset().
|
static |
Initializes the transceiver.
This function is called to initialize the transceiver.
References CMD_FORCE_TRX_OFF, DELAY_US, P_ON_TO_CLKM_ATTEMPTS, P_ON_TO_CLKM_AVAILABLE_TYP_US, pal_trx_bit_read(), pal_trx_reg_read(), pal_trx_reg_write(), PART_NUM_AT86RF212, RG_PART_NUM, RG_TRX_STATE, RST_HIGH, RST_LOW, RST_PULSE_WIDTH_US, SLEEP_TO_TRX_OFF_ATTEMPTS, SLP_TR_LOW, SR_TRX_STATUS, tal_trx_status, TRX_FAILURE, TRX_OFF, TRX_POLL_WAIT_TIME_US, and TRX_SUCCESS.
Referenced by tal_init().
|
static |
Reset transceiver.
References DELAY_US, pal_trx_bit_read(), RST_HIGH, RST_LOW, RST_PULSE_WIDTH_US, SLEEP_TO_TRX_OFF_ATTEMPTS, SLEEP_TO_TRX_OFF_TYP_US, SLP_TR_LOW, SR_TRX_STATUS, tal_trx_status, TRX_FAILURE, TRX_OFF, TRX_POLL_WAIT_TIME_US, and TRX_SUCCESS.
Referenced by internal_tal_reset().
|
static |
Implements the handling of the transmission end.
This function handles the callback for the transmission end.
References Assert, AT86RFX_CHANNEL_ACCESS_FAILURE, AT86RFX_FAILURE, AT86RFX_SUCCESS, AT86RFX_TX_STATUS_NOTIFY, TAL_IDLE, tal_state, TRAC_CHANNEL_ACCESS_FAILURE, TRAC_INVALID, TRAC_SUCCESS, and trx_trac_status.
Referenced by handle_tal_state().
|
static |
Current state of the TAL state machine.
Referenced by handle_tal_state(), handle_tx_end_irq(), internal_tal_reset(), trx_irq_handler_cb(), tx_end_handling(), and tx_frame_config().
|
static |
Current state of the transceiver.
Referenced by set_trx_state(), trx_init(), and trx_reset().
|
static |
Keep track of transceiver status.
Referenced by tx_end_handling().