+ async command error_t CC2420Power.flushRxFifo()
+ {
+ uint16_t dummy;
+ atomic {
+ if ( !call SpiResource.isOwner() )
+ return FAIL;
+ if ( call FIFO.get() ){ // check if there is something in the RXFIFO
+ // SFLUSHRX: "Flush the RX FIFO buffer and reset the demodulator.
+ // Always read at least one byte from the RXFIFO before
+ // issuing the SFLUSHRX command strobe" (CC2420 Datasheet)
+ call CSN.clr();
+ call RXFIFO_REGISTER.read(&dummy); // reading the byte
+ call CSN.set();
+ call CSN.clr();
+ // "SFLUSHRX command strobe should be issued twice to ensure
+ // that the SFD pin goes back to its idle state." (CC2420 Datasheet)
+ call SFLUSHRX.strobe();
+ call SFLUSHRX.strobe();
+ call CSN.set();
+ }
+ }
+ return SUCCESS;
+ }