Microchip® Advanced Software Framework

atmegarfr2/inc/tal_internal.h File Reference
#include "bmm.h"
#include "qmm.h"
#include "tal_slotted_csma.h"
#include "mac_build_config.h"

Macros

#define _BV(x)   (1 << (x))
 Bit value – compute the bitmask for a bit position. More...
 
#define PIN_ACK_OK_END()
 
#define PIN_ACK_OK_START()
 
#define PIN_ACK_WAITING_END()
 
#define PIN_ACK_WAITING_START()
 
#define PIN_BACKOFF_END()
 
#define PIN_BACKOFF_START()
 
#define PIN_BEACON_END()
 
#define PIN_BEACON_LOSS_TIMER_END()
 
#define PIN_BEACON_LOSS_TIMER_START()
 
#define PIN_BEACON_START()
 
#define PIN_CCA_END()
 
#define PIN_CCA_START()
 
#define PIN_CSMA_END()
 
#define PIN_CSMA_START()
 
#define PIN_NO_ACK_END()
 
#define PIN_NO_ACK_START()
 
#define PIN_TX_END()
 
#define PIN_TX_START()
 
#define PIN_WAITING_FOR_BEACON_END()
 
#define PIN_WAITING_FOR_BEACON_START()
 
#define TAL_PSDU_US_PER_OCTET(octets)   ((uint16_t)(octets) * 32)
 Conversion of number of PSDU octets to duration in microseconds. More...
 
#define TRX_IRQ_AWAKE_ONLY   (TRX_IRQ_AWAKE)
 
#define TRX_IRQ_CCA_ED_ONLY   (TRX_IRQ_CCA_ED_READY)
 
#define TRX_IRQ_DEFAULT
 
#define TRX_IRQ_NONE   (0)
 
Transceiver Access Macros
See Also
Transceiver macros section of group_pal_gpio
#define trx_reg_write(addr, data)   (*(volatile uint8_t *)(addr)) = (data)
 Writes data into a transceiver register. More...
 
#define trx_reg_read(addr)   (*(volatile uint8_t *)(addr))
 Reads current value from a transceiver register. More...
 
#define trx_frame_read(data, length)   memcpy((data), (void *)&TRXFBST, (length))
 Reads frame buffer of the transceiver. More...
 
#define trx_frame_write(data, length)   memcpy((void *)&TRXFBST, (data), (length))
 Writes data into frame buffer of the transceiver. More...
 
#define trx_bit_read(arg)   _trx_bit_read(arg)
 Subregister read. More...
 
#define trx_bit_write(arg1, val)   _trx_bit_write(arg1, val)
 Subregister write. More...
 
Transceiver Access Macros
#define TRX_RST_HIGH()   (TRXPR |= _BV(TRXRST))
 Set Reset Bit. More...
 
#define TRX_RST_LOW()   (TRXPR &= ~_BV(TRXRST))
 Clear Reset Bit. More...
 
#define TRX_SLP_TR_HIGH()   (TRXPR |= _BV(SLPTR))
 Set Sleep/TR Bit. More...
 
#define TRX_SLP_TR_LOW()   (TRXPR &= ~_BV(SLPTR))
 Clear Sleep/TR Bit. More...
 
Transceiver IRQ Macros
#define CLEAR_TRX_IRQ_TX_END()   (IRQ_STATUS = _BV(TX_END))
 Clears TRX TX_END interrupt. More...
 
#define CLEAR_TRX_IRQ_TSTAMP()   (IRQ_STATUS = _BV(RX_START))
 Clear RX TIME STAMP interrupt. More...
 
#define CLEAR_TRX_IRQ_RX_END()   (IRQ_STATUS = _BV(RX_END))
 Clear TRX RX_END interrupt. More...
 
#define CLEAR_TRX_IRQ_CCA_ED()   (IRQ_STATUS = _BV(CCA_ED_DONE_EN))
 Clear TRX CCA_ED_DONE interrupt. More...
 
#define CLEAR_TRX_IRQ_AMI()   (IRQ_STATUS = _BV(AMI))
 Clear AMI interrupt. More...
 
#define CLEAR_TRX_IRQ_BATMON()   (BATMON = _BV(BAT_LOW))
 Clear TRX BAT LOW interrupt. More...
 
#define CLEAR_TRX_IRQ_AWAKE()   (IRQ_STATUS = _BV(AWAKE))
 Clear TRX AWAKE interrupt. More...
 
#define CLEAR_TRX_IRQ_PLL_LOCK()   (IRQ_STATUS = _BV(PLL_LOCK))
 Clear TRX PLL LOCK interrupt. More...
 
#define CLEAR_TRX_IRQ_PLL_UNLOCK()   (IRQ_STATUS = _BV(PLL_UNLOCK))
 Clear TRX PLL UNLOCK interrupt. More...
 

Typedefs

typedef enum tal_state_tag tal_state_t
 TAL states. More...
 
typedef enum trx_irq_reason_tag trx_irq_reason_t
 Transceiver interrupt reasons. More...
 

Enumerations

enum  tal_state_tag {
  TAL_IDLE = 0,
  TAL_TX_AUTO = 1,
  TAL_TX_DONE = 2,
  TAL_SLOTTED_CSMA = 3,
  TAL_IDLE = 0,
  TAL_TX_AUTO = 1,
  TAL_TX_DONE = 2,
  TAL_SLOTTED_CSMA = 3
}
 TAL states. More...
 
enum  trx_irq_reason_tag {
  TRX_NO_IRQ = (0x00),
  TRX_IRQ_PLL_LOCK = (0x01),
  TRX_IRQ_PLL_UNLOCK = (0x02),
  TRX_IRQ_RX_START = (0x04),
  TRX_IRQ_RX_END = (0x08),
  TRX_IRQ_CCA_ED_READY = (0x10),
  TRX_IRQ_AMI = (0x20),
  TRX_IRQ_TX_END = (0x40),
  TRX_IRQ_AWAKE = (0x80),
  TRX_NO_IRQ = (0x00),
  TRX_IRQ_PLL_LOCK = (0x01),
  TRX_IRQ_PLL_UNLOCK = (0x02),
  TRX_IRQ_RX_START = (0x04),
  TRX_IRQ_RX_END = (0x08),
  TRX_IRQ_CCA_ED_READY = (0x10),
  TRX_IRQ_AMI = (0x20),
  TRX_IRQ_TX_END = (0x40),
  TRX_IRQ_AWAKE = (0x80)
}
 Transceiver interrupt reasons. More...
 

Functions

tal_trx_status_t set_trx_state (trx_cmd_t trx_cmd)
 Sets transceiver state. More...
 

Variables

uint8_t last_frame_length
 
frame_info_tmac_frame_ptr
 Frame pointer for the frame structure provided by the MCL. More...
 
volatile bool tal_awake_end_flag
 
csma_state_t tal_csma_state
 CSMA state machine variable. More...
 
uint8_t * tal_frame_to_tx
 Pointer to the 15.4 frame created by the TAL to be handed over to the transceiver. More...
 
queue_t tal_incoming_frame_queue
 Queue that contains all frames that are uploaded from the trx, but have not be processed by the MCL yet. More...
 
buffer_ttal_rx_buffer
 Pointer to receive buffer that can be used to upload a frame from the trx. More...
 
bool tal_rx_on_required
 Indicates if the transceiver needs to switch on its receiver by tal_task(), because it could not be switched on due to buffer shortage. More...
 
uint32_t tal_rx_timestamp
 Timestamp The timestamping is only required for beaconing networks or if timestamping is explicitly enabled. More...
 
tal_state_t tal_state
 Current state of the TAL state machine. More...
 
tal_trx_status_t tal_trx_status
 Current state of the transceiver. More...
 

#define _BV (   x)    (1 << (x))

Bit value – compute the bitmask for a bit position.

Referenced by switch_pll_on(), and tal_init().

#define CLEAR_TRX_IRQ_AMI ( )    (IRQ_STATUS = _BV(AMI))

Clear AMI interrupt.

#define CLEAR_TRX_IRQ_AWAKE ( )    (IRQ_STATUS = _BV(AWAKE))

Clear TRX AWAKE interrupt.

#define CLEAR_TRX_IRQ_BATMON ( )    (BATMON = _BV(BAT_LOW))

Clear TRX BAT LOW interrupt.

#define CLEAR_TRX_IRQ_CCA_ED ( )    (IRQ_STATUS = _BV(CCA_ED_DONE_EN))

Clear TRX CCA_ED_DONE interrupt.

#define CLEAR_TRX_IRQ_PLL_LOCK ( )    (IRQ_STATUS = _BV(PLL_LOCK))

Clear TRX PLL LOCK interrupt.

#define CLEAR_TRX_IRQ_PLL_UNLOCK ( )    (IRQ_STATUS = _BV(PLL_UNLOCK))

Clear TRX PLL UNLOCK interrupt.

#define CLEAR_TRX_IRQ_RX_END ( )    (IRQ_STATUS = _BV(RX_END))

Clear TRX RX_END interrupt.

#define CLEAR_TRX_IRQ_TSTAMP ( )    (IRQ_STATUS = _BV(RX_START))

Clear RX TIME STAMP interrupt.

#define CLEAR_TRX_IRQ_TX_END ( )    (IRQ_STATUS = _BV(TX_END))

Clears TRX TX_END interrupt.

#define PIN_ACK_OK_END ( )

Referenced by handle_tx_end_irq().

#define PIN_ACK_OK_START ( )

Referenced by handle_tx_end_irq().

#define PIN_ACK_WAITING_END ( )

Referenced by handle_tx_end_irq().

#define PIN_ACK_WAITING_START ( )
#define PIN_BACKOFF_END ( )

Referenced by cca_timer_handler_cb().

#define PIN_BACKOFF_START ( )
#define PIN_BEACON_END ( )

Referenced by process_incoming_frame().

#define PIN_BEACON_LOSS_TIMER_END ( )
#define PIN_BEACON_LOSS_TIMER_START ( )

Referenced by start_beacon_loss_timer().

#define PIN_BEACON_START ( )

Referenced by process_incoming_frame().

#define PIN_CCA_END ( )

Referenced by perform_cca_twice().

#define PIN_CCA_START ( )

Referenced by perform_cca_twice().

#define PIN_CSMA_END ( )

Referenced by tx_done().

#define PIN_CSMA_START ( )

Referenced by slotted_csma_start().

#define PIN_NO_ACK_END ( )
#define PIN_NO_ACK_START ( )

Referenced by handle_tx_end_irq().

#define PIN_TX_END ( )

Referenced by handle_tx_end_irq().

#define PIN_TX_START ( )
#define PIN_WAITING_FOR_BEACON_END ( )
#define PIN_WAITING_FOR_BEACON_START ( )
#define TAL_PSDU_US_PER_OCTET (   octets)    ((uint16_t)(octets) * 32)

Conversion of number of PSDU octets to duration in microseconds.

Referenced by calc_frame_transmit_duration(), and tx_done_handling().

#define trx_frame_read (   data,
  length 
)    memcpy((data), (void *)&TRXFBST, (length))

Reads frame buffer of the transceiver.

This macro reads the frame buffer of the transceiver.

Parameters
[out]dataPointer to the location to store frame
[in]lengthNumber of bytes to be read from the frame buffer.

Referenced by handle_received_frame_irq(), and PHY_TaskHandler().

#define trx_frame_write (   data,
  length 
)    memcpy((void *)&TRXFBST, (data), (length))

Writes data into frame buffer of the transceiver.

This macro writes data into the frame buffer of the transceiver

Parameters
[in]dataPointer to data to be written into frame buffer
[in]lengthNumber of bytes to be written into frame buffer

Referenced by PHY_DataReq(), send_frame(), and tfa_continuous_tx_start().

#define TRX_IRQ_AWAKE_ONLY   (TRX_IRQ_AWAKE)

Referenced by set_trx_state().

#define TRX_IRQ_CCA_ED_ONLY   (TRX_IRQ_CCA_ED_READY)
#define TRX_IRQ_DEFAULT
Value:
Signals the completion of a frame transmission.
Definition: atmegarfr2/inc/tal_internal.h:199
Signals completion of a frame reception.
Definition: atmegarfr2/inc/tal_internal.h:190
Signals begin of a receiving frame.
Definition: atmegarfr2/inc/tal_internal.h:187

Referenced by set_trx_state(), tal_generate_rand_seed(), tfa_get_batmon_voltage(), and trx_config().

#define TRX_IRQ_NONE   (0)
#define trx_reg_read (   addr)    (*(volatile uint8_t *)(addr))

Reads current value from a transceiver register.

This macro reads the current value from a transceiver register.

Parameters
addrSpecifies the address of the trx register from which the data shall be read
Returns
value of the register read

Referenced by handle_received_frame_irq(), phyReadRegister(), switch_pll_on(), tal_dump_registers(), tal_get_curr_trx_config(), tal_rpc_mode_config(), tal_set_frequency(), tal_set_frequency_regs(), tal_trx_reg_read(), tal_trx_reg_write(), tfa_ed_sample(), tfa_get_batmon_voltage(), and trx_init().

#define trx_reg_write (   addr,
  data 
)    (*(volatile uint8_t *)(addr)) = (data)

Writes data into a transceiver register.

This macro writes a value into transceiver register.

Parameters
addrAddress of the trx register
dataData to be written to trx register

Referenced by perform_cca_twice(), PHY_SetIEEEAddr(), phyWriteRegister(), send_frame(), set_trx_state(), switch_pll_on(), tal_generate_rand_seed(), tal_pib_set(), tal_rpc_mode_config(), tal_set_frequency(), tal_set_frequency_regs(), tal_trx_reg_write(), tfa_continuous_tx_start(), tfa_ed_sample(), tfa_get_batmon_voltage(), trx_config(), and write_all_tal_pib_to_trx().

#define TRX_RST_HIGH ( )    (TRXPR |= _BV(TRXRST))

Set Reset Bit.

Referenced by trx_init(), and trx_reset().

#define TRX_RST_LOW ( )    (TRXPR &= ~_BV(TRXRST))

Clear Reset Bit.

Referenced by trx_init(), and trx_reset().

#define TRX_SLP_TR_HIGH ( )    (TRXPR |= _BV(SLPTR))
#define TRX_SLP_TR_LOW ( )    (TRXPR &= ~_BV(SLPTR))

typedef enum tal_state_tag tal_state_t

TAL states.

Transceiver interrupt reasons.

TAL states.

Enumerator
TAL_IDLE 
TAL_TX_AUTO 
TAL_TX_DONE 
TAL_SLOTTED_CSMA 
TAL_IDLE 
TAL_TX_AUTO 
TAL_TX_DONE 
TAL_SLOTTED_CSMA 

Transceiver interrupt reasons.

Enumerator
TRX_NO_IRQ 

No interrupt is indicated by IRQ_STATUS register.

TRX_IRQ_PLL_LOCK 

PLL goes to lock-state.

TRX_IRQ_PLL_UNLOCK 

Signals an unlocked PLL.

TRX_IRQ_RX_START 

Signals begin of a receiving frame.

TRX_IRQ_RX_END 

Signals completion of a frame reception.

TRX_IRQ_CCA_ED_READY 

Signals the end of a CCA or ED measurement.

TRX_IRQ_AMI 

Signals an address match.

TRX_IRQ_TX_END 

Signals the completion of a frame transmission.

TRX_IRQ_AWAKE 

Indicates that the radio transceiver reached TRX_OFF state after P_ON, RESET, or SLEEP states.

TRX_NO_IRQ 

No interrupt is indicated by IRQ_STATUS register.

TRX_IRQ_PLL_LOCK 

PLL goes to lock-state.

TRX_IRQ_PLL_UNLOCK 

Signals an unlocked PLL.

TRX_IRQ_RX_START 

Signals begin of a receiving frame.

TRX_IRQ_RX_END 

Signals completion of a frame reception.

TRX_IRQ_CCA_ED_READY 

Signals the end of a CCA or ED measurement.

TRX_IRQ_AMI 

Signals an address match.

TRX_IRQ_TX_END 

Signals the completion of a frame transmission.

TRX_IRQ_AWAKE 

Indicates that the radio transceiver reached TRX_OFF state after P_ON, RESET, or SLEEP states.

tal_trx_status_t set_trx_state ( trx_cmd_t  trx_cmd)

Sets transceiver state.

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

uint8_t last_frame_length
frame_info_t* mac_frame_ptr

Frame pointer for the frame structure provided by the MCL.

volatile bool tal_awake_end_flag
csma_state_t tal_csma_state

CSMA state machine variable.

uint8_t* tal_frame_to_tx

Pointer to the 15.4 frame created by the TAL to be handed over to the transceiver.

queue_t tal_incoming_frame_queue

Queue that contains all frames that are uploaded from the trx, but have not be processed by the MCL yet.

buffer_t* tal_rx_buffer

Pointer to receive buffer that can be used to upload a frame from the trx.

uint32_t tal_rx_timestamp

Timestamp The timestamping is only required for beaconing networks or if timestamping is explicitly enabled.