I try to return number of second from 1970 with time function with stm32f4
card.
I have these datatype configured
RTC_HandleTypeDef RtcHandle;
RTC_DateTypeDef dateStruct;
RTC_TimeTypeDef timeStruct;
I do a call to
HAL_RTC_GetTime
HAL_RTC_GetDate
and i call this function
long SystemClock::getUnixTimestamp()
struct tm timeinfo;
//Setup a tm structure based on the RTC
timeinfo.tm_wday = dateStruct.WeekDay;
timeinfo.tm_mon = dateStruct.Month - 1;
timeinfo.tm_mday = dateStruct.Date;
timeinfo.tm_year = dateStruct.Year + 100;
timeinfo.tm_hour = timeStruct.Hours;
timeinfo.tm_min = timeStruct.Minutes;
timeinfo.tm_sec = timeStruct.Seconds;
time_t rawtime = mktime(&timeinfo);
trace_printf("Current date and time are: %s\n", ctime(&rawtime));
long x = time(&rawtime);
trace_printf("time %lu\n", x);
return x;
}
I see
Current date and time are: Wed Apr 29 22:46:00 2015
time 1430347560
5 second later, i do another call to HAL_RTC_GetTime, HAL_RTC_GetDate, getUnixTimestamp and i get
Current date and time are: Wed Apr 29 22:46:05 2015
time 1430347560
why time is not modified?