Rev 931 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 931 | Rev 938 | ||
---|---|---|---|
1 | // *************************************************************** |
1 | // *************************************************************** |
2 | // ** Spektrum Diversity v2.0 - use up to 4 satellite receivers ** |
2 | // ** Spektrum Diversity v2.1 - use up to 4 satellite receivers ** |
3 | // *************************************************************** |
3 | // *************************************************************** |
- | 4 | // ** Spektrum DSMX Binding Extension by Johannes Stein 2011/03 ** |
|
- | 5 | // ** ** |
|
- | 6 | // ** 3 Pulses = DSM2 1024/22ms ** |
|
- | 7 | // ** 5 Pulses = DSM2 2048/11ms ** |
|
- | 8 | // ** 7 Pulses = DSMX 22ms ** |
|
- | 9 | // ** 9 Pulses = DSMX 11ms ** |
|
- | 10 | // ** ** |
|
4 | // ** Target: An Atmel ATtiny2313 (RC-Oscillator @ 8 MHz) ** |
11 | // ** Target: An Atmel ATtiny2313 (RC-Oscillator @ 8 MHz) ** |
5 | // ** controls a 74HC151 Multiplexer ** |
12 | // ** controls a 74HC151 Multiplexer ** |
6 | // *************************************************************** |
13 | // *************************************************************** |
7 | // ** It monitors the data from 4 satellite receivers and ** |
14 | // ** It monitors the data from 4 satellite receivers and ** |
8 | // ** connects a valid one to the output via the multiplexer ** |
15 | // ** connects a valid one to the output via the multiplexer ** |
9 | // *************************************************************** |
16 | // *************************************************************** |
10 | // ** LED-Modes during startup ** |
17 | // ** LED-Modes during startup ** |
11 | // ** ************************ ** |
18 | // ** ************************ ** |
12 | // ** LED fast flash: Waiting for first signal ** |
19 | // ** LED fast flash: Waiting for first signal ** |
13 | // ** ** |
20 | // ** ** |
14 | // ** LED-Modes during operation ** |
21 | // ** LED-Modes during operation ** |
15 | // ** ************************** ** |
22 | // ** ************************** ** |
16 | // ** LED flash 1x - 4x: Shows which channel is active every 2s ** |
23 | // ** LED flash 1x - 4x: Shows which channel is active every 2s ** |
17 | // ** LED ON after flash: FAILURE - A used signal was lost ** |
24 | // ** LED ON after flash: FAILURE - A used signal was lost ** |
18 | // ** ** |
25 | // ** ** |
19 | // ** LED-Modes after Self-Test and pressed button ** |
26 | // ** LED-Modes after Self-Test and pressed button ** |
20 | // ** ******************************************** ** |
27 | // ** ******************************************** ** |
21 | // ** LED flashes at 1 Hz: Everything is fine ** |
28 | // ** LED flashes at 1 Hz: Everything is fine ** |
22 | // ** LED flashes some times: Times flashed -> damaged Channel# ** |
29 | // ** LED flashes some times: Times flashed -> damaged Channel# ** |
23 | // ** LED off: check voltage(regulator), button or firmware ** |
30 | // ** LED off: check voltage(regulator), button or firmware ** |
24 | // *************************************************************** |
31 | // *************************************************************** |
25 | // ** (c) 2010-0xFFFF Stefan Pendsa ** |
32 | // ** (c) 2010-0xFFFF Stefan Pendsa ** |
26 | // ** License: don't know - use it and have fun ** |
33 | // ** License: don't know - use it and have fun ** |
27 | // *************************************************************** |
34 | // *************************************************************** |
28 | 35 | ||
29 | #include <avr/io.h> |
36 | #include <avr/io.h> |
30 | #include <avr/eeprom.h> |
37 | #include <avr/eeprom.h> |
31 | #include <avr/interrupt.h> |
38 | #include <avr/interrupt.h> |
32 | #include <util/delay.h> |
39 | #include <util/delay.h> |
33 | 40 | ||
34 | 41 | ||
35 | #define LED_OFF PORTD |= 1 << PD0 |
42 | #define LED_OFF PORTD |= 1 << PD0 |
36 | #define LED_ON PORTD &= ~(1 << PD0) |
43 | #define LED_ON PORTD &= ~(1 << PD0) |
37 | 44 | ||
38 | volatile unsigned char Timer0Event = 0; |
45 | volatile unsigned char Timer0Event = 0; |
39 | volatile unsigned int Timer1Event; |
46 | volatile unsigned int Timer1Event; |
40 | volatile unsigned char BlinkCode = 0; |
47 | volatile unsigned char BlinkCode = 0; |
41 | volatile unsigned char failure = 0; |
48 | volatile unsigned char failure = 0; |
42 | 49 | ||
43 | unsigned char eedummy EEMEM; // Dummy-Variable for Address 0 in EEPROM |
50 | unsigned char eedummy EEMEM; // Dummy-Variable for Address 0 in EEPROM |
44 | unsigned char eecheck EEMEM; // Check-Variable |
51 | unsigned char eecheck EEMEM; // Check-Variable |
45 | unsigned char bind; // Bind-Pulse-Counter (in RAM) |
52 | unsigned char bind; // Bind-Pulse-Counter (in RAM) |
46 | unsigned char eebind EEMEM; // Bind-Pulse-Counter (in EEPROM) |
53 | unsigned char eebind EEMEM; // Bind-Pulse-Counter (in EEPROM) |
47 | 54 | ||
48 | 55 | ||
49 | 56 | ||
50 | ISR(TIMER0_OVF_vect) // Triggered every 32,768 msec |
57 | ISR(TIMER0_OVF_vect) // Triggered every 32,768 msec |
51 | { |
58 | { |
52 | if (Timer0Event > 64) // Max. 64*32 msec = 2,097152 sec |
59 | if (Timer0Event > 64) // Max. 64*32 msec = 2,097152 sec |
53 | { |
60 | { |
54 | Timer0Event = 0; |
61 | Timer0Event = 0; |
55 | LED_OFF; |
62 | LED_OFF; |
56 | } |
63 | } |
57 | 64 | ||
58 | if(Timer0Event == 0 && BlinkCode > 0) LED_ON; |
65 | if(Timer0Event == 0 && BlinkCode > 0) LED_ON; |
59 | else if(Timer0Event == 4 && BlinkCode > 0) LED_OFF; |
66 | else if(Timer0Event == 4 && BlinkCode > 0) LED_OFF; |
60 | else if(Timer0Event == 8 && BlinkCode > 1) LED_ON; |
67 | else if(Timer0Event == 8 && BlinkCode > 1) LED_ON; |
61 | else if(Timer0Event == 12 && BlinkCode > 1) LED_OFF; |
68 | else if(Timer0Event == 12 && BlinkCode > 1) LED_OFF; |
62 | else if(Timer0Event == 16 && BlinkCode > 2) LED_ON; |
69 | else if(Timer0Event == 16 && BlinkCode > 2) LED_ON; |
63 | else if(Timer0Event == 20 && BlinkCode > 2) LED_OFF; |
70 | else if(Timer0Event == 20 && BlinkCode > 2) LED_OFF; |
64 | else if(Timer0Event == 24 && BlinkCode > 3) LED_ON; |
71 | else if(Timer0Event == 24 && BlinkCode > 3) LED_ON; |
65 | else if(Timer0Event == 28 && BlinkCode > 3) LED_OFF; |
72 | else if(Timer0Event == 28 && BlinkCode > 3) LED_OFF; |
66 | else if(Timer0Event == 35 && failure == 1) LED_ON; |
73 | else if(Timer0Event == 35 && failure == 1) LED_ON; |
67 | else if(Timer0Event == 55 && failure == 1) LED_OFF; |
74 | else if(Timer0Event == 55 && failure == 1) LED_OFF; |
68 | 75 | ||
69 | Timer0Event++; |
76 | Timer0Event++; |
70 | } |
77 | } |
71 | 78 | ||
72 | 79 | ||
73 | ISR(TIMER1_OVF_vect) // Triggered every 8,192 msec |
80 | ISR(TIMER1_OVF_vect) // Triggered every 8,192 msec |
74 | { |
81 | { |
75 | Timer1Event++; |
82 | Timer1Event++; |
76 | } |
83 | } |
77 | 84 | ||
78 | 85 | ||
79 | void SelectSat(unsigned char sat) |
86 | void SelectSat(unsigned char sat) |
80 | { |
87 | { |
81 | PORTD = (PORTD & 0b1100111) | (sat << 3); // Select the input for 74HC151 |
88 | PORTD = (PORTD & 0b1100111) | (sat << 3); // Select the input for 74HC151 |
82 | _delay_us(10); // Wait for stable state |
89 | _delay_us(10); // Wait for stable state |
83 | } |
90 | } |
84 | 91 | ||
85 | 92 | ||
86 | 93 | ||
87 | void ResetTimer1(void) |
94 | void ResetTimer1(void) |
88 | { |
95 | { |
89 | TCNT1H = 0; |
96 | TCNT1H = 0; |
90 | TCNT1L = 0; |
97 | TCNT1L = 0; |
91 | Timer1Event = 0; |
98 | Timer1Event = 0; |
92 | } |
99 | } |
93 | 100 | ||
94 | 101 | ||
95 | 102 | ||
96 | void Binding(void) // Binding sequence (for Spektrum sats only) |
103 | void Binding(void) // Binding sequence (for Spektrum sats only) |
97 | { |
104 | { |
98 | unsigned char i = 0; |
105 | unsigned char i = 0; |
99 | 106 | ||
100 | DDRB = 0b11110000; // Sat-Pins to output |
107 | DDRB = 0b11110000; // Sat-Pins to output |
101 | _delay_ms(80); // Let them time to boot up |
108 | _delay_ms(80); // Let them time to boot up |
102 | 109 | ||
103 | for (i=0;i<bind;i++) // Send negative 100µs pulses to all sat's |
110 | for (i=0;i<bind;i++) // Send negative 100µs pulses to all sat's |
104 | { |
111 | { |
105 | PORTB = 0b00000000; |
112 | PORTB = 0b00000000; |
106 | _delay_us(100); |
113 | _delay_us(100); |
107 | PORTB = 0b11110000; |
114 | PORTB = 0b11110000; |
108 | _delay_us(100); |
115 | _delay_us(100); |
109 | } |
116 | } |
110 | 117 | ||
111 | for (i=0;i<bind;i++) // Flash the number of used pulses to the LED |
118 | for (i=0;i<bind;i++) // Flash the number of used pulses to the LED |
112 | { |
119 | { |
113 | LED_ON; |
120 | LED_ON; |
114 | _delay_ms(100); |
121 | _delay_ms(100); |
115 | LED_OFF; |
122 | LED_OFF; |
116 | _delay_ms(250); |
123 | _delay_ms(250); |
117 | } |
124 | } |
118 | 125 | ||
119 | DDRB = 0b00000000; // Sat-Pins to input again |
126 | DDRB = 0b00000000; // Sat-Pins to input again |
120 | 127 | ||
121 | bind++; // Save increased bind-pulse-counter for next binding. |
128 | bind += 2; |
122 | if (bind > 6) bind = 3; // 3 pulses are for DX7+AR6200, 4-6 pulses have been seen... |
129 | if (bind > 9) bind = 3; // 3, 5, 7, 9 pulses, then start with 3 again |
123 | eeprom_write_byte(&eebind, bind); // around the world for other combinations. Hopefully it works for them. |
130 | eeprom_write_byte(&eebind, bind); // Save increased bind-pulse-counter for next binding. |
124 | _delay_ms(500); |
131 | _delay_ms(500); |
125 | } |
132 | } |
126 | 133 | ||
127 | 134 | ||
128 | 135 | ||
129 | void Testing(void) // Self Test |
136 | void Testing(void) // Self Test |
130 | { |
137 | { |
131 | unsigned char error = 0; |
138 | unsigned char error = 0; |
132 | unsigned char i = 0; |
139 | unsigned char i = 0; |
133 | 140 | ||
134 | DDRB = 0b11110000; // Port B Output for satellites, Input for feedback |
141 | DDRB = 0b11110000; // Port B Output for satellites, Input for feedback |
135 | 142 | ||
136 | PORTB = 0b01010000; // Test Pattern |
143 | PORTB = 0b01010000; // Test Pattern |
137 | SelectSat(0); |
144 | SelectSat(0); |
138 | if (!(PINB & (1<<PB3))) error = 1; |
145 | if (!(PINB & (1<<PB3))) error = 1; |
139 | SelectSat(1); |
146 | SelectSat(1); |
140 | if (PINB & (1<<PB3)) error = 2; |
147 | if (PINB & (1<<PB3)) error = 2; |
141 | SelectSat(2); |
148 | SelectSat(2); |
142 | if (!(PINB & (1<<PB3))) error = 3; |
149 | if (!(PINB & (1<<PB3))) error = 3; |
143 | SelectSat(3); |
150 | SelectSat(3); |
144 | if (PINB & (1<<PB3)) error = 4; |
151 | if (PINB & (1<<PB3)) error = 4; |
145 | 152 | ||
146 | PORTB = 0b10100000; // Another (inverted) Test Pattern |
153 | PORTB = 0b10100000; // Another (inverted) Test Pattern |
147 | SelectSat(0); |
154 | SelectSat(0); |
148 | if (PINB & (1<<PB3)) error = 1; |
155 | if (PINB & (1<<PB3)) error = 1; |
149 | SelectSat(1); |
156 | SelectSat(1); |
150 | if (!(PINB & (1<<PB3))) error = 2; |
157 | if (!(PINB & (1<<PB3))) error = 2; |
151 | SelectSat(2); |
158 | SelectSat(2); |
152 | if (PINB & (1<<PB3)) error = 3; |
159 | if (PINB & (1<<PB3)) error = 3; |
153 | SelectSat(3); |
160 | SelectSat(3); |
154 | if (!(PINB & (1<<PB3))) error = 4; |
161 | if (!(PINB & (1<<PB3))) error = 4; |
155 | 162 | ||
156 | DDRB = 0b00000000; // Port B Input again |
163 | DDRB = 0b00000000; // Port B Input again |
157 | 164 | ||
158 | while (PIND & (1<<PD6)); // Wait for Bind-Switch |
165 | while (PIND & (1<<PD6)); // Wait for Bind-Switch |
159 | 166 | ||
160 | while(1) // Never return |
167 | while(1) // Never return |
161 | { |
168 | { |
162 | if (error == 0) // When no error occured -> LED flashes at 1 Hz |
169 | if (error == 0) // When no error occured -> LED flashes at 1 Hz |
163 | { |
170 | { |
164 | LED_ON; |
171 | LED_ON; |
165 | _delay_ms(100); |
172 | _delay_ms(100); |
166 | LED_OFF; |
173 | LED_OFF; |
167 | _delay_ms(900); |
174 | _delay_ms(900); |
168 | } |
175 | } |
169 | else |
176 | else |
170 | { |
177 | { |
171 | for (i=0;i<error;i++) // When error occured -> Flash-Out the Errorcode |
178 | for (i=0;i<error;i++) // When error occured -> Flash-Out the Errorcode |
172 | { |
179 | { |
173 | LED_ON; |
180 | LED_ON; |
174 | _delay_ms(100); |
181 | _delay_ms(100); |
175 | LED_OFF; |
182 | LED_OFF; |
176 | _delay_ms(400); |
183 | _delay_ms(400); |
177 | } |
184 | } |
178 | _delay_ms(1000); |
185 | _delay_ms(1000); |
179 | } |
186 | } |
180 | 187 | ||
181 | } |
188 | } |
182 | 189 | ||
183 | } |
190 | } |
184 | 191 | ||
185 | 192 | ||
186 | 193 | ||
187 | int main(void) |
194 | int main(void) |
188 | { |
195 | { |
189 | unsigned char i = 0; |
196 | unsigned char i = 0; |
190 | unsigned char active[4]; |
197 | unsigned char active[4]; |
191 | unsigned char active_lo[4]; |
198 | unsigned char active_lo[4]; |
192 | unsigned char active_hi[4]; |
199 | unsigned char active_hi[4]; |
193 | unsigned char sat = 99; |
200 | unsigned char sat = 99; |
194 | 201 | ||
195 | 202 | ||
196 | DDRB = 0b00000000; // Port B Input for satellites and feedback |
203 | DDRB = 0b00000000; // Port B Input for satellites and feedback |
197 | DDRD = 0b0011001; // Port D Output for MUX and LED, Input for Switch & Test |
204 | DDRD = 0b0011001; // Port D Output for MUX and LED, Input for Switch & Test |
198 | PORTB = 0b11110000; // Port B Pullup's for (unused) satellites |
205 | PORTB = 0b11110000; // Port B Pullup's for (unused) satellites |
199 | PORTD = 0b1100001; // Port D Pullup's for Switch & Test, LED off |
206 | PORTD = 0b1100001; // Port D Pullup's for Switch & Test, LED off |
200 | 207 | ||
201 | if (eeprom_read_byte(&eecheck) != 0x42) // Invalid Data in EEPROM -> initialize |
208 | if (eeprom_read_byte(&eecheck) != 0x84) // Invalid Data in EEPROM -> initialize |
202 | { |
209 | { |
203 | eeprom_write_byte(&eecheck, 0x42); |
210 | eeprom_write_byte(&eecheck, 0x84); |
204 | bind = 3; |
211 | bind = 3; |
205 | eeprom_write_byte(&eebind, bind); |
212 | eeprom_write_byte(&eebind, bind); |
206 | } |
213 | } |
207 | else bind = eeprom_read_byte(&eebind); // Valid Data in EEPROM -> read bind-pulse-counter |
214 | else bind = eeprom_read_byte(&eebind); // Valid Data in EEPROM -> read bind-pulse-counter |
208 | 215 | ||
209 | 216 | ||
210 | if (!(PIND & (1<<PD5))) Testing(); // Initiate Self-Test when Test-Pad is low |
217 | if (!(PIND & (1<<PD5))) Testing(); // Initiate Self-Test when Test-Pad is low |
211 | if (!(PIND & (1<<PD6))) Binding(); // Initiate Binding when Bind-Button is pressed |
218 | if (!(PIND & (1<<PD6))) Binding(); // Initiate Binding when Bind-Button is pressed |
212 | 219 | ||
213 | 220 | ||
214 | for (i=0;i<4;i++) // Reset active-arrays |
221 | for (i=0;i<4;i++) // Reset active-arrays |
215 | { |
222 | { |
216 | active[i] = 0; |
223 | active[i] = 0; |
217 | active_lo[i] = 0; |
224 | active_lo[i] = 0; |
218 | active_hi[i] = 0; |
225 | active_hi[i] = 0; |
219 | } |
226 | } |
220 | 227 | ||
221 | _delay_ms(100); |
228 | _delay_ms(100); |
222 | 229 | ||
223 | TCCR0B = ( 1 << CS00 ) | ( 1 << CS02 ); // Timer0 Prescaler = 1024 -> 32,768 msec |
230 | TCCR0B = ( 1 << CS00 ) | ( 1 << CS02 ); // Timer0 Prescaler = 1024 -> 32,768 msec |
224 | TCCR1B = ( 1 << CS10 ); // Timer1 Prescaler = 1 -> 8,192 msec |
231 | TCCR1B = ( 1 << CS10 ); // Timer1 Prescaler = 1 -> 8,192 msec |
225 | TIMSK = ( 1 << TOIE0 ) | ( 1 << TOIE1 ); // Timer0+1 Overflow Interrupt Enable |
232 | TIMSK = ( 1 << TOIE0 ) | ( 1 << TOIE1 ); // Timer0+1 Overflow Interrupt Enable |
226 | sei(); // Global Interrupts enable |
233 | sei(); // Global Interrupts enable |
227 | 234 | ||
228 | ResetTimer1(); |
235 | ResetTimer1(); |
229 | while(sat == 99) // Wait for first signal |
236 | while(sat == 99) // Wait for first signal |
230 | { |
237 | { |
231 | if (Timer1Event == 10) LED_ON; // Blink while waiting |
238 | if (Timer1Event == 10) LED_ON; // Blink while waiting |
232 | if (Timer1Event == 20) |
239 | if (Timer1Event == 20) |
233 | { |
240 | { |
234 | LED_OFF; |
241 | LED_OFF; |
235 | Timer1Event = 0; |
242 | Timer1Event = 0; |
236 | } |
243 | } |
237 | 244 | ||
238 | while(Timer1Event < 3) // Check active satellites (for 3*8=24ms) |
245 | while(Timer1Event < 3) // Check active satellites (for 3*8=24ms) |
239 | { |
246 | { |
240 | for (i=0;i<4;i++) |
247 | for (i=0;i<4;i++) |
241 | { |
248 | { |
242 | if (PINB & (1<<(i+4))) active_hi[i] = 1; |
249 | if (PINB & (1<<(i+4))) active_hi[i] = 1; |
243 | else active_lo[i] = 1; |
250 | else active_lo[i] = 1; |
244 | } |
251 | } |
245 | } |
252 | } |
246 | 253 | ||
247 | for (i=0;i<4;i++) // When an input had low AND high signals, mark it as active |
254 | for (i=0;i<4;i++) // When an input had low AND high signals, mark it as active |
248 | { |
255 | { |
249 | if (active_lo[i] == 1 && active_hi[i] == 1) active[i] = 1; |
256 | if (active_lo[i] == 1 && active_hi[i] == 1) active[i] = 1; |
250 | } |
257 | } |
251 | 258 | ||
252 | 259 | ||
253 | for (i=0;i<4;i++) // Select first active satellite |
260 | for (i=0;i<4;i++) // Select first active satellite |
254 | { |
261 | { |
255 | if (active[i] == 1) |
262 | if (active[i] == 1) |
256 | { |
263 | { |
257 | SelectSat(i); |
264 | SelectSat(i); |
258 | sat = i; |
265 | sat = i; |
259 | BlinkCode = i+1; |
266 | BlinkCode = i+1; |
260 | break; |
267 | break; |
261 | } |
268 | } |
262 | } |
269 | } |
263 | 270 | ||
264 | } |
271 | } |
265 | 272 | ||
266 | 273 | ||
267 | 274 | ||
268 | 275 | ||
269 | while(1) // Main-Loop |
276 | while(1) // Main-Loop |
270 | { |
277 | { |
271 | for (i=0;i<4;i++) // Reset active-arrays |
278 | for (i=0;i<4;i++) // Reset active-arrays |
272 | { |
279 | { |
273 | active[i] = 0; |
280 | active[i] = 0; |
274 | active_lo[i] = 0; |
281 | active_lo[i] = 0; |
275 | active_hi[i] = 0; |
282 | active_hi[i] = 0; |
276 | } |
283 | } |
277 | 284 | ||
278 | ResetTimer1(); |
285 | ResetTimer1(); |
279 | while(Timer1Event < 3) // Check active satellites (for 3*8=24ms) |
286 | while(Timer1Event < 3) // Check active satellites (for 3*8=24ms) |
280 | { |
287 | { |
281 | for (i=0;i<4;i++) |
288 | for (i=0;i<4;i++) |
282 | { |
289 | { |
283 | if (PINB & (1<<(i+4))) active_hi[i] = 1; |
290 | if (PINB & (1<<(i+4))) active_hi[i] = 1; |
284 | else active_lo[i] = 1; |
291 | else active_lo[i] = 1; |
285 | } |
292 | } |
286 | } |
293 | } |
287 | 294 | ||
288 | 295 | ||
289 | for (i=0;i<4;i++) // When an input had low AND high signals, mark it as active |
296 | for (i=0;i<4;i++) // When an input had low AND high signals, mark it as active |
290 | { |
297 | { |
291 | if (active_lo[i] == 1 && active_hi[i] == 1) active[i] = 1; |
298 | if (active_lo[i] == 1 && active_hi[i] == 1) active[i] = 1; |
292 | } |
299 | } |
293 | 300 | ||
294 | 301 | ||
295 | if (active[0] == 0 && active[1] == 0 && active[2] == 0 && active[3] == 0 && sat != 99) |
302 | if (active[0] == 0 && active[1] == 0 && active[2] == 0 && active[3] == 0 && sat != 99) |
296 | { |
303 | { |
297 | failure = 1; // Set Failure-LED when the signal is lost completely |
304 | failure = 1; // Set Failure-LED when the signal is lost completely |
298 | BlinkCode = 0; |
305 | BlinkCode = 0; |
299 | sat = 99; |
306 | sat = 99; |
300 | } |
307 | } |
301 | 308 | ||
302 | 309 | ||
303 | for (i=0;i<4;i++) // Select active satellite (priorized) |
310 | for (i=0;i<4;i++) // Select active satellite (priorized) |
304 | { |
311 | { |
305 | if (active[i] == 1) |
312 | if (active[i] == 1) |
306 | { |
313 | { |
307 | SelectSat(i); |
314 | SelectSat(i); |
308 | if (sat != i) failure = 1; // Set Failure-LED when the active satellite changes |
315 | if (sat != i) failure = 1; // Set Failure-LED when the active satellite changes |
309 | sat = i; |
316 | sat = i; |
310 | BlinkCode = i+1; |
317 | BlinkCode = i+1; |
311 | break; |
318 | break; |
312 | } |
319 | } |
313 | } |
320 | } |
314 | 321 | ||
315 | 322 | ||
316 | 323 | ||
317 | if (!(PIND & (1<<PD6))) failure = 0; // Reset Failure-LED when Bind-Button is pressed |
324 | if (!(PIND & (1<<PD6))) failure = 0; // Reset Failure-LED when Bind-Button is pressed |
318 | } |
325 | } |
319 | 326 | ||
320 | } |
327 | } |
321 | 328 |