You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#include "rtc_process.h"
|
|
|
|
#include "sw_timer.h"
|
|
|
|
#include "driver_ds3231_basic.h"
|
|
|
|
#include "save_file.h"
|
|
|
|
|
|
|
|
|
|
|
|
static RTC_TIME rtc_Time;
|
|
|
|
|
|
|
|
static void RTC_Get_IC_Time_Process(void);
|
|
|
|
|
|
|
|
|
|
|
|
void RTC_Process_Initialization(void)
|
|
|
|
{
|
|
|
|
ds3231_basic_init();
|
|
|
|
SW_Timer_Callback_Register(SW_TIMER_RUN_CONTINUE, 1000, RTC_Get_IC_Time_Process);
|
|
|
|
RTC_Get_IC_Time_Process();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void RTC_Get_IC_Time_Process(void)
|
|
|
|
{
|
|
|
|
ds3231_time_t t;
|
|
|
|
ds3231_basic_get_time(&t);
|
|
|
|
|
|
|
|
rtc_Time.rtc_Year = t.year;
|
|
|
|
rtc_Time.rtc_Month = t.month;
|
|
|
|
rtc_Time.rtc_Date = t.date;
|
|
|
|
if(t.format == DS3231_FORMAT_24H)
|
|
|
|
rtc_Time.rtc_Hour = t.hour;
|
|
|
|
else
|
|
|
|
rtc_Time.rtc_Hour = t.hour % 12 + t.am_pm * 12;
|
|
|
|
rtc_Time.rtc_Min = t.minute;
|
|
|
|
rtc_Time.rtc_Sec = t.second;
|
|
|
|
|
|
|
|
//dbg_printf("Read RTC : %04d-%02d-%02d %02d:%02d:%02d\r\n", rtc_Time.rtc_Year, rtc_Time.rtc_Month, rtc_Time.rtc_Date, rtc_Time.rtc_Hour, rtc_Time.rtc_Min, rtc_Time.rtc_Sec);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RTC_TIME RTC_Get_Time(void)
|
|
|
|
{
|
|
|
|
return rtc_Time;
|
|
|
|
}
|
|
|
|
|
|
|
|
|