Rev 2124 | Rev 2130 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2124 | Rev 2125 | ||
---|---|---|---|
Line 17... | Line 17... | ||
17 | #include "eeprom.h" |
17 | #include "eeprom.h" |
18 | #include "printf_P.h" |
18 | #include "printf_P.h" |
Line 19... | Line 19... | ||
19 | 19 | ||
20 | int16_t main(void) { |
20 | int16_t main(void) { |
- | 21 | uint16_t timer; |
|
Line 21... | Line 22... | ||
21 | uint16_t timer; |
22 | static uint8_t profileTimer; |
22 | 23 | ||
Line 23... | Line 24... | ||
23 | // disable interrupts global |
24 | // disable interrupts global |
Line 113... | Line 114... | ||
113 | printf("\n\n\r"); |
114 | printf("\n\n\r"); |
Line 114... | Line 115... | ||
114 | 115 | ||
115 | while (1) { |
116 | while (1) { |
116 | if (runFlightControl) { // control interval |
117 | if (runFlightControl) { // control interval |
- | 118 | runFlightControl = 0; // reset Flag, is enabled every 2 ms by ISR of timer0 |
|
117 | runFlightControl = 0; // reset Flag, is enabled every 2 ms by ISR of timer0 |
119 | |
118 | if (!analogDataReady) { |
120 | if (!analogDataReady) { |
119 | // Analog data should have been ready but is not!! |
121 | // Analog data should have been ready but is not!! |
120 | debugOut.digital[0] |= DEBUG_MAINLOOP_TIMER; |
122 | debugOut.digital[0] |= DEBUG_MAINLOOP_TIMER; |
121 | } else { |
123 | } else { |
Line 154... | Line 156... | ||
154 | #endif |
156 | #endif |
155 | flight_control(); |
157 | flight_control(); |
156 | #ifdef DO_PROFILE |
158 | #ifdef DO_PROFILE |
157 | stopProfileTimer(FLIGHT); |
159 | stopProfileTimer(FLIGHT); |
158 | #endif |
160 | #endif |
159 | 161 | ||
160 | // Allow Serial Data Transmit if motors must not updated or motors are not running |
162 | // Allow Serial Data Transmit if motors must not updated or motors are not running |
161 | if (!runFlightControl || !isFlying) { |
163 | if (!runFlightControl || !isFlying) { |
162 | usart0_transmitTxData(); |
164 | usart0_transmitTxData(); |
163 | } |
165 | } |
Line 172... | Line 174... | ||
172 | } else { // If we are above USB voltage, or if we have once been above warning voltage |
174 | } else { // If we are above USB voltage, or if we have once been above warning voltage |
173 | if (aboveWarningLimitVoltageSeen || UBat > UBAT_AT_5V) { |
175 | if (aboveWarningLimitVoltageSeen || UBat > UBAT_AT_5V) { |
174 | beepBatteryAlarm(); |
176 | beepBatteryAlarm(); |
175 | } |
177 | } |
176 | } |
178 | } |
- | 179 | calculateFeaturedServoValues(); |
|
177 | timer = setDelay(20); // every 20 ms |
180 | timer = setDelay(20); // every 20 ms |
178 | } |
181 | } |
179 | output_update(); |
- | |
180 | } |
- | |
Line 181... | Line -... | ||
181 | - | ||
182 | calculateFeaturedServoValues(); |
- | |
183 | - | ||
184 | if (runFlightControl) { // Time for the next iteration was up before the current finished. Signal error. |
- | |
185 | debugOut.digital[1] |= DEBUG_MAINLOOP_TIMER; |
- | |
186 | } else { |
- | |
187 | debugOut.digital[1] &= ~DEBUG_MAINLOOP_TIMER; |
- | |
188 | } |
- | |
189 | - | ||
190 | #ifdef DO_PROFILE |
- | |
191 | static uint8_t profileTimer; |
- | |
192 | if (profileTimer++ == 0) { |
182 | |
193 | debugProfileTimers(24); |
- | |
194 | } |
- | |
Line -... | Line 183... | ||
- | 183 | output_update(); |
|
- | 184 | ||
- | 185 | if (runFlightControl) { // Time for the next iteration was up before the current finished. Signal error. |
|
- | 186 | debugOut.digital[1] |= DEBUG_MAINLOOP_TIMER; |
|
- | 187 | } else { |
|
- | 188 | debugOut.digital[1] &= ~DEBUG_MAINLOOP_TIMER; |
|
195 | #endif |
189 | } |
196 | 190 | } |
|
197 | } |
191 | } |