Transmits data using Slotted CSMA/CA mechanism.
Macros | |
#define | ACK_FRAME (0x02) |
#define | ACK_FRAME_LEN (0x05) |
#define | CCA_GUARD_DURATION_US |
#define | CSMA_BEACON_LOSS_GUARD_TIME_US (2000) |
#define | PRE_BEACON_GUARD_TIME_US (1000) |
Typedefs | |
typedef enum csma_state_tag | csma_state_t |
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) |
Referenced by calc_frame_transmit_duration(), and calculate_transaction_duration().
#define CCA_GUARD_DURATION_US |
Referenced by csma_backoff_calculation().
#define CSMA_BEACON_LOSS_GUARD_TIME_US (2000) |
Referenced by start_beacon_loss_timer().
#define PRE_BEACON_GUARD_TIME_US (1000) |
Referenced by csma_backoff_calculation().
typedef enum csma_state_tag csma_state_t |
enum csma_state_tag |
|
static |
Handler for beacon loss timer.
parameter | Unused 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.
phy_frame | Address to the frame |
octets
symbols
References ACK_FRAME_LEN, aMaxSIFSFrameSize, aTurnaroundTime, aUnitBackoffPeriod, FCF_ACK_REQUEST, macMinLIFSPeriod_def, macMinSIFSPeriod_def, PHY_OVERHEAD, PL_POS_FCF_1, SYMBOLS_PER_OCTET, and TAL_PSDU_US_PER_OCTET.
|
static |
Calculates the entire transaction duration.
References ACK_FRAME_LEN, aMaxSIFSFrameSize, aTurnaroundTime, aUnitBackoffPeriod, FCF_ACK_REQUEST, mac_frame_ptr, macMinLIFSPeriod_def, macMinSIFSPeriod_def, frame_info_tag::mpdu, PHY_OVERHEAD, PL_POS_FCF_1, SYMBOLS_PER_OCTET, tal_frame_to_tx, and transaction_duration_periods.
Referenced by slotted_csma_start().
|
static |
CCA timer callback.
parameter | Unused 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 |
Checks if node is receiving beacons.
References aMaxLostBeacons, pal_get_current_time(), tal_add_time_symbols(), TAL_GET_BEACON_INTERVAL_TIME, and tal_pib.
Referenced by slotted_csma_start().
|
static |
Calculates backoff duration and handles the start of the CCA.
References Assert, aUnitBackoffPeriod, BACKOFF_WAITING_FOR_BEACON, BACKOFF_WAITING_FOR_CCA_TIMER, BE, CCA_GUARD_DURATION_US, CCA_PREPARATION_DURATION_US, cca_starttime_us, cca_timer_handler_cb(), CSMA_ACCESS_FAILURE, FUNC_PTR, MAC_SUCCESS, NB, NULL, pal_add_time_us(), pal_get_current_time(), pal_sub_time_us(), pal_timer_start(), PAL_TMR_INVALID_TIMEOUT, PIN_BACKOFF_START, PRE_BEACON_GUARD_TIME_US, remaining_backoff_periods, SLEEP_TO_TRX_OFF_TYP_US, start_beacon_loss_timer(), tal_add_time_symbols(), TAL_CONVERT_SYMBOLS_TO_US, TAL_CSMA_CCA, tal_csma_state, TAL_GET_SUPERFRAME_DURATION_TIME, tal_pib, TAL_RADIO_WAKEUP_TIME_SYM, tal_sub_time_symbols(), TIMEOUT_ABSOLUTE, and transaction_duration_periods.
Referenced by slotted_csma_start(), and slotted_csma_state_handling().
|
inlinestatic |
|
static |
Performs CCA twice.
References Assert, aUnitBackoffPeriod, CCA_CH_IDLE, CCA_COMPLETED, CCA_DURATION_SYM, CCA_PRE_START_DURATION_US, CCA_PREPARATION_DURATION_US, CCA_START, cca_starttime_us, CMD_PLL_ON, CMD_RX_AACK_ON, CMD_RX_ON, CMD_TRX_OFF, pal_add_time_us(), pal_get_current_time(), pal_timer_delay, PHY_BUSY, PHY_IDLE, PIN_CCA_END, PIN_CCA_START, PLL_ON, RG_IRQ_STATUS, RX_DISABLE, RX_ENABLE, set_trx_state(), SLEEP_TO_TRX_OFF_TYP_US, SR_CCA_DONE, SR_CCA_REQUEST, SR_CCA_STATUS, SR_RX_PDT_DIS, TAL_CONVERT_SYMBOLS_TO_US, tal_trx_status, trx_bit_read(), trx_bit_write(), TRX_OFF_TO_PLL_ON_TIME_US, trx_reg_read(), and TRX_SLEEP.
Referenced by cca_timer_handler_cb().
|
static |
Sends the frame at the next backoff boundary.
References cca_starttime_us, FRAME_SENDING, NO_CSMA_NO_IFS, pal_add_time_us(), pal_get_current_time(), PIN_TX_START, PRE_TX_DURATION_US, send_frame(), and tal_csma_state.
Referenced by cca_timer_handler_cb().
Starts slotted CSMA.
References BE, calculate_transaction_duration(), check_beacon_reception(), csma_backoff_calculation(), csma_param_init(), number_of_tx_retries, PIN_CSMA_START, remaining_backoff_periods, tal_pib, TAL_SLOTTED_CSMA, and tal_state.
void slotted_csma_state_handling | ( | void | ) |
State machine handling slotted CSMA.
References Assert, BACKOFF_WAITING_FOR_BEACON, BACKOFF_WAITING_FOR_CCA_TIMER, BE, CMD_RX_AACK_ON, CSMA_ACCESS_FAILURE, csma_backoff_calculation(), CSMA_HANDLE_BEACON, FRAME_SENDING, MAC_CHANNEL_ACCESS_FAILURE, MAC_NO_ACK, MAC_SUCCESS, macMaxCSMABackoffs, NB, NO_BEACON_TRACKING, number_of_tx_retries, pal_timer_stop(), PIN_BEACON_LOSS_TIMER_END, PIN_NO_ACK_END, PIN_WAITING_FOR_BEACON_END, remaining_backoff_periods, set_trx_state(), TAL_CSMA_BEACON_LOSS_TIMER, tal_csma_state, TAL_FRAME_PENDING, tal_pib, tx_done(), TX_DONE_FRAME_PENDING, TX_DONE_NO_ACK, and TX_DONE_SUCCESS.
|
static |
Starts the beacon loss timer.
References aMaxLostBeacons, Assert, beacon_loss_timer_cb(), CSMA_BEACON_LOSS_GUARD_TIME_US, FUNC_PTR, MAC_SUCCESS, NULL, pal_timer_start(), PAL_TMR_ALREADY_RUNNING, PAL_TMR_INVALID_TIMEOUT, PIN_BEACON_LOSS_TIMER_START, TAL_CONVERT_SYMBOLS_TO_US, TAL_CSMA_BEACON_LOSS_TIMER, TAL_GET_BEACON_INTERVAL_TIME, tal_pib, and TIMEOUT_RELATIVE.
Referenced by csma_backoff_calculation().
|
static |
Finalizes the CSMA procedure.
status | Result 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().
Referenced by slotted_csma_state_handling().
|
static |
Referenced by csma_backoff_calculation(), csma_param_init(), slotted_csma_start(), and slotted_csma_state_handling().
|
static |
Referenced by csma_backoff_calculation(), perform_cca_twice(), and send_frame_at_next_backoff_boundary().
|
static |
Referenced by csma_backoff_calculation(), csma_param_init(), and slotted_csma_state_handling().
|
static |
Referenced by slotted_csma_start(), and slotted_csma_state_handling().
|
static |
Referenced by csma_backoff_calculation(), slotted_csma_start(), and slotted_csma_state_handling().
|
static |
Referenced by calculate_transaction_duration(), and csma_backoff_calculation().