//---------------------------------------------------------------------------------------------------- // gobal logging handler void Logging_Update(void) { static uint16_t logtimer = 0; static logfilestate_t logstate = LOGFILE_IDLE; if(SD_SWITCH) // a card is in slot { if(CheckDelay(logtimer)) { logtimer = SetDelay(10); // faster makes no sense // call the logger handlers if no error has occured if(logstate != LOGFILE_ERROR) logstate = Logging_KML(LogCfg.KML_Interval); if(logstate != LOGFILE_ERROR) logstate = Logging_GPX(LogCfg.GPX_Interval); // a logging error has occured if(logstate == LOGFILE_ERROR) { if(Fat16_IsValid()) // wait for reinizialization of fat16 from outside { Logging_Init(); // initialize the logs logstate = LOGFILE_IDLE; logtimer = SetDelay(10); // try next log in 10 mili sec } else { // retry in 5 seconds logtimer = SetDelay(5000); // try again in 5 sec } } //EOF logfile error } // EOF CheckDelay }// EOF Card in Slot }
int main() { SystemCoreClockUpdate(); Uart_Init(); Logging_Init(); MCP9808_Init(); Uart_Setup(9600); while(1) { Uart_Idle(); Logging_Idle(); MCP9808_Idle(); } }