Rev 92 | Rev 111 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 92 | Rev 110 | ||
---|---|---|---|
Line 114... | Line 114... | ||
114 | void GetNaviCtrlVersion(void) |
114 | void GetNaviCtrlVersion(void) |
115 | { |
115 | { |
116 | u8 msg[25]; |
116 | u8 msg[25]; |
Line 117... | Line 117... | ||
117 | 117 | ||
118 | sprintf(msg,"\n\r NaviCtrl V%d.%d%c", VERSION_MAJOR, VERSION_MINOR, 'a'+ VERSION_PATCH); |
118 | sprintf(msg,"\n\r NaviCtrl V%d.%d%c", VERSION_MAJOR, VERSION_MINOR, 'a'+ VERSION_PATCH); |
119 | SerialPutString(msg); |
119 | UART1_PutString(msg); |
Line 120... | Line 120... | ||
120 | } |
120 | } |
121 | 121 | ||
Line 226... | Line 226... | ||
226 | TIMER1_Init(); |
226 | TIMER1_Init(); |
227 | // initialize the LEDs (needs Timer 1) |
227 | // initialize the LEDs (needs Timer 1) |
228 | Led_Init(); |
228 | Led_Init(); |
229 | // initialize the debug UART1 |
229 | // initialize the debug UART1 |
230 | UART1_Init(); |
230 | UART1_Init(); |
231 | SerialPutString("\r\n---------------------------------------------"); |
231 | UART1_PutString("\r\n---------------------------------------------"); |
232 | // initialize UART2 to FLIGHTCTRL |
232 | // initialize UART2 to FLIGHTCTRL |
233 | UART2_Init(); |
233 | UART2_Init(); |
234 | // initialize UART0 (to MKGPS or MK3MAG) |
234 | // initialize UART0 (to MKGPS or MK3MAG) |
235 | UART0_Init(); |
235 | UART0_Init(); |
236 | // initialize usb |
236 | // initialize usb |
Line 248... | Line 248... | ||
248 | // initialize logging (needs settings) |
248 | // initialize logging (needs settings) |
249 | Logging_Init(); |
249 | Logging_Init(); |
Line 250... | Line 250... | ||
250 | 250 | ||
251 | TimerCompassUpdate = SetDelay(5); |
251 | TimerCompassUpdate = SetDelay(5); |
252 | TimerCheckError = SetDelay(3000); |
252 | TimerCheckError = SetDelay(3000); |
253 | SerialPutString("\r\n---------------------------------------------"); |
253 | UART1_PutString("\r\n---------------------------------------------"); |
254 | SerialPutString("\n\r Version information:"); |
254 | UART1_PutString("\n\r Version information:"); |
255 | GetNaviCtrlVersion(); |
255 | GetNaviCtrlVersion(); |
256 | SPI0_GetFlightCtrlVersion(); |
256 | SPI0_GetFlightCtrlVersion(); |
257 | if(FC_Version.Compatible != FC_SPI_COMPATIBLE) |
257 | if(FC_Version.Compatible != FC_SPI_COMPATIBLE) |
258 | { |
258 | { |
259 | //sprintf(ErrorMSG,"\r\n %d <-> %d", FlightCtrlVersion.NaviCompatible, FC_SPI_COMPATIBLE); |
259 | //sprintf(ErrorMSG,"\r\n %d <-> %d", FlightCtrlVersion.NaviCompatible, FC_SPI_COMPATIBLE); |
260 | //SerialPutString(ErrorMSG); |
260 | //UART1_PutString(ErrorMSG); |
261 | SerialPutString("\n\r Flight-Ctrl not compatible"); |
261 | UART1_PutString("\n\r Flight-Ctrl not compatible"); |
262 | LED_RED_ON; |
262 | LED_RED_ON; |
Line 263... | Line 263... | ||
263 | } |
263 | } |
264 | 264 | ||
265 | I2C1_GetMK3MagVersion(); |
265 | I2C1_GetMK3MagVersion(); |
266 | if(MK3MAG_Version.Compatible != MK3MAG_I2C_COMPATIBLE) |
266 | if(MK3MAG_Version.Compatible != MK3MAG_I2C_COMPATIBLE) |
267 | { |
267 | { |
268 | SerialPutString("\n\r MK3Mag not compatible"); |
268 | UART1_PutString("\n\r MK3Mag not compatible"); |
Line 269... | Line 269... | ||
269 | LED_RED_ON; |
269 | LED_RED_ON; |
Line 270... | Line 270... | ||
270 | } |
270 | } |
271 | 271 | ||
272 | SerialPutString("\r\n---------------------------------------------\r\n\r\n"); |
272 | UART1_PutString("\r\n---------------------------------------------\r\n\r\n"); |
273 | 273 | ||
Line 274... | Line 274... | ||
274 | for (;;) |
274 | for (;;) |
275 | { |
275 | { |
276 | UART1_ProcessRxData(); // process request |
- | |
Line 277... | Line 276... | ||
277 | UART1_TransmitTxData(); // send answer |
276 | UART1_ProcessRxData(); // process request |
278 | 277 | UART1_TransmitTxData(); // send answer |
|
279 | SPI0_UpdateBuffer(); |
278 | |
280 | UART0_Transmit(); // empty txd buffer |
279 | SPI0_UpdateBuffer(); |
281 | UART1_Transmit(); // empty txd buffer |
280 | UART0_Transmit(); // empty txd buffer |
282 | 281 | ||
283 | // ------------------------- I2C Timing -------------------------------- |
282 | // ------------------------- I2C Timing -------------------------------- |
284 | if(I2C_State != I2C_OFF) |
283 | if(I2C_State != I2C_OFF) |
285 | { |
284 | { |
286 | if (CheckDelay(TimerCompassUpdate)) |
285 | if (CheckDelay(TimerCompassUpdate)) |
287 | { |
286 | { |
288 | // check for hanging I2C bus |
287 | // check for hanging I2C bus |
289 | if(CheckDelay(I2C1_Timeout)) |
288 | if(CheckDelay(I2C1_Timeout)) |
290 | { // reset I2C |
289 | { // reset I2C |
Line 317... | Line 316... | ||
317 | if(!CheckSPIOkay) GPS_Navigation(); // process the GPS data even if the FC is not connected |
316 | if(!CheckSPIOkay) GPS_Navigation(); // process the GPS data even if the FC is not connected |
318 | CheckErrors(); |
317 | CheckErrors(); |
319 | if(FC.MKFlags & MKFLAG_FLY) NaviData.FlyingTime++; // we want to count the battery-time |
318 | if(FC.MKFlags & MKFLAG_FLY) NaviData.FlyingTime++; // we want to count the battery-time |
320 | // else NaviData.FlyingTime = 0; |
319 | // else NaviData.FlyingTime = 0; |
321 | TimerCheckError = SetDelay(1000); |
320 | TimerCheckError = SetDelay(1000); |
322 | Request_SendFollowMe = TRUE; |
321 | UART1_Request_SendFollowMe = TRUE; |
323 | if(SerialLinkOkay) SerialLinkOkay--; |
322 | if(SerialLinkOkay) SerialLinkOkay--; |
324 | if(SerialLinkOkay < 250 - 5) NCFlags |= NC_FLAG_NOSERIALLINK; // 5 seconds timeout for serial communication |
323 | if(SerialLinkOkay < 250 - 5) NCFlags |= NC_FLAG_NOSERIALLINK; // 5 seconds timeout for serial communication |
325 | else NCFlags &= ~NC_FLAG_NOSERIALLINK; |
324 | else NCFlags &= ~NC_FLAG_NOSERIALLINK; |
326 | } |
325 | } |
327 | // ---------------- Logging --------------------------------------- |
326 | // ---------------- Logging --------------------------------------- |