Microchip® Advanced Software Framework

tal.h File Reference

This file contains TAL API function declarations.

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

#include <stdint.h>
#include <stdbool.h>
#include "pal.h"
#include "tal_config.h"
#include "tal_generic.h"
#include "bmm.h"
#include "stack_config.h"
#include "return_val.h"
#include "tal_types.h"
#include "mac_build_config.h"
#include "qmm.h"
#include "tal_rf215.h"
#include "tal_multi_trx.h"

Data Structures

struct  frame_info_tag
 Globally used frame information structure. More...
 
struct  tal_pib_tag
 

Macros

#define BAND_2400   (1)
 2.4 GHz (channels 11 through 26) More...
 
#define BAND_900   (0)
 868 / 910 MHz (channels 0 through 10) using BPSK More...
 
#define BAND_MULTIPLE   (2)
 450 / 900 MHz and 2.4 GHz - Multiple band support More...
 
#define mac_i_pan_coordinator   (0x0B)
 Attribute id of mac_i_pan_coordinator PIB. More...
 
#define MAX_CHANNEL   (26)
 Maximum channel. More...
 
#define MAX_FRAME_DURATION
 Maximum number of symbols in a frame for the current PHY. More...
 
#define MAX_SYMBOL_TIME   (0x0FFFFFFF)
 The maximum time in symbols for a 32 bit timer. More...
 
#define MIN_CHANNEL   (11)
 Minimum channel. More...
 
#define NO_OF_SYMBOLS_PREAMBLE_SFD
 Number of symbols forming the synchronization header (SHR) for the current PHY. More...
 
#define NUM_TRX   2
 
#define RF_BAND   BAND_MULTIPLE
 
#define SYMBOL_MASK   (0x0FFFFFFF)
 Symbol mask for ignoring most significant nibble. More...
 
#define TAL_BIT_MASK(ADDR, MASK, POS)   MASK
 Get bit mask from sub register definition. More...
 
#define TAL_BIT_POS(ADDR, MASK, POS)   POS
 Get bit position from sub register definition. More...
 
#define TAL_CONVERT_SYMBOLS_TO_US(trx_id, symbols)
 
#define TAL_GET_BEACON_INTERVAL_TIME(BO)   ((1UL * aBaseSuperframeDuration) << (BO))
 Beacon Interval time in symbols. More...
 
#define TAL_GET_SUPERFRAME_DURATION_TIME(SO)   ((1UL * aBaseSuperframeDuration) << (SO))
 Superframe Duration time in symbols. More...
 
#define VALID_CHANNEL_MASK   (0x07FFF800UL)
 Valid channel masks for scanning. More...
 

Typedefs

typedef enum csma_mode_tag csma_mode_t
 CSMA Mode supported by transceiver. More...
 
typedef struct frame_info_tag frame_info_t
 Globally used frame information structure. More...
 
typedef enum sleep_mode_tag sleep_mode_t
 Sleep Mode supported by transceiver. More...
 
typedef __PACK__DATA__ struct
tal_pib_tag 
tal_pib_t
 

Enumerations

enum  csma_mode_tag {
  NO_CSMA_NO_IFS,
  NO_CSMA_WITH_IFS,
  CSMA_UNSLOTTED,
  CSMA_SLOTTED
}
 CSMA Mode supported by transceiver. More...
 
enum  SHORTENUM {
  ASSOCIATIONREQUEST = (0x01),
  ASSOCIATIONRESPONSE,
  DISASSOCIATIONNOTIFICATION,
  DATAREQUEST,
  PANIDCONFLICTNOTIFICAION,
  ORPHANNOTIFICATION,
  BEACONREQUEST,
  COORDINATORREALIGNMENT,
  GTSREQUEST,
  ORPHANREALIGNMENT,
  BEACON_MESSAGE,
  DATAREQUEST_IMPL_POLL,
  NULL_FRAME,
  MCPS_MESSAGE
}
 MAC Message types. More...
 
enum  sleep_mode_tag {
  SLEEP_MODE_1,
  DEEP_SLEEP_MODE
}
 Sleep Mode supported by transceiver. More...
 

Functions

retval_t tal_generate_rand_seed (void)
 Generates a 16-bit random number used as initial seed for srand() More...
 
uint16_t tal_get_symbol_duration_us (trx_id_t trx_id)
 Gets the symbol duration in us. More...
 
retval_t tal_init (void)
 Initializes the TAL. More...
 
void tal_task (void)
 TAL task handling. More...
 
retval_t trx_reset (trx_id_t trx_id)
 Resets transceiver(s) More...
 

Variables

tal_pib_t tal_pib [NUM_TRX]
 TAL PIBs. More...
 

#define BAND_2400   (1)

2.4 GHz (channels 11 through 26)

#define BAND_900   (0)

868 / 910 MHz (channels 0 through 10) using BPSK

#define BAND_MULTIPLE   (2)

450 / 900 MHz and 2.4 GHz - Multiple band support

#define mac_i_pan_coordinator   (0x0B)

Attribute id of mac_i_pan_coordinator PIB.

Referenced by tal_pib_get(), and tal_pib_set().

#define MAX_CHANNEL   (26)

Maximum channel.

#define MAX_FRAME_DURATION
Value:
(aMaxPHYPacketSize + 1) * SYMBOLS_PER_OCTET)
#define aMaxPHYPacketSize
Maximum size of PHY packet.
Definition: ieee_const.h:81
#define NO_OF_SYMBOLS_PREAMBLE_SFD
Number of symbols forming the synchronization header (SHR) for the current PHY.
Definition: tal.h:839

Maximum number of symbols in a frame for the current PHY.

This value is the base for the PHY PIB attribute phyMaxFrameDuration.

#define MAX_SYMBOL_TIME   (0x0FFFFFFF)

The maximum time in symbols for a 32 bit timer.

#define MIN_CHANNEL   (11)

Minimum channel.

#define NO_OF_SYMBOLS_PREAMBLE_SFD
Value:
(NO_SYMBOLS_PREAMBLE + \
NO_SYMBOLS_SFD)

Number of symbols forming the synchronization header (SHR) for the current PHY.

This value is the base for the PHY PIB attribute phySHRDuration.

#define RF_BAND   BAND_MULTIPLE
#define SYMBOL_MASK   (0x0FFFFFFF)

Symbol mask for ignoring most significant nibble.

#define TAL_BIT_MASK (   ADDR,
  MASK,
  POS 
)    MASK

Get bit mask from sub register definition.

#define TAL_BIT_POS (   ADDR,
  MASK,
  POS 
)    POS

Get bit position from sub register definition.

#define TAL_CONVERT_SYMBOLS_TO_US (   trx_id,
  symbols 
)
Value:
((uint32_t)(symbols) * \
uint16_t tal_get_symbol_duration_us(trx_id_t trx_id)
Gets the symbol duration in us.
Definition: tal_4g_utils.c:534

Referenced by start_ed_scan().

#define TAL_GET_BEACON_INTERVAL_TIME (   BO)    ((1UL * aBaseSuperframeDuration) << (BO))

Beacon Interval time in symbols.

#define TAL_GET_SUPERFRAME_DURATION_TIME (   SO)    ((1UL * aBaseSuperframeDuration) << (SO))

Superframe Duration time in symbols.

#define VALID_CHANNEL_MASK   (0x07FFF800UL)

Valid channel masks for scanning.

typedef enum csma_mode_tag csma_mode_t

CSMA Mode supported by transceiver.

typedef struct frame_info_tag frame_info_t

Globally used frame information structure.

Sleep Mode supported by transceiver.

CSMA Mode supported by transceiver.

Enumerator
NO_CSMA_NO_IFS 
NO_CSMA_WITH_IFS 
CSMA_UNSLOTTED 
CSMA_SLOTTED 
enum SHORTENUM

MAC Message types.

Enumerator
ASSOCIATIONREQUEST 
ASSOCIATIONRESPONSE 
DISASSOCIATIONNOTIFICATION 
DATAREQUEST 
PANIDCONFLICTNOTIFICAION 
ORPHANNOTIFICATION 
BEACONREQUEST 
COORDINATORREALIGNMENT 
GTSREQUEST 
ORPHANREALIGNMENT 
BEACON_MESSAGE 
DATAREQUEST_IMPL_POLL 
NULL_FRAME 
MCPS_MESSAGE 

Sleep Mode supported by transceiver.

Enumerator
SLEEP_MODE_1 
DEEP_SLEEP_MODE 

retval_t tal_generate_rand_seed ( void  )

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. The generated random 16-bit number is feed into function srand() as initial seed. The transceiver state is initally set to RX_ON. After the completion of the random seed generation, the trancseiver is set to TRX_OFF.

This function generates a 16-bit random number by means of using the Random Number Generator from the transceiver.

The generated random 16-bit number is feed into function srand() as initial seed.

References MAC_SUCCESS, pal_timer_delay, RF09, RF24, RF_BASE_ADDR_OFFSET, RF_NOP, RF_RX, RF_TRXOFF, RG_RF09_RNDV, RG_RF09_RXBWC, SR_BBC0_PC_BBEN, SR_RF09_CMD_CMD, switch_to_txprep(), TAL_BUSY, TAL_IDLE, TAL_SLEEP, tal_state, TAL_TRX_ASLEEP, trx_bit_write(), trx_reg_read(), trx_reg_write(), and trx_state.

Referenced by tal_init().

uint16_t tal_get_symbol_duration_us ( trx_id_t  trx_id)

Gets the symbol duration in us.

Parameters
trx_idTransceiver identifier
Returns
Duration of a symbol in us

References FSK, LEG_OQPSK, OFDM, OQPSK, PGM_READ_WORD, and tal_pib.

Referenced by calculate_pib_values().

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.

Returns
MAC_SUCCESS if the transceiver state is changed to TRX_OFF and the current device part number and version number are correct; FAILURE otherwise

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

void tal_task ( void  )

TAL task handling.

This function

  • Checks and allocates the receive buffer.
  • Processes the TAL incoming frame queue.
  • Implements the TAL state machine.

This function

  • handles any pending IRQ flags
  • Processes the TAL incoming frame queue. The function needs to be called on a regular basis.

References BB_IRQ_AGCH, BB_IRQ_AGCR, BB_IRQ_NO_IRQ, BB_IRQ_RXAM, BB_IRQ_RXEM, BB_IRQ_RXFE, BB_IRQ_RXFS, BB_IRQ_TXFE, bmm_buffer_alloc(), ENTER_CRITICAL_REGION, handle_batmon_irq(), handle_ed_end_irq(), handle_rx_end_irq(), handle_trxerr(), handle_tx_end_irq(), LARGE_BUFFER_SIZE, LEAVE_CRITICAL_REGION, NUM_TRX, process_incoming_frame(), qmm_queue_remove(), RF_IRQ_BATLOW, RF_IRQ_EDC, RF_IRQ_IQIFSF, RF_IRQ_TRXERR, RF_IRQ_TRXRDY, RF_IRQ_WAKEUP, switch_to_rx(), TAL_BB_IRQ_CLR, tal_bb_irqs, tal_buf_shortage, TAL_IDLE, TAL_RF_IRQ_CLR, tal_rf_irqs, TAL_SLEEP, tal_state, TX_CCATX, and tx_state.

Referenced by performance_analyzer_task().

tal_pib_t tal_pib[NUM_TRX]

TAL PIBs.

Referenced by ack_timout_cb(), ack_transmission_done(), app_transmit_frame(), apply_channel_settings(), calc_ch_page(), calculate_cca_duration_us(), calculate_pib_values(), cca_start(), ceiling_sym(), check_valid_freq_range(), complete_rx_transaction(), conf_fsk(), conf_leg_oqpsk(), conf_ofdm(), conf_oqpsk(), conf_trx_modulation(), config_fsk_rpc(), config_phy(), configure_frame_sending(), configure_pibs(), configure_range_test_frame_sending(), continue_deferred_transmission(), csma_continue(), csma_start(), fsk_rfcfg(), get_AckTiming_us(), get_AckWaitDuration_us(), get_board_details(), get_cca_duration_us(), get_cca_thres(), get_data_rate(), get_node_info(), get_sun_max_ch_no(), get_supported_channels_tuple(), handle_ed_end_irq(), handle_ifs(), handle_incoming_frame(), handle_incoming_msg(), handle_rx_end_irq(), handle_tx_end_irq(), init_tal_pib(), ofdm_rfcfg(), oqpsk_ack_psdu_duration_sym(), oqpsk_get_chip_rate(), oqpsk_rfcfg(), per_mode_initiator_rx_cb(), per_mode_initiator_task(), per_mode_initiator_tx_done_cb(), per_mode_receptor_rx_cb(), perf_set_sun_page(), phr_duration_sym(), process_incoming_frame(), send_peer_conf(), set_channel(), set_channel_app(), set_fsk_pibs(), set_phy_based_on_channel_page(), set_phy_frame_length(), set_sfd(), set_tx_pwr(), shr_duration_sym(), start_ack_wait_timer(), start_backoff(), start_rpc(), stop_rpc(), tal_ed_start(), tal_get_symbol_duration_us(), tal_init(), tal_pib_get(), tal_pib_set(), tal_set_tx_pwr(), tal_tx_frame(), tfa_cca_perform(), tfa_continuous_tx_start(), transmit_frame(), tx_done_handling(), upload_frame(), usr_range_test_beacon_rsp(), usr_range_test_beacon_tx(), usr_range_test_marker_ind(), and write_all_tal_pib_to_trx().