Guido Ottaviani / Mbed 2 deprecated LeonardoMbos

Dependencies:   mbos Watchdog TextLCD mbed ConfigFile

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Task5SetTime.cpp Source File

Task5SetTime.cpp

00001 #include "Task5SetTime.h"
00002 
00003 void SetTimeTask(void)
00004 {/**
00005  *\brief TASK 5, Set RTC system time if the GPS time is valid
00006  */
00007  struct tm t;
00008  
00009  os.SetTimer(SET_TIME_TMR, 60000, 60000);
00010  while(1)
00011  {  
00012  os.WaitEvent(SET_TIME_EVT);
00013 
00014     if(info.sig != 0)    
00015     {
00016        t.tm_mday=info.utc.day;
00017        t.tm_mon=info.utc.mon;
00018        t.tm_year=info.utc.year; 
00019        t.tm_hour=info.utc.hour;
00020        t.tm_min=info.utc.min;
00021        t.tm_sec=info.utc.sec;        
00022           
00023         time_t seconds = mktime(&t);       
00024         set_time(seconds);
00025         
00026         SetTimeOk = 1; // RTC was set 
00027     }
00028  }    
00029 }