My fork
Dependencies: BLE_API nRF51822-bluetooth-mdw
Fork of microbit-dal by
Diff: source/drivers/MicroBitRadio.cpp
- Revision:
- 66:2fc7d7c2fffc
- Parent:
- 65:f7ebabf23e15
- Child:
- 69:b62f231e51ce
--- a/source/drivers/MicroBitRadio.cpp Wed Jul 13 12:18:45 2016 +0100 +++ b/source/drivers/MicroBitRadio.cpp Wed Jul 13 12:18:46 2016 +0100 @@ -59,10 +59,6 @@ extern "C" void RADIO_IRQHandler(void) { - // Move on to the next buffer, if possible. - MicroBitRadio::instance->queueRxBuf(); - NRF_RADIO->PACKETPTR = (uint32_t) MicroBitRadio::instance->getRxBuf(); - if(NRF_RADIO->EVENTS_READY) { NRF_RADIO->EVENTS_READY = 0; @@ -74,12 +70,24 @@ if(NRF_RADIO->EVENTS_END) { NRF_RADIO->EVENTS_END = 0; - if(NRF_RADIO->CRCSTATUS == 1) { uint8_t sample = NRF_RADIO->RSSISAMPLE; + // Associate this packet's rssi value with the data just + // transferred by DMA receive MicroBitRadio::instance->setRSSI(sample); + + // Now move on to the next buffer, if possible. + // The queued packet will get the rssi value set above. + MicroBitRadio::instance->queueRxBuf(); + + // Set the new buffer for DMA + NRF_RADIO->PACKETPTR = (uint32_t) MicroBitRadio::instance->getRxBuf(); + } + else + { + MicroBitRadio::instance->setRSSI(0); } // Start listening and wait for the END event