Microchip® Advanced Software Framework

at86rf230b.c File Reference

Driver for AT86RF230B 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"

Macros

#define TAL_MAIN_STATE_MASK   (0x0F)
 
#define TAL_TX_SUB_STATE_MASK   (0xF0)
 

Functions

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 uint8_t trx_trac_status
 Keep track of transceiver status. More...
 

#define TAL_MAIN_STATE_MASK   (0x0F)
#define TAL_TX_SUB_STATE_MASK   (0xF0)

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 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

Sets transceiver state.

Parameters
trx_cmdneeds to be one of the trx commands
Returns
current trx state

References Assert, 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 handle_received_frame_irq(), handle_tx_end_irq(), tal_init(), and tx_frame_config().

static void trx_config ( void  )
static

Configures the transceiver.

This function is called to configure the transceiver after reset.

References CLKM_1MHz, CLKM_2mA, pal_trx_bit_write(), pal_trx_reg_write(), PD_ACK_BIT_SET_ENABLE, RG_CSMA_SEED_0, RG_IRQ_MASK, RG_TRX_CTRL_0, SR_AACK_SET_PD, SR_CSMA_SEED_1, SR_TX_AUTO_CRC_ON, TRX_IRQ_DEFAULT, and TX_AUTO_CRC_ENABLE.

Referenced by internal_tal_reset().

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. and version no. are correct TRX_FAILURE otherwise

References AT86RF230, AT86RF230_REV_B, CMD_TRX_OFF, DELAY_US, P_ON_TO_CLKM_AVAILABLE, pal_trx_bit_read(), pal_trx_reg_read(), pal_trx_reg_write(), RG_PART_NUM, RG_TRX_STATE, RG_VERSION_NUM, RST_HIGH, RST_LOW, RST_PULSE_WIDTH_US, SLP_TR_LOW, SR_TRX_STATUS, tal_trx_status, TRX_FAILURE, TRX_OFF, 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_US, SLP_TR_LOW, SR_TRX_STATUS, tal_trx_status, TRX_FAILURE, TRX_OFF, 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().

uint8_t trx_trac_status
static

Keep track of transceiver status.

Referenced by tx_end_handling().