Rev 2130 | Rev 2133 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2130 | Rev 2132 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include <avr/boot.h> |
1 | #include <avr/boot.h> |
2 | #include <avr/io.h> |
2 | #include <avr/io.h> |
3 | #include <avr/interrupt.h> |
3 | #include <avr/interrupt.h> |
- | 4 | #include <avr/wdt.h> |
|
4 | #include <util/delay.h> |
5 | #include <util/delay.h> |
Line 5... | Line 6... | ||
5 | 6 | ||
6 | #include "timer0.h" |
7 | #include "timer0.h" |
7 | #include "timer2.h" |
8 | #include "timer2.h" |
Line 15... | Line 16... | ||
15 | #include "configuration.h" |
16 | #include "configuration.h" |
16 | #include "controlMixer.h" |
17 | #include "controlMixer.h" |
17 | #include "eeprom.h" |
18 | #include "eeprom.h" |
18 | #include "printf_P.h" |
19 | #include "printf_P.h" |
Line -... | Line 20... | ||
- | 20 | ||
- | 21 | uint8_t resetFlag = 0; |
|
- | 22 | ||
- | 23 | void reset(void) { |
|
- | 24 | resetFlag = 1; |
|
- | 25 | wdt_enable(WDTO_15MS); |
|
- | 26 | while (1) |
|
- | 27 | ; |
|
- | 28 | } |
|
19 | 29 | ||
20 | int16_t main(void) { |
30 | int16_t main(void) { |
- | 31 | uint16_t timer = 0; |
|
- | 32 | ||
21 | uint16_t timer; |
33 | #ifdef DO_PROFILE |
- | 34 | static uint8_t profileTimer; |
|
Line 22... | Line 35... | ||
22 | static uint8_t profileTimer; |
35 | #endif |
23 | 36 | ||
Line 24... | Line -... | ||
24 | // disable interrupts global |
- | |
25 | cli(); |
- | |
26 | - | ||
27 | // disable watchdog |
- | |
28 | MCUSR &= ~(1 << WDRF); |
- | |
29 | WDTCSR |= (1 << WDCE) | (1 << WDE); |
- | |
30 | WDTCSR = 0; |
- | |
31 | 37 | // disable interrupts global |
|
Line 32... | Line 38... | ||
32 | // This is strange: It should NOT be necessarty to do. But the call of the same, |
38 | cli(); |
33 | // in channelMap_readOrDefault (if eeprom read fails) just sets all to 0,0,0,.... |
39 | |
34 | // channelMap_default(); |
40 | wdt_enable(WDTO_120MS); |
35 | 41 | ||
Line 59... | Line 65... | ||
59 | beep(2000); |
65 | beep(2000); |
Line 60... | Line 66... | ||
60 | 66 | ||
61 | while (1) { |
67 | while (1) { |
62 | if (runFlightControl) { // control interval |
68 | if (runFlightControl) { // control interval |
- | 69 | runFlightControl = 0; // reset Flag, is enabled every 2 ms by ISR of timer0 |
|
- | 70 | ||
- | 71 | if (!resetFlag) { |
|
- | 72 | wdt_reset(); |
|
- | 73 | } |
|
63 | runFlightControl = 0; // reset Flag, is enabled every 2 ms by ISR of timer0 |
74 | |
64 | if (sensorDataReady != ALL_DATA_READY) { |
75 | if (sensorDataReady != ALL_DATA_READY) { |
65 | // Analog data should have been ready but is not!! |
76 | // Analog data should have been ready but is not!! |
66 | debugOut.digital[0] |= DEBUG_MAINLOOP_TIMER; |
77 | debugOut.digital[0] |= DEBUG_MAINLOOP_TIMER; |
67 | } else { |
78 | } else { |
Line 105... | Line 116... | ||
105 | debugOut.digital[1] |= DEBUG_MAINLOOP_TIMER; |
116 | debugOut.digital[1] |= DEBUG_MAINLOOP_TIMER; |
106 | } else { |
117 | } else { |
107 | debugOut.digital[1] &= ~DEBUG_MAINLOOP_TIMER; |
118 | debugOut.digital[1] &= ~DEBUG_MAINLOOP_TIMER; |
108 | } |
119 | } |
109 | } |
120 | } |
- | 121 | } |
|
110 | return (1); |
122 | return (1); |
111 | } |
123 | } |