]> git.zerfleddert.de Git - fhem-stuff/blob - culfw/culfw-asksin-fix.diff
04dab924f388a8241f5d63526f44549e165959f7
[fhem-stuff] / culfw / culfw-asksin-fix.diff
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,17 @@
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 + 0x3e, 0xc3
32 };
33
34 void
35 @@ -56,18 +57,16 @@
36 my_delay_us(100);
37
38 // load configuration
39 - for (uint8_t i = 0; i<50; i += 2) {
40 -
41 - if (pgm_read_byte( &ASKSIN_CFG[i] )>0x40)
42 - break;
43 -
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]) );
47 }
48
49 ccStrobe( CC1100_SCAL );
50
51 - my_delay_ms(1);
52 + my_delay_ms(4);
53 +
54 + ccRX();
55 }
56
57 void
58 @@ -97,14 +96,10 @@
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
74 @@ -113,7 +108,6 @@
75
76 dec[l] = enc[l] ^ dec[2];
77
78 -
79 if (tx_report & REP_BINTIME) {
80
81 DC('a');
82 @@ -133,24 +127,14 @@
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
113 @@ -173,20 +157,7 @@
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
134 @@ -195,6 +166,15 @@
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
143 + } else {
144 + my_delay_ms(10);
145 + }
146 +
147 // send
148 CC1100_ASSERT;
149 cc1100_sendbyte(CC1100_WRITE_BURST | CC1100_TXFIFO);
150 @@ -205,12 +185,17 @@
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 + ;
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 + }
166
167 - while( cc1100_readReg( CC1100_MARCSTATE ) != 1 )
168 - my_delay_ms(5);
169 -
170 if(asksin_on) {
171 ccRX();
172 } else {
Impressum, Datenschutz