]> git.zerfleddert.de Git - fhem-stuff/blob - culfw/culfw-asksin-fix.diff
b17fd05a3c6f7af7c486277d95f894535d01a8c4
[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, 0x33, // always go into RX after TX, 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,13 +96,13 @@
59 }
60
61 rssi = cc1100_sendbyte( 0 );
62 -
63 +
64 CC1100_DEASSERT;
65
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 );
72 +
73 + ccRX();
74
75 dec[0] = enc[0];
76 dec[1] = (~enc[1]) ^ 0x89;
77 @@ -113,7 +112,6 @@
78
79 dec[l] = enc[l] ^ dec[2];
80
81 -
82 if (tx_report & REP_BINTIME) {
83
84 DC('a');
85 @@ -133,24 +131,17 @@
86 }
87
88 return;
89 -
90 }
91 -
92 -
93 - switch (cc1100_readReg( CC1100_MARCSTATE )) {
94 -
95 - // RX_OVERFLOW
96 - case 17:
97 - // IDLE
98 - case 1:
99 - ccStrobe( CC1100_SFRX );
100 - ccStrobe( CC1100_SIDLE );
101 - ccStrobe( CC1100_SNOP );
102 - ccStrobe( CC1100_SRX );
103 - break;
104 -
105 - }
106
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 );
114 + break;
115 + }
116 }
117
118 void
119 @@ -173,20 +164,7 @@
120 my_delay_ms(3); // 3ms: Found by trial and error
121 }
122
123 - ccStrobe(CC1100_SIDLE);
124 - ccStrobe(CC1100_SFRX );
125 - ccStrobe(CC1100_SFTX );
126 -
127 - if (dec[2] & (1 << 4)) { //BURST-bit set?
128 - ccStrobe(CC1100_STX ); //We need to send a burst
129 -
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
133 - }
134 -
135 // "crypt"
136 -
137 enc[0] = dec[0];
138 enc[1] = (~dec[1]) ^ 0x89;
139
140 @@ -195,6 +173,15 @@
141
142 enc[l] = dec[l] ^ dec[2];
143
144 + ccTX();
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
149 + } else {
150 + my_delay_ms(10);
151 + }
152 +
153 // send
154 CC1100_ASSERT;
155 cc1100_sendbyte(CC1100_WRITE_BURST | CC1100_TXFIFO);
156 @@ -205,12 +192,17 @@
157
158 CC1100_DEASSERT;
159
160 - ccStrobe( CC1100_SFRX );
161 - ccStrobe( CC1100_STX );
162 + // wait for TX to finish
163 + while(cc1100_readReg( CC1100_MARCSTATE ) == MARCSTATE_TX)
164 + ;
165 +
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 );
171 + }
172
173 - while( cc1100_readReg( CC1100_MARCSTATE ) != 1 )
174 - my_delay_ms(5);
175 -
176 if(asksin_on) {
177 ccRX();
178 } else {
Impressum, Datenschutz