Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages

Transmits data using Slotted CSMA/CA mechanism.

Macros

#define ACK_FRAME   (0x02)
 
#define ACK_FRAME_LEN   (0x05)
 
#define CCA_GUARD_DURATION_US
 
#define CONVERT_OCTETS_TO_SYM(octets)   (2 * octets)
 
#define CSMA_BEACON_LOSS_GUARD_TIME_US   (2000)
 
#define PRE_BEACON_GUARD_TIME_US   (1000)
 

Typedefs

typedef enum csma_state_tag csma_state_t
 
typedef enum csma_state_tag csma_state_t
 
typedef enum csma_state_tag csma_state_t
 

Enumerations

enum  csma_state_tag {
  CSMA_IDLE = 0,
  BACKOFF_WAITING_FOR_CCA_TIMER,
  BACKOFF_WAITING_FOR_BEACON,
  CSMA_ACCESS_FAILURE,
  FRAME_SENDING,
  TX_DONE_SUCCESS,
  TX_DONE_FRAME_PENDING,
  TX_DONE_NO_ACK,
  NO_BEACON_TRACKING,
  CSMA_HANDLE_BEACON,
  CSMA_IDLE = 0,
  BACKOFF_WAITING_FOR_CCA_TIMER,
  BACKOFF_WAITING_FOR_BEACON,
  CSMA_ACCESS_FAILURE,
  FRAME_SENDING,
  TX_DONE_SUCCESS,
  TX_DONE_FRAME_PENDING,
  TX_DONE_NO_ACK,
  NO_BEACON_TRACKING,
  CSMA_HANDLE_BEACON,
  CSMA_IDLE = 0,
  BACKOFF_WAITING_FOR_CCA_TIMER,
  BACKOFF_WAITING_FOR_BEACON,
  CSMA_ACCESS_FAILURE,
  FRAME_SENDING,
  TX_DONE_SUCCESS,
  TX_DONE_FRAME_PENDING,
  TX_DONE_NO_ACK,
  NO_BEACON_TRACKING,
  CSMA_HANDLE_BEACON,
  CSMA_IDLE = 0,
  BACKOFF_WAITING_FOR_CCA_TIMER,
  BACKOFF_WAITING_FOR_BEACON,
  CSMA_ACCESS_FAILURE,
  FRAME_SENDING,
  TX_DONE_SUCCESS,
  TX_DONE_FRAME_PENDING,
  TX_DONE_NO_ACK,
  NO_BEACON_TRACKING,
  CSMA_HANDLE_BEACON,
  CSMA_IDLE = 0,
  BACKOFF_WAITING_FOR_CCA_TIMER,
  BACKOFF_WAITING_FOR_BEACON,
  CSMA_ACCESS_FAILURE,
  FRAME_SENDING,
  TX_DONE_SUCCESS,
  TX_DONE_FRAME_PENDING,
  TX_DONE_NO_ACK,
  NO_BEACON_TRACKING,
  CSMA_HANDLE_BEACON
}
 
enum  csma_state_tag {
  CSMA_IDLE = 0,
  BACKOFF_WAITING_FOR_CCA_TIMER,
  BACKOFF_WAITING_FOR_BEACON,
  CSMA_ACCESS_FAILURE,
  FRAME_SENDING,
  TX_DONE_SUCCESS,
  TX_DONE_FRAME_PENDING,
  TX_DONE_NO_ACK,
  NO_BEACON_TRACKING,
  CSMA_HANDLE_BEACON,
  CSMA_IDLE = 0,
  BACKOFF_WAITING_FOR_CCA_TIMER,
  BACKOFF_WAITING_FOR_BEACON,
  CSMA_ACCESS_FAILURE,
  FRAME_SENDING,
  TX_DONE_SUCCESS,
  TX_DONE_FRAME_PENDING,
  TX_DONE_NO_ACK,
  NO_BEACON_TRACKING,
  CSMA_HANDLE_BEACON,
  CSMA_IDLE = 0,
  BACKOFF_WAITING_FOR_CCA_TIMER,
  BACKOFF_WAITING_FOR_BEACON,
  CSMA_ACCESS_FAILURE,
  FRAME_SENDING,
  TX_DONE_SUCCESS,
  TX_DONE_FRAME_PENDING,
  TX_DONE_NO_ACK,
  NO_BEACON_TRACKING,
  CSMA_HANDLE_BEACON,
  CSMA_IDLE = 0,
  BACKOFF_WAITING_FOR_CCA_TIMER,
  BACKOFF_WAITING_FOR_BEACON,
  CSMA_ACCESS_FAILURE,
  FRAME_SENDING,
  TX_DONE_SUCCESS,
  TX_DONE_FRAME_PENDING,
  TX_DONE_NO_ACK,
  NO_BEACON_TRACKING,
  CSMA_HANDLE_BEACON,
  CSMA_IDLE = 0,
  BACKOFF_WAITING_FOR_CCA_TIMER,
  BACKOFF_WAITING_FOR_BEACON,
  CSMA_ACCESS_FAILURE,
  FRAME_SENDING,
  TX_DONE_SUCCESS,
  TX_DONE_FRAME_PENDING,
  TX_DONE_NO_ACK,
  NO_BEACON_TRACKING,
  CSMA_HANDLE_BEACON
}
 
enum  csma_state_tag {
  CSMA_IDLE = 0,
  BACKOFF_WAITING_FOR_CCA_TIMER,
  BACKOFF_WAITING_FOR_BEACON,
  CSMA_ACCESS_FAILURE,
  FRAME_SENDING,
  TX_DONE_SUCCESS,
  TX_DONE_FRAME_PENDING,
  TX_DONE_NO_ACK,
  NO_BEACON_TRACKING,
  CSMA_HANDLE_BEACON,
  CSMA_IDLE = 0,
  BACKOFF_WAITING_FOR_CCA_TIMER,
  BACKOFF_WAITING_FOR_BEACON,
  CSMA_ACCESS_FAILURE,
  FRAME_SENDING,
  TX_DONE_SUCCESS,
  TX_DONE_FRAME_PENDING,
  TX_DONE_NO_ACK,
  NO_BEACON_TRACKING,
  CSMA_HANDLE_BEACON,
  CSMA_IDLE = 0,
  BACKOFF_WAITING_FOR_CCA_TIMER,
  BACKOFF_WAITING_FOR_BEACON,
  CSMA_ACCESS_FAILURE,
  FRAME_SENDING,
  TX_DONE_SUCCESS,
  TX_DONE_FRAME_PENDING,
  TX_DONE_NO_ACK,
  NO_BEACON_TRACKING,
  CSMA_HANDLE_BEACON,
  CSMA_IDLE = 0,
  BACKOFF_WAITING_FOR_CCA_TIMER,
  BACKOFF_WAITING_FOR_BEACON,
  CSMA_ACCESS_FAILURE,
  FRAME_SENDING,
  TX_DONE_SUCCESS,
  TX_DONE_FRAME_PENDING,
  TX_DONE_NO_ACK,
  NO_BEACON_TRACKING,
  CSMA_HANDLE_BEACON,
  CSMA_IDLE = 0,
  BACKOFF_WAITING_FOR_CCA_TIMER,
  BACKOFF_WAITING_FOR_BEACON,
  CSMA_ACCESS_FAILURE,
  FRAME_SENDING,
  TX_DONE_SUCCESS,
  TX_DONE_FRAME_PENDING,
  TX_DONE_NO_ACK,
  NO_BEACON_TRACKING,
  CSMA_HANDLE_BEACON
}
 

Functions

static void beacon_loss_timer_cb (void *parameter)
 Handler for beacon loss timer. More...
 
uint16_t calc_frame_transmit_duration (uint8_t *phy_frame)
 Calculates the entire transaction duration. More...
 
static void calculate_transaction_duration (void)
 Calculates the entire transaction duration. More...
 
static void cca_timer_handler_cb (void *parameter)
 CCA timer callback. More...
 
static bool check_beacon_reception (void)
 Checks if node is receiving beacons. More...
 
static void csma_backoff_calculation (void)
 Calculates backoff duration and handles the start of the CCA. More...
 
static void csma_param_init (void)
 Initializes CSMA variables. More...
 
static uint8_t perform_cca_twice (void)
 Performs CCA twice. More...
 
static void send_frame_at_next_backoff_boundary (void)
 Sends the frame at the next backoff boundary. More...
 
bool slotted_csma_start (bool perform_frame_retry)
 Starts slotted CSMA. More...
 
void slotted_csma_state_handling (void)
 State machine handling slotted CSMA. More...
 
static void start_beacon_loss_timer (void)
 Starts the beacon loss timer. More...
 
static void tx_done (retval_t status)
 Finalizes the CSMA procedure. More...
 

Variables

static uint8_t BE
 
static uint32_t cca_starttime_us
 
static uint8_t NB
 
static uint8_t number_of_tx_retries
 
static uint8_t remaining_backoff_periods
 
static uint8_t transaction_duration_periods
 

#define ACK_FRAME   (0x02)
#define ACK_FRAME_LEN   (0x05)
#define CCA_GUARD_DURATION_US
Value:
(1000) /* used for calculation overhead
**/

Referenced by csma_backoff_calculation().

#define CONVERT_OCTETS_TO_SYM (   octets)    (2 * octets)
#define CSMA_BEACON_LOSS_GUARD_TIME_US   (2000)

Referenced by start_beacon_loss_timer().

#define PRE_BEACON_GUARD_TIME_US   (1000)

Enumerator
CSMA_IDLE 
BACKOFF_WAITING_FOR_CCA_TIMER 
BACKOFF_WAITING_FOR_BEACON 
CSMA_ACCESS_FAILURE 
FRAME_SENDING 
TX_DONE_SUCCESS 
TX_DONE_FRAME_PENDING 
TX_DONE_NO_ACK 
NO_BEACON_TRACKING 
CSMA_HANDLE_BEACON 
CSMA_IDLE 
BACKOFF_WAITING_FOR_CCA_TIMER 
BACKOFF_WAITING_FOR_BEACON 
CSMA_ACCESS_FAILURE 
FRAME_SENDING 
TX_DONE_SUCCESS 
TX_DONE_FRAME_PENDING 
TX_DONE_NO_ACK 
NO_BEACON_TRACKING 
CSMA_HANDLE_BEACON 
CSMA_IDLE 
BACKOFF_WAITING_FOR_CCA_TIMER 
BACKOFF_WAITING_FOR_BEACON 
CSMA_ACCESS_FAILURE 
FRAME_SENDING 
TX_DONE_SUCCESS 
TX_DONE_FRAME_PENDING 
TX_DONE_NO_ACK 
NO_BEACON_TRACKING 
CSMA_HANDLE_BEACON 
CSMA_IDLE 
BACKOFF_WAITING_FOR_CCA_TIMER 
BACKOFF_WAITING_FOR_BEACON 
CSMA_ACCESS_FAILURE 
FRAME_SENDING 
TX_DONE_SUCCESS 
TX_DONE_FRAME_PENDING 
TX_DONE_NO_ACK 
NO_BEACON_TRACKING 
CSMA_HANDLE_BEACON 
CSMA_IDLE 
BACKOFF_WAITING_FOR_CCA_TIMER 
BACKOFF_WAITING_FOR_BEACON 
CSMA_ACCESS_FAILURE 
FRAME_SENDING 
TX_DONE_SUCCESS 
TX_DONE_FRAME_PENDING 
TX_DONE_NO_ACK 
NO_BEACON_TRACKING 
CSMA_HANDLE_BEACON 
Enumerator
CSMA_IDLE 
BACKOFF_WAITING_FOR_CCA_TIMER 
BACKOFF_WAITING_FOR_BEACON 
CSMA_ACCESS_FAILURE 
FRAME_SENDING 
TX_DONE_SUCCESS 
TX_DONE_FRAME_PENDING 
TX_DONE_NO_ACK 
NO_BEACON_TRACKING 
CSMA_HANDLE_BEACON 
CSMA_IDLE 
BACKOFF_WAITING_FOR_CCA_TIMER 
BACKOFF_WAITING_FOR_BEACON 
CSMA_ACCESS_FAILURE 
FRAME_SENDING 
TX_DONE_SUCCESS 
TX_DONE_FRAME_PENDING 
TX_DONE_NO_ACK 
NO_BEACON_TRACKING 
CSMA_HANDLE_BEACON 
CSMA_IDLE 
BACKOFF_WAITING_FOR_CCA_TIMER 
BACKOFF_WAITING_FOR_BEACON 
CSMA_ACCESS_FAILURE 
FRAME_SENDING 
TX_DONE_SUCCESS 
TX_DONE_FRAME_PENDING 
TX_DONE_NO_ACK 
NO_BEACON_TRACKING 
CSMA_HANDLE_BEACON 
CSMA_IDLE 
BACKOFF_WAITING_FOR_CCA_TIMER 
BACKOFF_WAITING_FOR_BEACON 
CSMA_ACCESS_FAILURE 
FRAME_SENDING 
TX_DONE_SUCCESS 
TX_DONE_FRAME_PENDING 
TX_DONE_NO_ACK 
NO_BEACON_TRACKING 
CSMA_HANDLE_BEACON 
CSMA_IDLE 
BACKOFF_WAITING_FOR_CCA_TIMER 
BACKOFF_WAITING_FOR_BEACON 
CSMA_ACCESS_FAILURE 
FRAME_SENDING 
TX_DONE_SUCCESS 
TX_DONE_FRAME_PENDING 
TX_DONE_NO_ACK 
NO_BEACON_TRACKING 
CSMA_HANDLE_BEACON 
Enumerator
CSMA_IDLE 
BACKOFF_WAITING_FOR_CCA_TIMER 
BACKOFF_WAITING_FOR_BEACON 
CSMA_ACCESS_FAILURE 
FRAME_SENDING 
TX_DONE_SUCCESS 
TX_DONE_FRAME_PENDING 
TX_DONE_NO_ACK 
NO_BEACON_TRACKING 
CSMA_HANDLE_BEACON 
CSMA_IDLE 
BACKOFF_WAITING_FOR_CCA_TIMER 
BACKOFF_WAITING_FOR_BEACON 
CSMA_ACCESS_FAILURE 
FRAME_SENDING 
TX_DONE_SUCCESS 
TX_DONE_FRAME_PENDING 
TX_DONE_NO_ACK 
NO_BEACON_TRACKING 
CSMA_HANDLE_BEACON 
CSMA_IDLE 
BACKOFF_WAITING_FOR_CCA_TIMER 
BACKOFF_WAITING_FOR_BEACON 
CSMA_ACCESS_FAILURE 
FRAME_SENDING 
TX_DONE_SUCCESS 
TX_DONE_FRAME_PENDING 
TX_DONE_NO_ACK 
NO_BEACON_TRACKING 
CSMA_HANDLE_BEACON 
CSMA_IDLE 
BACKOFF_WAITING_FOR_CCA_TIMER 
BACKOFF_WAITING_FOR_BEACON 
CSMA_ACCESS_FAILURE 
FRAME_SENDING 
TX_DONE_SUCCESS 
TX_DONE_FRAME_PENDING 
TX_DONE_NO_ACK 
NO_BEACON_TRACKING 
CSMA_HANDLE_BEACON 
CSMA_IDLE 
BACKOFF_WAITING_FOR_CCA_TIMER 
BACKOFF_WAITING_FOR_BEACON 
CSMA_ACCESS_FAILURE 
FRAME_SENDING 
TX_DONE_SUCCESS 
TX_DONE_FRAME_PENDING 
TX_DONE_NO_ACK 
NO_BEACON_TRACKING 
CSMA_HANDLE_BEACON 

static void beacon_loss_timer_cb ( void *  parameter)
static

Handler for beacon loss timer.

Parameters
parameterUnused callback parameter

References Assert, BACKOFF_WAITING_FOR_BEACON, NO_BEACON_TRACKING, PIN_BEACON_LOSS_TIMER_END, and tal_csma_state.

Referenced by start_beacon_loss_timer().

uint16_t calc_frame_transmit_duration ( uint8_t *  phy_frame)

Calculates the entire transaction duration.

octets

symbols

static void cca_timer_handler_cb ( void *  parameter)
static

CCA timer callback.

Parameters
parameterUnused callback parameter

References CSMA_ACCESS_FAILURE, perform_cca_twice(), PHY_IDLE, PIN_BACKOFF_END, send_frame_at_next_backoff_boundary(), and tal_csma_state.

Referenced by csma_backoff_calculation().

static bool check_beacon_reception ( void  )
static

Checks if node is receiving beacons.

Returns
true: beacons are received otherwise false

References aMaxLostBeacons, pal_get_current_time(), tal_add_time_symbols(), TAL_GET_BEACON_INTERVAL_TIME, and tal_pib.

static void csma_param_init ( void  )
inlinestatic

Initializes CSMA variables.

References BE, NB, and tal_pib.

static void send_frame_at_next_backoff_boundary ( void  )
static
bool slotted_csma_start ( bool  perform_frame_retry)

Starts slotted CSMA.

void slotted_csma_state_handling ( void  )

State machine handling slotted CSMA.

static void tx_done ( retval_t  status)
static

Finalizes the CSMA procedure.

Parameters
statusResult of the slotted transmission

References Assert, CSMA_IDLE, mac_frame_ptr, pal_is_timer_running(), PIN_CSMA_END, TAL_CSMA_BEACON_LOSS_TIMER, tal_csma_state, TAL_IDLE, TAL_SLOTTED_CSMA, tal_state, and tal_tx_frame_done_cb().

uint8_t BE
static
uint32_t cca_starttime_us
static
uint8_t NB
static
uint8_t number_of_tx_retries
static
uint8_t remaining_backoff_periods
static
uint8_t transaction_duration_periods
static