Rev 1221 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1221 | Rev 1222 | ||
---|---|---|---|
Line 126... | Line 126... | ||
126 | } |
126 | } |
Line 127... | Line 127... | ||
127 | 127 | ||
128 | 128 | ||
129 | int16_t main (void) |
129 | int16_t main (void) |
- | 130 | { |
|
Line 130... | Line 131... | ||
130 | { |
131 | uint16_t timer; |
131 | unsigned int timer; |
132 | uint8_t i; |
Line 132... | Line 133... | ||
132 | 133 | ||
Line 171... | Line 172... | ||
171 | #endif |
172 | #endif |
Line 172... | Line 173... | ||
172 | 173 | ||
173 | // enable interrupts global |
174 | // enable interrupts global |
Line -... | Line 175... | ||
- | 175 | sei(); |
|
174 | sei(); |
176 | |
175 | 177 | printf("\n\r==================================="); |
|
176 | printf("\n\rFlightControl"); |
178 | printf("\n\rFlightControl"); |
177 | printf("\n\rHardware: %d.%d", BoardRelease/10, BoardRelease%10); |
179 | printf("\n\rHardware: %d.%d", BoardRelease/10, BoardRelease%10); |
178 | if(CPUType == ATMEGA644P) |
180 | if(CPUType == ATMEGA644P) |
179 | printf("\r\n CPU: Atmega644p"); |
181 | printf("\r\n CPU: Atmega644p"); |
180 | else |
182 | else |
181 | printf("\r\n CPU: Atmega644"); |
183 | printf("\r\n CPU: Atmega644"); |
182 | printf("\n\rSoftware: V%d.%d%c",VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH + 'a'); |
184 | printf("\n\rSoftware: V%d.%d%c",VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH + 'a'); |
Line 183... | Line 185... | ||
183 | printf("\n\r=============================="); |
185 | printf("\n\r==================================="); |
184 | GRN_ON; |
186 | GRN_ON; |
Line -... | Line 187... | ||
- | 187 | ||
- | 188 | // Parameter Set handling |
|
- | 189 | ParamSet_Init(); |
|
- | 190 | ||
- | 191 | // Check connected BL-Ctrls |
|
- | 192 | printf("\n\rFound BL-Ctrl: "); |
|
- | 193 | motor_read = 0; |
|
- | 194 | UpdateMotor = 0; |
|
- | 195 | SendMotorData(); |
|
- | 196 | while(!UpdateMotor); |
|
- | 197 | motor_read = 0; // read the first I2C-Data |
|
- | 198 | for(i = 0; i < MAX_MOTORS; i++) |
|
- | 199 | { |
|
- | 200 | UpdateMotor = 0; |
|
- | 201 | SendMotorData(); |
|
- | 202 | while(!UpdateMotor); |
|
- | 203 | if(Motor[i].Present) printf("%d ",i+1); |
|
- | 204 | } |
|
- | 205 | for(i = 0; i < MAX_MOTORS; i++) |
|
- | 206 | { |
|
- | 207 | if(!Motor[i].Present && Mixer.Motor[i][MIX_GAS] > 0) printf("\n\r\n\r!! MISSING BL-CTRL: %d !!",i+1); |
|
- | 208 | Motor[i].Error = 0; |
|
185 | 209 | } |
|
186 | // Parameter Set handling |
210 | printf("\n\r==================================="); |
187 | ParamSet_Init(); |
211 | |
188 | 212 | ||
Line 236... | Line 260... | ||
236 | ExternControl.Digital[0] = 0x55; |
260 | ExternControl.Digital[0] = 0x55; |
Line 237... | Line 261... | ||
237 | 261 | ||
238 | 262 | ||
239 | printf("\n\rControl: "); |
263 | printf("\n\rControl: "); |
Line 240... | Line 264... | ||
240 | if (ParamSet.GlobalConfig & CFG_HEADING_HOLD) printf("HeadingHold"); |
264 | if (ParamSet.GlobalConfig & CFG_HEADING_HOLD) printf("HeadingHold"); |
Line 241... | Line 265... | ||
241 | else printf("Neutral"); |
265 | else printf("Neutral (ACC-Mode)"); |
Line 267... | Line 291... | ||
267 | ExternStickNick= 0; |
291 | ExternStickNick= 0; |
268 | ExternStickRoll = 0; |
292 | ExternStickRoll = 0; |
269 | ExternStickYaw = 0; |
293 | ExternStickYaw = 0; |
270 | } |
294 | } |
271 | if(RC_Quality) RC_Quality--; |
295 | if(RC_Quality) RC_Quality--; |
- | 296 | ||
- | 297 | #ifdef USE_NAVICTRL |
|
272 | if(!I2CTimeout) |
298 | if(NCDataOkay) |
273 | { |
299 | { |
- | 300 | if(--NCDataOkay == 0) // no data from NC |
|
- | 301 | { // set gps control sticks neutral |
|
- | 302 | GPSStickNick = 0; |
|
- | 303 | GPSStickRoll = 0; |
|
- | 304 | NCSerialDataOkay = 0; |
|
- | 305 | } |
|
- | 306 | } |
|
- | 307 | #endif |
|
- | 308 | ||
- | 309 | if(!--I2CTimeout || MissingMotor) // try to reset the i2c if motor is missing ot timeout |
|
- | 310 | { |
|
- | 311 | RED_ON; |
|
274 | I2CTimeout = 5; |
312 | if(!I2CTimeout) |
- | 313 | { |
|
275 | I2C_Reset(); |
314 | I2C_Reset(); |
- | 315 | I2CTimeout = 5; |
|
- | 316 | } |
|
276 | if((BeepModulation == 0xFFFF) && (MKFlags & MKFLAG_MOTOR_RUN) ) |
317 | if((BeepModulation == 0xFFFF) && (MKFlags & MKFLAG_MOTOR_RUN) ) |
277 | { |
318 | { |
278 | BeepTime = 10000; // 1 second |
319 | BeepTime = 10000; // 1 second |
279 | BeepModulation = 0x0080; |
320 | BeepModulation = 0x0080; |
280 | } |
321 | } |
281 | } |
322 | } |
282 | else |
323 | else |
283 | { |
324 | { |
284 | I2CTimeout--; |
- | |
285 | RED_OFF; |
325 | RED_OFF; |
286 | } |
326 | } |
Line 287... | Line 327... | ||
287 | 327 | ||
288 | // allow Serial Data Transmit if motors must not updated or motors are not running |
328 | // allow Serial Data Transmit if motors must not updated or motors are not running |
Line 308... | Line 348... | ||
308 | #endif |
348 | #endif |
309 | timer = SetDelay(20); // every 20 ms |
349 | timer = SetDelay(20); // every 20 ms |
310 | } |
350 | } |
Line 311... | Line 351... | ||
311 | 351 | ||
312 | LED_Update(); |
- | |
313 | //J4LOW; |
352 | LED_Update(); |
Line 314... | Line 353... | ||
314 | } |
353 | } |
315 | 354 | ||
316 | #ifdef USE_NAVICTRL |
355 | #ifdef USE_NAVICTRL |