0x12, 0x03,
0x15, 0x34,
- 0x17, 0x30, // always go into IDLE
-+ 0x17, 0x33, // always go into RX after TX, CCA, ELV uses 0x03
++ 0x17, 0x3F, // always go into RX after TX, CCA, ELV uses 0x03
0x18, 0x18,
0x19, 0x16,
0x1B, 0x43,
}
void
-@@ -97,13 +96,13 @@
- }
-
- rssi = cc1100_sendbyte( 0 );
+@@ -77,80 +76,74 @@
+ uint8_t dec[MAX_ASKSIN_MSG];
+ uint8_t rssi;
+ uint8_t l;
++ uint8_t rxfifo_cnt;
+
+ if(!asksin_on)
+ return;
+
+ // see if a CRC OK pkt has been arrived
+ if (bit_is_set( CC1100_IN_PORT, CC1100_IN_PIN )) {
++ while((rxfifo_cnt = cc1100_readReg(CC1100_RXBYTES)) != 0x00) {
++ if (rxfifo_cnt & 0x80) // Overflow
++ break;
+
+- enc[0] = cc1100_readReg( CC1100_RXFIFO ) & 0x7f; // read len
++ enc[0] = cc1100_readReg( CC1100_RXFIFO ) & 0x7f; // read len
+
+- if (enc[0]>=MAX_ASKSIN_MSG)
+- enc[0] = MAX_ASKSIN_MSG-1;
-
-+
- CC1100_DEASSERT;
+- CC1100_ASSERT;
+- cc1100_sendbyte( CC1100_READ_BURST | CC1100_RXFIFO );
+-
+- for (uint8_t i=0; i<enc[0]; i++) {
+- enc[i+1] = cc1100_sendbyte( 0 );
+- }
+-
+- rssi = cc1100_sendbyte( 0 );
+-
+- CC1100_DEASSERT;
++ if (enc[0]>=MAX_ASKSIN_MSG)
++ enc[0] = MAX_ASKSIN_MSG-1;
++
++ CC1100_ASSERT;
++ cc1100_sendbyte( CC1100_READ_BURST | CC1100_RXFIFO );
++
++ for (uint8_t i=0; i<enc[0]; i++) {
++ enc[i+1] = cc1100_sendbyte( 0 );
++ }
++
++ rssi = cc1100_sendbyte( 0 );
++ /* LQI = */ cc1100_sendbyte( 0 );
- ccStrobe( CC1100_SFRX );
- ccStrobe( CC1100_SIDLE );
- ccStrobe( CC1100_SNOP );
- ccStrobe( CC1100_SRX );
-+ while(cc1100_readReg(CC1100_RXBYTES) & 0x7f)
-+ cc1100_readReg( CC1100_RXFIFO );
-+
-+ ccRX();
-
- dec[0] = enc[0];
- dec[1] = (~enc[1]) ^ 0x89;
-@@ -113,7 +112,6 @@
-
- dec[l] = enc[l] ^ dec[2];
-
++ CC1100_DEASSERT;
+
+- dec[0] = enc[0];
+- dec[1] = (~enc[1]) ^ 0x89;
+-
+- for (l = 2; l < dec[0]; l++)
+- dec[l] = (enc[l-1] + 0xdc) ^ enc[l];
+-
+- dec[l] = enc[l] ^ dec[2];
-
- if (tx_report & REP_BINTIME) {
+-
+- if (tx_report & REP_BINTIME) {
++ while(cc1100_readReg(CC1100_RXBYTES) & 0x7f)
++ cc1100_readReg( CC1100_RXFIFO );
++
++ dec[0] = enc[0];
++ dec[1] = (~enc[1]) ^ 0x89;
- DC('a');
-@@ -133,24 +131,17 @@
+- DC('a');
+- for (uint8_t i=0; i<=dec[0]; i++)
+- DC( dec[i] );
+-
+- } else {
+- DC('A');
++ for (l = 2; l < dec[0]; l++)
++ dec[l] = (enc[l-1] + 0xdc) ^ enc[l];
+
+- for (uint8_t i=0; i<=dec[0]; i++)
+- DH2( dec[i] );
++ dec[l] = enc[l] ^ dec[2];
+
+- if (tx_report & REP_RSSI)
+- DH2(rssi);
+-
+- DNL();
++ if (tx_report & REP_BINTIME) {
++
++ DC('a');
++ for (uint8_t i=0; i<=dec[0]; i++)
++ DC( dec[i] );
++
++ } else {
++ DC('A');
++
++ for (uint8_t i=0; i<=dec[0]; i++)
++ DH2( dec[i] );
++
++ if (tx_report & REP_RSSI)
++ DH2(rssi);
++
++ DNL();
++ }
}
-
- return;
+-
+- return;
-
}
-
}
void
-@@ -173,20 +164,7 @@
+@@ -173,20 +166,7 @@
my_delay_ms(3); // 3ms: Found by trial and error
}
enc[0] = dec[0];
enc[1] = (~dec[1]) ^ 0x89;
-@@ -195,6 +173,15 @@
+@@ -195,6 +175,15 @@
enc[l] = dec[l] ^ dec[2];
// send
CC1100_ASSERT;
cc1100_sendbyte(CC1100_WRITE_BURST | CC1100_TXFIFO);
-@@ -205,12 +192,17 @@
+@@ -205,12 +194,17 @@
CC1100_DEASSERT;