-+ if (cc1100_readReg( CC1100_MARCSTATE ) == MARCSTATE_RXFIFO_OVERFLOW) {
-+ ccStrobe( CC1100_SFRX );
-+ ccStrobe( CC1100_SIDLE );
-+ ccStrobe( CC1100_SNOP );
-+ ccStrobe( CC1100_SRX );
-+ }
- }
-
- void
-@@ -173,20 +162,7 @@
- my_delay_ms(3); // 3ms: Found by trial and error
- }
-
-- ccStrobe(CC1100_SIDLE);
-- ccStrobe(CC1100_SFRX );
-- ccStrobe(CC1100_SFTX );
--
-- if (dec[2] & (1 << 4)) { //BURST-bit set?
-- ccStrobe(CC1100_STX ); //We need to send a burst
--
-- //According to ELV, devices get activated every 300ms, so send burst for 360ms
-- for(l = 0; l < 3; l++)
-- my_delay_ms(120); //arg is uint_8, so loop
-- }
--
- // "crypt"
--
- enc[0] = dec[0];
- enc[1] = (~dec[1]) ^ 0x89;
+- // see if a CRC OK pkt has been arrived
+- if (bit_is_set( CC1100_IN_PORT, CC1100_IN_PIN )) {
++ // see if there is data to be read
++ while (bit_is_set( CC1100_IN_PORT, CC1100_IN_PIN )) {
++ rxfifo_cnt = read_cc1100_rxbytes();
++
++ if (rxfifo_cnt & 0x80) // Overflow
++ break;
++
++ rxfifo_cnt &= 0x7f;
++
++ // We must not read the last byte from the RX fifo while RX is in progress (Errata 1)
++ while ((rxfifo_cnt < 2) && (cc1100_readReg(CC1100_PKTSTATUS) & (1 << 3))) {
++ my_delay_ms(1);
++ rxfifo_cnt = read_cc1100_rxbytes() & 0x7f;
++ }
++
+ enc[0] = cc1100_readReg( CC1100_RXFIFO ) & 0x7f; // read len
++ rxfifo_cnt--;