Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSeconds)
- {
- if (IS_RTC_SECONDS(seconds) && IS_RTC_MINUTES(minutes) && IS_RTC_HOUR24(hours))
- {
- RTC_TimeTypeDef RTC_TimeStruct;
- RTC_TimeStruct.Hours = hours;
- RTC_TimeStruct.Minutes = minutes;
- RTC_TimeStruct.Seconds = seconds;
- if(subSeconds != NULL)
- {
- RTC_TimeStruct.SubSeconds = subSeconds;
- }
- HAL_RTC_SetTime(&hrtc, &RTC_TimeStruct, RTC_FORMAT_BIN);
- }
- }
- void getTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *subSeconds)
- {
- RTC_TimeTypeDef RTC_TimeStruct;
- if ((hours != NULL) && (minutes != NULL) && (seconds != NULL) && (subSeconds != NULL))
- {
- HAL_RTC_GetTime(&hrtc, &RTC_TimeStruct, RTC_FORMAT_BIN);
- *hours = RTC_TimeStruct.Hours;
- *minutes = RTC_TimeStruct.Minutes;
- *seconds = RTC_TimeStruct.Seconds;
- *subSeconds = RTC_TimeStruct.SubSeconds;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement