]>
Commit | Line | Data |
---|---|---|
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, | |
14 | @@ -26,16 +26,18 @@ | |
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, | |
29 | 0x3e, 0xc3, | |
30 | - 0xff | |
31 | + 0xff, 0xff | |
32 | }; | |
33 | ||
34 | void | |
35 | @@ -56,7 +58,7 @@ | |
36 | my_delay_us(100); | |
37 | ||
38 | // load configuration | |
39 | - for (uint8_t i = 0; i<50; i += 2) { | |
40 | + for (uint8_t i = 0; i < sizeof(ASKSIN_CFG); i += 2) { | |
41 | ||
42 | if (pgm_read_byte( &ASKSIN_CFG[i] )>0x40) | |
43 | break; | |
44 | @@ -67,7 +69,9 @@ | |
45 | ||
46 | ccStrobe( CC1100_SCAL ); | |
47 | ||
48 | - my_delay_ms(1); | |
49 | + my_delay_ms(4); | |
50 | + | |
51 | + ccRX(); | |
52 | } | |
53 | ||
54 | void | |
55 | @@ -97,14 +101,10 @@ | |
56 | } | |
57 | ||
58 | rssi = cc1100_sendbyte( 0 ); | |
59 | + /* LQI = */ cc1100_sendbyte( 0 ); | |
60 | ||
61 | CC1100_DEASSERT; | |
62 | ||
63 | - ccStrobe( CC1100_SFRX ); | |
64 | - ccStrobe( CC1100_SIDLE ); | |
65 | - ccStrobe( CC1100_SNOP ); | |
66 | - ccStrobe( CC1100_SRX ); | |
67 | - | |
68 | dec[0] = enc[0]; | |
69 | dec[1] = (~enc[1]) ^ 0x89; | |
70 | ||
71 | @@ -113,7 +113,6 @@ | |
72 | ||
73 | dec[l] = enc[l] ^ dec[2]; | |
74 | ||
75 | - | |
76 | if (tx_report & REP_BINTIME) { | |
77 | ||
78 | DC('a'); | |
79 | @@ -133,24 +132,14 @@ | |
80 | } | |
81 | ||
82 | return; | |
83 | - | |
84 | } | |
85 | - | |
86 | - | |
87 | - switch (cc1100_readReg( CC1100_MARCSTATE )) { | |
88 | - | |
89 | - // RX_OVERFLOW | |
90 | - case 17: | |
91 | - // IDLE | |
92 | - case 1: | |
93 | - ccStrobe( CC1100_SFRX ); | |
94 | - ccStrobe( CC1100_SIDLE ); | |
95 | - ccStrobe( CC1100_SNOP ); | |
96 | - ccStrobe( CC1100_SRX ); | |
97 | - break; | |
98 | - | |
99 | - } | |
100 | ||
101 | + if (cc1100_readReg( CC1100_MARCSTATE ) == MARCSTATE_RXFIFO_OVERFLOW) { | |
102 | + ccStrobe( CC1100_SFRX ); | |
103 | + ccStrobe( CC1100_SIDLE ); | |
104 | + ccStrobe( CC1100_SNOP ); | |
105 | + ccStrobe( CC1100_SRX ); | |
106 | + } | |
107 | } | |
108 | ||
109 | void | |
110 | @@ -173,20 +162,7 @@ | |
111 | my_delay_ms(3); // 3ms: Found by trial and error | |
112 | } | |
113 | ||
114 | - ccStrobe(CC1100_SIDLE); | |
115 | - ccStrobe(CC1100_SFRX ); | |
116 | - ccStrobe(CC1100_SFTX ); | |
117 | - | |
118 | - if (dec[2] & (1 << 4)) { //BURST-bit set? | |
119 | - ccStrobe(CC1100_STX ); //We need to send a burst | |
120 | - | |
121 | - //According to ELV, devices get activated every 300ms, so send burst for 360ms | |
122 | - for(l = 0; l < 3; l++) | |
123 | - my_delay_ms(120); //arg is uint_8, so loop | |
124 | - } | |
125 | - | |
126 | // "crypt" | |
127 | - | |
128 | enc[0] = dec[0]; | |
129 | enc[1] = (~dec[1]) ^ 0x89; | |
130 | ||
131 | @@ -195,6 +171,15 @@ | |
132 | ||
133 | enc[l] = dec[l] ^ dec[2]; | |
134 | ||
135 | + ccTX(); | |
136 | + if (dec[2] & (1 << 4)) { // BURST-bit set? | |
137 | + // According to ELV, devices get activated every 300ms, so send burst for 360ms | |
138 | + for(l = 0; l < 3; l++) | |
139 | + my_delay_ms(120); // arg is uint_8, so loop | |
140 | + } else { | |
141 | + my_delay_ms(10); | |
142 | + } | |
143 | + | |
144 | // send | |
145 | CC1100_ASSERT; | |
146 | cc1100_sendbyte(CC1100_WRITE_BURST | CC1100_TXFIFO); | |
147 | @@ -205,12 +190,10 @@ | |
148 | ||
149 | CC1100_DEASSERT; | |
150 | ||
151 | - ccStrobe( CC1100_SFRX ); | |
152 | - ccStrobe( CC1100_STX ); | |
153 | + // wait for TX to finish | |
154 | + while(cc1100_readReg( CC1100_MARCSTATE ) == MARCSTATE_TX) | |
155 | + ; | |
156 | ||
157 | - while( cc1100_readReg( CC1100_MARCSTATE ) != 1 ) | |
158 | - my_delay_ms(5); | |
159 | - | |
160 | if(asksin_on) { | |
161 | ccRX(); | |
162 | } else { |