289,6 → 289,9 |
//------------------------------------------------------ |
void SPI0_UpdateBuffer(void) |
{ |
static u32 timeout = 0; |
static u8 counter = 50; |
|
if (SPI_RxBuffer_Request) |
{ |
// avoid sending data via SPI during the update of the ToFlightCtrl structure |
416,7 → 419,14 |
GPS_Navigation(); |
ClearMKFlags = 1; |
|
if(counter) |
{ |
counter--; // count down to enable servo |
if(!counter) TIMER2_Init(); // enable Servo Output |
} |
|
SPI_RxBuffer_Request = 0; |
timeout = SetDelay(80); // 80 ms, new data are send every 20 ms |
|
DebugOut.Analog[0] = FromFlightCtrl.AngleNick; |
DebugOut.Analog[1] = FromFlightCtrl.AngleRoll; |
427,7 → 437,15 |
Data3D.AngleRoll = FromFlightCtrl.AngleRoll; // in 0.1 deg |
Data3D.Heading = FromFlightCtrl.GyroHeading; // in 0.1 deg |
} // EOF if(SPI_RxBuffer_Request) |
else // no new SPI data |
{ |
if(CheckDelay(timeout) && (counter == 0)) |
{ |
TIMER2_Deinit(); // disable Servo Output |
counter = 50; // reset counter for enabling Servo Output |
} |
} |
} |
|
//------------------------------------------------------ |
void SPI0_GetFlightCtrlVersion(void) |
454,7 → 472,7 |
}while (!CheckDelay(timeout)); |
UART1_PutString("."); |
repeat++; |
}while((FC_Version.Major == 0xFF) && (repeat < 12)); // 12*250ms = 3s |
}while((FC_Version.Major == 0xFF) && (repeat < 40)); // 40*250ms = 10s |
// if we got it |
if (FC_Version.Major != 0xFF) |
{ |