contiki-os/contiki — pull request #839 by gebart (2014-10-28 14:12:42+00:00)
Title: rf230bb: Handle all IRQ flags in one ISR call. (Q: Is the current ISR valid?)

I think the if statements in the ISR in rf230bb look weird. If the first flag is matched then no other IRQ flags will be checked. According to the data sheet, the IRQ signal is deasserted after reading the IRQ status register, which, as I understand it, would cause the other unhandled IRQ flags to be lost forever. See AT86RF212 data sheet, chapter 8.1 "Frame Receive Procedure".

If my understanding of the data sheet is correct, then this behaviour can possibly lead to missed TRX_END interrupts, because RX_START is checked first. The reason that these two flags would be set at the same time could be that the handling of the interrupt from the radio has been delayed by other code either disabling interrupts, or another ISR with a higher priority was executing during the time between RX_START and TRX_END.

I have attached an untested example solution for the problem described above.

The reason I discovered this is that I am looking over the rf230bb code in order to try to find the source of an issue I am seeing with dropped packets from time to time. I have not yet had time to evaluate if this change fixes the problem.