Microchip® Advanced Software Framework

tal_multi_trx.h File Reference

This file contains TAL API function declaration for multi trx support.

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

#include <stdint.h>
#include <stdbool.h>
#include "pal.h"
#include "return_val.h"
#include "tal_generic.h"

Functions

retval_t tal_pib_get (trx_id_t trx_id, uint8_t attribute, uint8_t *value)
 Gets a TAL PIB attribute. More...
 
retval_t tal_pib_set (trx_id_t trx_id, uint8_t attribute, pib_value_t *value)
 Sets a TAL PIB attribute. More...
 
retval_t tal_pib_set_all (uint8_t attribute, pib_value_t *value)
 Sets a TAL PIB attribute for all existing trx Ids for this device. 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...
 
uint8_t tal_rx_enable (trx_id_t trx_id, uint8_t state)
 Switches receiver on or off. More...
 
void tal_rx_frame_cb (trx_id_t trx_id, frame_info_t *rx_frame)
 User call back function for frame reception. More...
 
retval_t tal_trx_sleep (trx_id_t trx_id)
 Sets the transceiver to sleep. More...
 
retval_t tal_trx_wakeup (trx_id_t trx_id)
 Wakes up the transceiver from sleep. More...
 
retval_t tal_tx_frame (trx_id_t trx_id, frame_info_t *tx_frame, csma_mode_t csma_mode, bool perform_frame_retry)
 Requests to TAL to transmit frame. More...
 
void tal_tx_frame_done_cb (trx_id_t trx_id, retval_t status, frame_info_t *frame)
 User call back function for frame transmission. More...
 

retval_t tal_pib_get ( trx_id_t  trx_id,
uint8_t  attribute,
uint8_t *  value 
)

Gets a TAL PIB attribute.

This function is called to retrieve the transceiver information base attributes.

Parameters
trx_idTransceiver identifier
[in]attributeTAL infobase attribute ID
[out]valueTAL infobase attribute value
Returns

This function is called to retrieve the transceiver information base attributes.

Parameters
[in]trx_idTransceiver identifier
[in]attributeTAL infobase attribute ID
[out]valueTAL infobase attribute value
Returns

References Assert, LEG_OQPSK, mac_i_pan_coordinator, MAC_SUCCESS, MAC_UNSUPPORTED_ATTRIBUTE, macACKTiming, macAckWaitDuration, macAdaptDataRateForACK, macFCSType, macFrameFilterFrameTypes, macFrameFilterFrameVersions, macIeeeAddress, macMaxBE, macMaxCSMABackoffs, macMaxFrameRetries, macMaxNumRxFramesDuringBackoff, macMinBE, macPANId, macPromiscuousMode, macShortAddress, NUM_TRX, phyCCADuration, phyCCAMode, phyCCAThreshold, phyCCATimeMethod, phyChannelsSupported, phyCurrentChannel, phyCurrentPage, phyCurrentSUNPageEntry, phyFSKFECEnabled, phyFSKFECInterleavingRSC, phyFSKFECScheme, phyFSKModeSwitchEnabled, phyFSKPreambleLength, phyFSKRawModeEnabled, phyFSKRawModeRxLength, phyFSKScramblePSDU, phyHighRateEnabled, phyMaxFrameDuration, phyModeSwitchDuration, phyModeSwitchNewMode, phyModeSwitchSettlingDelay, phyMRFSKSFD, phyOFDMInterleaving, phyOFDMMCS, phyOnAirDuration, phyOQPSKRateMode, phyRPCEnabled, phySetting, phySymbolsPerOctet, phyTransmitPower, status, and tal_pib.

retval_t tal_pib_set ( trx_id_t  trx_id,
uint8_t  attribute,
pib_value_t value 
)

Sets a TAL PIB attribute.

This function is called to set the transceiver information base attributes.

Parameters
trx_idTransceiver identifier
attributeTAL infobase attribute ID
valueTAL infobase attribute value to be set
Returns
  • MAC_UNSUPPORTED_ATTRIBUTE if the TAL info base attribute is not found
  • TAL_BUSY if the TAL is not in TAL_IDLE state. An exception is macBeaconTxTime which can be accepted by TAL even if TAL is not in TAL_IDLE state.
  • MAC_SUCCESS if the attempt to set the PIB attribute was successful
  • TAL_TRX_ASLEEP if trx is in SLEEP mode and access to trx is required

References Assert, calculate_cca_duration_us(), calculate_pib_values(), CCA_MODE_1_ED, conf_trx_modulation(), config_fsk_rpc(), config_phy(), FCS_TYPE_4_OCTETS, FSK, get_supported_channels_tuple(), LEG_OQPSK, mac_i_pan_coordinator, MAC_INVALID_PARAMETER, MAC_SUCCESS, MAC_UNSUPPORTED_ATTRIBUTE, macACKTiming, macAckWaitDuration, macAdaptDataRateForACK, macFCSType, macFrameFilterFrameTypes, macFrameFilterFrameVersions, macIeeeAddress, macMaxBE, macMaxCSMABackoffs, macMaxFrameRetries, macMaxNumRxFramesDuringBackoff, macMinBE, macPANId, macPromiscuousMode, macShortAddress, NUM_TRX, OFDM, OQPSK, PHY_RX_ON, PHY_TRX_OFF, phyCCADuration, phyCCAMode, phyCCAThreshold, phyCCATimeMethod, phyCurrentChannel, phyCurrentPage, phyFSKFECEnabled, phyFSKFECInterleavingRSC, phyFSKFECScheme, phyFSKModeSwitchEnabled, phyFSKPreambleLength, phyFSKRawModeEnabled, phyFSKRawModeRxLength, phyFSKScramblePSDU, phyHighRateEnabled, phyModeSwitchDuration, phyModeSwitchNewMode, phyModeSwitchSettlingDelay, phyMRFSKSFD, phyOFDMInterleaving, phyOFDMMCS, phyOnAirDuration, phyOQPSKRateMode, phyRPCEnabled, phySetting, phyTransmitPower, pib_value_t::pib_value_16bit, pib_value_t::pib_value_32bit, pib_value_t::pib_value_64bit, pib_value_t::pib_value_8bit, pib_value_t::pib_value_bool, RF_BASE_ADDR_OFFSET, RF_RX, RG_BBC0_AFFTM, RG_BBC0_AMEDT, RG_BBC0_FSKRRXFLL, RG_BBC0_MACEA0, RG_BBC0_MACPID0F0, RG_BBC0_MACSHA0F0, set_channel(), set_ed_sample_duration(), set_phy_based_on_channel_page(), set_sfd(), set_tx_pwr(), SR_BBC0_AFC0_PM, SR_BBC0_AFC1_PANC0, SR_BBC0_AFFVM_AFFVM, SR_BBC0_AMCS_AACK, SR_BBC0_AMCS_AACKDR, SR_BBC0_FSKC2_FECIE, SR_BBC0_FSKC2_FECS, SR_BBC0_FSKC2_MSE, SR_BBC0_FSKPHRTX_DW, SR_BBC0_FSKPHRTX_SFD, SR_BBC0_OFDMC_POI, SR_BBC0_OFDMPHRTX_MCS, SR_BBC0_OQPSKC2_RPC, SR_BBC0_OQPSKC3_HRLEG, SR_BBC0_OQPSKPHRTX_MOD, SR_BBC0_PC_FCST, status, TAL_BUSY, TAL_IDLE, tal_pib, tal_rx_enable(), TAL_SLEEP, tal_state, TAL_TRX_ASLEEP, and trx_default_state.

retval_t tal_pib_set_all ( uint8_t  attribute,
pib_value_t value 
)

Sets a TAL PIB attribute for all existing trx Ids for this device.

This function is called to set the transceiver information base attributes for all transceivers on this device. This function simply calls function tal_pib_set() for all existing trx Ids.

Parameters
attributeTAL infobase attribute ID
valueTAL infobase attribute value to be set
Returns
  • MAC_UNSUPPORTED_ATTRIBUTE if the TAL info base attribute is not found
  • TAL_BUSY if the TAL is not in TAL_IDLE state. An exception is macBeaconTxTime which can be accepted by TAL even if TAL is not in TAL_IDLE state.
  • MAC_SUCCESS if the attempt to set the PIB attribute was successful
  • TAL_TRX_ASLEEP if trx is in SLEEP mode and access to trx is required

References MAC_SUCCESS, NUM_TRX, status, and tal_pib_set().

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.

Parameters
trx_idTransceiver identifier
set_default_pibDefines whether PIB values need to be set to its default values
Returns

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_reset(), trx_state, TX_IDLE, tx_state, and write_all_tal_pib_to_trx().

uint8_t tal_rx_enable ( trx_id_t  trx_id,
uint8_t  state 
)

Switches receiver on or off.

This function switches the receiver on (PHY_RX_ON) or off (PHY_TRX_OFF).

Parameters
trx_idTransceiver identifier
stateNew state of receiver
Returns
  • TAL_BUSY if the TAL state machine cannot switch receiver on or off,
  • PHY_TRX_OFF if receiver has been switched off, or
  • PHY_RX_ON otherwise.

References Assert, NUM_TRX, pal_is_timer_running(), PHY_RX_ON, PHY_TRX_OFF, RF09, RF_BASE_ADDR_OFFSET, RF_RX, RF_TRXOFF, RG_RF09_CMD, start_rpc(), stop_rpc(), switch_to_rx(), switch_to_txprep(), tal_buf_shortage, TAL_BUSY, TAL_IDLE, TAL_SLEEP, tal_state, TAL_TRX_ASLEEP, trx_default_state, and trx_state.

retval_t tal_trx_sleep ( trx_id_t  trx_id)

Sets the transceiver to sleep.

This function sets the transceiver to sleep state.

Parameters
trx_idTransceiver identifier
Returns

Sets the transceiver to sleep.

This function sets the entire device to state DEEP_SLEEP.

Parameters
trx_idTransceiver identifier
modeDefines sleep mode of transceiver (Not used for 215 trx)
Returns

References Assert, MAC_SUCCESS, NULL, NUM_TRX, RF09, RF24, RF_BASE_ADDR_OFFSET, RF_SLEEP, RF_TRXOFF, RG_RF09_CMD, TAL_BB_IRQ_CLR_ALL, tal_buf_shortage, TAL_BUSY, TAL_IDLE, TAL_RF_IRQ_CLR_ALL, tal_rx_buffer, TAL_SLEEP, tal_state, TAL_TRX_ASLEEP, and trx_state.

retval_t tal_trx_wakeup ( trx_id_t  trx_id)

Wakes up the transceiver from sleep.

This function awakes the transceiver from sleep state.

Parameters
trx_idTransceiver identifier
Returns
  • TAL_TRX_AWAKE - The transceiver is already awake
  • MAC_SUCCESS - The transceiver is woken up from sleep
  • FAILURE - The transceiver did not wake-up from sleep

Wakes up the transceiver from sleep.

This function awakes the transceiver from state SLEEP.

Parameters
trx_idTransceiver identifier
Returns
  • TAL_TRX_AWAKE - The transceiver is already awake
  • MAC_SUCCESS - The transceiver is woken up from sleep
  • FAILURE - The transceiver did not wake-up from sleep

References Assert, config_phy(), FAILURE, MAC_SUCCESS, NULL, NUM_TRX, pal_get_current_time(), pal_sub_time_us(), RF09, RF24, RF_BASE_ADDR_OFFSET, RF_IRQ_WAKEUP, RF_TRXOFF, RG_RF09_CMD, start_time, TAL_IDLE, TAL_RF_IRQ_CLR, TAL_RF_IS_IRQ_SET, tal_rx_buffer, TAL_SLEEP, tal_state, TAL_TRX_AWAKE, TAL_WAKING_UP, trx_config(), trx_state, and write_all_tal_pib_to_trx().

retval_t tal_tx_frame ( trx_id_t  trx_id,
frame_info_t tx_frame,
csma_mode_t  csma_mode,
bool  perform_frame_retry 
)

Requests to TAL to transmit frame.

This function is called by the MAC to deliver a frame to the TAL to be transmitted by the transceiver.

Parameters
trx_idTransceiver identifier
tx_framePointer to the frame_info_t structure or to frame array to be transmitted
csma_modeIndicates mode of csma-ca to be performed for this frame
perform_frame_retryIndicates whether to retries are to be performed for this frame
Returns

This function is called by the MAC to deliver a frame to the TAL to be transmitted by the transceiver.

Parameters
trx_idTransceiver identifier
tx_framePointer to the frame_info_t structure updated by the MAC layer
csma_modeIndicates mode of csma-ca to be performed for this frame
perform_frame_retryIndicates whether to retries are to be performed for this frame
Returns

References ack_requested, Assert, CSMA_SLOTTED, csma_start(), CSMA_UNSLOTTED, FCF_ACK_REQUEST, frame_buf_filled, global_csma_mode, handle_ifs(), mac_frame_ptr, MAC_INVALID_PARAMETER, MAC_SUCCESS, frame_info_tag::mpdu, NO_CCA, NO_CSMA_WITH_IFS, NULL, NUM_TRX, number_of_tx_retries, TAL_BUSY, tal_frame_to_tx, TAL_IDLE, tal_pib, TAL_SLEEP, tal_state, TAL_TRX_ASLEEP, TAL_TX, and transmit_frame().