Subversion Repositories DashDisplay

Rev

Rev 56 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /**
  2.   ******************************************************************************
  3.   * @file    stm32l1xx_ll_rtc.h
  4.   * @author  MCD Application Team
  5.   * @brief   Header file of RTC LL module.
  6.   ******************************************************************************
  7.   * @attention
  8.   *
  9.   * Copyright (c) 2016 STMicroelectronics.
  10.   * All rights reserved.
  11.   *
  12.   * This software is licensed under terms that can be found in the LICENSE file
  13.   * in the root directory of this software component.
  14.   * If no LICENSE file comes with this software, it is provided AS-IS.
  15.   *
  16.   ******************************************************************************
  17.   */
  18.  
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32L1xx_LL_RTC_H
  21. #define STM32L1xx_LL_RTC_H
  22.  
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26.  
  27. /* Includes ------------------------------------------------------------------*/
  28. #include "stm32l1xx.h"
  29.  
  30. /** @addtogroup STM32L1xx_LL_Driver
  31.   * @{
  32.   */
  33.  
  34. #if defined(RTC)
  35.  
  36. /** @defgroup RTC_LL RTC
  37.   * @{
  38.   */
  39.  
  40. /* Private types -------------------------------------------------------------*/
  41. /* Private variables ---------------------------------------------------------*/
  42. /* Private constants ---------------------------------------------------------*/
  43. /** @defgroup RTC_LL_Private_Constants RTC Private Constants
  44.   * @{
  45.   */
  46. /* Masks Definition */
  47. #define RTC_INIT_MASK                 0xFFFFFFFFU
  48. #define RTC_RSF_MASK                  ((uint32_t)~(RTC_ISR_INIT | RTC_ISR_RSF))
  49.  
  50. /* Write protection defines */
  51. #define RTC_WRITE_PROTECTION_DISABLE  ((uint8_t)0xFFU)
  52. #define RTC_WRITE_PROTECTION_ENABLE_1 ((uint8_t)0xCAU)
  53. #define RTC_WRITE_PROTECTION_ENABLE_2 ((uint8_t)0x53U)
  54.  
  55. /* Defines used to combine date & time */
  56. #define RTC_OFFSET_WEEKDAY            24U
  57. #define RTC_OFFSET_DAY                16U
  58. #define RTC_OFFSET_MONTH              8U
  59. #define RTC_OFFSET_HOUR               16U
  60. #define RTC_OFFSET_MINUTE             8U
  61.  
  62. /**
  63.   * @}
  64.   */
  65.  
  66. /* Private macros ------------------------------------------------------------*/
  67. #if defined(USE_FULL_LL_DRIVER)
  68. /** @defgroup RTC_LL_Private_Macros RTC Private Macros
  69.   * @{
  70.   */
  71. /**
  72.   * @}
  73.   */
  74. #endif /*USE_FULL_LL_DRIVER*/
  75.  
  76. /* Exported types ------------------------------------------------------------*/
  77. #if defined(USE_FULL_LL_DRIVER)
  78. /** @defgroup RTC_LL_ES_INIT RTC Exported Init structure
  79.   * @{
  80.   */
  81.  
  82. /**
  83.   * @brief  RTC Init structures definition
  84.   */
  85. typedef struct
  86. {
  87.   uint32_t HourFormat;   /*!< Specifies the RTC Hours Format.
  88.                               This parameter can be a value of @ref RTC_LL_EC_HOURFORMAT
  89.  
  90.                               This feature can be modified afterwards using unitary function
  91.                               @ref LL_RTC_SetHourFormat(). */
  92.  
  93.   uint32_t AsynchPrescaler; /*!< Specifies the RTC Asynchronous Predivider value.
  94.                               This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F
  95.  
  96.                               This feature can be modified afterwards using unitary function
  97.                               @ref LL_RTC_SetAsynchPrescaler(). */
  98.  
  99.   uint32_t SynchPrescaler;  /*!< Specifies the RTC Synchronous Predivider value.
  100.                               This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF
  101.  
  102.                               This feature can be modified afterwards using unitary function
  103.                               @ref LL_RTC_SetSynchPrescaler(). */
  104. } LL_RTC_InitTypeDef;
  105.  
  106. /**
  107.   * @brief  RTC Time structure definition
  108.   */
  109. typedef struct
  110. {
  111.   uint32_t TimeFormat; /*!< Specifies the RTC AM/PM Time.
  112.                             This parameter can be a value of @ref RTC_LL_EC_TIME_FORMAT
  113.  
  114.                             This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetFormat(). */
  115.  
  116.   uint8_t Hours;       /*!< Specifies the RTC Time Hours.
  117.                             This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the @ref LL_RTC_TIME_FORMAT_PM is selected.
  118.                             This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the @ref LL_RTC_TIME_FORMAT_AM_OR_24 is selected.
  119.  
  120.                             This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetHour(). */
  121.  
  122.   uint8_t Minutes;     /*!< Specifies the RTC Time Minutes.
  123.                             This parameter must be a number between Min_Data = 0 and Max_Data = 59
  124.  
  125.                             This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetMinute(). */
  126.  
  127.   uint8_t Seconds;     /*!< Specifies the RTC Time Seconds.
  128.                             This parameter must be a number between Min_Data = 0 and Max_Data = 59
  129.  
  130.                             This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetSecond(). */
  131. } LL_RTC_TimeTypeDef;
  132.  
  133. /**
  134.   * @brief  RTC Date structure definition
  135.   */
  136. typedef struct
  137. {
  138.   uint8_t WeekDay;  /*!< Specifies the RTC Date WeekDay.
  139.                          This parameter can be a value of @ref RTC_LL_EC_WEEKDAY
  140.  
  141.                          This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetWeekDay(). */
  142.  
  143.   uint8_t Month;    /*!< Specifies the RTC Date Month.
  144.                          This parameter can be a value of @ref RTC_LL_EC_MONTH
  145.  
  146.                          This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetMonth(). */
  147.  
  148.   uint8_t Day;      /*!< Specifies the RTC Date Day.
  149.                          This parameter must be a number between Min_Data = 1 and Max_Data = 31
  150.  
  151.                          This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetDay(). */
  152.  
  153.   uint8_t Year;     /*!< Specifies the RTC Date Year.
  154.                          This parameter must be a number between Min_Data = 0 and Max_Data = 99
  155.  
  156.                          This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetYear(). */
  157. } LL_RTC_DateTypeDef;
  158.  
  159. /**
  160.   * @brief  RTC Alarm structure definition
  161.   */
  162. typedef struct
  163. {
  164.   LL_RTC_TimeTypeDef AlarmTime;  /*!< Specifies the RTC Alarm Time members. */
  165.  
  166.   uint32_t AlarmMask;            /*!< Specifies the RTC Alarm Masks.
  167.                                       This parameter can be a value of @ref RTC_LL_EC_ALMA_MASK for ALARM A or @ref RTC_LL_EC_ALMB_MASK for ALARM B.
  168.  
  169.                                       This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetMask() for ALARM A
  170.                                       or @ref LL_RTC_ALMB_SetMask() for ALARM B.
  171.                                  */
  172.  
  173.   uint32_t AlarmDateWeekDaySel;  /*!< Specifies the RTC Alarm is on day or WeekDay.
  174.                                       This parameter can be a value of @ref RTC_LL_EC_ALMA_WEEKDAY_SELECTION for ALARM A or @ref RTC_LL_EC_ALMB_WEEKDAY_SELECTION for ALARM B
  175.  
  176.                                       This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_EnableWeekday() or @ref LL_RTC_ALMA_DisableWeekday()
  177.                                       for ALARM A or @ref LL_RTC_ALMB_EnableWeekday() or @ref LL_RTC_ALMB_DisableWeekday() for ALARM B
  178.                                  */
  179.  
  180.   uint8_t AlarmDateWeekDay;      /*!< Specifies the RTC Alarm Day/WeekDay.
  181.                                       If AlarmDateWeekDaySel set to day, this parameter  must be a number between Min_Data = 1 and Max_Data = 31.
  182.  
  183.                                       This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetDay()
  184.                                       for ALARM A or @ref LL_RTC_ALMB_SetDay() for ALARM B.
  185.  
  186.                                       If AlarmDateWeekDaySel set to Weekday, this parameter can be a value of @ref RTC_LL_EC_WEEKDAY.
  187.  
  188.                                       This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetWeekDay()
  189.                                       for ALARM A or @ref LL_RTC_ALMB_SetWeekDay() for ALARM B.
  190.                                  */
  191. } LL_RTC_AlarmTypeDef;
  192.  
  193. /**
  194.   * @}
  195.   */
  196. #endif /* USE_FULL_LL_DRIVER */
  197.  
  198. /* Exported constants --------------------------------------------------------*/
  199. /** @defgroup RTC_LL_Exported_Constants RTC Exported Constants
  200.   * @{
  201.   */
  202.  
  203. #if defined(USE_FULL_LL_DRIVER)
  204. /** @defgroup RTC_LL_EC_FORMAT FORMAT
  205.   * @{
  206.   */
  207. #define LL_RTC_FORMAT_BIN                  0x00000000U /*!< Binary data format */
  208. #define LL_RTC_FORMAT_BCD                  0x00000001U /*!< BCD data format */
  209. /**
  210.   * @}
  211.   */
  212.  
  213. /** @defgroup RTC_LL_EC_ALMA_WEEKDAY_SELECTION RTC Alarm A Date WeekDay
  214.   * @{
  215.   */
  216. #define LL_RTC_ALMA_DATEWEEKDAYSEL_DATE    0x00000000U             /*!< Alarm A Date is selected */
  217. #define LL_RTC_ALMA_DATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL        /*!< Alarm A WeekDay is selected */
  218. /**
  219.   * @}
  220.   */
  221.  
  222. /** @defgroup RTC_LL_EC_ALMB_WEEKDAY_SELECTION RTC Alarm B Date WeekDay
  223.   * @{
  224.   */
  225. #define LL_RTC_ALMB_DATEWEEKDAYSEL_DATE    0x00000000U             /*!< Alarm B Date is selected */
  226. #define LL_RTC_ALMB_DATEWEEKDAYSEL_WEEKDAY RTC_ALRMBR_WDSEL        /*!< Alarm B WeekDay is selected */
  227. /**
  228.   * @}
  229.   */
  230.  
  231. #endif /* USE_FULL_LL_DRIVER */
  232.  
  233. /** @defgroup RTC_LL_EC_GET_FLAG Get Flags Defines
  234.   * @brief    Flags defines which can be used with LL_RTC_ReadReg function
  235.   * @{
  236.   */
  237. #if defined(RTC_SMOOTHCALIB_SUPPORT)
  238. #define LL_RTC_ISR_RECALPF                 RTC_ISR_RECALPF
  239. #endif /* RTC_SMOOTHCALIB_SUPPORT */
  240. #if defined(RTC_TAMPER3_SUPPORT)
  241. #define LL_RTC_ISR_TAMP3F                  RTC_ISR_TAMP3F
  242. #endif /* RTC_TAMPER3_SUPPORT */
  243. #if defined(RTC_TAMPER2_SUPPORT)
  244. #define LL_RTC_ISR_TAMP2F                  RTC_ISR_TAMP2F
  245. #endif /* RTC_TAMPER2_SUPPORT */
  246. #define LL_RTC_ISR_TAMP1F                  RTC_ISR_TAMP1F
  247. #define LL_RTC_ISR_TSOVF                   RTC_ISR_TSOVF
  248. #define LL_RTC_ISR_TSF                     RTC_ISR_TSF
  249. #define LL_RTC_ISR_WUTF                    RTC_ISR_WUTF
  250. #define LL_RTC_ISR_ALRBF                   RTC_ISR_ALRBF
  251. #define LL_RTC_ISR_ALRAF                   RTC_ISR_ALRAF
  252. #define LL_RTC_ISR_INITF                   RTC_ISR_INITF
  253. #define LL_RTC_ISR_RSF                     RTC_ISR_RSF
  254. #define LL_RTC_ISR_INITS                   RTC_ISR_INITS
  255. #define LL_RTC_ISR_SHPF                    RTC_ISR_SHPF
  256. #define LL_RTC_ISR_WUTWF                   RTC_ISR_WUTWF
  257. #define LL_RTC_ISR_ALRBWF                  RTC_ISR_ALRBWF
  258. #define LL_RTC_ISR_ALRAWF                  RTC_ISR_ALRAWF
  259. /**
  260.   * @}
  261.   */
  262.  
  263. /** @defgroup RTC_LL_EC_IT IT Defines
  264.   * @brief    IT defines which can be used with LL_RTC_ReadReg and  LL_RTC_WriteReg functions
  265.   * @{
  266.   */
  267. #define LL_RTC_CR_TSIE                     RTC_CR_TSIE
  268. #define LL_RTC_CR_WUTIE                    RTC_CR_WUTIE
  269. #define LL_RTC_CR_ALRBIE                   RTC_CR_ALRBIE
  270. #define LL_RTC_CR_ALRAIE                   RTC_CR_ALRAIE
  271. #define LL_RTC_TAFCR_TAMPIE               RTC_TAFCR_TAMPIE
  272. /**
  273.   * @}
  274.   */
  275.  
  276. /** @defgroup RTC_LL_EC_WEEKDAY  WEEK DAY
  277.   * @{
  278.   */
  279. #define LL_RTC_WEEKDAY_MONDAY              ((uint8_t)0x01U) /*!< Monday    */
  280. #define LL_RTC_WEEKDAY_TUESDAY             ((uint8_t)0x02U) /*!< Tuesday   */
  281. #define LL_RTC_WEEKDAY_WEDNESDAY           ((uint8_t)0x03U) /*!< Wednesday */
  282. #define LL_RTC_WEEKDAY_THURSDAY            ((uint8_t)0x04U) /*!< Thrusday  */
  283. #define LL_RTC_WEEKDAY_FRIDAY              ((uint8_t)0x05U) /*!< Friday    */
  284. #define LL_RTC_WEEKDAY_SATURDAY            ((uint8_t)0x06U) /*!< Saturday  */
  285. #define LL_RTC_WEEKDAY_SUNDAY              ((uint8_t)0x07U) /*!< Sunday    */
  286. /**
  287.   * @}
  288.   */
  289.  
  290. /** @defgroup RTC_LL_EC_MONTH  MONTH
  291.   * @{
  292.   */
  293. #define LL_RTC_MONTH_JANUARY               ((uint8_t)0x01U)  /*!< January   */
  294. #define LL_RTC_MONTH_FEBRUARY              ((uint8_t)0x02U)  /*!< February  */
  295. #define LL_RTC_MONTH_MARCH                 ((uint8_t)0x03U)  /*!< March     */
  296. #define LL_RTC_MONTH_APRIL                 ((uint8_t)0x04U)  /*!< April     */
  297. #define LL_RTC_MONTH_MAY                   ((uint8_t)0x05U)  /*!< May       */
  298. #define LL_RTC_MONTH_JUNE                  ((uint8_t)0x06U)  /*!< June      */
  299. #define LL_RTC_MONTH_JULY                  ((uint8_t)0x07U)  /*!< July      */
  300. #define LL_RTC_MONTH_AUGUST                ((uint8_t)0x08U)  /*!< August    */
  301. #define LL_RTC_MONTH_SEPTEMBER             ((uint8_t)0x09U)  /*!< September */
  302. #define LL_RTC_MONTH_OCTOBER               ((uint8_t)0x10U)  /*!< October   */
  303. #define LL_RTC_MONTH_NOVEMBER              ((uint8_t)0x11U)  /*!< November  */
  304. #define LL_RTC_MONTH_DECEMBER              ((uint8_t)0x12U)  /*!< December  */
  305. /**
  306.   * @}
  307.   */
  308.  
  309. /** @defgroup RTC_LL_EC_HOURFORMAT  HOUR FORMAT
  310.   * @{
  311.   */
  312. #define LL_RTC_HOURFORMAT_24HOUR           0x00000000U           /*!< 24 hour/day format */
  313. #define LL_RTC_HOURFORMAT_AMPM             RTC_CR_FMT            /*!< AM/PM hour format */
  314. /**
  315.   * @}
  316.   */
  317.  
  318. /** @defgroup RTC_LL_EC_ALARMOUT  ALARM OUTPUT
  319.   * @{
  320.   */
  321. #define LL_RTC_ALARMOUT_DISABLE            0x00000000U             /*!< Output disabled */
  322. #define LL_RTC_ALARMOUT_ALMA               RTC_CR_OSEL_0           /*!< Alarm A output enabled */
  323. #define LL_RTC_ALARMOUT_ALMB               RTC_CR_OSEL_1           /*!< Alarm B output enabled */
  324. #define LL_RTC_ALARMOUT_WAKEUP             RTC_CR_OSEL             /*!< Wakeup output enabled */
  325. /**
  326.   * @}
  327.   */
  328.  
  329. /** @defgroup RTC_LL_EC_ALARM_OUTPUTTYPE  ALARM OUTPUT TYPE
  330.   * @{
  331.   */
  332. #define LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN  0x00000000U                          /*!< RTC_ALARM, when mapped on PC13, is open-drain output */
  333. #define LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL   RTC_TAFCR_ALARMOUTTYPE /*!< RTC_ALARM, when mapped on PC13, is push-pull output */
  334. /**
  335.   * @}
  336.   */
  337.  
  338. /** @defgroup RTC_LL_EC_OUTPUTPOLARITY_PIN  OUTPUT POLARITY PIN
  339.   * @{
  340.   */
  341. #define LL_RTC_OUTPUTPOLARITY_PIN_HIGH     0x00000000U           /*!< Pin is high when ALRAF/ALRBF/WUTF is asserted (depending on OSEL)*/
  342. #define LL_RTC_OUTPUTPOLARITY_PIN_LOW      RTC_CR_POL            /*!< Pin is low when ALRAF/ALRBF/WUTF is asserted (depending on OSEL) */
  343. /**
  344.   * @}
  345.   */
  346.  
  347. /** @defgroup RTC_LL_EC_TIME_FORMAT TIME FORMAT
  348.   * @{
  349.   */
  350. #define LL_RTC_TIME_FORMAT_AM_OR_24        0x00000000U           /*!< AM or 24-hour format */
  351. #define LL_RTC_TIME_FORMAT_PM              RTC_TR_PM             /*!< PM */
  352. /**
  353.   * @}
  354.   */
  355.  
  356. #if defined(RTC_SUBSECOND_SUPPORT)
  357. /** @defgroup RTC_LL_EC_SHIFT_SECOND  SHIFT SECOND
  358.   * @{
  359.   */
  360. #define LL_RTC_SHIFT_SECOND_DELAY          0x00000000U           /* Delay (seconds) = SUBFS / (PREDIV_S + 1) */
  361. #define LL_RTC_SHIFT_SECOND_ADVANCE        RTC_SHIFTR_ADD1S      /* Advance (seconds) = (1 - (SUBFS / (PREDIV_S + 1))) */
  362. /**
  363.   * @}
  364.   */
  365. #endif /* RTC_SUBSECOND_SUPPORT */
  366.  
  367. /** @defgroup RTC_LL_EC_ALMA_MASK  ALARMA MASK
  368.   * @{
  369.   */
  370. #define LL_RTC_ALMA_MASK_NONE              0x00000000U             /*!< No masks applied on Alarm A*/
  371. #define LL_RTC_ALMA_MASK_DATEWEEKDAY       RTC_ALRMAR_MSK4         /*!< Date/day do not care in Alarm A comparison */
  372. #define LL_RTC_ALMA_MASK_HOURS             RTC_ALRMAR_MSK3         /*!< Hours do not care in Alarm A comparison */
  373. #define LL_RTC_ALMA_MASK_MINUTES           RTC_ALRMAR_MSK2         /*!< Minutes do not care in Alarm A comparison */
  374. #define LL_RTC_ALMA_MASK_SECONDS           RTC_ALRMAR_MSK1         /*!< Seconds do not care in Alarm A comparison */
  375. #define LL_RTC_ALMA_MASK_ALL               (RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1) /*!< Masks all */
  376. /**
  377.   * @}
  378.   */
  379.  
  380. /** @defgroup RTC_LL_EC_ALMA_TIME_FORMAT  ALARMA TIME FORMAT
  381.   * @{
  382.   */
  383. #define LL_RTC_ALMA_TIME_FORMAT_AM         0x00000000U           /*!< AM or 24-hour format */
  384. #define LL_RTC_ALMA_TIME_FORMAT_PM         RTC_ALRMAR_PM         /*!< PM */
  385. /**
  386.   * @}
  387.   */
  388.  
  389. /** @defgroup RTC_LL_EC_ALMB_MASK  ALARMB MASK
  390.   * @{
  391.   */
  392. #define LL_RTC_ALMB_MASK_NONE              0x00000000U             /*!< No masks applied on Alarm B                */
  393. #define LL_RTC_ALMB_MASK_DATEWEEKDAY       RTC_ALRMBR_MSK4         /*!< Date/day do not care in Alarm B comparison */
  394. #define LL_RTC_ALMB_MASK_HOURS             RTC_ALRMBR_MSK3         /*!< Hours do not care in Alarm B comparison    */
  395. #define LL_RTC_ALMB_MASK_MINUTES           RTC_ALRMBR_MSK2         /*!< Minutes do not care in Alarm B comparison  */
  396. #define LL_RTC_ALMB_MASK_SECONDS           RTC_ALRMBR_MSK1         /*!< Seconds do not care in Alarm B comparison  */
  397. #define LL_RTC_ALMB_MASK_ALL               (RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1) /*!< Masks all */
  398. /**
  399.   * @}
  400.   */
  401.  
  402. /** @defgroup RTC_LL_EC_ALMB_TIME_FORMAT  ALARMB TIME FORMAT
  403.   * @{
  404.   */
  405. #define LL_RTC_ALMB_TIME_FORMAT_AM         0x00000000U           /*!< AM or 24-hour format */
  406. #define LL_RTC_ALMB_TIME_FORMAT_PM         RTC_ALRMBR_PM         /*!< PM */
  407. /**
  408.   * @}
  409.   */
  410.  
  411. /** @defgroup RTC_LL_EC_TIMESTAMP_EDGE  TIMESTAMP EDGE
  412.   * @{
  413.   */
  414. #define LL_RTC_TIMESTAMP_EDGE_RISING       0x00000000U           /*!< RTC_TS input rising edge generates a time-stamp event */
  415. #define LL_RTC_TIMESTAMP_EDGE_FALLING      RTC_CR_TSEDGE         /*!< RTC_TS input falling edge generates a time-stamp even */
  416. /**
  417.   * @}
  418.   */
  419.  
  420. /** @defgroup RTC_LL_EC_TS_TIME_FORMAT  TIMESTAMP TIME FORMAT
  421.   * @{
  422.   */
  423. #define LL_RTC_TS_TIME_FORMAT_AM           0x00000000U           /*!< AM or 24-hour format */
  424. #define LL_RTC_TS_TIME_FORMAT_PM           RTC_TSTR_PM           /*!< PM */
  425. /**
  426.   * @}
  427.   */
  428.  
  429. /** @defgroup RTC_LL_EC_TAMPER  TAMPER
  430.   * @{
  431.   */
  432. #define LL_RTC_TAMPER_1                    RTC_TAFCR_TAMP1E /*!< RTC_TAMP1 input detection */
  433. #if defined(RTC_TAMPER2_SUPPORT)
  434. #define LL_RTC_TAMPER_2                    RTC_TAFCR_TAMP2E /*!< RTC_TAMP2 input detection */
  435. #endif /* RTC_TAMPER2_SUPPORT */
  436. #if defined(RTC_TAMPER3_SUPPORT)
  437. #define LL_RTC_TAMPER_3                    RTC_TAFCR_TAMP3E /*!< RTC_TAMP3 input detection */
  438. #endif /* RTC_TAMPER3_SUPPORT */
  439. /**
  440.   * @}
  441.   */
  442.  
  443. #if defined(RTC_TAFCR_TAMPFLT)
  444. /** @defgroup RTC_LL_EC_TAMPER_DURATION  TAMPER DURATION
  445.   * @{
  446.   */
  447. #define LL_RTC_TAMPER_DURATION_1RTCCLK     0x00000000U                             /*!< Tamper pins are pre-charged before sampling during 1 RTCCLK cycle  */
  448. #define LL_RTC_TAMPER_DURATION_2RTCCLK     RTC_TAFCR_TAMPPRCH_0  /*!< Tamper pins are pre-charged before sampling during 2 RTCCLK cycles */
  449. #define LL_RTC_TAMPER_DURATION_4RTCCLK     RTC_TAFCR_TAMPPRCH_1  /*!< Tamper pins are pre-charged before sampling during 4 RTCCLK cycles */
  450. #define LL_RTC_TAMPER_DURATION_8RTCCLK     RTC_TAFCR_TAMPPRCH    /*!< Tamper pins are pre-charged before sampling during 8 RTCCLK cycles */
  451. /**
  452.   * @}
  453.   */
  454.  
  455. /** @defgroup RTC_LL_EC_TAMPER_FILTER  TAMPER FILTER
  456.   * @{
  457.   */
  458. #define LL_RTC_TAMPER_FILTER_DISABLE       0x00000000U                              /*!< Tamper filter is disabled */
  459. #define LL_RTC_TAMPER_FILTER_2SAMPLE       RTC_TAFCR_TAMPFLT_0    /*!< Tamper is activated after 2 consecutive samples at the active level */
  460. #define LL_RTC_TAMPER_FILTER_4SAMPLE       RTC_TAFCR_TAMPFLT_1    /*!< Tamper is activated after 4 consecutive samples at the active level */
  461. #define LL_RTC_TAMPER_FILTER_8SAMPLE       RTC_TAFCR_TAMPFLT      /*!< Tamper is activated after 8 consecutive samples at the active level. */
  462. /**
  463.   * @}
  464.   */
  465.  
  466. /** @defgroup RTC_LL_EC_TAMPER_SAMPLFREQDIV  TAMPER SAMPLING FREQUENCY DIVIDER
  467.   * @{
  468.   */
  469. #define LL_RTC_TAMPER_SAMPLFREQDIV_32768   0x00000000U                                                      /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 32768 */
  470. #define LL_RTC_TAMPER_SAMPLFREQDIV_16384   RTC_TAFCR_TAMPFREQ_0                           /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 16384 */
  471. #define LL_RTC_TAMPER_SAMPLFREQDIV_8192    RTC_TAFCR_TAMPFREQ_1                           /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 8192 */
  472. #define LL_RTC_TAMPER_SAMPLFREQDIV_4096    (RTC_TAFCR_TAMPFREQ_1 | RTC_TAFCR_TAMPFREQ_0) /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 4096 */
  473. #define LL_RTC_TAMPER_SAMPLFREQDIV_2048    RTC_TAFCR_TAMPFREQ_2                           /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 2048 */
  474. #define LL_RTC_TAMPER_SAMPLFREQDIV_1024    (RTC_TAFCR_TAMPFREQ_2 | RTC_TAFCR_TAMPFREQ_0) /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 1024 */
  475. #define LL_RTC_TAMPER_SAMPLFREQDIV_512     (RTC_TAFCR_TAMPFREQ_2 | RTC_TAFCR_TAMPFREQ_1) /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 512 */
  476. #define LL_RTC_TAMPER_SAMPLFREQDIV_256     RTC_TAFCR_TAMPFREQ                             /*!< Each of the tamper inputs are sampled with a frequency =  RTCCLK / 256 */
  477. /**
  478.   * @}
  479.   */
  480. #endif /* RTC_TAFCR_TAMPFLT */
  481.  
  482. /** @defgroup RTC_LL_EC_TAMPER_ACTIVELEVEL  TAMPER ACTIVE LEVEL
  483.   * @{
  484.   */
  485. #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP1    RTC_TAFCR_TAMP1TRG /*!< RTC_TAMP1 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
  486. #if defined(RTC_TAMPER2_SUPPORT)
  487. #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP2    RTC_TAFCR_TAMP2TRG /*!< RTC_TAMP2 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
  488. #endif /* RTC_TAMPER2_SUPPORT */
  489. #if defined(RTC_TAMPER3_SUPPORT)
  490. #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP3    RTC_TAFCR_TAMP3TRG /*!< RTC_TAMP3 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
  491. #endif /* RTC_TAMPER3_SUPPORT */
  492. /**
  493.   * @}
  494.   */
  495.  
  496. /** @defgroup RTC_LL_EC_WAKEUPCLOCK_DIV  WAKEUP CLOCK DIV
  497.   * @{
  498.   */
  499. #define LL_RTC_WAKEUPCLOCK_DIV_16          0x00000000U                           /*!< RTC/16 clock is selected */
  500. #define LL_RTC_WAKEUPCLOCK_DIV_8           (RTC_CR_WUCKSEL_0)                    /*!< RTC/8 clock is selected */
  501. #define LL_RTC_WAKEUPCLOCK_DIV_4           (RTC_CR_WUCKSEL_1)                    /*!< RTC/4 clock is selected */
  502. #define LL_RTC_WAKEUPCLOCK_DIV_2           (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_0) /*!< RTC/2 clock is selected */
  503. #define LL_RTC_WAKEUPCLOCK_CKSPRE          (RTC_CR_WUCKSEL_2)                    /*!< ck_spre (usually 1 Hz) clock is selected */
  504. #define LL_RTC_WAKEUPCLOCK_CKSPRE_WUT      (RTC_CR_WUCKSEL_2 | RTC_CR_WUCKSEL_1) /*!< ck_spre (usually 1 Hz) clock is selected and 2exp16 is added to the WUT counter value*/
  505. /**
  506.   * @}
  507.   */
  508.  
  509. /** @defgroup RTC_LL_EC_BKP  BACKUP
  510.   * @{
  511.   */
  512. #define LL_RTC_BKP_DR0                     0x00000000U
  513. #define LL_RTC_BKP_DR1                     0x00000001U
  514. #define LL_RTC_BKP_DR2                     0x00000002U
  515. #define LL_RTC_BKP_DR3                     0x00000003U
  516. #define LL_RTC_BKP_DR4                     0x00000004U
  517. #if RTC_BKP_NUMBER > 5U
  518. #define LL_RTC_BKP_DR5                     0x00000005U
  519. #define LL_RTC_BKP_DR6                     0x00000006U
  520. #define LL_RTC_BKP_DR7                     0x00000007U
  521. #define LL_RTC_BKP_DR8                     0x00000008U
  522. #define LL_RTC_BKP_DR9                     0x00000009U
  523. #define LL_RTC_BKP_DR10                    0x0000000AU
  524. #define LL_RTC_BKP_DR11                    0x0000000BU
  525. #define LL_RTC_BKP_DR12                    0x0000000CU
  526. #define LL_RTC_BKP_DR13                    0x0000000DU
  527. #define LL_RTC_BKP_DR14                    0x0000000EU
  528. #define LL_RTC_BKP_DR15                    0x0000000FU
  529. #if RTC_BKP_NUMBER > 16U
  530. #define LL_RTC_BKP_DR16                    0x00000010U
  531. #define LL_RTC_BKP_DR17                    0x00000011U
  532. #define LL_RTC_BKP_DR18                    0x00000012U
  533. #define LL_RTC_BKP_DR19                    0x00000013U
  534. #if RTC_BKP_NUMBER > 20U
  535. #define LL_RTC_BKP_DR20                    0x00000014U
  536. #define LL_RTC_BKP_DR21                    0x00000015U
  537. #define LL_RTC_BKP_DR22                    0x00000016U
  538. #define LL_RTC_BKP_DR23                    0x00000017U
  539. #define LL_RTC_BKP_DR24                    0x00000018U
  540. #define LL_RTC_BKP_DR25                    0x00000019U
  541. #define LL_RTC_BKP_DR26                    0x0000001AU
  542. #define LL_RTC_BKP_DR27                    0x0000001BU
  543. #define LL_RTC_BKP_DR28                    0x0000001CU
  544. #define LL_RTC_BKP_DR29                    0x0000001DU
  545. #define LL_RTC_BKP_DR30                    0x0000001EU
  546. #define LL_RTC_BKP_DR31                    0x0000001FU
  547. #endif /* RTC_BKP_NUMBER > 20U */
  548. #endif /* RTC_BKP_NUMBER > 16U */
  549. #endif /* RTC_BKP_NUMBER >  5U */
  550. /**
  551.   * @}
  552.   */
  553.  
  554. /** @defgroup RTC_LL_EC_CALIB_OUTPUT  Calibration output
  555.   * @{
  556.   */
  557. #define LL_RTC_CALIB_OUTPUT_NONE           0x00000000U                 /*!< Calibration output disabled */
  558. #if defined(RTC_CR_COSEL)
  559. #define LL_RTC_CALIB_OUTPUT_1HZ            (RTC_CR_COE | RTC_CR_COSEL) /*!< Calibration output is 1 Hz */
  560. #endif /* RTC_CR_COSEL */
  561. #define LL_RTC_CALIB_OUTPUT_512HZ          (RTC_CR_COE)                /*!< Calibration output is 512 Hz */
  562. /**
  563.   * @}
  564.   */
  565.  
  566. /** @defgroup RTC_LL_EC_CALIB_SIGN Coarse digital calibration sign
  567.   * @{
  568.   */
  569. #define LL_RTC_CALIB_SIGN_POSITIVE         0x00000000U           /*!< Positive calibration: calendar update frequency is increased */
  570. #define LL_RTC_CALIB_SIGN_NEGATIVE         RTC_CALIBR_DCS        /*!< Negative calibration: calendar update frequency is decreased */
  571. /**
  572.   * @}
  573.   */
  574.  
  575. /** @defgroup RTC_LL_EC_CALIB_INSERTPULSE  Calibration pulse insertion
  576.   * @{
  577.   */
  578. #define LL_RTC_CALIB_INSERTPULSE_NONE      0x00000000U           /*!< No RTCCLK pulses are added */
  579. #define LL_RTC_CALIB_INSERTPULSE_SET       RTC_CALR_CALP         /*!< One RTCCLK pulse is effectively inserted every 2exp11 pulses (frequency increased by 488.5 ppm) */
  580. /**
  581.   * @}
  582.   */
  583.  
  584. /** @defgroup RTC_LL_EC_CALIB_PERIOD  Calibration period
  585.   * @{
  586.   */
  587. #define LL_RTC_CALIB_PERIOD_32SEC          0x00000000U           /*!< Use a 32-second calibration cycle period */
  588. #define LL_RTC_CALIB_PERIOD_16SEC          RTC_CALR_CALW16       /*!< Use a 16-second calibration cycle period */
  589. #define LL_RTC_CALIB_PERIOD_8SEC           RTC_CALR_CALW8        /*!< Use a 8-second calibration cycle period */
  590. /**
  591.   * @}
  592.   */
  593.  
  594. /**
  595.   * @}
  596.   */
  597.  
  598. /* Exported macro ------------------------------------------------------------*/
  599. /** @defgroup RTC_LL_Exported_Macros RTC Exported Macros
  600.   * @{
  601.   */
  602.  
  603. /** @defgroup RTC_LL_EM_WRITE_READ Common Write and read registers Macros
  604.   * @{
  605.   */
  606.  
  607. /**
  608.   * @brief  Write a value in RTC register
  609.   * @param  __INSTANCE__ RTC Instance
  610.   * @param  __REG__ Register to be written
  611.   * @param  __VALUE__ Value to be written in the register
  612.   * @retval None
  613.   */
  614. #define LL_RTC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  615.  
  616. /**
  617.   * @brief  Read a value in RTC register
  618.   * @param  __INSTANCE__ RTC Instance
  619.   * @param  __REG__ Register to be read
  620.   * @retval Register value
  621.   */
  622. #define LL_RTC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  623. /**
  624.   * @}
  625.   */
  626.  
  627. /** @defgroup RTC_LL_EM_Convert Convert helper Macros
  628.   * @{
  629.   */
  630.  
  631. /**
  632.   * @brief  Helper macro to convert a value from 2 digit decimal format to BCD format
  633.   * @param  __VALUE__ Byte to be converted
  634.   * @retval Converted byte
  635.   */
  636. #define __LL_RTC_CONVERT_BIN2BCD(__VALUE__) (uint8_t)((((__VALUE__) / 10U) << 4U) | ((__VALUE__) % 10U))
  637.  
  638. /**
  639.   * @brief  Helper macro to convert a value from BCD format to 2 digit decimal format
  640.   * @param  __VALUE__ BCD value to be converted
  641.   * @retval Converted byte
  642.   */
  643. #define __LL_RTC_CONVERT_BCD2BIN(__VALUE__) (uint8_t)(((uint8_t)((__VALUE__) & (uint8_t)0xF0U) >> (uint8_t)0x4U) * 10U + ((__VALUE__) & (uint8_t)0x0FU))
  644.  
  645. /**
  646.   * @}
  647.   */
  648.  
  649. /** @defgroup RTC_LL_EM_Date Date helper Macros
  650.   * @{
  651.   */
  652.  
  653. /**
  654.   * @brief  Helper macro to retrieve weekday.
  655.   * @param  __RTC_DATE__ Date returned by @ref  LL_RTC_DATE_Get function.
  656.   * @retval Returned value can be one of the following values:
  657.   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
  658.   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
  659.   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  660.   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
  661.   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
  662.   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
  663.   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
  664.   */
  665. #define __LL_RTC_GET_WEEKDAY(__RTC_DATE__) (((__RTC_DATE__) >> RTC_OFFSET_WEEKDAY) & 0x000000FFU)
  666.  
  667. /**
  668.   * @brief  Helper macro to retrieve Year in BCD format
  669.   * @param  __RTC_DATE__ Value returned by @ref  LL_RTC_DATE_Get
  670.   * @retval Year in BCD format (0x00 . . . 0x99)
  671.   */
  672. #define __LL_RTC_GET_YEAR(__RTC_DATE__) ((__RTC_DATE__) & 0x000000FFU)
  673.  
  674. /**
  675.   * @brief  Helper macro to retrieve Month in BCD format
  676.   * @param  __RTC_DATE__ Value returned by @ref  LL_RTC_DATE_Get
  677.   * @retval Returned value can be one of the following values:
  678.   *         @arg @ref LL_RTC_MONTH_JANUARY
  679.   *         @arg @ref LL_RTC_MONTH_FEBRUARY
  680.   *         @arg @ref LL_RTC_MONTH_MARCH
  681.   *         @arg @ref LL_RTC_MONTH_APRIL
  682.   *         @arg @ref LL_RTC_MONTH_MAY
  683.   *         @arg @ref LL_RTC_MONTH_JUNE
  684.   *         @arg @ref LL_RTC_MONTH_JULY
  685.   *         @arg @ref LL_RTC_MONTH_AUGUST
  686.   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
  687.   *         @arg @ref LL_RTC_MONTH_OCTOBER
  688.   *         @arg @ref LL_RTC_MONTH_NOVEMBER
  689.   *         @arg @ref LL_RTC_MONTH_DECEMBER
  690.   */
  691. #define __LL_RTC_GET_MONTH(__RTC_DATE__) (((__RTC_DATE__) >>RTC_OFFSET_MONTH) & 0x000000FFU)
  692.  
  693. /**
  694.   * @brief  Helper macro to retrieve Day in BCD format
  695.   * @param  __RTC_DATE__ Value returned by @ref  LL_RTC_DATE_Get
  696.   * @retval Day in BCD format (0x01 . . . 0x31)
  697.   */
  698. #define __LL_RTC_GET_DAY(__RTC_DATE__) (((__RTC_DATE__) >>RTC_OFFSET_DAY) & 0x000000FFU)
  699.  
  700. /**
  701.   * @}
  702.   */
  703.  
  704. /** @defgroup RTC_LL_EM_Time Time helper Macros
  705.   * @{
  706.   */
  707.  
  708. /**
  709.   * @brief  Helper macro to retrieve hour in BCD format
  710.   * @param  __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
  711.   * @retval Hours in BCD format (0x01. . .0x12 or between Min_Data=0x00 and Max_Data=0x23)
  712.   */
  713. #define __LL_RTC_GET_HOUR(__RTC_TIME__) (((__RTC_TIME__) >> RTC_OFFSET_HOUR) & 0x000000FFU)
  714.  
  715. /**
  716.   * @brief  Helper macro to retrieve minute in BCD format
  717.   * @param  __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
  718.   * @retval Minutes in BCD format (0x00. . .0x59)
  719.   */
  720. #define __LL_RTC_GET_MINUTE(__RTC_TIME__) (((__RTC_TIME__) >> RTC_OFFSET_MINUTE) & 0x000000FFU)
  721.  
  722. /**
  723.   * @brief  Helper macro to retrieve second in BCD format
  724.   * @param  __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
  725.   * @retval Seconds in  format (0x00. . .0x59)
  726.   */
  727. #define __LL_RTC_GET_SECOND(__RTC_TIME__) ((__RTC_TIME__) & 0x000000FFU)
  728.  
  729. /**
  730.   * @}
  731.   */
  732.  
  733. /**
  734.   * @}
  735.   */
  736.  
  737. /* Exported functions --------------------------------------------------------*/
  738. /** @defgroup RTC_LL_Exported_Functions RTC Exported Functions
  739.   * @{
  740.   */
  741.  
  742. /** @defgroup RTC_LL_EF_Configuration Configuration
  743.   * @{
  744.   */
  745.  
  746. /**
  747.   * @brief  Set Hours format (24 hour/day or AM/PM hour format)
  748.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  749.   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  750.   * @rmtoll CR           FMT           LL_RTC_SetHourFormat
  751.   * @param  RTCx RTC Instance
  752.   * @param  HourFormat This parameter can be one of the following values:
  753.   *         @arg @ref LL_RTC_HOURFORMAT_24HOUR
  754.   *         @arg @ref LL_RTC_HOURFORMAT_AMPM
  755.   * @retval None
  756.   */
  757. __STATIC_INLINE void LL_RTC_SetHourFormat(RTC_TypeDef *RTCx, uint32_t HourFormat)
  758. {
  759.   MODIFY_REG(RTCx->CR, RTC_CR_FMT, HourFormat);
  760. }
  761.  
  762. /**
  763.   * @brief  Get Hours format (24 hour/day or AM/PM hour format)
  764.   * @rmtoll CR           FMT           LL_RTC_GetHourFormat
  765.   * @param  RTCx RTC Instance
  766.   * @retval Returned value can be one of the following values:
  767.   *         @arg @ref LL_RTC_HOURFORMAT_24HOUR
  768.   *         @arg @ref LL_RTC_HOURFORMAT_AMPM
  769.   */
  770. __STATIC_INLINE uint32_t LL_RTC_GetHourFormat(RTC_TypeDef *RTCx)
  771. {
  772.   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_FMT));
  773. }
  774.  
  775. /**
  776.   * @brief  Select the flag to be routed to RTC_ALARM output
  777.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  778.   * @rmtoll CR           OSEL          LL_RTC_SetAlarmOutEvent
  779.   * @param  RTCx RTC Instance
  780.   * @param  AlarmOutput This parameter can be one of the following values:
  781.   *         @arg @ref LL_RTC_ALARMOUT_DISABLE
  782.   *         @arg @ref LL_RTC_ALARMOUT_ALMA
  783.   *         @arg @ref LL_RTC_ALARMOUT_ALMB
  784.   *         @arg @ref LL_RTC_ALARMOUT_WAKEUP
  785.   * @retval None
  786.   */
  787. __STATIC_INLINE void LL_RTC_SetAlarmOutEvent(RTC_TypeDef *RTCx, uint32_t AlarmOutput)
  788. {
  789.   MODIFY_REG(RTCx->CR, RTC_CR_OSEL, AlarmOutput);
  790. }
  791.  
  792. /**
  793.   * @brief  Get the flag to be routed to RTC_ALARM output
  794.   * @rmtoll CR           OSEL          LL_RTC_GetAlarmOutEvent
  795.   * @param  RTCx RTC Instance
  796.   * @retval Returned value can be one of the following values:
  797.   *         @arg @ref LL_RTC_ALARMOUT_DISABLE
  798.   *         @arg @ref LL_RTC_ALARMOUT_ALMA
  799.   *         @arg @ref LL_RTC_ALARMOUT_ALMB
  800.   *         @arg @ref LL_RTC_ALARMOUT_WAKEUP
  801.   */
  802. __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutEvent(RTC_TypeDef *RTCx)
  803. {
  804.   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_OSEL));
  805. }
  806.  
  807. /**
  808.   * @brief  Set RTC_ALARM output type (ALARM in push-pull or open-drain output)
  809.   * @note   Used only when RTC_ALARM is mapped on PC13
  810.   * @rmtoll TAFCR        ALARMOUTTYPE  LL_RTC_SetAlarmOutputType
  811.   * @param  RTCx RTC Instance
  812.   * @param  Output This parameter can be one of the following values:
  813.   *         @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
  814.   *         @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
  815.   * @retval None
  816.   */
  817. __STATIC_INLINE void LL_RTC_SetAlarmOutputType(RTC_TypeDef *RTCx, uint32_t Output)
  818. {
  819.   MODIFY_REG(RTCx->TAFCR, RTC_TAFCR_ALARMOUTTYPE, Output);
  820. }
  821.  
  822. /**
  823.   * @brief  Get RTC_ALARM output type (ALARM in push-pull or open-drain output)
  824.   * @note   used only when RTC_ALARM is mapped on PC13
  825.   * @rmtoll TAFCR        ALARMOUTTYPE  LL_RTC_GetAlarmOutputType
  826.   * @param  RTCx RTC Instance
  827.   * @retval Returned value can be one of the following values:
  828.   *         @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
  829.   *         @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
  830.   */
  831. __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutputType(RTC_TypeDef *RTCx)
  832. {
  833.   return (uint32_t)(READ_BIT(RTCx->TAFCR, RTC_TAFCR_ALARMOUTTYPE));
  834. }
  835.  
  836. /**
  837.   * @brief  Enable initialization mode
  838.   * @note   Initialization mode is used to program time and date register (RTC_TR and RTC_DR)
  839.   *         and prescaler register (RTC_PRER).
  840.   *         Counters are stopped and start counting from the new value when INIT is reset.
  841.   * @rmtoll ISR          INIT          LL_RTC_EnableInitMode
  842.   * @param  RTCx RTC Instance
  843.   * @retval None
  844.   */
  845. __STATIC_INLINE void LL_RTC_EnableInitMode(RTC_TypeDef *RTCx)
  846. {
  847.   /* Set the Initialization mode */
  848.   WRITE_REG(RTCx->ISR, RTC_INIT_MASK);
  849. }
  850.  
  851. /**
  852.   * @brief  Disable initialization mode (Free running mode)
  853.   * @rmtoll ISR          INIT          LL_RTC_DisableInitMode
  854.   * @param  RTCx RTC Instance
  855.   * @retval None
  856.   */
  857. __STATIC_INLINE void LL_RTC_DisableInitMode(RTC_TypeDef *RTCx)
  858. {
  859.   /* Exit Initialization mode */
  860.   WRITE_REG(RTCx->ISR, (uint32_t)~RTC_ISR_INIT);
  861. }
  862.  
  863. /**
  864.   * @brief  Set Output polarity (pin is low when ALRAF/ALRBF/WUTF is asserted)
  865.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  866.   * @rmtoll CR           POL           LL_RTC_SetOutputPolarity
  867.   * @param  RTCx RTC Instance
  868.   * @param  Polarity This parameter can be one of the following values:
  869.   *         @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_HIGH
  870.   *         @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_LOW
  871.   * @retval None
  872.   */
  873. __STATIC_INLINE void LL_RTC_SetOutputPolarity(RTC_TypeDef *RTCx, uint32_t Polarity)
  874. {
  875.   MODIFY_REG(RTCx->CR, RTC_CR_POL, Polarity);
  876. }
  877.  
  878. /**
  879.   * @brief  Get Output polarity
  880.   * @rmtoll CR           POL           LL_RTC_GetOutputPolarity
  881.   * @param  RTCx RTC Instance
  882.   * @retval Returned value can be one of the following values:
  883.   *         @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_HIGH
  884.   *         @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_LOW
  885.   */
  886. __STATIC_INLINE uint32_t LL_RTC_GetOutputPolarity(RTC_TypeDef *RTCx)
  887. {
  888.   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_POL));
  889. }
  890.  
  891. #if defined(RTC_CR_BYPSHAD)
  892. /**
  893.   * @brief  Enable Bypass the shadow registers
  894.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  895.   * @rmtoll CR           BYPSHAD       LL_RTC_EnableShadowRegBypass
  896.   * @param  RTCx RTC Instance
  897.   * @retval None
  898.   */
  899. __STATIC_INLINE void LL_RTC_EnableShadowRegBypass(RTC_TypeDef *RTCx)
  900. {
  901.   SET_BIT(RTCx->CR, RTC_CR_BYPSHAD);
  902. }
  903.  
  904. /**
  905.   * @brief  Disable Bypass the shadow registers
  906.   * @rmtoll CR           BYPSHAD       LL_RTC_DisableShadowRegBypass
  907.   * @param  RTCx RTC Instance
  908.   * @retval None
  909.   */
  910. __STATIC_INLINE void LL_RTC_DisableShadowRegBypass(RTC_TypeDef *RTCx)
  911. {
  912.   CLEAR_BIT(RTCx->CR, RTC_CR_BYPSHAD);
  913. }
  914.  
  915. /**
  916.   * @brief  Check if Shadow registers bypass is enabled or not.
  917.   * @rmtoll CR           BYPSHAD       LL_RTC_IsShadowRegBypassEnabled
  918.   * @param  RTCx RTC Instance
  919.   * @retval State of bit (1 or 0).
  920.   */
  921. __STATIC_INLINE uint32_t LL_RTC_IsShadowRegBypassEnabled(RTC_TypeDef *RTCx)
  922. {
  923.   return ((READ_BIT(RTCx->CR, RTC_CR_BYPSHAD) == (RTC_CR_BYPSHAD)) ? 1UL : 0UL);
  924. }
  925. #endif /* RTC_CR_BYPSHAD */
  926.  
  927. /**
  928.   * @brief  Enable RTC_REFIN reference clock detection (50 or 60 Hz)
  929.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  930.   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  931.   * @rmtoll CR           REFCKON       LL_RTC_EnableRefClock
  932.   * @param  RTCx RTC Instance
  933.   * @retval None
  934.   */
  935. __STATIC_INLINE void LL_RTC_EnableRefClock(RTC_TypeDef *RTCx)
  936. {
  937.   SET_BIT(RTCx->CR, RTC_CR_REFCKON);
  938. }
  939.  
  940. /**
  941.   * @brief  Disable RTC_REFIN reference clock detection (50 or 60 Hz)
  942.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  943.   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  944.   * @rmtoll CR           REFCKON       LL_RTC_DisableRefClock
  945.   * @param  RTCx RTC Instance
  946.   * @retval None
  947.   */
  948. __STATIC_INLINE void LL_RTC_DisableRefClock(RTC_TypeDef *RTCx)
  949. {
  950.   CLEAR_BIT(RTCx->CR, RTC_CR_REFCKON);
  951. }
  952.  
  953. /**
  954.   * @brief  Set Asynchronous prescaler factor
  955.   * @rmtoll PRER         PREDIV_A      LL_RTC_SetAsynchPrescaler
  956.   * @param  RTCx RTC Instance
  957.   * @param  AsynchPrescaler Value between Min_Data = 0 and Max_Data = 0x7F
  958.   * @retval None
  959.   */
  960. __STATIC_INLINE void LL_RTC_SetAsynchPrescaler(RTC_TypeDef *RTCx, uint32_t AsynchPrescaler)
  961. {
  962.   MODIFY_REG(RTCx->PRER, RTC_PRER_PREDIV_A, AsynchPrescaler << RTC_PRER_PREDIV_A_Pos);
  963. }
  964.  
  965. /**
  966.   * @brief  Set Synchronous prescaler factor
  967.   * @rmtoll PRER         PREDIV_S      LL_RTC_SetSynchPrescaler
  968.   * @param  RTCx RTC Instance
  969.   * @param  SynchPrescaler Value between Min_Data = 0 and Max_Data = 0x7FFF
  970.   * @retval None
  971.   */
  972. __STATIC_INLINE void LL_RTC_SetSynchPrescaler(RTC_TypeDef *RTCx, uint32_t SynchPrescaler)
  973. {
  974.   MODIFY_REG(RTCx->PRER, RTC_PRER_PREDIV_S, SynchPrescaler);
  975. }
  976.  
  977. /**
  978.   * @brief  Get Asynchronous prescaler factor
  979.   * @rmtoll PRER         PREDIV_A      LL_RTC_GetAsynchPrescaler
  980.   * @param  RTCx RTC Instance
  981.   * @retval Value between Min_Data = 0 and Max_Data = 0x7F
  982.   */
  983. __STATIC_INLINE uint32_t LL_RTC_GetAsynchPrescaler(RTC_TypeDef *RTCx)
  984. {
  985.   return (uint32_t)(READ_BIT(RTCx->PRER, RTC_PRER_PREDIV_A) >> RTC_PRER_PREDIV_A_Pos);
  986. }
  987.  
  988. /**
  989.   * @brief  Get Synchronous prescaler factor
  990.   * @rmtoll PRER         PREDIV_S      LL_RTC_GetSynchPrescaler
  991.   * @param  RTCx RTC Instance
  992.   * @retval Value between Min_Data = 0 and Max_Data = 0x7FFF
  993.   */
  994. __STATIC_INLINE uint32_t LL_RTC_GetSynchPrescaler(RTC_TypeDef *RTCx)
  995. {
  996.   return (uint32_t)(READ_BIT(RTCx->PRER, RTC_PRER_PREDIV_S));
  997. }
  998.  
  999. /**
  1000.   * @brief  Enable the write protection for RTC registers.
  1001.   * @rmtoll WPR          KEY           LL_RTC_EnableWriteProtection
  1002.   * @param  RTCx RTC Instance
  1003.   * @retval None
  1004.   */
  1005. __STATIC_INLINE void LL_RTC_EnableWriteProtection(RTC_TypeDef *RTCx)
  1006. {
  1007.   WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_DISABLE);
  1008. }
  1009.  
  1010. /**
  1011.   * @brief  Disable the write protection for RTC registers.
  1012.   * @rmtoll WPR          KEY           LL_RTC_DisableWriteProtection
  1013.   * @param  RTCx RTC Instance
  1014.   * @retval None
  1015.   */
  1016. __STATIC_INLINE void LL_RTC_DisableWriteProtection(RTC_TypeDef *RTCx)
  1017. {
  1018.   WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_ENABLE_1);
  1019.   WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_ENABLE_2);
  1020. }
  1021.  
  1022. /**
  1023.   * @}
  1024.   */
  1025.  
  1026. /** @defgroup RTC_LL_EF_Time Time
  1027.   * @{
  1028.   */
  1029.  
  1030. /**
  1031.   * @brief  Set time format (AM/24-hour or PM notation)
  1032.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1033.   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1034.   * @rmtoll TR           PM            LL_RTC_TIME_SetFormat
  1035.   * @param  RTCx RTC Instance
  1036.   * @param  TimeFormat This parameter can be one of the following values:
  1037.   *         @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
  1038.   *         @arg @ref LL_RTC_TIME_FORMAT_PM
  1039.   * @retval None
  1040.   */
  1041. __STATIC_INLINE void LL_RTC_TIME_SetFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
  1042. {
  1043.   MODIFY_REG(RTCx->TR, RTC_TR_PM, TimeFormat);
  1044. }
  1045.  
  1046. /**
  1047.   * @brief  Get time format (AM or PM notation)
  1048.   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1049.   *       before reading this bit
  1050.   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  1051.   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  1052.   * @rmtoll TR           PM            LL_RTC_TIME_GetFormat
  1053.   * @param  RTCx RTC Instance
  1054.   * @retval Returned value can be one of the following values:
  1055.   *         @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
  1056.   *         @arg @ref LL_RTC_TIME_FORMAT_PM
  1057.   */
  1058. __STATIC_INLINE uint32_t LL_RTC_TIME_GetFormat(RTC_TypeDef *RTCx)
  1059. {
  1060.   return (uint32_t)(READ_BIT(RTCx->TR, RTC_TR_PM));
  1061. }
  1062.  
  1063. /**
  1064.   * @brief  Set Hours in BCD format
  1065.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1066.   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1067.   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert hour from binary to BCD format
  1068.   * @rmtoll TR           HT            LL_RTC_TIME_SetHour\n
  1069.   *         TR           HU            LL_RTC_TIME_SetHour
  1070.   * @param  RTCx RTC Instance
  1071.   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1072.   * @retval None
  1073.   */
  1074. __STATIC_INLINE void LL_RTC_TIME_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
  1075. {
  1076.   MODIFY_REG(RTCx->TR, (RTC_TR_HT | RTC_TR_HU),
  1077.              (((Hours & 0xF0U) << (RTC_TR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos)));
  1078. }
  1079.  
  1080. /**
  1081.   * @brief  Get Hours in BCD format
  1082.   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1083.   *       before reading this bit
  1084.   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  1085.   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  1086.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert hour from BCD to
  1087.   *       Binary format
  1088.   * @rmtoll TR           HT            LL_RTC_TIME_GetHour\n
  1089.   *         TR           HU            LL_RTC_TIME_GetHour
  1090.   * @param  RTCx RTC Instance
  1091.   * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1092.   */
  1093. __STATIC_INLINE uint32_t LL_RTC_TIME_GetHour(RTC_TypeDef *RTCx)
  1094. {
  1095.   return (uint32_t)((READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU))) >> RTC_TR_HU_Pos);
  1096. }
  1097.  
  1098. /**
  1099.   * @brief  Set Minutes in BCD format
  1100.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1101.   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1102.   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
  1103.   * @rmtoll TR           MNT           LL_RTC_TIME_SetMinute\n
  1104.   *         TR           MNU           LL_RTC_TIME_SetMinute
  1105.   * @param  RTCx RTC Instance
  1106.   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
  1107.   * @retval None
  1108.   */
  1109. __STATIC_INLINE void LL_RTC_TIME_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
  1110. {
  1111.   MODIFY_REG(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU),
  1112.              (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)));
  1113. }
  1114.  
  1115. /**
  1116.   * @brief  Get Minutes in BCD format
  1117.   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1118.   *       before reading this bit
  1119.   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  1120.   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  1121.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert minute from BCD
  1122.   *       to Binary format
  1123.   * @rmtoll TR           MNT           LL_RTC_TIME_GetMinute\n
  1124.   *         TR           MNU           LL_RTC_TIME_GetMinute
  1125.   * @param  RTCx RTC Instance
  1126.   * @retval Value between Min_Data=0x00 and Max_Data=0x59
  1127.   */
  1128. __STATIC_INLINE uint32_t LL_RTC_TIME_GetMinute(RTC_TypeDef *RTCx)
  1129. {
  1130.   return (uint32_t)(READ_BIT(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU)) >> RTC_TR_MNU_Pos);
  1131. }
  1132.  
  1133. /**
  1134.   * @brief  Set Seconds in BCD format
  1135.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1136.   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1137.   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
  1138.   * @rmtoll TR           ST            LL_RTC_TIME_SetSecond\n
  1139.   *         TR           SU            LL_RTC_TIME_SetSecond
  1140.   * @param  RTCx RTC Instance
  1141.   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
  1142.   * @retval None
  1143.   */
  1144. __STATIC_INLINE void LL_RTC_TIME_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
  1145. {
  1146.   MODIFY_REG(RTCx->TR, (RTC_TR_ST | RTC_TR_SU),
  1147.              (((Seconds & 0xF0U) << (RTC_TR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos)));
  1148. }
  1149.  
  1150. /**
  1151.   * @brief  Get Seconds in BCD format
  1152.   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1153.   *       before reading this bit
  1154.   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  1155.   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  1156.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD
  1157.   *       to Binary format
  1158.   * @rmtoll TR           ST            LL_RTC_TIME_GetSecond\n
  1159.   *         TR           SU            LL_RTC_TIME_GetSecond
  1160.   * @param  RTCx RTC Instance
  1161.   * @retval Value between Min_Data=0x00 and Max_Data=0x59
  1162.   */
  1163. __STATIC_INLINE uint32_t LL_RTC_TIME_GetSecond(RTC_TypeDef *RTCx)
  1164. {
  1165.   return (uint32_t)(READ_BIT(RTCx->TR, (RTC_TR_ST | RTC_TR_SU)) >> RTC_TR_SU_Pos);
  1166. }
  1167.  
  1168. /**
  1169.   * @brief  Set time (hour, minute and second) in BCD format
  1170.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1171.   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1172.   * @note TimeFormat and Hours should follow the same format
  1173.   * @rmtoll TR           PM            LL_RTC_TIME_Config\n
  1174.   *         TR           HT            LL_RTC_TIME_Config\n
  1175.   *         TR           HU            LL_RTC_TIME_Config\n
  1176.   *         TR           MNT           LL_RTC_TIME_Config\n
  1177.   *         TR           MNU           LL_RTC_TIME_Config\n
  1178.   *         TR           ST            LL_RTC_TIME_Config\n
  1179.   *         TR           SU            LL_RTC_TIME_Config
  1180.   * @param  RTCx RTC Instance
  1181.   * @param  Format12_24 This parameter can be one of the following values:
  1182.   *         @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
  1183.   *         @arg @ref LL_RTC_TIME_FORMAT_PM
  1184.   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1185.   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
  1186.   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
  1187.   * @retval None
  1188.   */
  1189. __STATIC_INLINE void LL_RTC_TIME_Config(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
  1190. {
  1191.   uint32_t temp;
  1192.  
  1193.   temp = Format12_24                                                                            | \
  1194.          (((Hours   & 0xF0U) << (RTC_TR_HT_Pos  - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos))    | \
  1195.          (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)) | \
  1196.          (((Seconds & 0xF0U) << (RTC_TR_ST_Pos  - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos));
  1197.   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);
  1198. }
  1199.  
  1200. /**
  1201.   * @brief  Get time (hour, minute and second) in BCD format
  1202.   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1203.   *       before reading this bit
  1204.   * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  1205.   *       shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  1206.   * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
  1207.   *       are available to get independently each parameter.
  1208.   * @rmtoll TR           HT            LL_RTC_TIME_Get\n
  1209.   *         TR           HU            LL_RTC_TIME_Get\n
  1210.   *         TR           MNT           LL_RTC_TIME_Get\n
  1211.   *         TR           MNU           LL_RTC_TIME_Get\n
  1212.   *         TR           ST            LL_RTC_TIME_Get\n
  1213.   *         TR           SU            LL_RTC_TIME_Get
  1214.   * @param  RTCx RTC Instance
  1215.   * @retval Combination of hours, minutes and seconds (Format: 0x00HHMMSS).
  1216.   */
  1217. __STATIC_INLINE uint32_t LL_RTC_TIME_Get(RTC_TypeDef *RTCx)
  1218. {
  1219.   return (uint32_t)(READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU | RTC_TR_MNT | RTC_TR_MNU | RTC_TR_ST | RTC_TR_SU)));
  1220. }
  1221.  
  1222. /**
  1223.   * @brief  Memorize whether the daylight saving time change has been performed
  1224.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1225.   * @rmtoll CR           BKP           LL_RTC_TIME_EnableDayLightStore
  1226.   * @param  RTCx RTC Instance
  1227.   * @retval None
  1228.   */
  1229. __STATIC_INLINE void LL_RTC_TIME_EnableDayLightStore(RTC_TypeDef *RTCx)
  1230. {
  1231.   SET_BIT(RTCx->CR, RTC_CR_BKP);
  1232. }
  1233.  
  1234. /**
  1235.   * @brief  Disable memorization whether the daylight saving time change has been performed.
  1236.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1237.   * @rmtoll CR           BKP           LL_RTC_TIME_DisableDayLightStore
  1238.   * @param  RTCx RTC Instance
  1239.   * @retval None
  1240.   */
  1241. __STATIC_INLINE void LL_RTC_TIME_DisableDayLightStore(RTC_TypeDef *RTCx)
  1242. {
  1243.   CLEAR_BIT(RTCx->CR, RTC_CR_BKP);
  1244. }
  1245.  
  1246. /**
  1247.   * @brief  Check if RTC Day Light Saving stored operation has been enabled or not
  1248.   * @rmtoll CR           BKP           LL_RTC_TIME_IsDayLightStoreEnabled
  1249.   * @param  RTCx RTC Instance
  1250.   * @retval State of bit (1 or 0).
  1251.   */
  1252. __STATIC_INLINE uint32_t LL_RTC_TIME_IsDayLightStoreEnabled(RTC_TypeDef *RTCx)
  1253. {
  1254.   return ((READ_BIT(RTCx->CR, RTC_CR_BKP) == (RTC_CR_BKP)) ? 1UL : 0UL);
  1255. }
  1256.  
  1257. /**
  1258.   * @brief  Subtract 1 hour (winter time change)
  1259.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1260.   * @rmtoll CR           SUB1H         LL_RTC_TIME_DecHour
  1261.   * @param  RTCx RTC Instance
  1262.   * @retval None
  1263.   */
  1264. __STATIC_INLINE void LL_RTC_TIME_DecHour(RTC_TypeDef *RTCx)
  1265. {
  1266.   SET_BIT(RTCx->CR, RTC_CR_SUB1H);
  1267. }
  1268.  
  1269. /**
  1270.   * @brief  Add 1 hour (summer time change)
  1271.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1272.   * @rmtoll CR           ADD1H         LL_RTC_TIME_IncHour
  1273.   * @param  RTCx RTC Instance
  1274.   * @retval None
  1275.   */
  1276. __STATIC_INLINE void LL_RTC_TIME_IncHour(RTC_TypeDef *RTCx)
  1277. {
  1278.   SET_BIT(RTCx->CR, RTC_CR_ADD1H);
  1279. }
  1280.  
  1281. #if defined(RTC_SUBSECOND_SUPPORT)
  1282. /**
  1283.   * @brief  Get subseconds value in the synchronous prescaler counter.
  1284.   * @note  You can use both SubSeconds value and SecondFraction (PREDIV_S through
  1285.   *        LL_RTC_GetSynchPrescaler function) terms returned to convert Calendar
  1286.   *        SubSeconds value in second fraction ratio with time unit following
  1287.   *        generic formula:
  1288.   *          ==> Seconds fraction ratio * time_unit =
  1289.   *                 [(SecondFraction-SubSeconds)/(SecondFraction+1)] * time_unit
  1290.   *        This conversion can be performed only if no shift operation is pending
  1291.   *        (ie. SHFP=0) when PREDIV_S >= SS.
  1292.   * @rmtoll SSR          SS            LL_RTC_TIME_GetSubSecond
  1293.   * @param  RTCx RTC Instance
  1294.   * @retval Subseconds value (number between 0 and 65535)
  1295.   */
  1296. __STATIC_INLINE uint32_t LL_RTC_TIME_GetSubSecond(RTC_TypeDef *RTCx)
  1297. {
  1298.   return (uint32_t)(READ_BIT(RTCx->SSR, RTC_SSR_SS));
  1299. }
  1300.  
  1301. /**
  1302.   * @brief  Synchronize to a remote clock with a high degree of precision.
  1303.   * @note   This operation effectively subtracts from (delays) or advance the clock of a fraction of a second.
  1304.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1305.   * @note   When REFCKON is set, firmware must not write to Shift control register.
  1306.   * @rmtoll SHIFTR       ADD1S         LL_RTC_TIME_Synchronize\n
  1307.   *         SHIFTR       SUBFS         LL_RTC_TIME_Synchronize
  1308.   * @param  RTCx RTC Instance
  1309.   * @param  ShiftSecond This parameter can be one of the following values:
  1310.   *         @arg @ref LL_RTC_SHIFT_SECOND_DELAY
  1311.   *         @arg @ref LL_RTC_SHIFT_SECOND_ADVANCE
  1312.   * @param  Fraction Number of Seconds Fractions (any value from 0 to 0x7FFF)
  1313.   * @retval None
  1314.   */
  1315. __STATIC_INLINE void LL_RTC_TIME_Synchronize(RTC_TypeDef *RTCx, uint32_t ShiftSecond, uint32_t Fraction)
  1316. {
  1317.   WRITE_REG(RTCx->SHIFTR, ShiftSecond | Fraction);
  1318. }
  1319. #endif /* RTC_SUBSECOND_SUPPORT */
  1320.  
  1321. /**
  1322.   * @}
  1323.   */
  1324.  
  1325. /** @defgroup RTC_LL_EF_Date Date
  1326.   * @{
  1327.   */
  1328.  
  1329. /**
  1330.   * @brief  Set Year in BCD format
  1331.   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Year from binary to BCD format
  1332.   * @rmtoll DR           YT            LL_RTC_DATE_SetYear\n
  1333.   *         DR           YU            LL_RTC_DATE_SetYear
  1334.   * @param  RTCx RTC Instance
  1335.   * @param  Year Value between Min_Data=0x00 and Max_Data=0x99
  1336.   * @retval None
  1337.   */
  1338. __STATIC_INLINE void LL_RTC_DATE_SetYear(RTC_TypeDef *RTCx, uint32_t Year)
  1339. {
  1340.   MODIFY_REG(RTCx->DR, (RTC_DR_YT | RTC_DR_YU),
  1341.              (((Year & 0xF0U) << (RTC_DR_YT_Pos - 4U)) | ((Year & 0x0FU) << RTC_DR_YU_Pos)));
  1342. }
  1343.  
  1344. /**
  1345.   * @brief  Get Year in BCD format
  1346.   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1347.   *       before reading this bit
  1348.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Year from BCD to Binary format
  1349.   * @rmtoll DR           YT            LL_RTC_DATE_GetYear\n
  1350.   *         DR           YU            LL_RTC_DATE_GetYear
  1351.   * @param  RTCx RTC Instance
  1352.   * @retval Value between Min_Data=0x00 and Max_Data=0x99
  1353.   */
  1354. __STATIC_INLINE uint32_t LL_RTC_DATE_GetYear(RTC_TypeDef *RTCx)
  1355. {
  1356.   return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_YT | RTC_DR_YU))) >> RTC_DR_YU_Pos);
  1357. }
  1358.  
  1359. /**
  1360.   * @brief  Set Week day
  1361.   * @rmtoll DR           WDU           LL_RTC_DATE_SetWeekDay
  1362.   * @param  RTCx RTC Instance
  1363.   * @param  WeekDay This parameter can be one of the following values:
  1364.   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
  1365.   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1366.   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1367.   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1368.   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1369.   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1370.   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1371.   * @retval None
  1372.   */
  1373. __STATIC_INLINE void LL_RTC_DATE_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
  1374. {
  1375.   MODIFY_REG(RTCx->DR, RTC_DR_WDU, WeekDay << RTC_DR_WDU_Pos);
  1376. }
  1377.  
  1378. /**
  1379.   * @brief  Get Week day
  1380.   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1381.   *       before reading this bit
  1382.   * @rmtoll DR           WDU           LL_RTC_DATE_GetWeekDay
  1383.   * @param  RTCx RTC Instance
  1384.   * @retval Returned value can be one of the following values:
  1385.   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
  1386.   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1387.   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1388.   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1389.   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1390.   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1391.   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1392.   */
  1393. __STATIC_INLINE uint32_t LL_RTC_DATE_GetWeekDay(RTC_TypeDef *RTCx)
  1394. {
  1395.   return (uint32_t)(READ_BIT(RTCx->DR, RTC_DR_WDU) >> RTC_DR_WDU_Pos);
  1396. }
  1397.  
  1398. /**
  1399.   * @brief  Set Month in BCD format
  1400.   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Month from binary to BCD format
  1401.   * @rmtoll DR           MT            LL_RTC_DATE_SetMonth\n
  1402.   *         DR           MU            LL_RTC_DATE_SetMonth
  1403.   * @param  RTCx RTC Instance
  1404.   * @param  Month This parameter can be one of the following values:
  1405.   *         @arg @ref LL_RTC_MONTH_JANUARY
  1406.   *         @arg @ref LL_RTC_MONTH_FEBRUARY
  1407.   *         @arg @ref LL_RTC_MONTH_MARCH
  1408.   *         @arg @ref LL_RTC_MONTH_APRIL
  1409.   *         @arg @ref LL_RTC_MONTH_MAY
  1410.   *         @arg @ref LL_RTC_MONTH_JUNE
  1411.   *         @arg @ref LL_RTC_MONTH_JULY
  1412.   *         @arg @ref LL_RTC_MONTH_AUGUST
  1413.   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
  1414.   *         @arg @ref LL_RTC_MONTH_OCTOBER
  1415.   *         @arg @ref LL_RTC_MONTH_NOVEMBER
  1416.   *         @arg @ref LL_RTC_MONTH_DECEMBER
  1417.   * @retval None
  1418.   */
  1419. __STATIC_INLINE void LL_RTC_DATE_SetMonth(RTC_TypeDef *RTCx, uint32_t Month)
  1420. {
  1421.   MODIFY_REG(RTCx->DR, (RTC_DR_MT | RTC_DR_MU),
  1422.              (((Month & 0xF0U) << (RTC_DR_MT_Pos - 4U)) | ((Month & 0x0FU) << RTC_DR_MU_Pos)));
  1423. }
  1424.  
  1425. /**
  1426.   * @brief  Get Month in BCD format
  1427.   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1428.   *       before reading this bit
  1429.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Month from BCD to Binary format
  1430.   * @rmtoll DR           MT            LL_RTC_DATE_GetMonth\n
  1431.   *         DR           MU            LL_RTC_DATE_GetMonth
  1432.   * @param  RTCx RTC Instance
  1433.   * @retval Returned value can be one of the following values:
  1434.   *         @arg @ref LL_RTC_MONTH_JANUARY
  1435.   *         @arg @ref LL_RTC_MONTH_FEBRUARY
  1436.   *         @arg @ref LL_RTC_MONTH_MARCH
  1437.   *         @arg @ref LL_RTC_MONTH_APRIL
  1438.   *         @arg @ref LL_RTC_MONTH_MAY
  1439.   *         @arg @ref LL_RTC_MONTH_JUNE
  1440.   *         @arg @ref LL_RTC_MONTH_JULY
  1441.   *         @arg @ref LL_RTC_MONTH_AUGUST
  1442.   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
  1443.   *         @arg @ref LL_RTC_MONTH_OCTOBER
  1444.   *         @arg @ref LL_RTC_MONTH_NOVEMBER
  1445.   *         @arg @ref LL_RTC_MONTH_DECEMBER
  1446.   */
  1447. __STATIC_INLINE uint32_t LL_RTC_DATE_GetMonth(RTC_TypeDef *RTCx)
  1448. {
  1449.   return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_MT | RTC_DR_MU))) >> RTC_DR_MU_Pos);
  1450. }
  1451.  
  1452. /**
  1453.   * @brief  Set Day in BCD format
  1454.   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
  1455.   * @rmtoll DR           DT            LL_RTC_DATE_SetDay\n
  1456.   *         DR           DU            LL_RTC_DATE_SetDay
  1457.   * @param  RTCx RTC Instance
  1458.   * @param  Day Value between Min_Data=0x01 and Max_Data=0x31
  1459.   * @retval None
  1460.   */
  1461. __STATIC_INLINE void LL_RTC_DATE_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
  1462. {
  1463.   MODIFY_REG(RTCx->DR, (RTC_DR_DT | RTC_DR_DU),
  1464.              (((Day & 0xF0U) << (RTC_DR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_DR_DU_Pos)));
  1465. }
  1466.  
  1467. /**
  1468.   * @brief  Get Day in BCD format
  1469.   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1470.   *       before reading this bit
  1471.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
  1472.   * @rmtoll DR           DT            LL_RTC_DATE_GetDay\n
  1473.   *         DR           DU            LL_RTC_DATE_GetDay
  1474.   * @param  RTCx RTC Instance
  1475.   * @retval Value between Min_Data=0x01 and Max_Data=0x31
  1476.   */
  1477. __STATIC_INLINE uint32_t LL_RTC_DATE_GetDay(RTC_TypeDef *RTCx)
  1478. {
  1479.   return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_DT | RTC_DR_DU))) >> RTC_DR_DU_Pos);
  1480. }
  1481.  
  1482. /**
  1483.   * @brief  Set date (WeekDay, Day, Month and Year) in BCD format
  1484.   * @rmtoll DR           WDU           LL_RTC_DATE_Config\n
  1485.   *         DR           MT            LL_RTC_DATE_Config\n
  1486.   *         DR           MU            LL_RTC_DATE_Config\n
  1487.   *         DR           DT            LL_RTC_DATE_Config\n
  1488.   *         DR           DU            LL_RTC_DATE_Config\n
  1489.   *         DR           YT            LL_RTC_DATE_Config\n
  1490.   *         DR           YU            LL_RTC_DATE_Config
  1491.   * @param  RTCx RTC Instance
  1492.   * @param  WeekDay This parameter can be one of the following values:
  1493.   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
  1494.   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1495.   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1496.   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1497.   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1498.   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1499.   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1500.   * @param  Day Value between Min_Data=0x01 and Max_Data=0x31
  1501.   * @param  Month This parameter can be one of the following values:
  1502.   *         @arg @ref LL_RTC_MONTH_JANUARY
  1503.   *         @arg @ref LL_RTC_MONTH_FEBRUARY
  1504.   *         @arg @ref LL_RTC_MONTH_MARCH
  1505.   *         @arg @ref LL_RTC_MONTH_APRIL
  1506.   *         @arg @ref LL_RTC_MONTH_MAY
  1507.   *         @arg @ref LL_RTC_MONTH_JUNE
  1508.   *         @arg @ref LL_RTC_MONTH_JULY
  1509.   *         @arg @ref LL_RTC_MONTH_AUGUST
  1510.   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
  1511.   *         @arg @ref LL_RTC_MONTH_OCTOBER
  1512.   *         @arg @ref LL_RTC_MONTH_NOVEMBER
  1513.   *         @arg @ref LL_RTC_MONTH_DECEMBER
  1514.   * @param  Year Value between Min_Data=0x00 and Max_Data=0x99
  1515.   * @retval None
  1516.   */
  1517. __STATIC_INLINE void LL_RTC_DATE_Config(RTC_TypeDef *RTCx, uint32_t WeekDay, uint32_t Day, uint32_t Month, uint32_t Year)
  1518. {
  1519.   uint32_t temp;
  1520.  
  1521.   temp = (  WeekDay                                                    << RTC_DR_WDU_Pos) | \
  1522.          (((Year  & 0xF0U) << (RTC_DR_YT_Pos - 4U)) | ((Year  & 0x0FU) << RTC_DR_YU_Pos)) | \
  1523.          (((Month & 0xF0U) << (RTC_DR_MT_Pos - 4U)) | ((Month & 0x0FU) << RTC_DR_MU_Pos)) | \
  1524.          (((Day   & 0xF0U) << (RTC_DR_DT_Pos - 4U)) | ((Day   & 0x0FU) << RTC_DR_DU_Pos));
  1525.  
  1526.   MODIFY_REG(RTCx->DR, (RTC_DR_WDU | RTC_DR_MT | RTC_DR_MU | RTC_DR_DT | RTC_DR_DU | RTC_DR_YT | RTC_DR_YU), temp);
  1527. }
  1528.  
  1529. /**
  1530.   * @brief  Get date (WeekDay, Day, Month and Year) in BCD format
  1531.   * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1532.   *       before reading this bit
  1533.   * @note helper macros __LL_RTC_GET_WEEKDAY, __LL_RTC_GET_YEAR, __LL_RTC_GET_MONTH,
  1534.   * and __LL_RTC_GET_DAY are available to get independently each parameter.
  1535.   * @rmtoll DR           WDU           LL_RTC_DATE_Get\n
  1536.   *         DR           MT            LL_RTC_DATE_Get\n
  1537.   *         DR           MU            LL_RTC_DATE_Get\n
  1538.   *         DR           DT            LL_RTC_DATE_Get\n
  1539.   *         DR           DU            LL_RTC_DATE_Get\n
  1540.   *         DR           YT            LL_RTC_DATE_Get\n
  1541.   *         DR           YU            LL_RTC_DATE_Get
  1542.   * @param  RTCx RTC Instance
  1543.   * @retval Combination of WeekDay, Day, Month and Year (Format: 0xWWDDMMYY).
  1544.   */
  1545. __STATIC_INLINE uint32_t LL_RTC_DATE_Get(RTC_TypeDef *RTCx)
  1546. {
  1547.   uint32_t temp;
  1548.  
  1549.   temp = READ_BIT(RTCx->DR, (RTC_DR_WDU | RTC_DR_MT | RTC_DR_MU | RTC_DR_DT | RTC_DR_DU | RTC_DR_YT | RTC_DR_YU));
  1550.  
  1551.   return (uint32_t)((((temp &              RTC_DR_WDU) >> RTC_DR_WDU_Pos) << RTC_OFFSET_WEEKDAY) | \
  1552.                     (((temp & (RTC_DR_DT | RTC_DR_DU)) >> RTC_DR_DU_Pos)  << RTC_OFFSET_DAY)     | \
  1553.                     (((temp & (RTC_DR_MT | RTC_DR_MU)) >> RTC_DR_MU_Pos)  << RTC_OFFSET_MONTH)   | \
  1554.                      ((temp & (RTC_DR_YT | RTC_DR_YU)) >> RTC_DR_YU_Pos));
  1555. }
  1556.  
  1557. /**
  1558.   * @}
  1559.   */
  1560.  
  1561. /** @defgroup RTC_LL_EF_ALARMA ALARMA
  1562.   * @{
  1563.   */
  1564.  
  1565. /**
  1566.   * @brief  Enable Alarm A
  1567.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1568.   * @rmtoll CR           ALRAE         LL_RTC_ALMA_Enable
  1569.   * @param  RTCx RTC Instance
  1570.   * @retval None
  1571.   */
  1572. __STATIC_INLINE void LL_RTC_ALMA_Enable(RTC_TypeDef *RTCx)
  1573. {
  1574.   SET_BIT(RTCx->CR, RTC_CR_ALRAE);
  1575. }
  1576.  
  1577. /**
  1578.   * @brief  Disable Alarm A
  1579.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1580.   * @rmtoll CR           ALRAE         LL_RTC_ALMA_Disable
  1581.   * @param  RTCx RTC Instance
  1582.   * @retval None
  1583.   */
  1584. __STATIC_INLINE void LL_RTC_ALMA_Disable(RTC_TypeDef *RTCx)
  1585. {
  1586.   CLEAR_BIT(RTCx->CR, RTC_CR_ALRAE);
  1587. }
  1588.  
  1589. /**
  1590.   * @brief  Specify the Alarm A masks.
  1591.   * @rmtoll ALRMAR       MSK4          LL_RTC_ALMA_SetMask\n
  1592.   *         ALRMAR       MSK3          LL_RTC_ALMA_SetMask\n
  1593.   *         ALRMAR       MSK2          LL_RTC_ALMA_SetMask\n
  1594.   *         ALRMAR       MSK1          LL_RTC_ALMA_SetMask
  1595.   * @param  RTCx RTC Instance
  1596.   * @param  Mask This parameter can be a combination of the following values:
  1597.   *         @arg @ref LL_RTC_ALMA_MASK_NONE
  1598.   *         @arg @ref LL_RTC_ALMA_MASK_DATEWEEKDAY
  1599.   *         @arg @ref LL_RTC_ALMA_MASK_HOURS
  1600.   *         @arg @ref LL_RTC_ALMA_MASK_MINUTES
  1601.   *         @arg @ref LL_RTC_ALMA_MASK_SECONDS
  1602.   *         @arg @ref LL_RTC_ALMA_MASK_ALL
  1603.   * @retval None
  1604.   */
  1605. __STATIC_INLINE void LL_RTC_ALMA_SetMask(RTC_TypeDef *RTCx, uint32_t Mask)
  1606. {
  1607.   MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1, Mask);
  1608. }
  1609.  
  1610. /**
  1611.   * @brief  Get the Alarm A masks.
  1612.   * @rmtoll ALRMAR       MSK4          LL_RTC_ALMA_GetMask\n
  1613.   *         ALRMAR       MSK3          LL_RTC_ALMA_GetMask\n
  1614.   *         ALRMAR       MSK2          LL_RTC_ALMA_GetMask\n
  1615.   *         ALRMAR       MSK1          LL_RTC_ALMA_GetMask
  1616.   * @param  RTCx RTC Instance
  1617.   * @retval Returned value can be can be a combination of the following values:
  1618.   *         @arg @ref LL_RTC_ALMA_MASK_NONE
  1619.   *         @arg @ref LL_RTC_ALMA_MASK_DATEWEEKDAY
  1620.   *         @arg @ref LL_RTC_ALMA_MASK_HOURS
  1621.   *         @arg @ref LL_RTC_ALMA_MASK_MINUTES
  1622.   *         @arg @ref LL_RTC_ALMA_MASK_SECONDS
  1623.   *         @arg @ref LL_RTC_ALMA_MASK_ALL
  1624.   */
  1625. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetMask(RTC_TypeDef *RTCx)
  1626. {
  1627.   return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1));
  1628. }
  1629.  
  1630. /**
  1631.   * @brief  Enable AlarmA Week day selection (DU[3:0] represents the week day. DT[1:0] is do not care)
  1632.   * @rmtoll ALRMAR       WDSEL         LL_RTC_ALMA_EnableWeekday
  1633.   * @param  RTCx RTC Instance
  1634.   * @retval None
  1635.   */
  1636. __STATIC_INLINE void LL_RTC_ALMA_EnableWeekday(RTC_TypeDef *RTCx)
  1637. {
  1638.   SET_BIT(RTCx->ALRMAR, RTC_ALRMAR_WDSEL);
  1639. }
  1640.  
  1641. /**
  1642.   * @brief  Disable AlarmA Week day selection (DU[3:0] represents the date )
  1643.   * @rmtoll ALRMAR       WDSEL         LL_RTC_ALMA_DisableWeekday
  1644.   * @param  RTCx RTC Instance
  1645.   * @retval None
  1646.   */
  1647. __STATIC_INLINE void LL_RTC_ALMA_DisableWeekday(RTC_TypeDef *RTCx)
  1648. {
  1649.   CLEAR_BIT(RTCx->ALRMAR, RTC_ALRMAR_WDSEL);
  1650. }
  1651.  
  1652. /**
  1653.   * @brief  Set ALARM A Day in BCD format
  1654.   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
  1655.   * @rmtoll ALRMAR       DT            LL_RTC_ALMA_SetDay\n
  1656.   *         ALRMAR       DU            LL_RTC_ALMA_SetDay
  1657.   * @param  RTCx RTC Instance
  1658.   * @param  Day Value between Min_Data=0x01 and Max_Data=0x31
  1659.   * @retval None
  1660.   */
  1661. __STATIC_INLINE void LL_RTC_ALMA_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
  1662. {
  1663.   MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_DT | RTC_ALRMAR_DU),
  1664.              (((Day & 0xF0U) << (RTC_ALRMAR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_ALRMAR_DU_Pos)));
  1665. }
  1666.  
  1667. /**
  1668.   * @brief  Get ALARM A Day in BCD format
  1669.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
  1670.   * @rmtoll ALRMAR       DT            LL_RTC_ALMA_GetDay\n
  1671.   *         ALRMAR       DU            LL_RTC_ALMA_GetDay
  1672.   * @param  RTCx RTC Instance
  1673.   * @retval Value between Min_Data=0x01 and Max_Data=0x31
  1674.   */
  1675. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetDay(RTC_TypeDef *RTCx)
  1676. {
  1677.   return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_DT | RTC_ALRMAR_DU))) >> RTC_ALRMAR_DU_Pos);
  1678. }
  1679.  
  1680. /**
  1681.   * @brief  Set ALARM A Weekday
  1682.   * @rmtoll ALRMAR       DU            LL_RTC_ALMA_SetWeekDay
  1683.   * @param  RTCx RTC Instance
  1684.   * @param  WeekDay This parameter can be one of the following values:
  1685.   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
  1686.   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1687.   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1688.   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1689.   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1690.   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1691.   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1692.   * @retval None
  1693.   */
  1694. __STATIC_INLINE void LL_RTC_ALMA_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
  1695. {
  1696.   MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_DU, WeekDay << RTC_ALRMAR_DU_Pos);
  1697. }
  1698.  
  1699. /**
  1700.   * @brief  Get ALARM A Weekday
  1701.   * @rmtoll ALRMAR       DU            LL_RTC_ALMA_GetWeekDay
  1702.   * @param  RTCx RTC Instance
  1703.   * @retval Returned value can be one of the following values:
  1704.   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
  1705.   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1706.   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1707.   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1708.   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1709.   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1710.   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1711.   */
  1712. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetWeekDay(RTC_TypeDef *RTCx)
  1713. {
  1714.   return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_DU) >> RTC_ALRMAR_DU_Pos);
  1715. }
  1716.  
  1717. /**
  1718.   * @brief  Set Alarm A time format (AM/24-hour or PM notation)
  1719.   * @rmtoll ALRMAR       PM            LL_RTC_ALMA_SetTimeFormat
  1720.   * @param  RTCx RTC Instance
  1721.   * @param  TimeFormat This parameter can be one of the following values:
  1722.   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
  1723.   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
  1724.   * @retval None
  1725.   */
  1726. __STATIC_INLINE void LL_RTC_ALMA_SetTimeFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
  1727. {
  1728.   MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_PM, TimeFormat);
  1729. }
  1730.  
  1731. /**
  1732.   * @brief  Get Alarm A time format (AM or PM notation)
  1733.   * @rmtoll ALRMAR       PM            LL_RTC_ALMA_GetTimeFormat
  1734.   * @param  RTCx RTC Instance
  1735.   * @retval Returned value can be one of the following values:
  1736.   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
  1737.   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
  1738.   */
  1739. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetTimeFormat(RTC_TypeDef *RTCx)
  1740. {
  1741.   return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_PM));
  1742. }
  1743.  
  1744. /**
  1745.   * @brief  Set ALARM A Hours in BCD format
  1746.   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Hours from binary to BCD format
  1747.   * @rmtoll ALRMAR       HT            LL_RTC_ALMA_SetHour\n
  1748.   *         ALRMAR       HU            LL_RTC_ALMA_SetHour
  1749.   * @param  RTCx RTC Instance
  1750.   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1751.   * @retval None
  1752.   */
  1753. __STATIC_INLINE void LL_RTC_ALMA_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
  1754. {
  1755.   MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_HT | RTC_ALRMAR_HU),
  1756.              (((Hours & 0xF0U) << (RTC_ALRMAR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMAR_HU_Pos)));
  1757. }
  1758.  
  1759. /**
  1760.   * @brief  Get ALARM A Hours in BCD format
  1761.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
  1762.   * @rmtoll ALRMAR       HT            LL_RTC_ALMA_GetHour\n
  1763.   *         ALRMAR       HU            LL_RTC_ALMA_GetHour
  1764.   * @param  RTCx RTC Instance
  1765.   * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1766.   */
  1767. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetHour(RTC_TypeDef *RTCx)
  1768. {
  1769.   return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_HT | RTC_ALRMAR_HU))) >> RTC_ALRMAR_HU_Pos);
  1770. }
  1771.  
  1772. /**
  1773.   * @brief  Set ALARM A Minutes in BCD format
  1774.   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
  1775.   * @rmtoll ALRMAR       MNT           LL_RTC_ALMA_SetMinute\n
  1776.   *         ALRMAR       MNU           LL_RTC_ALMA_SetMinute
  1777.   * @param  RTCx RTC Instance
  1778.   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
  1779.   * @retval None
  1780.   */
  1781. __STATIC_INLINE void LL_RTC_ALMA_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
  1782. {
  1783.   MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU),
  1784.              (((Minutes & 0xF0U) << (RTC_ALRMAR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMAR_MNU_Pos)));
  1785. }
  1786.  
  1787. /**
  1788.   * @brief  Get ALARM A Minutes in BCD format
  1789.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
  1790.   * @rmtoll ALRMAR       MNT           LL_RTC_ALMA_GetMinute\n
  1791.   *         ALRMAR       MNU           LL_RTC_ALMA_GetMinute
  1792.   * @param  RTCx RTC Instance
  1793.   * @retval Value between Min_Data=0x00 and Max_Data=0x59
  1794.   */
  1795. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetMinute(RTC_TypeDef *RTCx)
  1796. {
  1797.   return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU))) >> RTC_ALRMAR_MNU_Pos);
  1798. }
  1799.  
  1800. /**
  1801.   * @brief  Set ALARM A Seconds in BCD format
  1802.   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
  1803.   * @rmtoll ALRMAR       ST            LL_RTC_ALMA_SetSecond\n
  1804.   *         ALRMAR       SU            LL_RTC_ALMA_SetSecond
  1805.   * @param  RTCx RTC Instance
  1806.   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
  1807.   * @retval None
  1808.   */
  1809. __STATIC_INLINE void LL_RTC_ALMA_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
  1810. {
  1811.   MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_ST | RTC_ALRMAR_SU),
  1812.              (((Seconds & 0xF0U) << (RTC_ALRMAR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMAR_SU_Pos)));
  1813. }
  1814.  
  1815. /**
  1816.   * @brief  Get ALARM A Seconds in BCD format
  1817.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
  1818.   * @rmtoll ALRMAR       ST            LL_RTC_ALMA_GetSecond\n
  1819.   *         ALRMAR       SU            LL_RTC_ALMA_GetSecond
  1820.   * @param  RTCx RTC Instance
  1821.   * @retval Value between Min_Data=0x00 and Max_Data=0x59
  1822.   */
  1823. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSecond(RTC_TypeDef *RTCx)
  1824. {
  1825.   return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_ST | RTC_ALRMAR_SU))) >> RTC_ALRMAR_SU_Pos);
  1826. }
  1827.  
  1828. /**
  1829.   * @brief  Set Alarm A Time (hour, minute and second) in BCD format
  1830.   * @rmtoll ALRMAR       PM            LL_RTC_ALMA_ConfigTime\n
  1831.   *         ALRMAR       HT            LL_RTC_ALMA_ConfigTime\n
  1832.   *         ALRMAR       HU            LL_RTC_ALMA_ConfigTime\n
  1833.   *         ALRMAR       MNT           LL_RTC_ALMA_ConfigTime\n
  1834.   *         ALRMAR       MNU           LL_RTC_ALMA_ConfigTime\n
  1835.   *         ALRMAR       ST            LL_RTC_ALMA_ConfigTime\n
  1836.   *         ALRMAR       SU            LL_RTC_ALMA_ConfigTime
  1837.   * @param  RTCx RTC Instance
  1838.   * @param  Format12_24 This parameter can be one of the following values:
  1839.   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
  1840.   *         @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
  1841.   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1842.   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
  1843.   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
  1844.   * @retval None
  1845.   */
  1846. __STATIC_INLINE void LL_RTC_ALMA_ConfigTime(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
  1847. {
  1848.   uint32_t temp;
  1849.  
  1850.   temp = Format12_24                                                                                    | \
  1851.          (((Hours   & 0xF0U) << (RTC_ALRMAR_HT_Pos  - 4U)) | ((Hours   & 0x0FU) << RTC_ALRMAR_HU_Pos))  | \
  1852.          (((Minutes & 0xF0U) << (RTC_ALRMAR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMAR_MNU_Pos)) | \
  1853.          (((Seconds & 0xF0U) << (RTC_ALRMAR_ST_Pos  - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMAR_SU_Pos));
  1854.  
  1855.   MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_PM | RTC_ALRMAR_HT | RTC_ALRMAR_HU | RTC_ALRMAR_MNT | RTC_ALRMAR_MNU | RTC_ALRMAR_ST | RTC_ALRMAR_SU, temp);
  1856. }
  1857.  
  1858. /**
  1859.   * @brief  Get Alarm B Time (hour, minute and second) in BCD format
  1860.   * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
  1861.   * are available to get independently each parameter.
  1862.   * @rmtoll ALRMAR       HT            LL_RTC_ALMA_GetTime\n
  1863.   *         ALRMAR       HU            LL_RTC_ALMA_GetTime\n
  1864.   *         ALRMAR       MNT           LL_RTC_ALMA_GetTime\n
  1865.   *         ALRMAR       MNU           LL_RTC_ALMA_GetTime\n
  1866.   *         ALRMAR       ST            LL_RTC_ALMA_GetTime\n
  1867.   *         ALRMAR       SU            LL_RTC_ALMA_GetTime
  1868.   * @param  RTCx RTC Instance
  1869.   * @retval Combination of hours, minutes and seconds.
  1870.   */
  1871. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetTime(RTC_TypeDef *RTCx)
  1872. {
  1873.   return (uint32_t)((LL_RTC_ALMA_GetHour(RTCx) << RTC_OFFSET_HOUR) | (LL_RTC_ALMA_GetMinute(RTCx) << RTC_OFFSET_MINUTE) | LL_RTC_ALMA_GetSecond(RTCx));
  1874. }
  1875.  
  1876. #if defined(RTC_SUBSECOND_SUPPORT)
  1877. /**
  1878.   * @brief  Mask the most-significant bits of the subseconds field starting from
  1879.   *         the bit specified in parameter Mask
  1880.   * @note This register can be written only when ALRAE is reset in RTC_CR register,
  1881.   *       or in initialization mode.
  1882.   * @rmtoll ALRMASSR     MASKSS        LL_RTC_ALMA_SetSubSecondMask
  1883.   * @param  RTCx RTC Instance
  1884.   * @param  Mask Value between Min_Data=0x00 and Max_Data=0xF
  1885.   * @retval None
  1886.   */
  1887. __STATIC_INLINE void LL_RTC_ALMA_SetSubSecondMask(RTC_TypeDef *RTCx, uint32_t Mask)
  1888. {
  1889.   MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_MASKSS, Mask << RTC_ALRMASSR_MASKSS_Pos);
  1890. }
  1891.  
  1892. /**
  1893.   * @brief  Get Alarm A subseconds mask
  1894.   * @rmtoll ALRMASSR     MASKSS        LL_RTC_ALMA_GetSubSecondMask
  1895.   * @param  RTCx RTC Instance
  1896.   * @retval Value between Min_Data=0x00 and Max_Data=0xF
  1897.   */
  1898. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecondMask(RTC_TypeDef *RTCx)
  1899. {
  1900.   return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_MASKSS) >> RTC_ALRMASSR_MASKSS_Pos);
  1901. }
  1902.  
  1903. /**
  1904.   * @brief  Set Alarm A subseconds value
  1905.   * @rmtoll ALRMASSR     SS            LL_RTC_ALMA_SetSubSecond
  1906.   * @param  RTCx RTC Instance
  1907.   * @param  Subsecond Value between Min_Data=0x00 and Max_Data=0x7FFF
  1908.   * @retval None
  1909.   */
  1910. __STATIC_INLINE void LL_RTC_ALMA_SetSubSecond(RTC_TypeDef *RTCx, uint32_t Subsecond)
  1911. {
  1912.   MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_SS, Subsecond);
  1913. }
  1914.  
  1915. /**
  1916.   * @brief  Get Alarm A subseconds value
  1917.   * @rmtoll ALRMASSR     SS            LL_RTC_ALMA_GetSubSecond
  1918.   * @param  RTCx RTC Instance
  1919.   * @retval Value between Min_Data=0x00 and Max_Data=0x7FFF
  1920.   */
  1921. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecond(RTC_TypeDef *RTCx)
  1922. {
  1923.   return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_SS));
  1924. }
  1925. #endif /* RTC_SUBSECOND_SUPPORT */
  1926.  
  1927. /**
  1928.   * @}
  1929.   */
  1930.  
  1931. /** @defgroup RTC_LL_EF_ALARMB ALARMB
  1932.   * @{
  1933.   */
  1934.  
  1935. /**
  1936.   * @brief  Enable Alarm B
  1937.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1938.   * @rmtoll CR           ALRBE         LL_RTC_ALMB_Enable
  1939.   * @param  RTCx RTC Instance
  1940.   * @retval None
  1941.   */
  1942. __STATIC_INLINE void LL_RTC_ALMB_Enable(RTC_TypeDef *RTCx)
  1943. {
  1944.   SET_BIT(RTCx->CR, RTC_CR_ALRBE);
  1945. }
  1946.  
  1947. /**
  1948.   * @brief  Disable Alarm B
  1949.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1950.   * @rmtoll CR           ALRBE         LL_RTC_ALMB_Disable
  1951.   * @param  RTCx RTC Instance
  1952.   * @retval None
  1953.   */
  1954. __STATIC_INLINE void LL_RTC_ALMB_Disable(RTC_TypeDef *RTCx)
  1955. {
  1956.   CLEAR_BIT(RTCx->CR, RTC_CR_ALRBE);
  1957. }
  1958.  
  1959. /**
  1960.   * @brief  Specify the Alarm B masks.
  1961.   * @rmtoll ALRMBR       MSK4          LL_RTC_ALMB_SetMask\n
  1962.   *         ALRMBR       MSK3          LL_RTC_ALMB_SetMask\n
  1963.   *         ALRMBR       MSK2          LL_RTC_ALMB_SetMask\n
  1964.   *         ALRMBR       MSK1          LL_RTC_ALMB_SetMask
  1965.   * @param  RTCx RTC Instance
  1966.   * @param  Mask This parameter can be a combination of the following values:
  1967.   *         @arg @ref LL_RTC_ALMB_MASK_NONE
  1968.   *         @arg @ref LL_RTC_ALMB_MASK_DATEWEEKDAY
  1969.   *         @arg @ref LL_RTC_ALMB_MASK_HOURS
  1970.   *         @arg @ref LL_RTC_ALMB_MASK_MINUTES
  1971.   *         @arg @ref LL_RTC_ALMB_MASK_SECONDS
  1972.   *         @arg @ref LL_RTC_ALMB_MASK_ALL
  1973.   * @retval None
  1974.   */
  1975. __STATIC_INLINE void LL_RTC_ALMB_SetMask(RTC_TypeDef *RTCx, uint32_t Mask)
  1976. {
  1977.   MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1, Mask);
  1978. }
  1979.  
  1980. /**
  1981.   * @brief  Get the Alarm B masks.
  1982.   * @rmtoll ALRMBR       MSK4          LL_RTC_ALMB_GetMask\n
  1983.   *         ALRMBR       MSK3          LL_RTC_ALMB_GetMask\n
  1984.   *         ALRMBR       MSK2          LL_RTC_ALMB_GetMask\n
  1985.   *         ALRMBR       MSK1          LL_RTC_ALMB_GetMask
  1986.   * @param  RTCx RTC Instance
  1987.   * @retval Returned value can be can be a combination of the following values:
  1988.   *         @arg @ref LL_RTC_ALMB_MASK_NONE
  1989.   *         @arg @ref LL_RTC_ALMB_MASK_DATEWEEKDAY
  1990.   *         @arg @ref LL_RTC_ALMB_MASK_HOURS
  1991.   *         @arg @ref LL_RTC_ALMB_MASK_MINUTES
  1992.   *         @arg @ref LL_RTC_ALMB_MASK_SECONDS
  1993.   *         @arg @ref LL_RTC_ALMB_MASK_ALL
  1994.   */
  1995. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetMask(RTC_TypeDef *RTCx)
  1996. {
  1997.   return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1));
  1998. }
  1999.  
  2000. /**
  2001.   * @brief  Enable AlarmB Week day selection (DU[3:0] represents the week day. DT[1:0] is do not care)
  2002.   * @rmtoll ALRMBR       WDSEL         LL_RTC_ALMB_EnableWeekday
  2003.   * @param  RTCx RTC Instance
  2004.   * @retval None
  2005.   */
  2006. __STATIC_INLINE void LL_RTC_ALMB_EnableWeekday(RTC_TypeDef *RTCx)
  2007. {
  2008.   SET_BIT(RTCx->ALRMBR, RTC_ALRMBR_WDSEL);
  2009. }
  2010.  
  2011. /**
  2012.   * @brief  Disable AlarmB Week day selection (DU[3:0] represents the date )
  2013.   * @rmtoll ALRMBR       WDSEL         LL_RTC_ALMB_DisableWeekday
  2014.   * @param  RTCx RTC Instance
  2015.   * @retval None
  2016.   */
  2017. __STATIC_INLINE void LL_RTC_ALMB_DisableWeekday(RTC_TypeDef *RTCx)
  2018. {
  2019.   CLEAR_BIT(RTCx->ALRMBR, RTC_ALRMBR_WDSEL);
  2020. }
  2021.  
  2022. /**
  2023.   * @brief  Set ALARM B Day in BCD format
  2024.   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
  2025.   * @rmtoll ALRMBR       DT            LL_RTC_ALMB_SetDay\n
  2026.   *         ALRMBR       DU            LL_RTC_ALMB_SetDay
  2027.   * @param  RTCx RTC Instance
  2028.   * @param  Day Value between Min_Data=0x01 and Max_Data=0x31
  2029.   * @retval None
  2030.   */
  2031. __STATIC_INLINE void LL_RTC_ALMB_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
  2032. {
  2033.   MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_DT | RTC_ALRMBR_DU),
  2034.              (((Day & 0xF0U) << (RTC_ALRMBR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_ALRMBR_DU_Pos)));
  2035. }
  2036.  
  2037. /**
  2038.   * @brief  Get ALARM B Day in BCD format
  2039.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
  2040.   * @rmtoll ALRMBR       DT            LL_RTC_ALMB_GetDay\n
  2041.   *         ALRMBR       DU            LL_RTC_ALMB_GetDay
  2042.   * @param  RTCx RTC Instance
  2043.   * @retval Value between Min_Data=0x01 and Max_Data=0x31
  2044.   */
  2045. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetDay(RTC_TypeDef *RTCx)
  2046. {
  2047.   return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_DT | RTC_ALRMBR_DU))) >> RTC_ALRMBR_DU_Pos);
  2048. }
  2049.  
  2050. /**
  2051.   * @brief  Set ALARM B Weekday
  2052.   * @rmtoll ALRMBR       DU            LL_RTC_ALMB_SetWeekDay
  2053.   * @param  RTCx RTC Instance
  2054.   * @param  WeekDay This parameter can be one of the following values:
  2055.   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
  2056.   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
  2057.   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  2058.   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
  2059.   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
  2060.   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
  2061.   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
  2062.   * @retval None
  2063.   */
  2064. __STATIC_INLINE void LL_RTC_ALMB_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
  2065. {
  2066.   MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_DU, WeekDay << RTC_ALRMBR_DU_Pos);
  2067. }
  2068.  
  2069. /**
  2070.   * @brief  Get ALARM B Weekday
  2071.   * @rmtoll ALRMBR       DU            LL_RTC_ALMB_GetWeekDay
  2072.   * @param  RTCx RTC Instance
  2073.   * @retval Returned value can be one of the following values:
  2074.   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
  2075.   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
  2076.   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  2077.   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
  2078.   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
  2079.   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
  2080.   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
  2081.   */
  2082. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetWeekDay(RTC_TypeDef *RTCx)
  2083. {
  2084.   return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_DU) >> RTC_ALRMBR_DU_Pos);
  2085. }
  2086.  
  2087. /**
  2088.   * @brief  Set ALARM B time format (AM/24-hour or PM notation)
  2089.   * @rmtoll ALRMBR       PM            LL_RTC_ALMB_SetTimeFormat
  2090.   * @param  RTCx RTC Instance
  2091.   * @param  TimeFormat This parameter can be one of the following values:
  2092.   *         @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
  2093.   *         @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
  2094.   * @retval None
  2095.   */
  2096. __STATIC_INLINE void LL_RTC_ALMB_SetTimeFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
  2097. {
  2098.   MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_PM, TimeFormat);
  2099. }
  2100.  
  2101. /**
  2102.   * @brief  Get ALARM B time format (AM or PM notation)
  2103.   * @rmtoll ALRMBR       PM            LL_RTC_ALMB_GetTimeFormat
  2104.   * @param  RTCx RTC Instance
  2105.   * @retval Returned value can be one of the following values:
  2106.   *         @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
  2107.   *         @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
  2108.   */
  2109. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetTimeFormat(RTC_TypeDef *RTCx)
  2110. {
  2111.   return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_PM));
  2112. }
  2113.  
  2114. /**
  2115.   * @brief  Set ALARM B Hours in BCD format
  2116.   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Hours from binary to BCD format
  2117.   * @rmtoll ALRMBR       HT            LL_RTC_ALMB_SetHour\n
  2118.   *         ALRMBR       HU            LL_RTC_ALMB_SetHour
  2119.   * @param  RTCx RTC Instance
  2120.   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  2121.   * @retval None
  2122.   */
  2123. __STATIC_INLINE void LL_RTC_ALMB_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
  2124. {
  2125.   MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_HT | RTC_ALRMBR_HU),
  2126.              (((Hours & 0xF0U) << (RTC_ALRMBR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMBR_HU_Pos)));
  2127. }
  2128.  
  2129. /**
  2130.   * @brief  Get ALARM B Hours in BCD format
  2131.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
  2132.   * @rmtoll ALRMBR       HT            LL_RTC_ALMB_GetHour\n
  2133.   *         ALRMBR       HU            LL_RTC_ALMB_GetHour
  2134.   * @param  RTCx RTC Instance
  2135.   * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  2136.   */
  2137. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetHour(RTC_TypeDef *RTCx)
  2138. {
  2139.   return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_HT | RTC_ALRMBR_HU))) >> RTC_ALRMBR_HU_Pos);
  2140. }
  2141.  
  2142. /**
  2143.   * @brief  Set ALARM B Minutes in BCD format
  2144.   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
  2145.   * @rmtoll ALRMBR       MNT           LL_RTC_ALMB_SetMinute\n
  2146.   *         ALRMBR       MNU           LL_RTC_ALMB_SetMinute
  2147.   * @param  RTCx RTC Instance
  2148.   * @param  Minutes between Min_Data=0x00 and Max_Data=0x59
  2149.   * @retval None
  2150.   */
  2151. __STATIC_INLINE void LL_RTC_ALMB_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
  2152. {
  2153.   MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_MNT | RTC_ALRMBR_MNU),
  2154.              (((Minutes & 0xF0U) << (RTC_ALRMBR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMBR_MNU_Pos)));
  2155. }
  2156.  
  2157. /**
  2158.   * @brief  Get ALARM B Minutes in BCD format
  2159.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
  2160.   * @rmtoll ALRMBR       MNT           LL_RTC_ALMB_GetMinute\n
  2161.   *         ALRMBR       MNU           LL_RTC_ALMB_GetMinute
  2162.   * @param  RTCx RTC Instance
  2163.   * @retval Value between Min_Data=0x00 and Max_Data=0x59
  2164.   */
  2165. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetMinute(RTC_TypeDef *RTCx)
  2166. {
  2167.   return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_MNT | RTC_ALRMBR_MNU))) >> RTC_ALRMBR_MNU_Pos);
  2168. }
  2169.  
  2170. /**
  2171.   * @brief  Set ALARM B Seconds in BCD format
  2172.   * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
  2173.   * @rmtoll ALRMBR       ST            LL_RTC_ALMB_SetSecond\n
  2174.   *         ALRMBR       SU            LL_RTC_ALMB_SetSecond
  2175.   * @param  RTCx RTC Instance
  2176.   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
  2177.   * @retval None
  2178.   */
  2179. __STATIC_INLINE void LL_RTC_ALMB_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
  2180. {
  2181.   MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_ST | RTC_ALRMBR_SU),
  2182.              (((Seconds & 0xF0U) << (RTC_ALRMBR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMBR_SU_Pos)));
  2183. }
  2184.  
  2185. /**
  2186.   * @brief  Get ALARM B Seconds in BCD format
  2187.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
  2188.   * @rmtoll ALRMBR       ST            LL_RTC_ALMB_GetSecond\n
  2189.   *         ALRMBR       SU            LL_RTC_ALMB_GetSecond
  2190.   * @param  RTCx RTC Instance
  2191.   * @retval Value between Min_Data=0x00 and Max_Data=0x59
  2192.   */
  2193. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSecond(RTC_TypeDef *RTCx)
  2194. {
  2195.   return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_ST | RTC_ALRMBR_SU))) >> RTC_ALRMBR_SU_Pos);
  2196. }
  2197.  
  2198. /**
  2199.   * @brief  Set Alarm B Time (hour, minute and second) in BCD format
  2200.   * @rmtoll ALRMBR       PM            LL_RTC_ALMB_ConfigTime\n
  2201.   *         ALRMBR       HT            LL_RTC_ALMB_ConfigTime\n
  2202.   *         ALRMBR       HU            LL_RTC_ALMB_ConfigTime\n
  2203.   *         ALRMBR       MNT           LL_RTC_ALMB_ConfigTime\n
  2204.   *         ALRMBR       MNU           LL_RTC_ALMB_ConfigTime\n
  2205.   *         ALRMBR       ST            LL_RTC_ALMB_ConfigTime\n
  2206.   *         ALRMBR       SU            LL_RTC_ALMB_ConfigTime
  2207.   * @param  RTCx RTC Instance
  2208.   * @param  Format12_24 This parameter can be one of the following values:
  2209.   *         @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
  2210.   *         @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
  2211.   * @param  Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  2212.   * @param  Minutes Value between Min_Data=0x00 and Max_Data=0x59
  2213.   * @param  Seconds Value between Min_Data=0x00 and Max_Data=0x59
  2214.   * @retval None
  2215.   */
  2216. __STATIC_INLINE void LL_RTC_ALMB_ConfigTime(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
  2217. {
  2218.   uint32_t temp;
  2219.  
  2220.   temp = Format12_24                                                                                    | \
  2221.          (((Hours   & 0xF0U) << (RTC_ALRMBR_HT_Pos  - 4U)) | ((Hours   & 0x0FU) << RTC_ALRMBR_HU_Pos))  | \
  2222.          (((Minutes & 0xF0U) << (RTC_ALRMBR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMBR_MNU_Pos)) | \
  2223.          (((Seconds & 0xF0U) << (RTC_ALRMBR_ST_Pos  - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMBR_SU_Pos));
  2224.  
  2225.   MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_PM | RTC_ALRMBR_HT | RTC_ALRMBR_HU | RTC_ALRMBR_MNT | RTC_ALRMBR_MNU | RTC_ALRMBR_ST | RTC_ALRMBR_SU, temp);
  2226. }
  2227.  
  2228. /**
  2229.   * @brief  Get Alarm B Time (hour, minute and second) in BCD format
  2230.   * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
  2231.   * are available to get independently each parameter.
  2232.   * @rmtoll ALRMBR       HT            LL_RTC_ALMB_GetTime\n
  2233.   *         ALRMBR       HU            LL_RTC_ALMB_GetTime\n
  2234.   *         ALRMBR       MNT           LL_RTC_ALMB_GetTime\n
  2235.   *         ALRMBR       MNU           LL_RTC_ALMB_GetTime\n
  2236.   *         ALRMBR       ST            LL_RTC_ALMB_GetTime\n
  2237.   *         ALRMBR       SU            LL_RTC_ALMB_GetTime
  2238.   * @param  RTCx RTC Instance
  2239.   * @retval Combination of hours, minutes and seconds.
  2240.   */
  2241. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetTime(RTC_TypeDef *RTCx)
  2242. {
  2243.   return (uint32_t)((LL_RTC_ALMB_GetHour(RTCx) << RTC_OFFSET_HOUR) | (LL_RTC_ALMB_GetMinute(RTCx) << RTC_OFFSET_MINUTE) | LL_RTC_ALMB_GetSecond(RTCx));
  2244. }
  2245.  
  2246. #if defined(RTC_SUBSECOND_SUPPORT)
  2247. /**
  2248.   * @brief  Mask the most-significant bits of the subseconds field starting from
  2249.   *         the bit specified in parameter Mask
  2250.   * @note This register can be written only when ALRBE is reset in RTC_CR register,
  2251.   *       or in initialization mode.
  2252.   * @rmtoll ALRMBSSR     MASKSS        LL_RTC_ALMB_SetSubSecondMask
  2253.   * @param  RTCx RTC Instance
  2254.   * @param  Mask Value between Min_Data=0x00 and Max_Data=0xF
  2255.   * @retval None
  2256.   */
  2257. __STATIC_INLINE void LL_RTC_ALMB_SetSubSecondMask(RTC_TypeDef *RTCx, uint32_t Mask)
  2258. {
  2259.   MODIFY_REG(RTCx->ALRMBSSR, RTC_ALRMBSSR_MASKSS, Mask << RTC_ALRMBSSR_MASKSS_Pos);
  2260. }
  2261.  
  2262. /**
  2263.   * @brief  Get Alarm B subseconds mask
  2264.   * @rmtoll ALRMBSSR     MASKSS        LL_RTC_ALMB_GetSubSecondMask
  2265.   * @param  RTCx RTC Instance
  2266.   * @retval Value between Min_Data=0x00 and Max_Data=0xF
  2267.   */
  2268. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSubSecondMask(RTC_TypeDef *RTCx)
  2269. {
  2270.   return (uint32_t)(READ_BIT(RTCx->ALRMBSSR, RTC_ALRMBSSR_MASKSS)  >> RTC_ALRMBSSR_MASKSS_Pos);
  2271. }
  2272.  
  2273. /**
  2274.   * @brief  Set Alarm B subseconds value
  2275.   * @rmtoll ALRMBSSR     SS            LL_RTC_ALMB_SetSubSecond
  2276.   * @param  RTCx RTC Instance
  2277.   * @param  Subsecond Value between Min_Data=0x00 and Max_Data=0x7FFF
  2278.   * @retval None
  2279.   */
  2280. __STATIC_INLINE void LL_RTC_ALMB_SetSubSecond(RTC_TypeDef *RTCx, uint32_t Subsecond)
  2281. {
  2282.   MODIFY_REG(RTCx->ALRMBSSR, RTC_ALRMBSSR_SS, Subsecond);
  2283. }
  2284.  
  2285. /**
  2286.   * @brief  Get Alarm B subseconds value
  2287.   * @rmtoll ALRMBSSR     SS            LL_RTC_ALMB_GetSubSecond
  2288.   * @param  RTCx RTC Instance
  2289.   * @retval Value between Min_Data=0x00 and Max_Data=0x7FFF
  2290.   */
  2291. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSubSecond(RTC_TypeDef *RTCx)
  2292. {
  2293.   return (uint32_t)(READ_BIT(RTCx->ALRMBSSR, RTC_ALRMBSSR_SS));
  2294. }
  2295. #endif /* RTC_SUBSECOND_SUPPORT */
  2296.  
  2297. /**
  2298.   * @}
  2299.   */
  2300.  
  2301. /** @defgroup RTC_LL_EF_Timestamp Timestamp
  2302.   * @{
  2303.   */
  2304.  
  2305. /**
  2306.   * @brief  Enable Timestamp
  2307.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2308.   * @rmtoll CR           TSE           LL_RTC_TS_Enable
  2309.   * @param  RTCx RTC Instance
  2310.   * @retval None
  2311.   */
  2312. __STATIC_INLINE void LL_RTC_TS_Enable(RTC_TypeDef *RTCx)
  2313. {
  2314.   SET_BIT(RTCx->CR, RTC_CR_TSE);
  2315. }
  2316.  
  2317. /**
  2318.   * @brief  Disable Timestamp
  2319.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2320.   * @rmtoll CR           TSE           LL_RTC_TS_Disable
  2321.   * @param  RTCx RTC Instance
  2322.   * @retval None
  2323.   */
  2324. __STATIC_INLINE void LL_RTC_TS_Disable(RTC_TypeDef *RTCx)
  2325. {
  2326.   CLEAR_BIT(RTCx->CR, RTC_CR_TSE);
  2327. }
  2328.  
  2329. /**
  2330.   * @brief  Set Time-stamp event active edge
  2331.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2332.   * @note TSE must be reset when TSEDGE is changed to avoid unwanted TSF setting
  2333.   * @rmtoll CR           TSEDGE        LL_RTC_TS_SetActiveEdge
  2334.   * @param  RTCx RTC Instance
  2335.   * @param  Edge This parameter can be one of the following values:
  2336.   *         @arg @ref LL_RTC_TIMESTAMP_EDGE_RISING
  2337.   *         @arg @ref LL_RTC_TIMESTAMP_EDGE_FALLING
  2338.   * @retval None
  2339.   */
  2340. __STATIC_INLINE void LL_RTC_TS_SetActiveEdge(RTC_TypeDef *RTCx, uint32_t Edge)
  2341. {
  2342.   MODIFY_REG(RTCx->CR, RTC_CR_TSEDGE, Edge);
  2343. }
  2344.  
  2345. /**
  2346.   * @brief  Get Time-stamp event active edge
  2347.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2348.   * @rmtoll CR           TSEDGE        LL_RTC_TS_GetActiveEdge
  2349.   * @param  RTCx RTC Instance
  2350.   * @retval Returned value can be one of the following values:
  2351.   *         @arg @ref LL_RTC_TIMESTAMP_EDGE_RISING
  2352.   *         @arg @ref LL_RTC_TIMESTAMP_EDGE_FALLING
  2353.   */
  2354. __STATIC_INLINE uint32_t LL_RTC_TS_GetActiveEdge(RTC_TypeDef *RTCx)
  2355. {
  2356.   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_TSEDGE));
  2357. }
  2358.  
  2359. /**
  2360.   * @brief  Get Timestamp AM/PM notation (AM or 24-hour format)
  2361.   * @rmtoll TSTR         PM            LL_RTC_TS_GetTimeFormat
  2362.   * @param  RTCx RTC Instance
  2363.   * @retval Returned value can be one of the following values:
  2364.   *         @arg @ref LL_RTC_TS_TIME_FORMAT_AM
  2365.   *         @arg @ref LL_RTC_TS_TIME_FORMAT_PM
  2366.   */
  2367. __STATIC_INLINE uint32_t LL_RTC_TS_GetTimeFormat(RTC_TypeDef *RTCx)
  2368. {
  2369.   return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_PM));
  2370. }
  2371.  
  2372. /**
  2373.   * @brief  Get Timestamp Hours in BCD format
  2374.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
  2375.   * @rmtoll TSTR         HT            LL_RTC_TS_GetHour\n
  2376.   *         TSTR         HU            LL_RTC_TS_GetHour
  2377.   * @param  RTCx RTC Instance
  2378.   * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  2379.   */
  2380. __STATIC_INLINE uint32_t LL_RTC_TS_GetHour(RTC_TypeDef *RTCx)
  2381. {
  2382.   return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_HT | RTC_TSTR_HU) >> RTC_TSTR_HU_Pos);
  2383. }
  2384.  
  2385. /**
  2386.   * @brief  Get Timestamp Minutes in BCD format
  2387.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
  2388.   * @rmtoll TSTR         MNT           LL_RTC_TS_GetMinute\n
  2389.   *         TSTR         MNU           LL_RTC_TS_GetMinute
  2390.   * @param  RTCx RTC Instance
  2391.   * @retval Value between Min_Data=0x00 and Max_Data=0x59
  2392.   */
  2393. __STATIC_INLINE uint32_t LL_RTC_TS_GetMinute(RTC_TypeDef *RTCx)
  2394. {
  2395.   return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_MNT | RTC_TSTR_MNU) >> RTC_TSTR_MNU_Pos);
  2396. }
  2397.  
  2398. /**
  2399.   * @brief  Get Timestamp Seconds in BCD format
  2400.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
  2401.   * @rmtoll TSTR         ST            LL_RTC_TS_GetSecond\n
  2402.   *         TSTR         SU            LL_RTC_TS_GetSecond
  2403.   * @param  RTCx RTC Instance
  2404.   * @retval Value between Min_Data=0x00 and Max_Data=0x59
  2405.   */
  2406. __STATIC_INLINE uint32_t LL_RTC_TS_GetSecond(RTC_TypeDef *RTCx)
  2407. {
  2408.   return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_ST | RTC_TSTR_SU));
  2409. }
  2410.  
  2411. /**
  2412.   * @brief  Get Timestamp time (hour, minute and second) in BCD format
  2413.   * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
  2414.   * are available to get independently each parameter.
  2415.   * @rmtoll TSTR         HT            LL_RTC_TS_GetTime\n
  2416.   *         TSTR         HU            LL_RTC_TS_GetTime\n
  2417.   *         TSTR         MNT           LL_RTC_TS_GetTime\n
  2418.   *         TSTR         MNU           LL_RTC_TS_GetTime\n
  2419.   *         TSTR         ST            LL_RTC_TS_GetTime\n
  2420.   *         TSTR         SU            LL_RTC_TS_GetTime
  2421.   * @param  RTCx RTC Instance
  2422.   * @retval Combination of hours, minutes and seconds.
  2423.   */
  2424. __STATIC_INLINE uint32_t LL_RTC_TS_GetTime(RTC_TypeDef *RTCx)
  2425. {
  2426.   return (uint32_t)(READ_BIT(RTCx->TSTR,
  2427.                              RTC_TSTR_HT | RTC_TSTR_HU | RTC_TSTR_MNT | RTC_TSTR_MNU | RTC_TSTR_ST | RTC_TSTR_SU));
  2428. }
  2429.  
  2430. /**
  2431.   * @brief  Get Timestamp Week day
  2432.   * @rmtoll TSDR         WDU           LL_RTC_TS_GetWeekDay
  2433.   * @param  RTCx RTC Instance
  2434.   * @retval Returned value can be one of the following values:
  2435.   *         @arg @ref LL_RTC_WEEKDAY_MONDAY
  2436.   *         @arg @ref LL_RTC_WEEKDAY_TUESDAY
  2437.   *         @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  2438.   *         @arg @ref LL_RTC_WEEKDAY_THURSDAY
  2439.   *         @arg @ref LL_RTC_WEEKDAY_FRIDAY
  2440.   *         @arg @ref LL_RTC_WEEKDAY_SATURDAY
  2441.   *         @arg @ref LL_RTC_WEEKDAY_SUNDAY
  2442.   */
  2443. __STATIC_INLINE uint32_t LL_RTC_TS_GetWeekDay(RTC_TypeDef *RTCx)
  2444. {
  2445.   return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_WDU) >> RTC_TSDR_WDU_Pos);
  2446. }
  2447.  
  2448. /**
  2449.   * @brief  Get Timestamp Month in BCD format
  2450.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Month from BCD to Binary format
  2451.   * @rmtoll TSDR         MT            LL_RTC_TS_GetMonth\n
  2452.   *         TSDR         MU            LL_RTC_TS_GetMonth
  2453.   * @param  RTCx RTC Instance
  2454.   * @retval Returned value can be one of the following values:
  2455.   *         @arg @ref LL_RTC_MONTH_JANUARY
  2456.   *         @arg @ref LL_RTC_MONTH_FEBRUARY
  2457.   *         @arg @ref LL_RTC_MONTH_MARCH
  2458.   *         @arg @ref LL_RTC_MONTH_APRIL
  2459.   *         @arg @ref LL_RTC_MONTH_MAY
  2460.   *         @arg @ref LL_RTC_MONTH_JUNE
  2461.   *         @arg @ref LL_RTC_MONTH_JULY
  2462.   *         @arg @ref LL_RTC_MONTH_AUGUST
  2463.   *         @arg @ref LL_RTC_MONTH_SEPTEMBER
  2464.   *         @arg @ref LL_RTC_MONTH_OCTOBER
  2465.   *         @arg @ref LL_RTC_MONTH_NOVEMBER
  2466.   *         @arg @ref LL_RTC_MONTH_DECEMBER
  2467.   */
  2468. __STATIC_INLINE uint32_t LL_RTC_TS_GetMonth(RTC_TypeDef *RTCx)
  2469. {
  2470.   return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_MT | RTC_TSDR_MU) >> RTC_TSDR_MU_Pos);
  2471. }
  2472.  
  2473. /**
  2474.   * @brief  Get Timestamp Day in BCD format
  2475.   * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
  2476.   * @rmtoll TSDR         DT            LL_RTC_TS_GetDay\n
  2477.   *         TSDR         DU            LL_RTC_TS_GetDay
  2478.   * @param  RTCx RTC Instance
  2479.   * @retval Value between Min_Data=0x01 and Max_Data=0x31
  2480.   */
  2481. __STATIC_INLINE uint32_t LL_RTC_TS_GetDay(RTC_TypeDef *RTCx)
  2482. {
  2483.   return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_DT | RTC_TSDR_DU));
  2484. }
  2485.  
  2486. /**
  2487.   * @brief  Get Timestamp date (WeekDay, Day and Month) in BCD format
  2488.   * @note helper macros __LL_RTC_GET_WEEKDAY, __LL_RTC_GET_MONTH,
  2489.   * and __LL_RTC_GET_DAY are available to get independently each parameter.
  2490.   * @rmtoll TSDR         WDU           LL_RTC_TS_GetDate\n
  2491.   *         TSDR         MT            LL_RTC_TS_GetDate\n
  2492.   *         TSDR         MU            LL_RTC_TS_GetDate\n
  2493.   *         TSDR         DT            LL_RTC_TS_GetDate\n
  2494.   *         TSDR         DU            LL_RTC_TS_GetDate
  2495.   * @param  RTCx RTC Instance
  2496.   * @retval Combination of Weekday, Day and Month
  2497.   */
  2498. __STATIC_INLINE uint32_t LL_RTC_TS_GetDate(RTC_TypeDef *RTCx)
  2499. {
  2500.   return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_WDU | RTC_TSDR_MT | RTC_TSDR_MU | RTC_TSDR_DT | RTC_TSDR_DU));
  2501. }
  2502.  
  2503. #if defined(RTC_SUBSECOND_SUPPORT)
  2504. /**
  2505.   * @brief  Get time-stamp subseconds value
  2506.   * @rmtoll TSSSR        SS            LL_RTC_TS_GetSubSecond
  2507.   * @param  RTCx RTC Instance
  2508.   * @retval Value between Min_Data=0x00 and Max_Data=0xFFFF
  2509.   */
  2510. __STATIC_INLINE uint32_t LL_RTC_TS_GetSubSecond(RTC_TypeDef *RTCx)
  2511. {
  2512.   return (uint32_t)(READ_BIT(RTCx->TSSSR, RTC_TSSSR_SS));
  2513. }
  2514. #endif /* RTC_SUBSECOND_SUPPORT */
  2515.  
  2516. #if defined(RTC_TAFCR_TAMPTS)
  2517. /**
  2518.   * @brief  Activate timestamp on tamper detection event
  2519.   * @rmtoll TAFCR       TAMPTS        LL_RTC_TS_EnableOnTamper
  2520.   * @param  RTCx RTC Instance
  2521.   * @retval None
  2522.   */
  2523. __STATIC_INLINE void LL_RTC_TS_EnableOnTamper(RTC_TypeDef *RTCx)
  2524. {
  2525.   SET_BIT(RTCx->TAFCR, RTC_TAFCR_TAMPTS);
  2526. }
  2527.  
  2528. /**
  2529.   * @brief  Disable timestamp on tamper detection event
  2530.   * @rmtoll TAFCR       TAMPTS        LL_RTC_TS_DisableOnTamper
  2531.   * @param  RTCx RTC Instance
  2532.   * @retval None
  2533.   */
  2534. __STATIC_INLINE void LL_RTC_TS_DisableOnTamper(RTC_TypeDef *RTCx)
  2535. {
  2536.   CLEAR_BIT(RTCx->TAFCR, RTC_TAFCR_TAMPTS);
  2537. }
  2538. #endif /* RTC_TAFCR_TAMPTS */
  2539.  
  2540. /**
  2541.   * @}
  2542.   */
  2543.  
  2544. /** @defgroup RTC_LL_EF_Tamper Tamper
  2545.   * @{
  2546.   */
  2547.  
  2548. /**
  2549.   * @brief  Enable RTC_TAMPx input detection
  2550.   * @rmtoll TAFCR       TAMP1E        LL_RTC_TAMPER_Enable\n
  2551.   *         TAFCR       TAMP2E        LL_RTC_TAMPER_Enable\n
  2552.   *         TAFCR       TAMP3E        LL_RTC_TAMPER_Enable
  2553.   * @param  RTCx RTC Instance
  2554.   * @param  Tamper This parameter can be a combination of the following values:
  2555.   *         @arg @ref LL_RTC_TAMPER_1
  2556.   *         @arg @ref LL_RTC_TAMPER_2 (*)
  2557.   *         @arg @ref LL_RTC_TAMPER_3 (*)
  2558.   *
  2559.   *         (*) value not applicable to all devices.
  2560.   * @retval None
  2561.   */
  2562. __STATIC_INLINE void LL_RTC_TAMPER_Enable(RTC_TypeDef *RTCx, uint32_t Tamper)
  2563. {
  2564.   SET_BIT(RTCx->TAFCR, Tamper);
  2565. }
  2566.  
  2567. /**
  2568.   * @brief  Clear RTC_TAMPx input detection
  2569.   * @rmtoll TAFCR       TAMP1E        LL_RTC_TAMPER_Disable\n
  2570.   *         TAFCR       TAMP2E        LL_RTC_TAMPER_Disable\n
  2571.   *         TAFCR       TAMP3E        LL_RTC_TAMPER_Disable
  2572.   * @param  RTCx RTC Instance
  2573.   * @param  Tamper This parameter can be a combination of the following values:
  2574.   *         @arg @ref LL_RTC_TAMPER_1
  2575.   *         @arg @ref LL_RTC_TAMPER_2 (*)
  2576.   *         @arg @ref LL_RTC_TAMPER_3 (*)
  2577.   *
  2578.   *         (*) value not applicable to all devices.
  2579.   * @retval None
  2580.   */
  2581. __STATIC_INLINE void LL_RTC_TAMPER_Disable(RTC_TypeDef *RTCx, uint32_t Tamper)
  2582. {
  2583.   CLEAR_BIT(RTCx->TAFCR, Tamper);
  2584. }
  2585.  
  2586. #if defined(RTC_TAFCR_TAMPFLT)
  2587. /**
  2588.   * @brief  Disable RTC_TAMPx pull-up disable (Disable precharge of RTC_TAMPx pins)
  2589.   * @rmtoll TAFCR       TAMPPUDIS     LL_RTC_TAMPER_DisablePullUp
  2590.   * @param  RTCx RTC Instance
  2591.   * @retval None
  2592.   */
  2593. __STATIC_INLINE void LL_RTC_TAMPER_DisablePullUp(RTC_TypeDef *RTCx)
  2594. {
  2595.   SET_BIT(RTCx->TAFCR, RTC_TAFCR_TAMPPUDIS);
  2596. }
  2597.  
  2598. /**
  2599.   * @brief  Enable RTC_TAMPx pull-up disable ( Precharge RTC_TAMPx pins before sampling)
  2600.   * @rmtoll TAFCR       TAMPPUDIS     LL_RTC_TAMPER_EnablePullUp
  2601.   * @param  RTCx RTC Instance
  2602.   * @retval None
  2603.   */
  2604. __STATIC_INLINE void LL_RTC_TAMPER_EnablePullUp(RTC_TypeDef *RTCx)
  2605. {
  2606.   CLEAR_BIT(RTCx->TAFCR, RTC_TAFCR_TAMPPUDIS);
  2607. }
  2608.  
  2609. /**
  2610.   * @brief  Set RTC_TAMPx precharge duration
  2611.   * @rmtoll TAFCR       TAMPPRCH      LL_RTC_TAMPER_SetPrecharge
  2612.   * @param  RTCx RTC Instance
  2613.   * @param  Duration This parameter can be one of the following values:
  2614.   *         @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
  2615.   *         @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
  2616.   *         @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
  2617.   *         @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
  2618.   * @retval None
  2619.   */
  2620. __STATIC_INLINE void LL_RTC_TAMPER_SetPrecharge(RTC_TypeDef *RTCx, uint32_t Duration)
  2621. {
  2622.   MODIFY_REG(RTCx->TAFCR, RTC_TAFCR_TAMPPRCH, Duration);
  2623. }
  2624.  
  2625. /**
  2626.   * @brief  Get RTC_TAMPx precharge duration
  2627.   * @rmtoll TAFCR       TAMPPRCH      LL_RTC_TAMPER_GetPrecharge
  2628.   * @param  RTCx RTC Instance
  2629.   * @retval Returned value can be one of the following values:
  2630.   *         @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
  2631.   *         @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
  2632.   *         @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
  2633.   *         @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
  2634.   */
  2635. __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetPrecharge(RTC_TypeDef *RTCx)
  2636. {
  2637.   return (uint32_t)(READ_BIT(RTCx->TAFCR, RTC_TAFCR_TAMPPRCH));
  2638. }
  2639.  
  2640. /**
  2641.   * @brief  Set RTC_TAMPx filter count
  2642.   * @rmtoll TAFCR       TAMPFLT       LL_RTC_TAMPER_SetFilterCount
  2643.   * @param  RTCx RTC Instance
  2644.   * @param  FilterCount This parameter can be one of the following values:
  2645.   *         @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
  2646.   *         @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
  2647.   *         @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
  2648.   *         @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
  2649.   * @retval None
  2650.   */
  2651. __STATIC_INLINE void LL_RTC_TAMPER_SetFilterCount(RTC_TypeDef *RTCx, uint32_t FilterCount)
  2652. {
  2653.   MODIFY_REG(RTCx->TAFCR, RTC_TAFCR_TAMPFLT, FilterCount);
  2654. }
  2655.  
  2656. /**
  2657.   * @brief  Get RTC_TAMPx filter count
  2658.   * @rmtoll TAFCR       TAMPFLT       LL_RTC_TAMPER_GetFilterCount
  2659.   * @param  RTCx RTC Instance
  2660.   * @retval Returned value can be one of the following values:
  2661.   *         @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
  2662.   *         @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
  2663.   *         @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
  2664.   *         @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
  2665.   */
  2666. __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetFilterCount(RTC_TypeDef *RTCx)
  2667. {
  2668.   return (uint32_t)(READ_BIT(RTCx->TAFCR, RTC_TAFCR_TAMPFLT));
  2669. }
  2670.  
  2671. /**
  2672.   * @brief  Set Tamper sampling frequency
  2673.   * @rmtoll TAFCR       TAMPFREQ      LL_RTC_TAMPER_SetSamplingFreq
  2674.   * @param  RTCx RTC Instance
  2675.   * @param  SamplingFreq This parameter can be one of the following values:
  2676.   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
  2677.   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
  2678.   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
  2679.   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
  2680.   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
  2681.   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
  2682.   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
  2683.   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
  2684.   * @retval None
  2685.   */
  2686. __STATIC_INLINE void LL_RTC_TAMPER_SetSamplingFreq(RTC_TypeDef *RTCx, uint32_t SamplingFreq)
  2687. {
  2688.   MODIFY_REG(RTCx->TAFCR, RTC_TAFCR_TAMPFREQ, SamplingFreq);
  2689. }
  2690.  
  2691. /**
  2692.   * @brief  Get Tamper sampling frequency
  2693.   * @rmtoll TAFCR       TAMPFREQ      LL_RTC_TAMPER_GetSamplingFreq
  2694.   * @param  RTCx RTC Instance
  2695.   * @retval Returned value can be one of the following values:
  2696.   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
  2697.   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
  2698.   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
  2699.   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
  2700.   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
  2701.   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
  2702.   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
  2703.   *         @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
  2704.   */
  2705. __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetSamplingFreq(RTC_TypeDef *RTCx)
  2706. {
  2707.   return (uint32_t)(READ_BIT(RTCx->TAFCR, RTC_TAFCR_TAMPFREQ));
  2708. }
  2709. #endif /* RTC_TAFCR_TAMPFLT */
  2710.  
  2711. /**
  2712.   * @brief  Enable Active level for Tamper input
  2713.   * @rmtoll TAFCR       TAMP1TRG      LL_RTC_TAMPER_EnableActiveLevel\n
  2714.   *         TAFCR       TAMP2TRG      LL_RTC_TAMPER_EnableActiveLevel\n
  2715.   *         TAFCR       TAMP3TRG      LL_RTC_TAMPER_EnableActiveLevel
  2716.   * @param  RTCx RTC Instance
  2717.   * @param  Tamper This parameter can be a combination of the following values:
  2718.   *         @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP1
  2719.   *         @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP2 (*)
  2720.   *         @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP3 (*)
  2721.   *
  2722.   *         (*) value not applicable to all devices.
  2723.   * @retval None
  2724.   */
  2725. __STATIC_INLINE void LL_RTC_TAMPER_EnableActiveLevel(RTC_TypeDef *RTCx, uint32_t Tamper)
  2726. {
  2727.   SET_BIT(RTCx->TAFCR, Tamper);
  2728. }
  2729.  
  2730. /**
  2731.   * @brief  Disable Active level for Tamper input
  2732.   * @rmtoll TAFCR       TAMP1TRG      LL_RTC_TAMPER_DisableActiveLevel\n
  2733.   *         TAFCR       TAMP2TRG      LL_RTC_TAMPER_DisableActiveLevel\n
  2734.   *         TAFCR       TAMP3TRG      LL_RTC_TAMPER_DisableActiveLevel
  2735.   * @param  RTCx RTC Instance
  2736.   * @param  Tamper This parameter can be a combination of the following values:
  2737.   *         @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP1
  2738.   *         @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP2 (*)
  2739.   *         @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP3 (*)
  2740.   *
  2741.   *         (*) value not applicable to all devices.
  2742.   * @retval None
  2743.   */
  2744. __STATIC_INLINE void LL_RTC_TAMPER_DisableActiveLevel(RTC_TypeDef *RTCx, uint32_t Tamper)
  2745. {
  2746.   CLEAR_BIT(RTCx->TAFCR, Tamper);
  2747. }
  2748.  
  2749. /**
  2750.   * @}
  2751.   */
  2752.  
  2753. /** @defgroup RTC_LL_EF_Wakeup Wakeup
  2754.   * @{
  2755.   */
  2756.  
  2757. /**
  2758.   * @brief  Enable Wakeup timer
  2759.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2760.   * @rmtoll CR           WUTE          LL_RTC_WAKEUP_Enable
  2761.   * @param  RTCx RTC Instance
  2762.   * @retval None
  2763.   */
  2764. __STATIC_INLINE void LL_RTC_WAKEUP_Enable(RTC_TypeDef *RTCx)
  2765. {
  2766.   SET_BIT(RTCx->CR, RTC_CR_WUTE);
  2767. }
  2768.  
  2769. /**
  2770.   * @brief  Disable Wakeup timer
  2771.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2772.   * @rmtoll CR           WUTE          LL_RTC_WAKEUP_Disable
  2773.   * @param  RTCx RTC Instance
  2774.   * @retval None
  2775.   */
  2776. __STATIC_INLINE void LL_RTC_WAKEUP_Disable(RTC_TypeDef *RTCx)
  2777. {
  2778.   CLEAR_BIT(RTCx->CR, RTC_CR_WUTE);
  2779. }
  2780.  
  2781. /**
  2782.   * @brief  Check if Wakeup timer is enabled or not
  2783.   * @rmtoll CR           WUTE          LL_RTC_WAKEUP_IsEnabled
  2784.   * @param  RTCx RTC Instance
  2785.   * @retval State of bit (1 or 0).
  2786.   */
  2787. __STATIC_INLINE uint32_t LL_RTC_WAKEUP_IsEnabled(RTC_TypeDef *RTCx)
  2788. {
  2789.   return ((READ_BIT(RTCx->CR, RTC_CR_WUTE) == (RTC_CR_WUTE)) ? 1UL : 0UL);
  2790. }
  2791.  
  2792. /**
  2793.   * @brief  Select Wakeup clock
  2794.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2795.   * @note   Bit can be written only when RTC_CR WUTE bit = 0 and RTC_ISR WUTWF bit = 1
  2796.   * @rmtoll CR           WUCKSEL       LL_RTC_WAKEUP_SetClock
  2797.   * @param  RTCx RTC Instance
  2798.   * @param  WakeupClock This parameter can be one of the following values:
  2799.   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_16
  2800.   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_8
  2801.   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_4
  2802.   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_2
  2803.   *         @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE
  2804.   *         @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE_WUT
  2805.   * @retval None
  2806.   */
  2807. __STATIC_INLINE void LL_RTC_WAKEUP_SetClock(RTC_TypeDef *RTCx, uint32_t WakeupClock)
  2808. {
  2809.   MODIFY_REG(RTCx->CR, RTC_CR_WUCKSEL, WakeupClock);
  2810. }
  2811.  
  2812. /**
  2813.   * @brief  Get Wakeup clock
  2814.   * @rmtoll CR           WUCKSEL       LL_RTC_WAKEUP_GetClock
  2815.   * @param  RTCx RTC Instance
  2816.   * @retval Returned value can be one of the following values:
  2817.   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_16
  2818.   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_8
  2819.   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_4
  2820.   *         @arg @ref LL_RTC_WAKEUPCLOCK_DIV_2
  2821.   *         @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE
  2822.   *         @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE_WUT
  2823.   */
  2824. __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetClock(RTC_TypeDef *RTCx)
  2825. {
  2826.   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_WUCKSEL));
  2827. }
  2828.  
  2829. /**
  2830.   * @brief  Set Wakeup auto-reload value
  2831.   * @note   Bit can be written only when WUTWF is set to 1 in RTC_ISR
  2832.   * @rmtoll WUTR         WUT           LL_RTC_WAKEUP_SetAutoReload
  2833.   * @param  RTCx RTC Instance
  2834.   * @param  Value Value between Min_Data=0x00 and Max_Data=0xFFFF
  2835.   * @retval None
  2836.   */
  2837. __STATIC_INLINE void LL_RTC_WAKEUP_SetAutoReload(RTC_TypeDef *RTCx, uint32_t Value)
  2838. {
  2839.   MODIFY_REG(RTCx->WUTR, RTC_WUTR_WUT, Value);
  2840. }
  2841.  
  2842. /**
  2843.   * @brief  Get Wakeup auto-reload value
  2844.   * @rmtoll WUTR         WUT           LL_RTC_WAKEUP_GetAutoReload
  2845.   * @param  RTCx RTC Instance
  2846.   * @retval Value between Min_Data=0x00 and Max_Data=0xFFFF
  2847.   */
  2848. __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetAutoReload(RTC_TypeDef *RTCx)
  2849. {
  2850.   return (uint32_t)(READ_BIT(RTCx->WUTR, RTC_WUTR_WUT));
  2851. }
  2852.  
  2853. /**
  2854.   * @}
  2855.   */
  2856.  
  2857. /** @defgroup RTC_LL_EF_Backup_Registers Backup_Registers
  2858.   * @{
  2859.   */
  2860.  
  2861. /**
  2862.   * @brief  Writes a data in a specified RTC Backup data register.
  2863.   * @rmtoll BKPxR        BKP           LL_RTC_BAK_SetRegister
  2864.   * @param  RTCx RTC Instance
  2865.   * @param  BackupRegister This parameter can be one of the following values:
  2866.   *         @arg @ref LL_RTC_BKP_DR0
  2867.   *         @arg @ref LL_RTC_BKP_DR1
  2868.   *         @arg @ref LL_RTC_BKP_DR2
  2869.   *         @arg @ref LL_RTC_BKP_DR3
  2870.   *         @arg @ref LL_RTC_BKP_DR4
  2871.   *         @arg @ref LL_RTC_BKP_DR5 (*)
  2872.   *         @arg @ref LL_RTC_BKP_DR6 (*)
  2873.   *         @arg @ref LL_RTC_BKP_DR7 (*)
  2874.   *         @arg @ref LL_RTC_BKP_DR8 (*)
  2875.   *         @arg @ref LL_RTC_BKP_DR9 (*)
  2876.   *         @arg @ref LL_RTC_BKP_DR10 (*)
  2877.   *         @arg @ref LL_RTC_BKP_DR11 (*)
  2878.   *         @arg @ref LL_RTC_BKP_DR12 (*)
  2879.   *         @arg @ref LL_RTC_BKP_DR13 (*)
  2880.   *         @arg @ref LL_RTC_BKP_DR14 (*)
  2881.   *         @arg @ref LL_RTC_BKP_DR15 (*)
  2882.   *         @arg @ref LL_RTC_BKP_DR16 (*)
  2883.   *         @arg @ref LL_RTC_BKP_DR17 (*)
  2884.   *         @arg @ref LL_RTC_BKP_DR18 (*)
  2885.   *         @arg @ref LL_RTC_BKP_DR19 (*)
  2886.   *         @arg @ref LL_RTC_BKP_DR20 (*)
  2887.   *         @arg @ref LL_RTC_BKP_DR21 (*)
  2888.   *         @arg @ref LL_RTC_BKP_DR22 (*)
  2889.   *         @arg @ref LL_RTC_BKP_DR23 (*)
  2890.   *         @arg @ref LL_RTC_BKP_DR24 (*)
  2891.   *         @arg @ref LL_RTC_BKP_DR25 (*)
  2892.   *         @arg @ref LL_RTC_BKP_DR26 (*)
  2893.   *         @arg @ref LL_RTC_BKP_DR27 (*)
  2894.   *         @arg @ref LL_RTC_BKP_DR28 (*)
  2895.   *         @arg @ref LL_RTC_BKP_DR29 (*)
  2896.   *         @arg @ref LL_RTC_BKP_DR30 (*)
  2897.   *         @arg @ref LL_RTC_BKP_DR31 (*)
  2898.   *
  2899.   *         (*) value not applicable to all devices.
  2900.   * @param  Data Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
  2901.   * @retval None
  2902.   */
  2903. __STATIC_INLINE void LL_RTC_BAK_SetRegister(RTC_TypeDef *RTCx, uint32_t BackupRegister, uint32_t Data)
  2904. {
  2905.   uint32_t temp;
  2906.  
  2907.   temp = (uint32_t)(&(RTCx->BKP0R));
  2908.   temp += (BackupRegister * 4U);
  2909.  
  2910.   /* Write the specified register */
  2911.   *(__IO uint32_t *)temp = (uint32_t)Data;
  2912. }
  2913.  
  2914. /**
  2915.   * @brief  Reads data from the specified RTC Backup data Register.
  2916.   * @rmtoll BKPxR        BKP           LL_RTC_BAK_GetRegister
  2917.   * @param  RTCx RTC Instance
  2918.   * @param  BackupRegister This parameter can be one of the following values:
  2919.   *         @arg @ref LL_RTC_BKP_DR0
  2920.   *         @arg @ref LL_RTC_BKP_DR1
  2921.   *         @arg @ref LL_RTC_BKP_DR2
  2922.   *         @arg @ref LL_RTC_BKP_DR3
  2923.   *         @arg @ref LL_RTC_BKP_DR4
  2924.   *         @arg @ref LL_RTC_BKP_DR5 (*)
  2925.   *         @arg @ref LL_RTC_BKP_DR6 (*)
  2926.   *         @arg @ref LL_RTC_BKP_DR7 (*)
  2927.   *         @arg @ref LL_RTC_BKP_DR8 (*)
  2928.   *         @arg @ref LL_RTC_BKP_DR9 (*)
  2929.   *         @arg @ref LL_RTC_BKP_DR10 (*)
  2930.   *         @arg @ref LL_RTC_BKP_DR11 (*)
  2931.   *         @arg @ref LL_RTC_BKP_DR12 (*)
  2932.   *         @arg @ref LL_RTC_BKP_DR13 (*)
  2933.   *         @arg @ref LL_RTC_BKP_DR14 (*)
  2934.   *         @arg @ref LL_RTC_BKP_DR15 (*)
  2935.   *         @arg @ref LL_RTC_BKP_DR16 (*)
  2936.   *         @arg @ref LL_RTC_BKP_DR17 (*)
  2937.   *         @arg @ref LL_RTC_BKP_DR18 (*)
  2938.   *         @arg @ref LL_RTC_BKP_DR19 (*)
  2939.   *         @arg @ref LL_RTC_BKP_DR20 (*)
  2940.   *         @arg @ref LL_RTC_BKP_DR21 (*)
  2941.   *         @arg @ref LL_RTC_BKP_DR22 (*)
  2942.   *         @arg @ref LL_RTC_BKP_DR23 (*)
  2943.   *         @arg @ref LL_RTC_BKP_DR24 (*)
  2944.   *         @arg @ref LL_RTC_BKP_DR25 (*)
  2945.   *         @arg @ref LL_RTC_BKP_DR26 (*)
  2946.   *         @arg @ref LL_RTC_BKP_DR27 (*)
  2947.   *         @arg @ref LL_RTC_BKP_DR28 (*)
  2948.   *         @arg @ref LL_RTC_BKP_DR29 (*)
  2949.   *         @arg @ref LL_RTC_BKP_DR30 (*)
  2950.   *         @arg @ref LL_RTC_BKP_DR31 (*)
  2951.   *
  2952.   *         (*) value not applicable to all devices.
  2953.   * @retval Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
  2954.   */
  2955. __STATIC_INLINE uint32_t LL_RTC_BAK_GetRegister(RTC_TypeDef *RTCx, uint32_t BackupRegister)
  2956. {
  2957.   uint32_t temp;
  2958.  
  2959.   temp = (uint32_t)(&(RTCx->BKP0R));
  2960.   temp += (BackupRegister * 4U);
  2961.  
  2962.   /* Read the specified register */
  2963.   return (*(__IO uint32_t *)temp);
  2964. }
  2965.  
  2966. /**
  2967.   * @}
  2968.   */
  2969.  
  2970. /** @defgroup RTC_LL_EF_Calibration Calibration
  2971.   * @{
  2972.   */
  2973.  
  2974. /**
  2975.   * @brief  Set Calibration output frequency (1 Hz or 512 Hz)
  2976.   * @note Bits are write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2977.   * @rmtoll CR           COE           LL_RTC_CAL_SetOutputFreq\n
  2978.   *         CR           COSEL         LL_RTC_CAL_SetOutputFreq
  2979.   * @param  RTCx RTC Instance
  2980.   * @param  Frequency This parameter can be one of the following values:
  2981.   *         @arg @ref LL_RTC_CALIB_OUTPUT_NONE
  2982.   *         @arg @ref LL_RTC_CALIB_OUTPUT_1HZ (*)
  2983.   *         @arg @ref LL_RTC_CALIB_OUTPUT_512HZ
  2984.   *
  2985.   *         (*) value not applicable to all devices.
  2986.   * @retval None
  2987.   */
  2988. __STATIC_INLINE void LL_RTC_CAL_SetOutputFreq(RTC_TypeDef *RTCx, uint32_t Frequency)
  2989. {
  2990. #if defined(RTC_CR_COSEL)
  2991.   MODIFY_REG(RTCx->CR, RTC_CR_COE | RTC_CR_COSEL, Frequency);
  2992. #else /* RTC_CR_COSEL */
  2993.   MODIFY_REG(RTCx->CR, RTC_CR_COE, Frequency);
  2994. #endif /* RTC_CR_COSEL */
  2995. }
  2996.  
  2997. /**
  2998.   * @brief  Get Calibration output frequency (1 Hz or 512 Hz)
  2999.   * @rmtoll CR           COE           LL_RTC_CAL_GetOutputFreq\n
  3000.   *         CR           COSEL         LL_RTC_CAL_GetOutputFreq
  3001.   * @param  RTCx RTC Instance
  3002.   * @retval Returned value can be one of the following values:
  3003.   *         @arg @ref LL_RTC_CALIB_OUTPUT_NONE
  3004.   *         @arg @ref LL_RTC_CALIB_OUTPUT_1HZ (*)
  3005.   *         @arg @ref LL_RTC_CALIB_OUTPUT_512HZ
  3006.   *
  3007.   *         (*) value not applicable to all devices.
  3008.   */
  3009. __STATIC_INLINE uint32_t LL_RTC_CAL_GetOutputFreq(RTC_TypeDef *RTCx)
  3010. {
  3011. #if defined(RTC_CR_COSEL)
  3012.   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_COE | RTC_CR_COSEL));
  3013. #else /* RTC_CR_COSEL */
  3014.   return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_COE));
  3015. #endif /* RTC_CR_COSEL */
  3016. }
  3017.  
  3018. /**
  3019.   * @brief  Enable Coarse digital calibration
  3020.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3021.   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  3022.   * @rmtoll CR           DCE           LL_RTC_CAL_EnableCoarseDigital
  3023.   * @param  RTCx RTC Instance
  3024.   * @retval None
  3025.   */
  3026. __STATIC_INLINE void LL_RTC_CAL_EnableCoarseDigital(RTC_TypeDef *RTCx)
  3027. {
  3028.   SET_BIT(RTCx->CR, RTC_CR_DCE);
  3029. }
  3030.  
  3031. /**
  3032.   * @brief  Disable Coarse digital calibration
  3033.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3034.   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  3035.   * @rmtoll CR           DCE           LL_RTC_CAL_DisableCoarseDigital
  3036.   * @param  RTCx RTC Instance
  3037.   * @retval None
  3038.   */
  3039. __STATIC_INLINE void LL_RTC_CAL_DisableCoarseDigital(RTC_TypeDef  *RTCx)
  3040. {
  3041.   CLEAR_BIT(RTCx->CR, RTC_CR_DCE);
  3042. }
  3043.  
  3044. /**
  3045.   * @brief  Set the coarse digital calibration
  3046.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3047.   * @note   It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  3048.   * @rmtoll CALIBR       DCS           LL_RTC_CAL_ConfigCoarseDigital\n
  3049.   *         CALIBR       DC            LL_RTC_CAL_ConfigCoarseDigital
  3050.   * @param  RTCx RTC Instance
  3051.   * @param  Sign This parameter can be one of the following values:
  3052.   *         @arg @ref LL_RTC_CALIB_SIGN_POSITIVE
  3053.   *         @arg @ref LL_RTC_CALIB_SIGN_NEGATIVE
  3054.   * @param  Value value of coarse calibration expressed in ppm (coded on 5 bits)
  3055.   * @note   This Calibration value should be between 0 and 63 when using negative sign with a 2-ppm step.
  3056.   * @note   This Calibration value should be between 0 and 126 when using positive sign with a 4-ppm step.
  3057.   * @retval None
  3058.   */
  3059. __STATIC_INLINE void LL_RTC_CAL_ConfigCoarseDigital(RTC_TypeDef *RTCx, uint32_t Sign, uint32_t Value)
  3060. {
  3061.   MODIFY_REG(RTCx->CALIBR, RTC_CALIBR_DCS | RTC_CALIBR_DC, Sign | Value);
  3062. }
  3063.  
  3064. /**
  3065.   * @brief  Get the coarse digital calibration value
  3066.   * @rmtoll CALIBR       DC            LL_RTC_CAL_GetCoarseDigitalValue
  3067.   * @param  RTCx RTC Instance
  3068.   * @retval value of coarse calibration expressed in ppm (coded on 5 bits)
  3069.   */
  3070. __STATIC_INLINE uint32_t LL_RTC_CAL_GetCoarseDigitalValue(RTC_TypeDef *RTCx)
  3071. {
  3072.   return (uint32_t)(READ_BIT(RTCx->CALIBR, RTC_CALIBR_DC));
  3073. }
  3074.  
  3075. /**
  3076.   * @brief  Get the coarse digital calibration sign
  3077.   * @rmtoll CALIBR       DCS           LL_RTC_CAL_GetCoarseDigitalSign
  3078.   * @param  RTCx RTC Instance
  3079.   * @retval Returned value can be one of the following values:
  3080.   *         @arg @ref LL_RTC_CALIB_SIGN_POSITIVE
  3081.   *         @arg @ref LL_RTC_CALIB_SIGN_NEGATIVE
  3082.   */
  3083. __STATIC_INLINE uint32_t LL_RTC_CAL_GetCoarseDigitalSign(RTC_TypeDef *RTCx)
  3084. {
  3085.   return (uint32_t)(READ_BIT(RTCx->CALIBR, RTC_CALIBR_DCS));
  3086. }
  3087.  
  3088. #if defined(RTC_SMOOTHCALIB_SUPPORT)
  3089. /**
  3090.   * @brief  Insert or not One RTCCLK pulse every 2exp11 pulses (frequency increased by 488.5 ppm)
  3091.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3092.   * @note   Bit can be written only when RECALPF is set to 0 in RTC_ISR
  3093.   * @rmtoll CALR         CALP          LL_RTC_CAL_SetPulse
  3094.   * @param  RTCx RTC Instance
  3095.   * @param  Pulse This parameter can be one of the following values:
  3096.   *         @arg @ref LL_RTC_CALIB_INSERTPULSE_NONE
  3097.   *         @arg @ref LL_RTC_CALIB_INSERTPULSE_SET
  3098.   * @retval None
  3099.   */
  3100. __STATIC_INLINE void LL_RTC_CAL_SetPulse(RTC_TypeDef *RTCx, uint32_t Pulse)
  3101. {
  3102.   MODIFY_REG(RTCx->CALR, RTC_CALR_CALP, Pulse);
  3103. }
  3104.  
  3105. /**
  3106.   * @brief  Check if one RTCCLK has been inserted or not every 2exp11 pulses (frequency increased by 488.5 ppm)
  3107.   * @rmtoll CALR         CALP          LL_RTC_CAL_IsPulseInserted
  3108.   * @param  RTCx RTC Instance
  3109.   * @retval State of bit (1 or 0).
  3110.   */
  3111. __STATIC_INLINE uint32_t LL_RTC_CAL_IsPulseInserted(RTC_TypeDef *RTCx)
  3112. {
  3113.   return ((READ_BIT(RTCx->CALR, RTC_CALR_CALP) == (RTC_CALR_CALP)) ? 1UL : 0UL);
  3114. }
  3115.  
  3116. /**
  3117.   * @brief  Set smooth calibration cycle period
  3118.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3119.   * @note   Bit can be written only when RECALPF is set to 0 in RTC_ISR
  3120.   * @rmtoll CALR         CALW8         LL_RTC_CAL_SetPeriod\n
  3121.   *         CALR         CALW16        LL_RTC_CAL_SetPeriod
  3122.   * @param  RTCx RTC Instance
  3123.   * @param  Period This parameter can be one of the following values:
  3124.   *         @arg @ref LL_RTC_CALIB_PERIOD_32SEC
  3125.   *         @arg @ref LL_RTC_CALIB_PERIOD_16SEC
  3126.   *         @arg @ref LL_RTC_CALIB_PERIOD_8SEC
  3127.   * @retval None
  3128.   */
  3129. __STATIC_INLINE void LL_RTC_CAL_SetPeriod(RTC_TypeDef *RTCx, uint32_t Period)
  3130. {
  3131.   MODIFY_REG(RTCx->CALR, RTC_CALR_CALW8 | RTC_CALR_CALW16, Period);
  3132. }
  3133.  
  3134. /**
  3135.   * @brief  Get smooth calibration cycle period
  3136.   * @rmtoll CALR         CALW8         LL_RTC_CAL_GetPeriod\n
  3137.   *         CALR         CALW16        LL_RTC_CAL_GetPeriod
  3138.   * @param  RTCx RTC Instance
  3139.   * @retval Returned value can be one of the following values:
  3140.   *         @arg @ref LL_RTC_CALIB_PERIOD_32SEC
  3141.   *         @arg @ref LL_RTC_CALIB_PERIOD_16SEC
  3142.   *         @arg @ref LL_RTC_CALIB_PERIOD_8SEC
  3143.   */
  3144. __STATIC_INLINE uint32_t LL_RTC_CAL_GetPeriod(RTC_TypeDef *RTCx)
  3145. {
  3146.   return (uint32_t)(READ_BIT(RTCx->CALR, RTC_CALR_CALW8 | RTC_CALR_CALW16));
  3147. }
  3148.  
  3149. /**
  3150.   * @brief  Set smooth Calibration minus
  3151.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3152.   * @note   Bit can be written only when RECALPF is set to 0 in RTC_ISR
  3153.   * @rmtoll CALR         CALM          LL_RTC_CAL_SetMinus
  3154.   * @param  RTCx RTC Instance
  3155.   * @param  CalibMinus Value between Min_Data=0x00 and Max_Data=0x1FF
  3156.   * @retval None
  3157.   */
  3158. __STATIC_INLINE void LL_RTC_CAL_SetMinus(RTC_TypeDef *RTCx, uint32_t CalibMinus)
  3159. {
  3160.   MODIFY_REG(RTCx->CALR, RTC_CALR_CALM, CalibMinus);
  3161. }
  3162.  
  3163. /**
  3164.   * @brief  Get smooth Calibration minus
  3165.   * @rmtoll CALR         CALM          LL_RTC_CAL_GetMinus
  3166.   * @param  RTCx RTC Instance
  3167.   * @retval Value between Min_Data=0x00 and Max_Data= 0x1FF
  3168.   */
  3169. __STATIC_INLINE uint32_t LL_RTC_CAL_GetMinus(RTC_TypeDef *RTCx)
  3170. {
  3171.   return (uint32_t)(READ_BIT(RTCx->CALR, RTC_CALR_CALM));
  3172. }
  3173. #endif /* RTC_SMOOTHCALIB_SUPPORT */
  3174.  
  3175. /**
  3176.   * @}
  3177.   */
  3178.  
  3179. /** @defgroup RTC_LL_EF_FLAG_Management FLAG_Management
  3180.   * @{
  3181.   */
  3182.  
  3183. #if defined(RTC_SMOOTHCALIB_SUPPORT)
  3184. /**
  3185.   * @brief  Get Recalibration pending Flag
  3186.   * @rmtoll ISR          RECALPF       LL_RTC_IsActiveFlag_RECALP
  3187.   * @param  RTCx RTC Instance
  3188.   * @retval State of bit (1 or 0).
  3189.   */
  3190. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RECALP(RTC_TypeDef *RTCx)
  3191. {
  3192.   return ((READ_BIT(RTCx->ISR, RTC_ISR_RECALPF) == (RTC_ISR_RECALPF)) ? 1UL : 0UL);
  3193. }
  3194. #endif /* RTC_SMOOTHCALIB_SUPPORT */
  3195.  
  3196. #if defined(RTC_TAMPER3_SUPPORT)
  3197. /**
  3198.   * @brief  Get RTC_TAMP3 detection flag
  3199.   * @rmtoll ISR          TAMP3F        LL_RTC_IsActiveFlag_TAMP3
  3200.   * @param  RTCx RTC Instance
  3201.   * @retval State of bit (1 or 0).
  3202.   */
  3203. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP3(RTC_TypeDef *RTCx)
  3204. {
  3205.   return ((READ_BIT(RTCx->ISR, RTC_ISR_TAMP3F) == (RTC_ISR_TAMP3F)) ? 1UL : 0UL);
  3206. }
  3207. #endif /* RTC_TAMPER3_SUPPORT */
  3208.  
  3209. #if defined(RTC_TAMPER2_SUPPORT)
  3210. /**
  3211.   * @brief  Get RTC_TAMP2 detection flag
  3212.   * @rmtoll ISR          TAMP2F        LL_RTC_IsActiveFlag_TAMP2
  3213.   * @param  RTCx RTC Instance
  3214.   * @retval State of bit (1 or 0).
  3215.   */
  3216. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP2(RTC_TypeDef *RTCx)
  3217. {
  3218.   return ((READ_BIT(RTCx->ISR, RTC_ISR_TAMP2F) == (RTC_ISR_TAMP2F)) ? 1UL : 0UL);
  3219. }
  3220. #endif /* RTC_TAMPER2_SUPPORT */
  3221.  
  3222. /**
  3223.   * @brief  Get RTC_TAMP1 detection flag
  3224.   * @rmtoll ISR          TAMP1F        LL_RTC_IsActiveFlag_TAMP1
  3225.   * @param  RTCx RTC Instance
  3226.   * @retval State of bit (1 or 0).
  3227.   */
  3228. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP1(RTC_TypeDef *RTCx)
  3229. {
  3230.   return ((READ_BIT(RTCx->ISR, RTC_ISR_TAMP1F) == (RTC_ISR_TAMP1F)) ? 1UL : 0UL);
  3231. }
  3232.  
  3233. /**
  3234.   * @brief  Get Time-stamp overflow flag
  3235.   * @rmtoll ISR          TSOVF         LL_RTC_IsActiveFlag_TSOV
  3236.   * @param  RTCx RTC Instance
  3237.   * @retval State of bit (1 or 0).
  3238.   */
  3239. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TSOV(RTC_TypeDef *RTCx)
  3240. {
  3241.   return ((READ_BIT(RTCx->ISR, RTC_ISR_TSOVF) == (RTC_ISR_TSOVF)) ? 1UL : 0UL);
  3242. }
  3243.  
  3244. /**
  3245.   * @brief  Get Time-stamp flag
  3246.   * @rmtoll ISR          TSF           LL_RTC_IsActiveFlag_TS
  3247.   * @param  RTCx RTC Instance
  3248.   * @retval State of bit (1 or 0).
  3249.   */
  3250. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TS(RTC_TypeDef *RTCx)
  3251. {
  3252.   return ((READ_BIT(RTCx->ISR, RTC_ISR_TSF) == (RTC_ISR_TSF)) ? 1UL : 0UL);
  3253. }
  3254.  
  3255. /**
  3256.   * @brief  Get Wakeup timer flag
  3257.   * @rmtoll ISR          WUTF          LL_RTC_IsActiveFlag_WUT
  3258.   * @param  RTCx RTC Instance
  3259.   * @retval State of bit (1 or 0).
  3260.   */
  3261. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUT(RTC_TypeDef *RTCx)
  3262. {
  3263.   return ((READ_BIT(RTCx->ISR, RTC_ISR_WUTF) == (RTC_ISR_WUTF)) ? 1UL : 0UL);
  3264. }
  3265.  
  3266. /**
  3267.   * @brief  Get Alarm B flag
  3268.   * @rmtoll ISR          ALRBF         LL_RTC_IsActiveFlag_ALRB
  3269.   * @param  RTCx RTC Instance
  3270.   * @retval State of bit (1 or 0).
  3271.   */
  3272. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRB(RTC_TypeDef *RTCx)
  3273. {
  3274.   return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRBF) == (RTC_ISR_ALRBF)) ? 1UL : 0UL);
  3275. }
  3276.  
  3277. /**
  3278.   * @brief  Get Alarm A flag
  3279.   * @rmtoll ISR          ALRAF         LL_RTC_IsActiveFlag_ALRA
  3280.   * @param  RTCx RTC Instance
  3281.   * @retval State of bit (1 or 0).
  3282.   */
  3283. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRA(RTC_TypeDef *RTCx)
  3284. {
  3285.   return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRAF) == (RTC_ISR_ALRAF)) ? 1UL : 0UL);
  3286. }
  3287.  
  3288. #if defined(RTC_TAMPER3_SUPPORT)
  3289. /**
  3290.   * @brief  Clear RTC_TAMP3 detection flag
  3291.   * @rmtoll ISR          TAMP3F        LL_RTC_ClearFlag_TAMP3
  3292.   * @param  RTCx RTC Instance
  3293.   * @retval None
  3294.   */
  3295. __STATIC_INLINE void LL_RTC_ClearFlag_TAMP3(RTC_TypeDef *RTCx)
  3296. {
  3297.   WRITE_REG(RTCx->ISR, (~((RTC_ISR_TAMP3F | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3298. }
  3299. #endif /* RTC_TAMPER3_SUPPORT */
  3300.  
  3301. #if defined(RTC_TAMPER2_SUPPORT)
  3302. /**
  3303.   * @brief  Clear RTC_TAMP2 detection flag
  3304.   * @rmtoll ISR          TAMP2F        LL_RTC_ClearFlag_TAMP2
  3305.   * @param  RTCx RTC Instance
  3306.   * @retval None
  3307.   */
  3308. __STATIC_INLINE void LL_RTC_ClearFlag_TAMP2(RTC_TypeDef *RTCx)
  3309. {
  3310.   WRITE_REG(RTCx->ISR, (~((RTC_ISR_TAMP2F | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3311. }
  3312. #endif /* RTC_TAMPER2_SUPPORT */
  3313.  
  3314. /**
  3315.   * @brief  Clear RTC_TAMP1 detection flag
  3316.   * @rmtoll ISR          TAMP1F        LL_RTC_ClearFlag_TAMP1
  3317.   * @param  RTCx RTC Instance
  3318.   * @retval None
  3319.   */
  3320. __STATIC_INLINE void LL_RTC_ClearFlag_TAMP1(RTC_TypeDef *RTCx)
  3321. {
  3322.   WRITE_REG(RTCx->ISR, (~((RTC_ISR_TAMP1F | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3323. }
  3324.  
  3325. /**
  3326.   * @brief  Clear Time-stamp overflow flag
  3327.   * @rmtoll ISR          TSOVF         LL_RTC_ClearFlag_TSOV
  3328.   * @param  RTCx RTC Instance
  3329.   * @retval None
  3330.   */
  3331. __STATIC_INLINE void LL_RTC_ClearFlag_TSOV(RTC_TypeDef *RTCx)
  3332. {
  3333.   WRITE_REG(RTCx->ISR, (~((RTC_ISR_TSOVF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3334. }
  3335.  
  3336. /**
  3337.   * @brief  Clear Time-stamp flag
  3338.   * @rmtoll ISR          TSF           LL_RTC_ClearFlag_TS
  3339.   * @param  RTCx RTC Instance
  3340.   * @retval None
  3341.   */
  3342. __STATIC_INLINE void LL_RTC_ClearFlag_TS(RTC_TypeDef *RTCx)
  3343. {
  3344.   WRITE_REG(RTCx->ISR, (~((RTC_ISR_TSF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3345. }
  3346.  
  3347. /**
  3348.   * @brief  Clear Wakeup timer flag
  3349.   * @rmtoll ISR          WUTF          LL_RTC_ClearFlag_WUT
  3350.   * @param  RTCx RTC Instance
  3351.   * @retval None
  3352.   */
  3353. __STATIC_INLINE void LL_RTC_ClearFlag_WUT(RTC_TypeDef *RTCx)
  3354. {
  3355.   WRITE_REG(RTCx->ISR, (~((RTC_ISR_WUTF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3356. }
  3357.  
  3358. /**
  3359.   * @brief  Clear Alarm B flag
  3360.   * @rmtoll ISR          ALRBF         LL_RTC_ClearFlag_ALRB
  3361.   * @param  RTCx RTC Instance
  3362.   * @retval None
  3363.   */
  3364. __STATIC_INLINE void LL_RTC_ClearFlag_ALRB(RTC_TypeDef *RTCx)
  3365. {
  3366.   WRITE_REG(RTCx->ISR, (~((RTC_ISR_ALRBF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3367. }
  3368.  
  3369. /**
  3370.   * @brief  Clear Alarm A flag
  3371.   * @rmtoll ISR          ALRAF         LL_RTC_ClearFlag_ALRA
  3372.   * @param  RTCx RTC Instance
  3373.   * @retval None
  3374.   */
  3375. __STATIC_INLINE void LL_RTC_ClearFlag_ALRA(RTC_TypeDef *RTCx)
  3376. {
  3377.   WRITE_REG(RTCx->ISR, (~((RTC_ISR_ALRAF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3378. }
  3379.  
  3380. /**
  3381.   * @brief  Get Initialization flag
  3382.   * @rmtoll ISR          INITF         LL_RTC_IsActiveFlag_INIT
  3383.   * @param  RTCx RTC Instance
  3384.   * @retval State of bit (1 or 0).
  3385.   */
  3386. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INIT(RTC_TypeDef *RTCx)
  3387. {
  3388.   return ((READ_BIT(RTCx->ISR, RTC_ISR_INITF) == (RTC_ISR_INITF)) ? 1UL : 0UL);
  3389. }
  3390.  
  3391. /**
  3392.   * @brief  Get Registers synchronization flag
  3393.   * @rmtoll ISR          RSF           LL_RTC_IsActiveFlag_RS
  3394.   * @param  RTCx RTC Instance
  3395.   * @retval State of bit (1 or 0).
  3396.   */
  3397. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RS(RTC_TypeDef *RTCx)
  3398. {
  3399.   return ((READ_BIT(RTCx->ISR, RTC_ISR_RSF) == (RTC_ISR_RSF)) ? 1UL : 0UL);
  3400. }
  3401.  
  3402. /**
  3403.   * @brief  Clear Registers synchronization flag
  3404.   * @rmtoll ISR          RSF           LL_RTC_ClearFlag_RS
  3405.   * @param  RTCx RTC Instance
  3406.   * @retval None
  3407.   */
  3408. __STATIC_INLINE void LL_RTC_ClearFlag_RS(RTC_TypeDef *RTCx)
  3409. {
  3410.   WRITE_REG(RTCx->ISR, (~((RTC_ISR_RSF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3411. }
  3412.  
  3413. /**
  3414.   * @brief  Get Initialization status flag
  3415.   * @rmtoll ISR          INITS         LL_RTC_IsActiveFlag_INITS
  3416.   * @param  RTCx RTC Instance
  3417.   * @retval State of bit (1 or 0).
  3418.   */
  3419. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INITS(RTC_TypeDef *RTCx)
  3420. {
  3421.   return ((READ_BIT(RTCx->ISR, RTC_ISR_INITS) == (RTC_ISR_INITS)) ? 1UL : 0UL);
  3422. }
  3423.  
  3424. #if defined(RTC_SUBSECOND_SUPPORT)
  3425. /**
  3426.   * @brief  Get Shift operation pending flag
  3427.   * @rmtoll ISR          SHPF          LL_RTC_IsActiveFlag_SHP
  3428.   * @param  RTCx RTC Instance
  3429.   * @retval State of bit (1 or 0).
  3430.   */
  3431. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SHP(RTC_TypeDef *RTCx)
  3432. {
  3433.   return ((READ_BIT(RTCx->ISR, RTC_ISR_SHPF) == (RTC_ISR_SHPF)) ? 1UL : 0UL);
  3434. }
  3435. #endif /* RTC_SUBSECOND_SUPPORT */
  3436.  
  3437. /**
  3438.   * @brief  Get Wakeup timer write flag
  3439.   * @rmtoll ISR          WUTWF         LL_RTC_IsActiveFlag_WUTW
  3440.   * @param  RTCx RTC Instance
  3441.   * @retval State of bit (1 or 0).
  3442.   */
  3443. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUTW(RTC_TypeDef *RTCx)
  3444. {
  3445.   return ((READ_BIT(RTCx->ISR, RTC_ISR_WUTWF) == (RTC_ISR_WUTWF)) ? 1UL : 0UL);
  3446. }
  3447.  
  3448. /**
  3449.   * @brief  Get Alarm B write flag
  3450.   * @rmtoll ISR          ALRBWF        LL_RTC_IsActiveFlag_ALRBW
  3451.   * @param  RTCx RTC Instance
  3452.   * @retval State of bit (1 or 0).
  3453.   */
  3454. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRBW(RTC_TypeDef *RTCx)
  3455. {
  3456.   return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRBWF) == (RTC_ISR_ALRBWF)) ? 1UL : 0UL);
  3457. }
  3458.  
  3459. /**
  3460.   * @brief  Get Alarm A write flag
  3461.   * @rmtoll ISR          ALRAWF        LL_RTC_IsActiveFlag_ALRAW
  3462.   * @param  RTCx RTC Instance
  3463.   * @retval State of bit (1 or 0).
  3464.   */
  3465. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRAW(RTC_TypeDef *RTCx)
  3466. {
  3467.   return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRAWF) == (RTC_ISR_ALRAWF)) ? 1UL : 0UL);
  3468. }
  3469.  
  3470. /**
  3471.   * @}
  3472.   */
  3473.  
  3474. /** @defgroup RTC_LL_EF_IT_Management IT_Management
  3475.   * @{
  3476.   */
  3477.  
  3478. /**
  3479.   * @brief  Enable Time-stamp interrupt
  3480.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3481.   * @rmtoll CR           TSIE          LL_RTC_EnableIT_TS
  3482.   * @param  RTCx RTC Instance
  3483.   * @retval None
  3484.   */
  3485. __STATIC_INLINE void LL_RTC_EnableIT_TS(RTC_TypeDef *RTCx)
  3486. {
  3487.   SET_BIT(RTCx->CR, RTC_CR_TSIE);
  3488. }
  3489.  
  3490. /**
  3491.   * @brief  Disable Time-stamp interrupt
  3492.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3493.   * @rmtoll CR           TSIE          LL_RTC_DisableIT_TS
  3494.   * @param  RTCx RTC Instance
  3495.   * @retval None
  3496.   */
  3497. __STATIC_INLINE void LL_RTC_DisableIT_TS(RTC_TypeDef *RTCx)
  3498. {
  3499.   CLEAR_BIT(RTCx->CR, RTC_CR_TSIE);
  3500. }
  3501.  
  3502. /**
  3503.   * @brief  Enable Wakeup timer interrupt
  3504.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3505.   * @rmtoll CR           WUTIE         LL_RTC_EnableIT_WUT
  3506.   * @param  RTCx RTC Instance
  3507.   * @retval None
  3508.   */
  3509. __STATIC_INLINE void LL_RTC_EnableIT_WUT(RTC_TypeDef *RTCx)
  3510. {
  3511.   SET_BIT(RTCx->CR, RTC_CR_WUTIE);
  3512. }
  3513.  
  3514. /**
  3515.   * @brief  Disable Wakeup timer interrupt
  3516.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3517.   * @rmtoll CR           WUTIE         LL_RTC_DisableIT_WUT
  3518.   * @param  RTCx RTC Instance
  3519.   * @retval None
  3520.   */
  3521. __STATIC_INLINE void LL_RTC_DisableIT_WUT(RTC_TypeDef *RTCx)
  3522. {
  3523.   CLEAR_BIT(RTCx->CR, RTC_CR_WUTIE);
  3524. }
  3525.  
  3526. /**
  3527.   * @brief  Enable Alarm B interrupt
  3528.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3529.   * @rmtoll CR           ALRBIE        LL_RTC_EnableIT_ALRB
  3530.   * @param  RTCx RTC Instance
  3531.   * @retval None
  3532.   */
  3533. __STATIC_INLINE void LL_RTC_EnableIT_ALRB(RTC_TypeDef *RTCx)
  3534. {
  3535.   SET_BIT(RTCx->CR, RTC_CR_ALRBIE);
  3536. }
  3537.  
  3538. /**
  3539.   * @brief  Disable Alarm B interrupt
  3540.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3541.   * @rmtoll CR           ALRBIE        LL_RTC_DisableIT_ALRB
  3542.   * @param  RTCx RTC Instance
  3543.   * @retval None
  3544.   */
  3545. __STATIC_INLINE void LL_RTC_DisableIT_ALRB(RTC_TypeDef *RTCx)
  3546. {
  3547.   CLEAR_BIT(RTCx->CR, RTC_CR_ALRBIE);
  3548. }
  3549.  
  3550. /**
  3551.   * @brief  Enable Alarm A interrupt
  3552.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3553.   * @rmtoll CR           ALRAIE        LL_RTC_EnableIT_ALRA
  3554.   * @param  RTCx RTC Instance
  3555.   * @retval None
  3556.   */
  3557. __STATIC_INLINE void LL_RTC_EnableIT_ALRA(RTC_TypeDef *RTCx)
  3558. {
  3559.   SET_BIT(RTCx->CR, RTC_CR_ALRAIE);
  3560. }
  3561.  
  3562. /**
  3563.   * @brief  Disable Alarm A interrupt
  3564.   * @note   Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3565.   * @rmtoll CR           ALRAIE        LL_RTC_DisableIT_ALRA
  3566.   * @param  RTCx RTC Instance
  3567.   * @retval None
  3568.   */
  3569. __STATIC_INLINE void LL_RTC_DisableIT_ALRA(RTC_TypeDef *RTCx)
  3570. {
  3571.   CLEAR_BIT(RTCx->CR, RTC_CR_ALRAIE);
  3572. }
  3573.  
  3574. /**
  3575.   * @brief  Enable all Tamper Interrupt
  3576.   * @rmtoll TAFCR       TAMPIE        LL_RTC_EnableIT_TAMP
  3577.   * @param  RTCx RTC Instance
  3578.   * @retval None
  3579.   */
  3580. __STATIC_INLINE void LL_RTC_EnableIT_TAMP(RTC_TypeDef *RTCx)
  3581. {
  3582.   SET_BIT(RTCx->TAFCR, RTC_TAFCR_TAMPIE);
  3583. }
  3584.  
  3585. /**
  3586.   * @brief  Disable all Tamper Interrupt
  3587.   * @rmtoll TAFCR       TAMPIE        LL_RTC_DisableIT_TAMP
  3588.   * @param  RTCx RTC Instance
  3589.   * @retval None
  3590.   */
  3591. __STATIC_INLINE void LL_RTC_DisableIT_TAMP(RTC_TypeDef *RTCx)
  3592. {
  3593.   CLEAR_BIT(RTCx->TAFCR, RTC_TAFCR_TAMPIE);
  3594. }
  3595.  
  3596. /**
  3597.   * @brief  Check if  Time-stamp interrupt is enabled or not
  3598.   * @rmtoll CR           TSIE          LL_RTC_IsEnabledIT_TS
  3599.   * @param  RTCx RTC Instance
  3600.   * @retval State of bit (1 or 0).
  3601.   */
  3602. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TS(RTC_TypeDef *RTCx)
  3603. {
  3604.   return ((READ_BIT(RTCx->CR, RTC_CR_TSIE) == (RTC_CR_TSIE)) ? 1UL : 0UL);
  3605. }
  3606.  
  3607. /**
  3608.   * @brief  Check if  Wakeup timer interrupt is enabled or not
  3609.   * @rmtoll CR           WUTIE         LL_RTC_IsEnabledIT_WUT
  3610.   * @param  RTCx RTC Instance
  3611.   * @retval State of bit (1 or 0).
  3612.   */
  3613. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_WUT(RTC_TypeDef *RTCx)
  3614. {
  3615.   return ((READ_BIT(RTCx->CR, RTC_CR_WUTIE) == (RTC_CR_WUTIE)) ? 1UL : 0UL);
  3616. }
  3617.  
  3618. /**
  3619.   * @brief  Check if  Alarm B interrupt is enabled or not
  3620.   * @rmtoll CR           ALRBIE        LL_RTC_IsEnabledIT_ALRB
  3621.   * @param  RTCx RTC Instance
  3622.   * @retval State of bit (1 or 0).
  3623.   */
  3624. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALRB(RTC_TypeDef *RTCx)
  3625. {
  3626.   return ((READ_BIT(RTCx->CR, RTC_CR_ALRBIE) == (RTC_CR_ALRBIE)) ? 1UL : 0UL);
  3627. }
  3628.  
  3629. /**
  3630.   * @brief  Check if  Alarm A interrupt is enabled or not
  3631.   * @rmtoll CR           ALRAIE        LL_RTC_IsEnabledIT_ALRA
  3632.   * @param  RTCx RTC Instance
  3633.   * @retval State of bit (1 or 0).
  3634.   */
  3635. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALRA(RTC_TypeDef *RTCx)
  3636. {
  3637.   return ((READ_BIT(RTCx->CR, RTC_CR_ALRAIE) == (RTC_CR_ALRAIE)) ? 1UL : 0UL);
  3638. }
  3639.  
  3640. /**
  3641.   * @brief  Check if all the TAMPER interrupts are enabled or not
  3642.   * @rmtoll TAFCR       TAMPIE        LL_RTC_IsEnabledIT_TAMP
  3643.   * @param  RTCx RTC Instance
  3644.   * @retval State of bit (1 or 0).
  3645.   */
  3646. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP(RTC_TypeDef *RTCx)
  3647. {
  3648.   return ((READ_BIT(RTCx->TAFCR,
  3649.                     RTC_TAFCR_TAMPIE) == (RTC_TAFCR_TAMPIE)) ? 1UL : 0UL);
  3650. }
  3651.  
  3652. /**
  3653.   * @}
  3654.   */
  3655.  
  3656. #if defined(USE_FULL_LL_DRIVER)
  3657. /** @defgroup RTC_LL_EF_Init Initialization and de-initialization functions
  3658.   * @{
  3659.   */
  3660.  
  3661. ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx);
  3662. ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct);
  3663. void        LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct);
  3664. ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct);
  3665. void        LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct);
  3666. ErrorStatus LL_RTC_DATE_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_DateTypeDef *RTC_DateStruct);
  3667. void        LL_RTC_DATE_StructInit(LL_RTC_DateTypeDef *RTC_DateStruct);
  3668. ErrorStatus LL_RTC_ALMA_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
  3669. ErrorStatus LL_RTC_ALMB_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
  3670. void        LL_RTC_ALMA_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
  3671. void        LL_RTC_ALMB_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
  3672. ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx);
  3673. ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx);
  3674. ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx);
  3675.  
  3676. /**
  3677.   * @}
  3678.   */
  3679. #endif /* USE_FULL_LL_DRIVER */
  3680.  
  3681. /**
  3682.   * @}
  3683.   */
  3684.  
  3685. /**
  3686.   * @}
  3687.   */
  3688.  
  3689. #endif /* defined(RTC) */
  3690.  
  3691. /**
  3692.   * @}
  3693.   */
  3694.  
  3695. #ifdef __cplusplus
  3696. }
  3697. #endif
  3698.  
  3699. #endif /* STM32L1xx_LL_RTC_H */
  3700.