/*================================================================================================= * @fn rxHaltCleanupFinalStep * * @brief Required cleanup if receiver is halted in the middle of a receive. * * @param none * * @return none *================================================================================================= */ static void rxHaltCleanupFinalStep(void) { /* cancel any upcoming ACK transmit complete callback */ MAC_RADIO_CANCEL_ACK_TX_DONE_CALLBACK(); /* set start of frame threshold */ MAC_RADIO_SET_RX_THRESHOLD(RX_THRESHOLD_START_LEN); /* flush the receive FIFO */ MAC_RADIO_FLUSH_RX_FIFO(); /* clear any receive interrupt that happened to squeak through */ MAC_RADIO_CLEAR_RX_THRESHOLD_INTERRUPT_FLAG(); /* if data buffer has been allocated, free it */ if (pRxBuf != NULL) { MEM_FREE((uint8 **)&pRxBuf); } /* MEM_FREE() sets parameter to NULL. */ pFuncRxState = &rxStartIsr; /* if receive was active, perform the post receive updates */ if (macRxActive || macRxOutgoingAckFlag) { macRxActive = MAC_RX_ACTIVE_NO_ACTIVITY; macRxOutgoingAckFlag = 0; rxPostRxUpdates(); } }
/************************************************************************************************** * @fn macRxOff * * @brief Turn off the receiver if it's not already off. * * @param none * * @return none ************************************************************************************************** */ MAC_INTERNAL_API void macRxOff(void) { halIntState_t s; DBG_PRINT1(DBGSYS, "macRxOff(): macRxOnFlag = 0x%X", macRxOnFlag); HAL_ENTER_CRITICAL_SECTION(s); if (macRxOnFlag) { macRxOnFlag = 0; DBG_PRINT0(DBGSYS, "MAC_RADIO_RXTX_OFF()"); MAC_RADIO_RXTX_OFF(); /* Wait till RX is completely off before issuing another RX related * command which may fail if issued beforehand. */ macCheckCommnadDone(&macRxEdScan.rxCmd.rfOpCmd); /* Wait till all FG commands are done */ macCheckCommnadDone(&macCsmaCaCmd.rfOpCmd); macCheckCommnadDone(&macTxCmd.rfOpCmd); macCheckCommnadDone(&macRxAckCmd.rfOpCmd); MAC_DEBUG_TURN_OFF_RX_LED(); /* just in case a receive was about to start, flush the receive FIFO */ MAC_RADIO_FLUSH_RX_FIFO(); /* clear any receive interrupt that happened to squeak through */ MAC_RADIO_CLEAR_RX_THRESHOLD_INTERRUPT_FLAG(); } HAL_EXIT_CRITICAL_SECTION(s); }
/************************************************************************************************** * @fn macRxRadioPowerUpInit * * @brief Initialization for after radio first powers up. * * @param none * * @return none ************************************************************************************************** */ MAC_INTERNAL_API void macRxRadioPowerUpInit(void) { /* set threshold at initial value */ MAC_RADIO_SET_RX_THRESHOLD(RX_THRESHOLD_START_LEN); /* clear any accidental threshold interrupt that happened as part of power up sequence */ MAC_RADIO_CLEAR_RX_THRESHOLD_INTERRUPT_FLAG(); /* enable threshold interrupts */ MAC_RADIO_ENABLE_RX_THRESHOLD_INTERRUPT(); }
/************************************************************************************************** * @fn macRxOff * * @brief Turn off the receiver if it's not already off. * * @param none * * @return none ************************************************************************************************** */ void macRxOff(void) { halIntState_t s; HAL_ENTER_CRITICAL_SECTION(s); if (macRxOnFlag) { macRxOnFlag = 0; MAC_RADIO_RXTX_OFF(); MAC_DEBUG_TURN_OFF_RX_LED(); /* just in case a receive was about to start, flush the receive FIFO */ MAC_RADIO_FLUSH_RX_FIFO(); /* clear any receive interrupt that happened to squeak through */ MAC_RADIO_CLEAR_RX_THRESHOLD_INTERRUPT_FLAG(); } HAL_EXIT_CRITICAL_SECTION(s); }