Rev 1980 | Rev 2039 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1980 | Rev 2018 | ||
---|---|---|---|
Line 98... | Line 98... | ||
98 | 98 | ||
99 | // initalize modules |
99 | // initalize modules |
100 | output_init(); |
100 | output_init(); |
101 | timer0_init(); |
101 | timer0_init(); |
102 | timer2_init(); |
102 | timer2_init(); |
103 | usart0_Init(); |
103 | usart0_init(); |
104 | if (CPUType == ATMEGA644P);// usart1_Init(); |
104 | if (CPUType == ATMEGA644P);// usart1_Init(); |
105 | RC_Init(); |
105 | RC_Init(); |
106 | analog_init(); |
106 | analog_init(); |
107 | I2C_init(); |
107 | I2C_init(); |
Line 189... | Line 189... | ||
189 | 189 | ||
Line 190... | Line 190... | ||
190 | beep(2000); |
190 | beep(2000); |
191 | 191 | ||
192 | printf("\n\rControl: "); |
192 | printf("\n\rControl: "); |
193 | if (staticParams.bitConfig & CFG_HEADING_HOLD) |
193 | if (staticParams.bitConfig & CFG_HEADING_HOLD) |
Line 194... | Line 194... | ||
194 | printf("HeadingHold"); |
194 | printf("Heading Hold"); |
Line 195... | Line 195... | ||
195 | else printf("Neutral (ACC-Mode)"); |
195 | else printf("RTL Mode"); |
Line 196... | Line 196... | ||
196 | 196 | ||
Line 197... | Line 197... | ||
197 | printf("\n\n\r"); |
197 | printf("\n\n\r"); |
198 | 198 | ||
199 | LCD_Clear(); |
199 | LCD_clear(); |
200 | 200 | ||
- | 201 | I2CTimeout = 5000; |
|
201 | I2CTimeout = 5000; |
202 | |
202 | 203 | while (1) { |
|
203 | while (1) { |
204 | if (runFlightControl) { // control interval |
Line 204... | Line 205... | ||
204 | if (runFlightControl) { // control interval |
205 | runFlightControl = 0; // reset Flag, is enabled every 2 ms by ISR of timer0 |
Line 215... | Line 216... | ||
215 | if (!--I2CTimeout || missingMotor) { // try to reset the i2c if motor is missing or timeout |
216 | if (!--I2CTimeout || missingMotor) { // try to reset the i2c if motor is missing or timeout |
216 | if (!I2CTimeout) { |
217 | if (!I2CTimeout) { |
217 | I2C_Reset(); |
218 | I2C_Reset(); |
218 | I2CTimeout = 5; |
219 | I2CTimeout = 5; |
219 | } |
220 | } |
- | 221 | beepI2CAlarm(); |
|
220 | } |
222 | } |
Line 221... | Line 223... | ||
221 | 223 | ||
222 | // Allow Serial Data Transmit if motors must not updated or motors are not running |
224 | // Allow Serial Data Transmit if motors must not updated or motors are not running |
223 | if (!runFlightControl || !(MKFlags & MKFLAG_MOTOR_RUN)) { |
225 | if (!runFlightControl || !(MKFlags & MKFLAG_MOTOR_RUN)) { |
224 | usart0_TransmitTxData(); |
226 | usart0_transmitTxData(); |
Line 225... | Line 227... | ||
225 | } |
227 | } |
Line 226... | Line 228... | ||
226 | 228 | ||
227 | usart0_ProcessRxData(); |
229 | usart0_processRxData(); |
228 | 230 | ||
229 | if (checkDelay(timer)) { |
231 | if (checkDelay(timer)) { |
Line 253... | Line 255... | ||
253 | } |
255 | } |
254 | #endif |
256 | #endif |
Line 255... | Line 257... | ||
255 | 257 | ||
Line 256... | Line 258... | ||
256 | calculateServoValues(); |
258 | calculateServoValues(); |
257 | 259 | ||
258 | if (runFlightControl) { // control interval |
260 | if (runFlightControl) { // Time for the next iteration was up before the current finished. Signal error. |
259 | debugOut.digital[1] |= DEBUG_MAINLOOP_TIMER; |
261 | debugOut.digital[1] |= DEBUG_MAINLOOP_TIMER; |
260 | } else { |
262 | } else { |
261 | debugOut.digital[1] &= ~DEBUG_MAINLOOP_TIMER; |
263 | debugOut.digital[1] &= ~DEBUG_MAINLOOP_TIMER; |