/** * \brief Handler for ACK reception timeout * * \param parameter Unused callback parameter */ static void ack_timer_expiry_handler_cb(void *parameter) { if (tal_csma_state == TX_DONE_SUCCESS) { return; } set_trx_state(CMD_FORCE_PLL_ON); /* debug pin to switch on: define ENABLE_DEBUG_PINS, pal_config.h */ PIN_NO_ACK_START(); tal_csma_state = TX_DONE_NO_ACK; /* debug pin to switch on: define ENABLE_DEBUG_PINS, pal_config.h */ PIN_NO_ACK_END(); PIN_ACK_WAITING_END(); parameter = parameter; /* Keep compiler happy. */ }
/* * \brief Handles interrupts issued due to end of transmission */ void handle_tx_end_irq(void) { /* Check if TX_END interrupt, is issued due to automatic ACK * transmission. */ #if ((MAC_START_REQUEST_CONFIRM == 1) && (defined BEACON_SUPPORT)) if ((tal_state != TAL_TX_AUTO) && (!tal_beacon_transmission)) #else if (tal_state != TAL_TX_AUTO) #endif { /* Automatic ACK transmission completed -> No further * processing. */ return; } #if ((MAC_START_REQUEST_CONFIRM == 1) && (defined BEACON_SUPPORT)) if (tal_beacon_transmission) { tal_beacon_transmission = false; if (tal_csma_state == BACKOFF_WAITING_FOR_BEACON) { /* Slotted CSMA has been waiting for a beacon, now it * can continue. */ tal_csma_state = CSMA_HANDLE_BEACON; } } else #endif /* ((MAC_START_REQUEST_CONFIRM == 1) && (defined BEACON_SUPPORT)) */ { /* Read trac status before enabling RX_AACK_ON. */ trx_trac_status = (trx_trac_status_t)trx_bit_read( SR_TRAC_STATUS); #ifdef BEACON_SUPPORT if (tal_csma_state == FRAME_SENDING) { /* Transmission was * issued by slotted CSMA **/ PIN_TX_END(); tal_state = TAL_SLOTTED_CSMA; /* Map status message of transceiver to TAL constants. **/ switch (trx_trac_status) { case TRAC_SUCCESS_DATA_PENDING: PIN_ACK_OK_START(); tal_csma_state = TX_DONE_FRAME_PENDING; break; case TRAC_SUCCESS: PIN_ACK_OK_START(); tal_csma_state = TX_DONE_SUCCESS; break; case TRAC_CHANNEL_ACCESS_FAILURE: PIN_NO_ACK_START(); tal_csma_state = CSMA_ACCESS_FAILURE; break; case TRAC_NO_ACK: PIN_NO_ACK_START(); tal_csma_state = TX_DONE_NO_ACK; break; case TRAC_INVALID: /* Handle this in the same way as * default. */ default: Assert("not handled trac status" == 0); tal_csma_state = CSMA_ACCESS_FAILURE; break; } PIN_ACK_OK_END(); PIN_ACK_WAITING_END(); } else #endif /* BEACON_SUPPORT */ /* Trx has handled the entire transmission incl. CSMA */ { tal_state = TAL_TX_DONE; /* Further handling is done by * tx_done_handling() */ } } /* * After transmission has finished, switch receiver on again. * Check if receive buffer is available. */ if (NULL == tal_rx_buffer) { set_trx_state(CMD_PLL_ON); tal_rx_on_required = true; } else { set_trx_state(CMD_RX_AACK_ON); } }
/* * \brief Handles interrupts issued due to end of transmission * * \param underrun_occured true if under-run has occurred */ void handle_tx_end_irq(bool underrun_occured) { #if ((MAC_START_REQUEST_CONFIRM == 1) && (defined BEACON_SUPPORT)) if (tal_beacon_transmission) { tal_beacon_transmission = false; if (tal_csma_state == BACKOFF_WAITING_FOR_BEACON) { /* Slotted CSMA has been waiting for a beacon, now it * can continue. */ tal_csma_state = CSMA_HANDLE_BEACON; } } else #endif /* ((MAC_START_REQUEST_CONFIRM == 1) && (defined BEACON_SUPPORT)) */ { #if (defined BEACON_SUPPORT) || (defined ENABLE_TSTAMP) /* * Store tx timestamp to frame_info_t structure. * The timestamping is only required for beaconing networks * or if timestamping is explicitly enabled. */ pal_trx_read_timestamp(&mac_frame_ptr->time_stamp); #endif /* #if (defined BEACON_SUPPORT) || (defined ENABLE_TSTAMP) */ /* Read trac status before enabling RX_AACK_ON. */ if (underrun_occured) { trx_trac_status = TRAC_INVALID; } else { trx_trac_status = (trx_trac_status_t)trx_bit_read( SR_TRAC_STATUS); } #ifdef BEACON_SUPPORT if (tal_csma_state == FRAME_SENDING) { /* Transmission was * issued by slotted CSMA **/ PIN_TX_END(); tal_state = TAL_SLOTTED_CSMA; /* Map status message of transceiver to TAL constants. **/ switch (trx_trac_status) { case TRAC_SUCCESS_DATA_PENDING: PIN_ACK_OK_START(); tal_csma_state = TX_DONE_FRAME_PENDING; break; case TRAC_SUCCESS: PIN_ACK_OK_START(); tal_csma_state = TX_DONE_SUCCESS; break; case TRAC_CHANNEL_ACCESS_FAILURE: PIN_NO_ACK_START(); tal_csma_state = CSMA_ACCESS_FAILURE; break; case TRAC_NO_ACK: PIN_NO_ACK_START(); tal_csma_state = TX_DONE_NO_ACK; break; case TRAC_INVALID: /* Handle this in the same way as * default. */ default: Assert("not handled trac status" == 0); tal_csma_state = CSMA_ACCESS_FAILURE; break; } PIN_ACK_OK_END(); PIN_ACK_WAITING_END(); } else #endif /* BEACON_SUPPORT */ /* Trx has handled the entire transmission incl. CSMA */ { tal_state = TAL_TX_DONE; /* Further handling is done by * tx_done_handling() */ } } /* * After transmission has finished, switch receiver on again. * Check if receive buffer is available. */ if (NULL == tal_rx_buffer) { set_trx_state(CMD_PLL_ON); tal_rx_on_required = true; } else { set_trx_state(CMD_RX_AACK_ON); } }