STM32F103xB HAL User Manual
Functions
Time and Date functions
RTC Exported Functions

RTC Time and Date functions. More...

Functions

HAL_StatusTypeDef HAL_RTC_SetTime (RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format)
 Sets RTC current time.
HAL_StatusTypeDef HAL_RTC_GetTime (RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format)
 Gets RTC current time.
HAL_StatusTypeDef HAL_RTC_SetDate (RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format)
 Sets RTC current date.
HAL_StatusTypeDef HAL_RTC_GetDate (RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format)
 Gets RTC current date.

Detailed Description

RTC Time and Date functions.

 ===============================================================================
                 ##### RTC Time and Date functions #####
 ===============================================================================

 [..] This section provides functions allowing to configure Time and Date features


Function Documentation

HAL_StatusTypeDef HAL_RTC_GetDate ( RTC_HandleTypeDef hrtc,
RTC_DateTypeDef sDate,
uint32_t  Format 
)

Gets RTC current date.

Parameters:
hrtcpointer to a RTC_HandleTypeDef structure that contains the configuration information for RTC.
sDate,:Pointer to Date structure
Format,:Specifies the format of the entered parameters. This parameter can be one of the following values:
  • RTC_FORMAT_BIN: Binary data format
  • RTC_FORMAT_BCD: BCD data format
Return values:
HALstatus

Definition at line 1027 of file stm32f1xx_hal_rtc.c.

References assert_param, RTC_DateTypeDef::Date, __RTC_HandleTypeDef::DateToUpdate, HAL_RTC_GetTime(), IS_RTC_FORMAT, RTC_DateTypeDef::Month, RTC_ByteToBcd2(), RTC_FORMAT_BIN, RTC_DateTypeDef::WeekDay, and RTC_DateTypeDef::Year.

HAL_StatusTypeDef HAL_RTC_GetTime ( RTC_HandleTypeDef hrtc,
RTC_TimeTypeDef sTime,
uint32_t  Format 
)

Gets RTC current time.

Parameters:
hrtcpointer to a RTC_HandleTypeDef structure that contains the configuration information for RTC.
sTime,:Pointer to Time structure
Format,:Specifies the format of the entered parameters. This parameter can be one of the following values:
  • RTC_FORMAT_BIN: Binary data format
  • RTC_FORMAT_BCD: BCD data format
Return values:
HALstatus

Definition at line 802 of file stm32f1xx_hal_rtc.c.

References __HAL_RTC_OVERFLOW_GET_FLAG, assert_param, RTC_TimeTypeDef::Hours, IS_RTC_FORMAT, RTC_TimeTypeDef::Minutes, RTC_ALARM_RESETVALUE, RTC_ByteToBcd2(), RTC_DateUpdate(), RTC_FLAG_OW, RTC_FORMAT_BIN, RTC_ReadAlarmCounter(), RTC_ReadTimeCounter(), RTC_WriteAlarmCounter(), RTC_WriteTimeCounter(), and RTC_TimeTypeDef::Seconds.

Referenced by HAL_RTC_GetDate(), HAL_RTC_SetAlarm(), and HAL_RTC_SetAlarm_IT().

HAL_StatusTypeDef HAL_RTC_SetDate ( RTC_HandleTypeDef hrtc,
RTC_DateTypeDef sDate,
uint32_t  Format 
)

Sets RTC current date.

Parameters:
hrtcpointer to a RTC_HandleTypeDef structure that contains the configuration information for RTC.
sDate,:Pointer to date structure
Format,:specifies the format of the entered parameters. This parameter can be one of the following values:
  • RTC_FORMAT_BIN: Binary data format
  • RTC_FORMAT_BCD: BCD data format
Return values:
HALstatus

Definition at line 913 of file stm32f1xx_hal_rtc.c.

References assert_param, RTC_DateTypeDef::Date, __RTC_HandleTypeDef::DateToUpdate, HAL_RTC_STATE_BUSY, HAL_RTC_STATE_ERROR, HAL_RTC_STATE_READY, IS_RTC_DATE, IS_RTC_FORMAT, IS_RTC_MONTH, IS_RTC_YEAR, RTC_DateTypeDef::Month, RTC_ALARM_RESETVALUE, RTC_Bcd2ToByte(), RTC_FORMAT_BIN, RTC_ReadAlarmCounter(), RTC_ReadTimeCounter(), RTC_WeekDayNum(), RTC_WriteAlarmCounter(), RTC_WriteTimeCounter(), __RTC_HandleTypeDef::State, RTC_DateTypeDef::WeekDay, and RTC_DateTypeDef::Year.

HAL_StatusTypeDef HAL_RTC_SetTime ( RTC_HandleTypeDef hrtc,
RTC_TimeTypeDef sTime,
uint32_t  Format 
)

Sets RTC current time.

Parameters:
hrtcpointer to a RTC_HandleTypeDef structure that contains the configuration information for RTC.
sTime,:Pointer to Time structure
Format,:Specifies the format of the entered parameters. This parameter can be one of the following values:
  • RTC_FORMAT_BIN: Binary data format
  • RTC_FORMAT_BCD: BCD data format
Return values:
HALstatus

Definition at line 703 of file stm32f1xx_hal_rtc.c.

References assert_param, HAL_RTC_STATE_BUSY, HAL_RTC_STATE_ERROR, HAL_RTC_STATE_READY, RTC_TimeTypeDef::Hours, __RTC_HandleTypeDef::Instance, IS_RTC_FORMAT, IS_RTC_HOUR24, IS_RTC_MINUTES, IS_RTC_SECONDS, RTC_TimeTypeDef::Minutes, RTC_ALARM_RESETVALUE, RTC_Bcd2ToByte(), RTC_FLAG_OW, RTC_FLAG_SEC, RTC_FORMAT_BIN, RTC_ReadAlarmCounter(), RTC_WriteAlarmCounter(), RTC_WriteTimeCounter(), RTC_TimeTypeDef::Seconds, and __RTC_HandleTypeDef::State.