Lines Matching refs:datetime
37 static bool RTC_CheckDatetimeFormat(const rtc_datetime_t *datetime);
46 static uint32_t RTC_ConvertDatetimeToSeconds(const rtc_datetime_t *datetime);
54 static void RTC_ConvertSecondsToDatetime(uint32_t seconds, rtc_datetime_t *datetime);
59 static bool RTC_CheckDatetimeFormat(const rtc_datetime_t *datetime) in RTC_CheckDatetimeFormat() argument
61 assert(datetime); in RTC_CheckDatetimeFormat()
69 …if ((datetime->year < YEAR_RANGE_START) || (datetime->year > YEAR_RANGE_END) || (datetime->month >… in RTC_CheckDatetimeFormat()
70 …(datetime->month < 1U) || (datetime->hour >= 24U) || (datetime->minute >= 60U) || (datetime->secon… in RTC_CheckDatetimeFormat()
77 …if ((((datetime->year & 3U) == 0U) && (datetime->year % 100U != 0U)) || (datetime->year % 400U == … in RTC_CheckDatetimeFormat()
83 if ((datetime->day > daysPerMonth[datetime->month]) || (datetime->day < 1U)) in RTC_CheckDatetimeFormat()
91 static uint32_t RTC_ConvertDatetimeToSeconds(const rtc_datetime_t *datetime) in RTC_ConvertDatetimeToSeconds() argument
93 assert(datetime); in RTC_ConvertDatetimeToSeconds()
101 seconds = ((uint32_t)datetime->year - 1970U) * DAYS_IN_A_YEAR; in RTC_ConvertDatetimeToSeconds()
103 seconds += (((uint32_t)datetime->year / 4U) - (1970U / 4U)); in RTC_ConvertDatetimeToSeconds()
105 seconds += monthDays[datetime->month]; in RTC_ConvertDatetimeToSeconds()
108 seconds += ((uint32_t)datetime->day - 1U); in RTC_ConvertDatetimeToSeconds()
110 if (((datetime->year & 3U) == 0x00U) && (datetime->month <= 2U)) in RTC_ConvertDatetimeToSeconds()
115 seconds = (seconds * SECONDS_IN_A_DAY) + (datetime->hour * SECONDS_IN_A_HOUR) + in RTC_ConvertDatetimeToSeconds()
116 (datetime->minute * SECONDS_IN_A_MINUTE) + datetime->second; in RTC_ConvertDatetimeToSeconds()
121 static void RTC_ConvertSecondsToDatetime(uint32_t seconds, rtc_datetime_t *datetime) in RTC_ConvertSecondsToDatetime() argument
123 assert(datetime); in RTC_ConvertSecondsToDatetime()
146 datetime->hour = (uint8_t)(secondsRemaining / SECONDS_IN_A_HOUR); in RTC_ConvertSecondsToDatetime()
148 datetime->minute = (uint8_t)(secondsRemaining / 60U); in RTC_ConvertSecondsToDatetime()
149 datetime->second = (uint8_t)(secondsRemaining % SECONDS_IN_A_MINUTE); in RTC_ConvertSecondsToDatetime()
153 datetime->year = YEAR_RANGE_START; in RTC_ConvertSecondsToDatetime()
158 datetime->year++; in RTC_ConvertSecondsToDatetime()
161 if ((datetime->year & 3U) != 0x00U) in RTC_ConvertSecondsToDatetime()
172 if ((datetime->year & 3U) == 0x00U) in RTC_ConvertSecondsToDatetime()
181 datetime->month = i; in RTC_ConvertSecondsToDatetime()
190 datetime->day = (uint8_t)days; in RTC_ConvertSecondsToDatetime()
231 status_t RTC_SetDatetime(RTC_Type *base, const rtc_datetime_t *datetime) in RTC_SetDatetime() argument
233 assert(datetime); in RTC_SetDatetime()
236 if (!(RTC_CheckDatetimeFormat(datetime))) in RTC_SetDatetime()
242 base->COUNT = RTC_ConvertDatetimeToSeconds(datetime); in RTC_SetDatetime()
253 void RTC_GetDatetime(RTC_Type *base, rtc_datetime_t *datetime) in RTC_GetDatetime() argument
255 assert(datetime); in RTC_GetDatetime()
260 RTC_ConvertSecondsToDatetime(seconds, datetime); in RTC_GetDatetime()
312 void RTC_GetAlarm(RTC_Type *base, rtc_datetime_t *datetime) in RTC_GetAlarm() argument
314 assert(datetime); in RTC_GetAlarm()
321 RTC_ConvertSecondsToDatetime(alarmSeconds, datetime); in RTC_GetAlarm()