The SZ / WakeupLight

Dependencies:   BSP_DISCO_F746NG_patch_fixed LCD_DISCO_F746NG TS_DISCO_F746NG FATFileSystem TinyJpgDec_interwork mbed-src

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers RTC.cpp Source File

RTC.cpp

00001 #include "WakeupLight.h"
00002 
00003 void RTC_Init(void)
00004 {
00005     rtc_init();
00006 }
00007 
00008 time_t RTC_Get(struct tm **tmStruct)
00009 {
00010     time_t              result;
00011 
00012     // rtc_read in IAR is buggy, it converts the rtc time to local time, sometimes with, sometimes without timezone
00013     result=time(NULL);
00014     localtime(&result);
00015 
00016     result=time(NULL);
00017 
00018     DPrintf_("RTC_Get: 0x%X.\r\n",result);
00019 
00020     if (tmStruct!=NULL)
00021         (*tmStruct)=localtime(&result);
00022 
00023     return result;
00024 }
00025 
00026 void RTC_Set(struct tm *tmStruct)
00027 {
00028     time_t              result;
00029 
00030     result=mktime(tmStruct);
00031 
00032     set_time(result);
00033 }
00034