My fork
Dependencies: BLE_API mbed-dev-bin nRF51822-bluetooth-mdw
Fork of microbit-dal-bluetooth-mdw by
Diff: source/drivers/MicroBitRadio.cpp
- Revision:
- 64:98cb56bf7711
- Parent:
- 25:27299423d813
- Child:
- 65:f7ebabf23e15
diff -r b4372a29994f -r 98cb56bf7711 source/drivers/MicroBitRadio.cpp --- a/source/drivers/MicroBitRadio.cpp Wed Jul 13 12:18:42 2016 +0100 +++ b/source/drivers/MicroBitRadio.cpp Wed Jul 13 12:18:43 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