static void handleEnergyScan() { if (sStartScan) { if ((otPlatAlarmMilliGetNow() - sScanStartTime) < sScanDuration) { int8_t curRssi = PHY_EdReq(); if (curRssi > sMaxRssi) { sMaxRssi = curRssi; } } else { sStartScan = false; otPlatRadioEnergyScanDone(sInstance, sMaxRssi); radioRestore(); } } }
void nrf5RadioProcess(otInstance *aInstance) { for (uint32_t i = 0; i < NRF_802154_RX_BUFFERS; i++) { if (sReceivedFrames[i].mPsdu != NULL) { #if OPENTHREAD_ENABLE_DIAG if (otPlatDiagModeGet()) { otPlatDiagRadioReceiveDone(aInstance, &sReceivedFrames[i], OT_ERROR_NONE); } else #endif { otPlatRadioReceiveDone(aInstance, &sReceivedFrames[i], OT_ERROR_NONE); } uint8_t *bufferAddress = &sReceivedFrames[i].mPsdu[-1]; sReceivedFrames[i].mPsdu = NULL; nrf_802154_buffer_free_raw(bufferAddress); } } if (isPendingEventSet(kPendingEventFrameTransmitted)) { resetPendingEvent(kPendingEventFrameTransmitted); #if OPENTHREAD_ENABLE_DIAG if (otPlatDiagModeGet()) { otPlatDiagRadioTransmitDone(aInstance, &sTransmitFrame, OT_ERROR_NONE); } else #endif { otRadioFrame *ackPtr = (sAckFrame.mPsdu == NULL) ? NULL : &sAckFrame; otPlatRadioTxDone(aInstance, &sTransmitFrame, ackPtr, OT_ERROR_NONE); } if (sAckFrame.mPsdu != NULL) { nrf_802154_buffer_free_raw(sAckFrame.mPsdu - 1); sAckFrame.mPsdu = NULL; } } if (isPendingEventSet(kPendingEventChannelAccessFailure)) { resetPendingEvent(kPendingEventChannelAccessFailure); #if OPENTHREAD_ENABLE_DIAG if (otPlatDiagModeGet()) { otPlatDiagRadioTransmitDone(aInstance, &sTransmitFrame, OT_ERROR_CHANNEL_ACCESS_FAILURE); } else #endif { otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL, OT_ERROR_CHANNEL_ACCESS_FAILURE); } } if (isPendingEventSet(kPendingEventInvalidOrNoAck)) { resetPendingEvent(kPendingEventInvalidOrNoAck); #if OPENTHREAD_ENABLE_DIAG if (otPlatDiagModeGet()) { otPlatDiagRadioTransmitDone(aInstance, &sTransmitFrame, OT_ERROR_NO_ACK); } else #endif { otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL, OT_ERROR_NO_ACK); } } if (isPendingEventSet(kPendingEventReceiveFailed)) { resetPendingEvent(kPendingEventReceiveFailed); #if OPENTHREAD_ENABLE_DIAG if (otPlatDiagModeGet()) { otPlatDiagRadioReceiveDone(aInstance, NULL, sReceiveError); } else #endif { otPlatRadioReceiveDone(aInstance, NULL, sReceiveError); } } if (isPendingEventSet(kPendingEventEnergyDetected)) { resetPendingEvent(kPendingEventEnergyDetected); otPlatRadioEnergyScanDone(aInstance, sEnergyDetected); } if (isPendingEventSet(kPendingEventSleep)) { if (nrf_802154_sleep()) { resetPendingEvent(kPendingEventSleep); } } if (isPendingEventSet(kPendingEventEnergyDetectionStart)) { nrf_802154_channel_set(sEnergyDetectionChannel); if (nrf_802154_energy_detection(sEnergyDetectionTime)) { resetPendingEvent(kPendingEventEnergyDetectionStart); } } }
void cbQorvoRadioEnergyScanDone(int8_t aEnergyScanMaxRssi) { scanstate = 0; otPlatRadioEnergyScanDone(pQorvoInstance, aEnergyScanMaxRssi); }