Microchip® Advanced Software Framework

at86rf212.c File Reference

Driver for AT86RF212 transceiver.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include "board.h"
#include "gpio.h"
#include "conf_at86rfx.h"
#include "at86rfx_driver.h"

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 void generate_rand_seed ( void  )
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 void handle_received_frame_irq ( void  )
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 void handle_tx_end_irq ( void  )
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 trx_retval_t internal_tal_reset ( void  )
static

Internal TAL reset function.

Returns
TRX_SUCCESS if the transceiver was successfully reset TRX_FAILURE otherwise

References generate_rand_seed(), TAL_IDLE, tal_state, trx_config(), TRX_FAILURE, trx_reset(), and TRX_SUCCESS.

Referenced by tal_init().

static tal_trx_status_t set_trx_state ( trx_cmd_t  trx_cmd)
static
static void trx_config ( void  )
static
static trx_retval_t trx_init ( void  )
static

Initializes the transceiver.

This function is called to initialize the transceiver.

Returns
TRX_SUCCESS if the transceiver state is changed to TRX_OFF and the current device part no. are correct TRX_FAILURE otherwise

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 trx_retval_t trx_reset ( void  )
static

Reset transceiver.

Returns
TRX_SUCCESS if the transceiver state is changed to TRX_OFF TRX_FAILURE otherwise

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

tal_state_t tal_state
static
tal_trx_status_t tal_trx_status
static

Current state of the transceiver.

Referenced by set_trx_state(), trx_init(), and trx_reset().

trx_trac_status_t trx_trac_status
static

Keep track of transceiver status.

Referenced by tx_end_handling().