RTC Exported Macros

RTC Exported Macros

group RTC_LL_Exported_Macros

Defines

LL_RTC_GET_BCDU ( value ) (((value) & RTC_ICSR_BCDU))

Helper macro to retrieve the value of BCD update.

Parameters :
Return values :

Value – of the BCD update in mixed mode

LL_RTC_GET_BIN ( value ) (((value) & RTC_ICSR_BIN))

Helper macro to retrieve the mode of RTC.

Parameters :
Return values :

Mode – of the RTC can be one of the value:

Common Write and read registers Macros

group RTC_LL_EM_WRITE_READ

Defines

LL_RTC_WRITE_REG ( reg , value ) STM32_WRITE_REG(RTC->reg, (value))

Write a value in RTC register.

Parameters :
  • reg – Register to be written

  • value – Value to be written in the register

LL_RTC_READ_REG ( reg ) STM32_READ_REG(RTC->reg)

Read a value in RTC register.

Parameters :
  • reg – Register to be read

Return values :

Register – value

Convert helper Macros

group RTC_LL_EM_Convert

Defines

LL_RTC_CONVERT_BIN2BCD ( value ) ((uint32_t)((((value) / 10U) << 4U) | ((value) % 10U)))

Helper macro to convert a value from 2 digit decimal format to BCD format.

Parameters :
  • value – Byte to be converted

Return values :

Converted – byte

LL_RTC_CONVERT_BCD2BIN ( value )

((uint32_t)((((uint32_t)((value) & (uint32_t)0xF0U) >> \

(uint32_t)0x4U) * 10U) + ((value) & (uint32_t)0x0FU)))


Helper macro to convert a value from BCD format to 2 digit decimal format.

Parameters :
  • value – BCD value to be converted

Return values :

Converted – byte

Global configuration helper Macros

group RTC_LL_EM_Global

Defines

LL_RTC_GET_ASYNCH_PRESCALER ( value ) (((value) & RTC_PRER_PREDIV_A) >> RTC_PRER_PREDIV_A_Pos)

Helper macro to retrieve the value of the asynchronous prescaler.

Parameters :
Return values :

Value – of the asynchronous prescaler

LL_RTC_GET_SYNCH_PRESCALER ( value ) (((value) & RTC_PRER_PREDIV_S) >> RTC_PRER_PREDIV_S_Pos)

Helper macro to retrieve the value of the synchronous prescaler.

Parameters :
Return values :

Value – of the synchronous prescaler

Calendar helper macros

group RTC_LL_EM_Calendar

Defines

LL_RTC_GET_CALENDAR_HOUR_FORMAT ( value ) (((value) & RTC_CR_FMT))

Helper macro to retrieve the calendar format value.

Parameters :
  • value – CR register value

Return values :

Mode – of the RTC can be one of the value:

LL_RTC_GET_SHADOW_REG_BYPASS ( value ) (((value) & RTC_CR_BYPSHAD))

Helper macro to retrieve the state of the bypass shadow register.

Parameters :
  • value – CR register value

Return values :

Mode – of the RTC can be one of the value:

Date helper Macros

group RTC_LL_EM_Date

Defines

LL_RTC_GET_WEEKDAY ( rtc_date ) (((rtc_date) >> RTC_OFFSET_WEEKDAY ) & 0x000000FFU)

Helper macro to retrieve weekday.

Parameters :
Return values :

Returned – value can be one of the following values:

LL_RTC_GET_YEAR ( rtc_date ) ((rtc_date) & 0x000000FFU)

Helper macro to retrieve Year in BCD format.

Parameters :
Return values :

Year – in BCD format (0x00 … 0x99)

LL_RTC_GET_MONTH ( rtc_date ) (((rtc_date) >> RTC_OFFSET_MONTH ) & 0x000000FFU)

Helper macro to retrieve Month in BCD format.

Parameters :
Return values :

Returned – value can be one of the following values:

LL_RTC_GET_DAY ( rtc_date ) (((rtc_date) >> RTC_OFFSET_DAY ) & 0x000000FFU)

Helper macro to retrieve Day in BCD format.

Parameters :
Return values :

Day – in BCD format (0x01 … 0x31)

Time helper Macros

group RTC_LL_EM_Time

Defines

LL_RTC_GET_HOUR ( rtc_time ) (((rtc_time) >> RTC_OFFSET_HOUR ) & 0x000000FFU)

Helper macro to retrieve hour in BCD format.

Parameters :
Return values :

Hours – in BCD format (0x01…0x12 or between Min_Data=0x00 and Max_Data=0x23)

LL_RTC_GET_MINUTE ( rtc_time ) (((rtc_time) >> RTC_OFFSET_MINUTE ) & 0x000000FFU)

Helper macro to retrieve minute in BCD format.

Parameters :
Return values :

Minutes – in BCD format (0x00…0x59)

LL_RTC_GET_SECOND ( rtc_time ) ((rtc_time) & 0x000000FFU)

Helper macro to retrieve second in BCD format.

Parameters :
Return values :

Seconds – in BCD format (0x00…0x59)

LL_RTC_GET_FORMAT ( rtc_time ) (((rtc_time) >> RTC_OFFSET_FORMAT ) & 0x0000000FU)

Helper macro to retrieve format.

Parameters :
Return values :

Format

Output helper macros

group RTC_LL_EM_Output

Defines

LL_RTC_GET_OUTPUT_POLARITY ( value ) (((value) & RTC_CR_TAMPALRM_TYPE) >> RTC_CR_TAMPALRM_TYPE_Pos)

Helper macro to retrieve the output polarity from the CR register.

Parameters :
  • value – CR register value

Return values :

Returned – value can be one of the following values:

LL_RTC_GET_OUTPUT_TYPE ( value ) (((value) & RTC_CR_TAMPALRM_TYPE) >> RTC_CR_TAMPALRM_TYPE_Pos)

Helper macro to retrieve the output type from the CR register.

Parameters :
  • value – CR register value

Return values :

Returned – value can be one of the following values:

LL_RTC_GET_OUTPUT_PULLUP ( value ) (((value) & RTC_CR_POL) >> RTC_CR_POL_Pos)

Helper macro to retrieve the output pull-up status from the CR register.

Parameters :
  • value – CR register value

Return values :

Returned – value can be one of the following values:

alarm helper macros

group RTC_LL_EM_Alarm_Time

Defines

LL_RTC_GET_ALARM_HOUR ( rtc_alarm_time_date )

(((rtc_alarm_time_date) & \

(RTC_ALRMAR_HU_Msk | RTC_ALRMAR_HT_Msk)) >> RTC_ALRMAR_HU_Pos)


Helper macro to retrieve alarm hour in BCD format.

Parameters :
  • rtc_alarm_time_date – Alarm time and date returned

Return values :

Hours – in BCD format (0x01…0x12 or between Min_Data=0x00 and Max_Data=0x23)

LL_RTC_GET_ALARM_MINUTE ( rtc_alarm_time_date )

(((rtc_alarm_time_date) & \

(RTC_ALRMAR_MNU_Msk | RTC_ALRMAR_MNT_Msk)) >>\

RTC_ALRMAR_MNU_Pos )


Helper macro to retrieve alarm minute in BCD format.

Parameters :
  • rtc_alarm_time_date – Alarm time and date returned

Return values :

Minutes – in BCD format (0x00…0x59)

LL_RTC_GET_ALARM_SECOND ( rtc_alarm_time_date )

(((rtc_alarm_time_date) & \

(RTC_ALRMAR_SU_Msk | RTC_ALRMAR_ST_Msk)) \

>> RTC_ALRMAR_SU_Pos )


Helper macro to retrieve alarm second in BCD format.

Parameters :
  • rtc_alarm_time_date – Alarm time and date returned

Return values :

Seconds – in BCD format (0x00…0x59)

LL_RTC_GET_ALARM_FORMAT ( rtc_alarm_time_date ) (((rtc_alarm_time_date) & (RTC_ALRMAR_PM_Msk)))

Helper macro to retrieve alarm time format.

Parameters :
  • rtc_alarm_time_date – Alarm time and date returned

Return values :

Format

LL_RTC_GET_ALARM_DAY ( rtc_alarm_time_date )

(((rtc_alarm_time_date) & (RTC_ALRMAR_DU_Msk | RTC_ALRMAR_DT_Msk))\

>> RTC_ALRMAR_DU_Pos )


Helper macro to retrieve alarm day in BCD format.

Parameters :
  • rtc_alarm_time_date – Alarm time and date returned

Return values :

Day – in BCD format (0x00…0x31)

LL_RTC_GET_ALARM_DAY_WDAY_SEL ( rtc_alarm_time_date ) (((rtc_alarm_time_date) & (RTC_ALRMAR_WDSEL_Msk)))

Helper macro to retrieve alarm day week day selection in BCD format.

Parameters :
  • rtc_alarm_time_date – Alarm time and date returned

Return values :

Day – weekday selection

LL_RTC_GET_ALARM_MASKS ( rtc_alarm_time_date )

((rtc_alarm_time_date) & (RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | \

RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1))


Helper macro to retrieve alarm mask selection in BCD format.

Parameters :
  • rtc_alarm_time_date – Alarm time and date returned

Return values :

Alarm – mask selection

LL_RTC_ALARM_GET_SS ( rtc_alarm_ss ) ((rtc_alarm_ss) & 0xFFFFU)

Helper macro to retrieve alarm subsecond in BCD format.

Parameters :
  • rtc_alarm_ss – Alarm subseconds mask and value returned

Return values :

Alarm – subseconds

LL_RTC_ALARM_GET_MASK_SS ( rtc_alarm_ss ) (((rtc_alarm_ss)>> RTC_OFFSET_ALR_MASK_SUBS_SECONDS ) & 0xFFU)

Helper macro to retrieve alarm subsecond mask selection in BCD format.

Parameters :
  • rtc_alarm_ss – Alarm subseconds mask and value returned

Return values :

Alarm – subseconds mask selection

LL_RTC_ALARM_A_GET_FLAG ( rtc_flags ) ((((rtc_flags) & RTC_SR_ALRAF) == RTC_SR_ALRAF) ? 1U : 0U)

Helper macro to retrieve the alarm A flag.

Parameters :
  • rtc_flags – Flags retrieved from RTC_SR register

Return values :
  • 0U – when the alarm flag A is unset

  • 1U – when the alarm flag A is set

LL_RTC_ALARM_B_GET_FLAG ( rtc_flags ) ((((rtc_flags) & RTC_SR_ALRBF) == RTC_SR_ALRBF) ? 1U : 0U)

Helper macro to retrieve the alarm B flag.

Parameters :
  • rtc_flags – Flags retrieved from RTC_SR register

Return values :
  • 0U – when the alarm flag B is unset

  • 1U – when the alarm flag B is set

LL_RTC_WAKEUP_GET_FLAG ( rtc_flags ) ((((rtc_flags) & RTC_SR_WUTF) == RTC_SR_WUTF) ? 1U : 0U)

Helper macro to retrieve the wake-up timer flag.

Parameters :
  • rtc_flags – Flags retrieved from RTC_SR

Return values :
  • 0U – when the wake-up timer flag is unset

  • 1U – when the wake-up timer flag is set

LL_RTC_TIMESTAMP_GET_FLAG ( rtc_flags ) ((((rtc_flags) & RTC_SR_TSF) == RTC_SR_TSF) ? 1U : 0U)

Helper macro to retrieve the timestamp flag.

Parameters :
  • rtc_flags – Timestamp flags retrieved from RTC_SR

Return values :
  • 0U – when the timestamp is unset

  • 1U – when the timestamp is set

LL_RTC_SSRU_GET_FLAG ( rtc_flags ) ((((rtc_flags) & RTC_SR_SSRUF) == RTC_SR_SSRUF) ? 1U : 0U)

Helper macro to retrieve the SSR underflow flag.

Parameters :
  • rtc_flags – SSRU flags retrieved from RTC_SR

Return values :
  • 0U – when the SRRU flag is unset

  • 1U – when the SRRU flag is set

Wake-up timer helper macros

group RTC_LL_EM_Wakeup_Time

Defines

LL_RTC_GET_WAKEUP_AUTORELOAD ( value ) (((value) & RTC_WUTR_WUT) >> RTC_WUTR_WUT_Pos)

Helper macro to retrieve the value of the wake-up auto-reload value.

Parameters :
  • value – WUTR register value

Return values :

Returned – value between 0x0 and 0xFFFF

LL_RTC_GET_WAKEUP_AUTOCLEAR ( value ) (((value) & RTC_WUTR_WUTOCLR) >> RTC_WUTR_WUTOCLR_Pos)

Helper macro to retrieve the value of the auto-clear value.

Parameters :
  • value – WUTR register value

Return values :

Returned – value between 0x0 and 0xFFFF