]>
Commit | Line | Data |
---|---|---|
b2720844 MG |
1 | Index: clib/rf_asksin.c |
2 | =================================================================== | |
3 | --- clib/rf_asksin.c (revision 373) | |
4 | +++ clib/rf_asksin.c (working copy) | |
5 | @@ -11,7 +11,7 @@ | |
6 | ||
7 | uint8_t asksin_on = 0; | |
8 | ||
9 | -const uint8_t PROGMEM ASKSIN_CFG[50] = { | |
10 | +const uint8_t PROGMEM ASKSIN_CFG[] = { | |
11 | 0x00, 0x07, | |
12 | 0x02, 0x2e, | |
13 | 0x03, 0x0d, | |
777ef621 | 14 | @@ -26,16 +26,17 @@ |
b2720844 MG |
15 | 0x11, 0x93, |
16 | 0x12, 0x03, | |
17 | 0x15, 0x34, | |
18 | - 0x17, 0x30, // always go into IDLE | |
19 | + 0x17, 0x3F, // always go into RX, CCA, ELV uses 0x03 | |
20 | 0x18, 0x18, | |
21 | 0x19, 0x16, | |
22 | 0x1B, 0x43, | |
23 | 0x21, 0x56, | |
24 | 0x25, 0x00, | |
25 | 0x26, 0x11, | |
26 | + 0x29, 0x59, | |
27 | + 0x2c, 0x81, | |
28 | 0x2D, 0x35, | |
777ef621 | 29 | - 0x3e, 0xc3, |
b2720844 | 30 | - 0xff |
777ef621 | 31 | + 0x3e, 0xc3 |
b2720844 MG |
32 | }; |
33 | ||
34 | void | |
777ef621 | 35 | @@ -56,18 +57,16 @@ |
b2720844 MG |
36 | my_delay_us(100); |
37 | ||
38 | // load configuration | |
39 | - for (uint8_t i = 0; i<50; i += 2) { | |
777ef621 MG |
40 | - |
41 | - if (pgm_read_byte( &ASKSIN_CFG[i] )>0x40) | |
42 | - break; | |
43 | - | |
b2720844 | 44 | + for (uint8_t i = 0; i < sizeof(ASKSIN_CFG); i += 2) { |
777ef621 MG |
45 | cc1100_writeReg( pgm_read_byte(&ASKSIN_CFG[i]), |
46 | pgm_read_byte(&ASKSIN_CFG[i+1]) ); | |
47 | } | |
b2720844 MG |
48 | |
49 | ccStrobe( CC1100_SCAL ); | |
50 | ||
51 | - my_delay_ms(1); | |
52 | + my_delay_ms(4); | |
53 | + | |
54 | + ccRX(); | |
55 | } | |
56 | ||
57 | void | |
777ef621 | 58 | @@ -97,14 +96,10 @@ |
b2720844 MG |
59 | } |
60 | ||
61 | rssi = cc1100_sendbyte( 0 ); | |
62 | + /* LQI = */ cc1100_sendbyte( 0 ); | |
63 | ||
64 | CC1100_DEASSERT; | |
65 | ||
66 | - ccStrobe( CC1100_SFRX ); | |
67 | - ccStrobe( CC1100_SIDLE ); | |
68 | - ccStrobe( CC1100_SNOP ); | |
69 | - ccStrobe( CC1100_SRX ); | |
70 | - | |
71 | dec[0] = enc[0]; | |
72 | dec[1] = (~enc[1]) ^ 0x89; | |
73 | ||
777ef621 | 74 | @@ -113,7 +108,6 @@ |
b2720844 MG |
75 | |
76 | dec[l] = enc[l] ^ dec[2]; | |
77 | ||
78 | - | |
79 | if (tx_report & REP_BINTIME) { | |
80 | ||
81 | DC('a'); | |
777ef621 | 82 | @@ -133,24 +127,14 @@ |
b2720844 MG |
83 | } |
84 | ||
85 | return; | |
86 | - | |
87 | } | |
88 | - | |
89 | - | |
90 | - switch (cc1100_readReg( CC1100_MARCSTATE )) { | |
91 | - | |
92 | - // RX_OVERFLOW | |
93 | - case 17: | |
94 | - // IDLE | |
95 | - case 1: | |
96 | - ccStrobe( CC1100_SFRX ); | |
97 | - ccStrobe( CC1100_SIDLE ); | |
98 | - ccStrobe( CC1100_SNOP ); | |
99 | - ccStrobe( CC1100_SRX ); | |
100 | - break; | |
101 | - | |
102 | - } | |
103 | ||
104 | + if (cc1100_readReg( CC1100_MARCSTATE ) == MARCSTATE_RXFIFO_OVERFLOW) { | |
105 | + ccStrobe( CC1100_SFRX ); | |
106 | + ccStrobe( CC1100_SIDLE ); | |
107 | + ccStrobe( CC1100_SNOP ); | |
108 | + ccStrobe( CC1100_SRX ); | |
109 | + } | |
110 | } | |
111 | ||
112 | void | |
777ef621 | 113 | @@ -173,20 +157,7 @@ |
b2720844 MG |
114 | my_delay_ms(3); // 3ms: Found by trial and error |
115 | } | |
116 | ||
117 | - ccStrobe(CC1100_SIDLE); | |
118 | - ccStrobe(CC1100_SFRX ); | |
119 | - ccStrobe(CC1100_SFTX ); | |
120 | - | |
121 | - if (dec[2] & (1 << 4)) { //BURST-bit set? | |
122 | - ccStrobe(CC1100_STX ); //We need to send a burst | |
123 | - | |
124 | - //According to ELV, devices get activated every 300ms, so send burst for 360ms | |
125 | - for(l = 0; l < 3; l++) | |
126 | - my_delay_ms(120); //arg is uint_8, so loop | |
127 | - } | |
128 | - | |
129 | // "crypt" | |
130 | - | |
131 | enc[0] = dec[0]; | |
132 | enc[1] = (~dec[1]) ^ 0x89; | |
133 | ||
777ef621 | 134 | @@ -195,6 +166,15 @@ |
b2720844 MG |
135 | |
136 | enc[l] = dec[l] ^ dec[2]; | |
137 | ||
138 | + ccTX(); | |
139 | + if (dec[2] & (1 << 4)) { // BURST-bit set? | |
140 | + // According to ELV, devices get activated every 300ms, so send burst for 360ms | |
141 | + for(l = 0; l < 3; l++) | |
142 | + my_delay_ms(120); // arg is uint_8, so loop | |
5f2228fc MG |
143 | + } else { |
144 | + my_delay_ms(10); | |
b2720844 MG |
145 | + } |
146 | + | |
147 | // send | |
148 | CC1100_ASSERT; | |
149 | cc1100_sendbyte(CC1100_WRITE_BURST | CC1100_TXFIFO); | |
777ef621 | 150 | @@ -205,12 +185,17 @@ |
b2720844 MG |
151 | |
152 | CC1100_DEASSERT; | |
153 | ||
154 | - ccStrobe( CC1100_SFRX ); | |
155 | - ccStrobe( CC1100_STX ); | |
156 | + // wait for TX to finish | |
157 | + while(cc1100_readReg( CC1100_MARCSTATE ) == MARCSTATE_TX) | |
158 | + ; | |
777ef621 MG |
159 | + |
160 | + if (cc1100_readReg( CC1100_MARCSTATE ) == MARCSTATE_TXFIFO_UNDERFLOW) { | |
161 | + ccStrobe( CC1100_SFTX ); | |
162 | + ccStrobe( CC1100_SIDLE ); | |
163 | + ccStrobe( CC1100_SNOP ); | |
164 | + ccStrobe( CC1100_SRX ); | |
165 | + } | |
b2720844 MG |
166 | |
167 | - while( cc1100_readReg( CC1100_MARCSTATE ) != 1 ) | |
168 | - my_delay_ms(5); | |
169 | - | |
170 | if(asksin_on) { | |
171 | ccRX(); | |
172 | } else { |