Rev 470 | Rev 473 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 470 | Rev 472 | ||
---|---|---|---|
Line 132... | Line 132... | ||
132 | //---------------------------------------------------------------------------------------------------- |
132 | //---------------------------------------------------------------------------------------------------- |
133 | void GetNaviCtrlVersion(void) |
133 | void GetNaviCtrlVersion(void) |
134 | { |
134 | { |
135 | u8 msg[25]; |
135 | u8 msg[25]; |
Line 136... | Line 136... | ||
136 | 136 | ||
137 | sprintf(msg,"\n\r NaviCtrl HW: V%d.%d SW: V%d.%d%c", Version_HW/10, Version_HW%10, VERSION_MAJOR, VERSION_MINOR, 'a'+ VERSION_PATCH); |
137 | sprintf(msg,"\n\r NaviCtrl HW: V%d.%d SW: V%d.%02d%c", Version_HW/10, Version_HW%10, VERSION_MAJOR, VERSION_MINOR, 'a'+ VERSION_PATCH); |
138 | UART1_PutString(msg); |
138 | UART1_PutString(msg); |
Line 139... | Line 139... | ||
139 | } |
139 | } |
Line 144... | Line 144... | ||
144 | { |
144 | { |
145 | static s32 no_error_delay = 0; |
145 | static s32 no_error_delay = 0; |
146 | s32 newErrorCode = 0; |
146 | s32 newErrorCode = 0; |
147 | UART_VersionInfo.HardwareError[0] = 0; |
147 | UART_VersionInfo.HardwareError[0] = 0; |
Line -... | Line 148... | ||
- | 148 | ||
148 | 149 | if((I2C_CompassPort == I2C_INTERN_1 && CheckDelay(I2C1_Timeout)) || (I2C_CompassPort == I2C_EXTERN_0 && CheckDelay(I2C0_Timeout)) || (Compass_Heading < 0)) |
|
149 | //ToDo |
150 | |
150 | if(CheckDelay(I2C1_Timeout) || (Compass_Heading < 0)) DebugOut.StatusRed |= AMPEL_COMPASS; |
151 | DebugOut.StatusRed |= AMPEL_COMPASS; |
Line 151... | Line 152... | ||
151 | else DebugOut.StatusRed &= ~AMPEL_COMPASS; // MK3Mag green status |
152 | else DebugOut.StatusRed &= ~AMPEL_COMPASS; // MK3Mag green status |
152 | 153 | ||
Line 161... | Line 162... | ||
161 | sprintf(ErrorMSG,"Calibrate... "); |
162 | sprintf(ErrorMSG,"Calibrate... "); |
162 | newErrorCode = 0; |
163 | newErrorCode = 0; |
163 | ErrorCode = 0; |
164 | ErrorCode = 0; |
164 | no_error_delay = 1; |
165 | no_error_delay = 1; |
165 | } |
166 | } |
166 | else |
- | |
167 | if(CheckDelay(SPI0_Timeout)) |
167 | else if(CheckDelay(I2C1_Timeout) && (I2C_CompassPort == I2C_INTERN_1)) |
168 | { |
168 | { |
169 | LED_RED_ON; |
169 | LED_RED_ON; |
170 | sprintf(ErrorMSG,"no FC communication "); |
170 | sprintf(ErrorMSG,"no compass communica"); |
- | 171 | //Reset I2CBus |
|
- | 172 | I2C1_Deinit(); |
|
- | 173 | I2C1_Init(); |
|
171 | newErrorCode = 3; |
174 | newErrorCode = 4; |
172 | StopNavigation = 1; |
175 | StopNavigation = 1; |
173 | DebugOut.StatusGreen &= ~AMPEL_FC; // status of FC Present |
176 | UART_VersionInfo.HardwareError[0] |= NC_ERROR0_COMPASS_RX; |
174 | DebugOut.StatusGreen &= ~AMPEL_BL; // status of BL Present |
177 | DebugOut.StatusRed |= AMPEL_COMPASS; |
175 | UART_VersionInfo.HardwareError[0] |= NC_ERROR0_SPI_RX; |
- | |
176 | } |
178 | } |
177 | //ToDo |
- | |
178 | else if(CheckDelay(I2C1_Timeout)) |
179 | else if(CheckDelay(I2C0_Timeout) && (I2C_CompassPort == I2C_EXTERN_0)) |
179 | { |
180 | { |
180 | LED_RED_ON; |
181 | LED_RED_ON; |
181 | sprintf(ErrorMSG,"no compass communica"); |
182 | sprintf(ErrorMSG,"no ext. compass "); |
182 | //Reset I2CBus |
183 | //Reset I2CBus |
183 | I2C1_Deinit(); |
184 | I2C0_Deinit(); |
184 | I2C1_Init(); |
185 | I2C0_Init(); |
185 | newErrorCode = 4; |
186 | newErrorCode = 4; |
186 | StopNavigation = 1; |
187 | StopNavigation = 1; |
187 | UART_VersionInfo.HardwareError[0] |= NC_ERROR0_COMPASS_RX; |
188 | UART_VersionInfo.HardwareError[0] |= NC_ERROR0_COMPASS_RX; |
188 | DebugOut.StatusRed |= AMPEL_COMPASS; |
189 | DebugOut.StatusRed |= AMPEL_COMPASS; |
189 | } |
190 | } |
- | 191 | else |
|
- | 192 | if(CheckDelay(SPI0_Timeout)) |
|
- | 193 | { |
|
- | 194 | LED_RED_ON; |
|
- | 195 | sprintf(ErrorMSG,"no FC communication "); |
|
- | 196 | newErrorCode = 3; |
|
- | 197 | StopNavigation = 1; |
|
- | 198 | DebugOut.StatusGreen &= ~AMPEL_FC; // status of FC Present |
|
- | 199 | DebugOut.StatusGreen &= ~AMPEL_BL; // status of BL Present |
|
- | 200 | UART_VersionInfo.HardwareError[0] |= NC_ERROR0_SPI_RX; |
|
- | 201 | } |
|
190 | else if(FC_Version.Compatible != FC_SPI_COMPATIBLE) |
202 | else if(FC_Version.Compatible != FC_SPI_COMPATIBLE) |
191 | { |
203 | { |
192 | LED_RED_ON; |
204 | LED_RED_ON; |
193 | #ifndef FOLLOW_ME |
205 | #ifndef FOLLOW_ME |
194 | sprintf(ErrorMSG,"FC not compatible "); |
206 | sprintf(ErrorMSG,"FC not compatible "); |
Line 328... | Line 340... | ||
328 | sprintf(ErrorMSG,"Magnet error "); |
340 | sprintf(ErrorMSG,"Magnet error "); |
329 | newErrorCode = 22; |
341 | newErrorCode = 22; |
330 | DebugOut.StatusRed |= AMPEL_COMPASS | AMPEL_NC; |
342 | DebugOut.StatusRed |= AMPEL_COMPASS | AMPEL_NC; |
331 | UART_VersionInfo.HardwareError[0] |= NC_ERROR0_COMPASS_VALUE; |
343 | UART_VersionInfo.HardwareError[0] |= NC_ERROR0_COMPASS_VALUE; |
332 | } |
344 | } |
333 | else if(BL_MinOfMaxPWM == 40 && (FC.StatusFlags & FC_STATUS_FLY) && !ErrorCode) |
345 | else if(((BL_MinOfMaxPWM == 40 && (FC.StatusFlags & FC_STATUS_FLY)) || BL_MinOfMaxPWM == 39) && !ErrorCode) |
334 | { |
346 | { |
335 | LED_RED_ON; |
347 | LED_RED_ON; |
336 | sprintf(ErrorMSG,"ERR:Motor restart "); |
348 | sprintf(ErrorMSG,"ERR:Motor restart "); |
337 | newErrorCode = 23; |
349 | newErrorCode = 23; |
338 | DebugOut.StatusRed |= AMPEL_BL; |
350 | DebugOut.StatusRed |= AMPEL_BL; |
339 | } |
351 | } |
- | 352 | else if(BL_MinOfMaxPWM < 30 && !ErrorCode) |
|
- | 353 | { |
|
- | 354 | unsigned int i; |
|
- | 355 | for(i = 0; i < 12; i++) if(Motor[i].MaxPWM == BL_MinOfMaxPWM) break; |
|
- | 356 | ||
- | 357 | LED_RED_ON; |
|
- | 358 | sprintf(ErrorMSG,"ERR:BL%2d Test:%2d ",i+1,BL_MinOfMaxPWM); |
|
- | 359 | newErrorCode = 32; |
|
- | 360 | DebugOut.StatusRed |= AMPEL_BL; |
|
- | 361 | } |
|
340 | else if(BL_MinOfMaxPWM != 255 && (BL_MinOfMaxPWM != 250) && (FC.StatusFlags & FC_STATUS_FLY) && !ErrorCode) |
362 | else if(BL_MinOfMaxPWM < 248 && (FC.StatusFlags & FC_STATUS_FLY) && !ErrorCode) |
341 | { |
363 | { |
342 | LED_RED_ON; |
364 | LED_RED_ON; |
343 | sprintf(ErrorMSG,"ERR:BL Limitation "); |
365 | sprintf(ErrorMSG,"ERR:BL Limitation "); |
344 | newErrorCode = 24; |
366 | newErrorCode = 24; |
345 | DebugOut.StatusRed |= AMPEL_BL; |
367 | DebugOut.StatusRed |= AMPEL_BL; |
Line 419... | Line 441... | ||
419 | UART2_TransmitTxData(); // FC send answer |
441 | UART2_TransmitTxData(); // FC send answer |
420 | CalcHeadFree(); |
442 | CalcHeadFree(); |
421 | // ---------------- Error Check Timing ---------------------------- |
443 | // ---------------- Error Check Timing ---------------------------- |
422 | if(CheckDelay(TimerCheckError) || (FC.StatusFlags & FC_STATUS_START && !(oldFcFlags & FC_STATUS_START))) // Timer or FY wants to start |
444 | if(CheckDelay(TimerCheckError) || (FC.StatusFlags & FC_STATUS_START && !(oldFcFlags & FC_STATUS_START))) // Timer or FY wants to start |
423 | { |
445 | { |
424 | //CreateNmeaGGA(); |
- | |
425 | if(CheckDelay(TimerCheckError)) |
446 | if(CheckDelay(TimerCheckError)) |
426 | { |
447 | { |
427 | TimerCheckError = SetDelay(1000); |
448 | TimerCheckError = SetDelay(1000); |
428 | if(++count5sec == 5) |
449 | if(++count5sec == 5) |
429 | { |
450 | { |
Line 438... | Line 459... | ||
438 | if(CheckDelay(SPI0_Timeout) && (DebugUART == UART1)) GPS_Navigation(&GPSData, &(ToFlightCtrl.GPSStick)); // process the GPS data even if the FC is not connected |
459 | if(CheckDelay(SPI0_Timeout) && (DebugUART == UART1)) GPS_Navigation(&GPSData, &(ToFlightCtrl.GPSStick)); // process the GPS data even if the FC is not connected |
Line 439... | Line 460... | ||
439 | 460 | ||
Line 440... | Line 461... | ||
440 | if(!CheckDelay(SPI0_Timeout) || (DebugUART == UART1)) CheckErrors(); |
461 | if(!CheckDelay(SPI0_Timeout) || (DebugUART == UART1)) CheckErrors(); |
441 | - | ||
442 | if(FC.StatusFlags & FC_STATUS_FLY) NaviData.FlyingTime++; // we want to count the battery-time |
462 | |
443 | // else NaviData.FlyingTime = 0; // not the time per flight |
463 | if(FC.StatusFlags & FC_STATUS_FLY) NaviData.FlyingTime++; // we want to count the battery-time |
444 | if(SerialLinkOkay) SerialLinkOkay--; |
464 | if(SerialLinkOkay) SerialLinkOkay--; |
445 | if(SerialLinkOkay < 250 - 5) NCFlags |= NC_FLAG_NOSERIALLINK; // 5 seconds timeout for serial communication |
465 | if(SerialLinkOkay < 250 - 5) NCFlags |= NC_FLAG_NOSERIALLINK; // 5 seconds timeout for serial communication |
446 | else NCFlags &= ~NC_FLAG_NOSERIALLINK; |
466 | else NCFlags &= ~NC_FLAG_NOSERIALLINK; |