1 Index: clib/rf_asksin.c
2 ===================================================================
3 --- clib/rf_asksin.c (revision 373)
4 +++ clib/rf_asksin.c (working copy)
9 -const uint8_t PROGMEM ASKSIN_CFG[50] = {
10 +const uint8_t PROGMEM ASKSIN_CFG[] = {
18 - 0x17, 0x30, // always go into IDLE
19 + 0x17, 0x33, // always go into RX after TX, CCA, ELV uses 0x03
39 - for (uint8_t i = 0; i<50; i += 2) {
41 - if (pgm_read_byte( &ASKSIN_CFG[i] )>0x40)
44 + for (uint8_t i = 0; i < sizeof(ASKSIN_CFG); i += 2) {
45 cc1100_writeReg( pgm_read_byte(&ASKSIN_CFG[i]),
46 pgm_read_byte(&ASKSIN_CFG[i+1]) );
49 ccStrobe( CC1100_SCAL );
61 rssi = cc1100_sendbyte( 0 );
66 - ccStrobe( CC1100_SFRX );
67 - ccStrobe( CC1100_SIDLE );
68 - ccStrobe( CC1100_SNOP );
69 - ccStrobe( CC1100_SRX );
70 + while(cc1100_readReg(CC1100_RXBYTES) & 0x7f)
71 + cc1100_readReg( CC1100_RXFIFO );
76 dec[1] = (~enc[1]) ^ 0x89;
79 dec[l] = enc[l] ^ dec[2];
82 if (tx_report & REP_BINTIME) {
93 - switch (cc1100_readReg( CC1100_MARCSTATE )) {
99 - ccStrobe( CC1100_SFRX );
100 - ccStrobe( CC1100_SIDLE );
101 - ccStrobe( CC1100_SNOP );
102 - ccStrobe( CC1100_SRX );
107 + switch(cc1100_readReg( CC1100_MARCSTATE )) {
108 + case MARCSTATE_RXFIFO_OVERFLOW:
109 + ccStrobe( CC1100_SFRX );
110 + case MARCSTATE_IDLE:
111 + ccStrobe( CC1100_SIDLE );
112 + ccStrobe( CC1100_SNOP );
113 + ccStrobe( CC1100_SRX );
120 my_delay_ms(3); // 3ms: Found by trial and error
123 - ccStrobe(CC1100_SIDLE);
124 - ccStrobe(CC1100_SFRX );
125 - ccStrobe(CC1100_SFTX );
127 - if (dec[2] & (1 << 4)) { //BURST-bit set?
128 - ccStrobe(CC1100_STX ); //We need to send a burst
130 - //According to ELV, devices get activated every 300ms, so send burst for 360ms
131 - for(l = 0; l < 3; l++)
132 - my_delay_ms(120); //arg is uint_8, so loop
138 enc[1] = (~dec[1]) ^ 0x89;
142 enc[l] = dec[l] ^ dec[2];
145 + if (dec[2] & (1 << 4)) { // BURST-bit set?
146 + // According to ELV, devices get activated every 300ms, so send burst for 360ms
147 + for(l = 0; l < 3; l++)
148 + my_delay_ms(120); // arg is uint_8, so loop
155 cc1100_sendbyte(CC1100_WRITE_BURST | CC1100_TXFIFO);
156 @@ -205,12 +192,17 @@
160 - ccStrobe( CC1100_SFRX );
161 - ccStrobe( CC1100_STX );
162 + // wait for TX to finish
163 + while(cc1100_readReg( CC1100_MARCSTATE ) == MARCSTATE_TX)
166 + if (cc1100_readReg( CC1100_MARCSTATE ) == MARCSTATE_TXFIFO_UNDERFLOW) {
167 + ccStrobe( CC1100_SFTX );
168 + ccStrobe( CC1100_SIDLE );
169 + ccStrobe( CC1100_SNOP );
170 + ccStrobe( CC1100_SRX );
173 - while( cc1100_readReg( CC1100_MARCSTATE ) != 1 )