STM32L4xx_HAL_Driver  1.14.0

Functions

__STATIC_INLINE void LL_RTC_TIME_SetFormat (RTC_TypeDef *RTCx, uint32_t TimeFormat)
 Set time format (AM/24-hour or PM notation) More...
 
__STATIC_INLINE uint32_t LL_RTC_TIME_GetFormat (RTC_TypeDef *RTCx)
 Get time format (AM or PM notation) More...
 
__STATIC_INLINE void LL_RTC_TIME_SetHour (RTC_TypeDef *RTCx, uint32_t Hours)
 Set Hours in BCD format. More...
 
__STATIC_INLINE uint32_t LL_RTC_TIME_GetHour (RTC_TypeDef *RTCx)
 Get Hours in BCD format. More...
 
__STATIC_INLINE void LL_RTC_TIME_SetMinute (RTC_TypeDef *RTCx, uint32_t Minutes)
 Set Minutes in BCD format. More...
 
__STATIC_INLINE uint32_t LL_RTC_TIME_GetMinute (RTC_TypeDef *RTCx)
 Get Minutes in BCD format. More...
 
__STATIC_INLINE void LL_RTC_TIME_SetSecond (RTC_TypeDef *RTCx, uint32_t Seconds)
 Set Seconds in BCD format. More...
 
__STATIC_INLINE uint32_t LL_RTC_TIME_GetSecond (RTC_TypeDef *RTCx)
 Get Seconds in BCD format. More...
 
__STATIC_INLINE void LL_RTC_TIME_Config (RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
 Set time (hour, minute and second) in BCD format. More...
 
__STATIC_INLINE uint32_t LL_RTC_TIME_Get (RTC_TypeDef *RTCx)
 Get time (hour, minute and second) in BCD format. More...
 
__STATIC_INLINE void LL_RTC_TIME_EnableDayLightStore (RTC_TypeDef *RTCx)
 Memorize whether the daylight saving time change has been performed. More...
 
__STATIC_INLINE void LL_RTC_TIME_DisableDayLightStore (RTC_TypeDef *RTCx)
 Disable memorization whether the daylight saving time change has been performed. More...
 
__STATIC_INLINE uint32_t LL_RTC_TIME_IsDayLightStoreEnabled (RTC_TypeDef *RTCx)
 Check if RTC Day Light Saving stored operation has been enabled or not RTC_CR BKP LL_RTC_TIME_IsDayLightStoreEnabled. More...
 
__STATIC_INLINE void LL_RTC_TIME_DecHour (RTC_TypeDef *RTCx)
 Subtract 1 hour (winter time change) More...
 
__STATIC_INLINE void LL_RTC_TIME_IncHour (RTC_TypeDef *RTCx)
 Add 1 hour (summer time change) More...
 
__STATIC_INLINE uint32_t LL_RTC_TIME_GetSubSecond (RTC_TypeDef *RTCx)
 Get Sub second value in the synchronous prescaler counter. More...
 
__STATIC_INLINE void LL_RTC_TIME_Synchronize (RTC_TypeDef *RTCx, uint32_t ShiftSecond, uint32_t Fraction)
 Synchronize to a remote clock with a high degree of precision. More...
 

Detailed Description

Function Documentation

◆ LL_RTC_TIME_Config()

__STATIC_INLINE void LL_RTC_TIME_Config ( RTC_TypeDef *  RTCx,
uint32_t  Format12_24,
uint32_t  Hours,
uint32_t  Minutes,
uint32_t  Seconds 
)

Set time (hour, minute and second) in BCD format.

Note
Bit is write-protected. LL_RTC_DisableWriteProtection function should be called before.
It can be written in initialization mode only (LL_RTC_EnableInitMode function)
TimeFormat and Hours should follow the same format RTC_TR PM LL_RTC_TIME_Config
RTC_TR HT LL_RTC_TIME_Config
RTC_TR HU LL_RTC_TIME_Config
RTC_TR MNT LL_RTC_TIME_Config
RTC_TR MNU LL_RTC_TIME_Config
RTC_TR ST LL_RTC_TIME_Config
RTC_TR SU LL_RTC_TIME_Config
Parameters
RTCxRTC Instance
Format12_24This parameter can be one of the following values:
  • LL_RTC_TIME_FORMAT_AM_OR_24
  • LL_RTC_TIME_FORMAT_PM
HoursValue between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
MinutesValue between Min_Data=0x00 and Max_Data=0x59
SecondsValue between Min_Data=0x00 and Max_Data=0x59
Return values
None

Definition at line 1507 of file stm32l4xx_ll_rtc.h.

1508 {
1509  register uint32_t temp = 0U;
1510 
1511  temp = Format12_24 | \
1512  (((Hours & 0xF0U) << (RTC_TR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos)) | \
1513  (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)) | \
1514  (((Seconds & 0xF0U) << (RTC_TR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos));
1515  MODIFY_REG(RTCx->TR, (RTC_TR_PM | RTC_TR_HT | RTC_TR_HU | RTC_TR_MNT | RTC_TR_MNU | RTC_TR_ST | RTC_TR_SU), temp);
1516 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)

◆ LL_RTC_TIME_DecHour()

__STATIC_INLINE void LL_RTC_TIME_DecHour ( RTC_TypeDef *  RTCx)

Subtract 1 hour (winter time change)

Note
Bit is write-protected. LL_RTC_DisableWriteProtection function should be called before. RTC_CR SUB1H LL_RTC_TIME_DecHour
Parameters
RTCxRTC Instance
Return values
None

Definition at line 1587 of file stm32l4xx_ll_rtc.h.

1588 {
1589  SET_BIT(RTCx->CR, RTC_CR_SUB1H);
1590 }

◆ LL_RTC_TIME_DisableDayLightStore()

__STATIC_INLINE void LL_RTC_TIME_DisableDayLightStore ( RTC_TypeDef *  RTCx)

Disable memorization whether the daylight saving time change has been performed.

Note
Bit is write-protected. LL_RTC_DisableWriteProtection function should be called before. RTC_CR BKP LL_RTC_TIME_DisableDayLightStore
Parameters
RTCxRTC Instance
Return values
None

Definition at line 1564 of file stm32l4xx_ll_rtc.h.

1565 {
1566  CLEAR_BIT(RTCx->CR, RTC_CR_BKP);
1567 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)

◆ LL_RTC_TIME_EnableDayLightStore()

__STATIC_INLINE void LL_RTC_TIME_EnableDayLightStore ( RTC_TypeDef *  RTCx)

Memorize whether the daylight saving time change has been performed.

Note
Bit is write-protected. LL_RTC_DisableWriteProtection function should be called before. RTC_CR BKP LL_RTC_TIME_EnableDayLightStore
Parameters
RTCxRTC Instance
Return values
None

Definition at line 1552 of file stm32l4xx_ll_rtc.h.

1553 {
1554  SET_BIT(RTCx->CR, RTC_CR_BKP);
1555 }

◆ LL_RTC_TIME_Get()

__STATIC_INLINE uint32_t LL_RTC_TIME_Get ( RTC_TypeDef *  RTCx)

Get time (hour, minute and second) in BCD format.

Note
if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set before reading this bit
Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND are available to get independently each parameter. RTC_TR HT LL_RTC_TIME_Get
RTC_TR HU LL_RTC_TIME_Get
RTC_TR MNT LL_RTC_TIME_Get
RTC_TR MNU LL_RTC_TIME_Get
RTC_TR ST LL_RTC_TIME_Get
RTC_TR SU LL_RTC_TIME_Get
Parameters
RTCxRTC Instance
Return values
Combinationof hours, minutes and seconds (Format: 0x00HHMMSS).

Definition at line 1535 of file stm32l4xx_ll_rtc.h.

1536 {
1537  register uint32_t temp = 0U;
1538 
1539  temp = READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU | RTC_TR_MNT | RTC_TR_MNU | RTC_TR_ST | RTC_TR_SU));
1540  return (uint32_t)((((((temp & RTC_TR_HT) >> RTC_TR_HT_Pos) << 4U) | ((temp & RTC_TR_HU) >> RTC_TR_HU_Pos)) << RTC_OFFSET_HOUR) | \
1541  (((((temp & RTC_TR_MNT) >> RTC_TR_MNT_Pos) << 4U) | ((temp & RTC_TR_MNU) >> RTC_TR_MNU_Pos)) << RTC_OFFSET_MINUTE) | \
1542  ((((temp & RTC_TR_ST) >> RTC_TR_ST_Pos) << 4U) | ((temp & RTC_TR_SU) >> RTC_TR_SU_Pos)));
1543 }

◆ LL_RTC_TIME_GetFormat()

__STATIC_INLINE uint32_t LL_RTC_TIME_GetFormat ( RTC_TypeDef *  RTCx)

Get time format (AM or PM notation)

Note
if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set before reading this bit
Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)). RTC_TR PM LL_RTC_TIME_GetFormat
Parameters
RTCxRTC Instance
Return values
Returnedvalue can be one of the following values:
  • LL_RTC_TIME_FORMAT_AM_OR_24
  • LL_RTC_TIME_FORMAT_PM

Definition at line 1376 of file stm32l4xx_ll_rtc.h.

1377 {
1378  return (uint32_t)(READ_BIT(RTCx->TR, RTC_TR_PM));
1379 }

◆ LL_RTC_TIME_GetHour()

__STATIC_INLINE uint32_t LL_RTC_TIME_GetHour ( RTC_TypeDef *  RTCx)

Get Hours in BCD format.

Note
if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set before reading this bit
Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert hour from BCD to Binary format RTC_TR HT LL_RTC_TIME_GetHour
RTC_TR HU LL_RTC_TIME_GetHour
Parameters
RTCxRTC Instance
Return values
Valuebetween Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23

Definition at line 1411 of file stm32l4xx_ll_rtc.h.

1412 {
1413  return ((READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU))) >> RTC_TR_HU_Pos);
1414 }

◆ LL_RTC_TIME_GetMinute()

__STATIC_INLINE uint32_t LL_RTC_TIME_GetMinute ( RTC_TypeDef *  RTCx)

Get Minutes in BCD format.

Note
if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set before reading this bit
Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert minute from BCD to Binary format RTC_TR MNT LL_RTC_TIME_GetMinute
RTC_TR MNU LL_RTC_TIME_GetMinute
Parameters
RTCxRTC Instance
Return values
Valuebetween Min_Data=0x00 and Max_Data=0x59

Definition at line 1446 of file stm32l4xx_ll_rtc.h.

1447 {
1448  return ((READ_BIT(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU))) >> RTC_TR_MNU_Pos);
1449 }

◆ LL_RTC_TIME_GetSecond()

__STATIC_INLINE uint32_t LL_RTC_TIME_GetSecond ( RTC_TypeDef *  RTCx)

Get Seconds in BCD format.

Note
if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set before reading this bit
Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format RTC_TR ST LL_RTC_TIME_GetSecond
RTC_TR SU LL_RTC_TIME_GetSecond
Parameters
RTCxRTC Instance
Return values
Valuebetween Min_Data=0x00 and Max_Data=0x59

Definition at line 1481 of file stm32l4xx_ll_rtc.h.

1482 {
1483  return ((READ_BIT(RTCx->TR, (RTC_TR_ST | RTC_TR_SU))) >> RTC_TR_SU_Pos);
1484 }

◆ LL_RTC_TIME_GetSubSecond()

__STATIC_INLINE uint32_t LL_RTC_TIME_GetSubSecond ( RTC_TypeDef *  RTCx)

Get Sub second value in the synchronous prescaler counter.

Note
You can use both SubSeconds value and SecondFraction (PREDIV_S through LL_RTC_GetSynchPrescaler function) terms returned to convert Calendar SubSeconds value in second fraction ratio with time unit following generic formula: ==> Seconds fraction ratio * time_unit= [(SecondFraction-SubSeconds)/(SecondFraction+1)] * time_unit This conversion can be performed only if no shift operation is pending (ie. SHFP=0) when PREDIV_S >= SS. RTC_SSR SS LL_RTC_TIME_GetSubSecond
Parameters
RTCxRTC Instance
Return values
Subsecond value (number between 0 and 65535)

Definition at line 1617 of file stm32l4xx_ll_rtc.h.

1618 {
1619  return (uint32_t)(READ_BIT(RTCx->SSR, RTC_SSR_SS));
1620 }

◆ LL_RTC_TIME_IncHour()

__STATIC_INLINE void LL_RTC_TIME_IncHour ( RTC_TypeDef *  RTCx)

Add 1 hour (summer time change)

Note
Bit is write-protected. LL_RTC_DisableWriteProtection function should be called before. RTC_CR ADD1H LL_RTC_TIME_IncHour
Parameters
RTCxRTC Instance
Return values
None

Definition at line 1599 of file stm32l4xx_ll_rtc.h.

1600 {
1601  SET_BIT(RTCx->CR, RTC_CR_ADD1H);
1602 }

◆ LL_RTC_TIME_IsDayLightStoreEnabled()

__STATIC_INLINE uint32_t LL_RTC_TIME_IsDayLightStoreEnabled ( RTC_TypeDef *  RTCx)

Check if RTC Day Light Saving stored operation has been enabled or not RTC_CR BKP LL_RTC_TIME_IsDayLightStoreEnabled.

Parameters
RTCxRTC Instance
Return values
Stateof bit (1 or 0).

Definition at line 1575 of file stm32l4xx_ll_rtc.h.

1576 {
1577  return (READ_BIT(RTCx->CR, RTC_CR_BKP) == (RTC_CR_BKP));
1578 }

◆ LL_RTC_TIME_SetFormat()

__STATIC_INLINE void LL_RTC_TIME_SetFormat ( RTC_TypeDef *  RTCx,
uint32_t  TimeFormat 
)

Set time format (AM/24-hour or PM notation)

Note
Bit is write-protected. LL_RTC_DisableWriteProtection function should be called before.
It can be written in initialization mode only (LL_RTC_EnableInitMode function) RTC_TR PM LL_RTC_TIME_SetFormat
Parameters
RTCxRTC Instance
TimeFormatThis parameter can be one of the following values:
  • LL_RTC_TIME_FORMAT_AM_OR_24
  • LL_RTC_TIME_FORMAT_PM
Return values
None

Definition at line 1359 of file stm32l4xx_ll_rtc.h.

1360 {
1361  MODIFY_REG(RTCx->TR, RTC_TR_PM, TimeFormat);
1362 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)

◆ LL_RTC_TIME_SetHour()

__STATIC_INLINE void LL_RTC_TIME_SetHour ( RTC_TypeDef *  RTCx,
uint32_t  Hours 
)

Set Hours in BCD format.

Note
Bit is write-protected. LL_RTC_DisableWriteProtection function should be called before.
It can be written in initialization mode only (LL_RTC_EnableInitMode function)
helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert hour from binary to BCD format RTC_TR HT LL_RTC_TIME_SetHour
RTC_TR HU LL_RTC_TIME_SetHour
Parameters
RTCxRTC Instance
HoursValue between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
Return values
None

Definition at line 1392 of file stm32l4xx_ll_rtc.h.

1393 {
1394  MODIFY_REG(RTCx->TR, (RTC_TR_HT | RTC_TR_HU),
1395  (((Hours & 0xF0U) << (RTC_TR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos)));
1396 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)

◆ LL_RTC_TIME_SetMinute()

__STATIC_INLINE void LL_RTC_TIME_SetMinute ( RTC_TypeDef *  RTCx,
uint32_t  Minutes 
)

Set Minutes in BCD format.

Note
Bit is write-protected. LL_RTC_DisableWriteProtection function should be called before.
It can be written in initialization mode only (LL_RTC_EnableInitMode function)
helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format RTC_TR MNT LL_RTC_TIME_SetMinute
RTC_TR MNU LL_RTC_TIME_SetMinute
Parameters
RTCxRTC Instance
MinutesValue between Min_Data=0x00 and Max_Data=0x59
Return values
None

Definition at line 1427 of file stm32l4xx_ll_rtc.h.

1428 {
1429  MODIFY_REG(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU),
1430  (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)));
1431 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)

◆ LL_RTC_TIME_SetSecond()

__STATIC_INLINE void LL_RTC_TIME_SetSecond ( RTC_TypeDef *  RTCx,
uint32_t  Seconds 
)

Set Seconds in BCD format.

Note
Bit is write-protected. LL_RTC_DisableWriteProtection function should be called before.
It can be written in initialization mode only (LL_RTC_EnableInitMode function)
helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format RTC_TR ST LL_RTC_TIME_SetSecond
RTC_TR SU LL_RTC_TIME_SetSecond
Parameters
RTCxRTC Instance
SecondsValue between Min_Data=0x00 and Max_Data=0x59
Return values
None

Definition at line 1462 of file stm32l4xx_ll_rtc.h.

1463 {
1464  MODIFY_REG(RTCx->TR, (RTC_TR_ST | RTC_TR_SU),
1465  (((Seconds & 0xF0U) << (RTC_TR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos)));
1466 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)

◆ LL_RTC_TIME_Synchronize()

__STATIC_INLINE void LL_RTC_TIME_Synchronize ( RTC_TypeDef *  RTCx,
uint32_t  ShiftSecond,
uint32_t  Fraction 
)

Synchronize to a remote clock with a high degree of precision.

Note
This operation effectively subtracts from (delays) or advance the clock of a fraction of a second.
Bit is write-protected. LL_RTC_DisableWriteProtection function should be called before.
When REFCKON is set, firmware must not write to Shift control register. RTC_SHIFTR ADD1S LL_RTC_TIME_Synchronize
RTC_SHIFTR SUBFS LL_RTC_TIME_Synchronize
Parameters
RTCxRTC Instance
ShiftSecondThis parameter can be one of the following values:
  • LL_RTC_SHIFT_SECOND_DELAY
  • LL_RTC_SHIFT_SECOND_ADVANCE
FractionNumber of Seconds Fractions (any value from 0 to 0x7FFF)
Return values
None

Definition at line 1636 of file stm32l4xx_ll_rtc.h.

1637 {
1638  WRITE_REG(RTCx->SHIFTR, ShiftSecond | Fraction);
1639 }