You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

5379 lines
193 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_ll_rtc.h
  4. * @author MCD Application Team
  5. * @brief Header file of RTC LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32H7xx_LL_RTC_H
  21. #define STM32H7xx_LL_RTC_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32h7xx.h"
  27. /** @addtogroup STM32H7xx_LL_Driver
  28. * @{
  29. */
  30. #if defined(RTC)
  31. /** @defgroup RTC_LL RTC
  32. * @{
  33. */
  34. /* Private types -------------------------------------------------------------*/
  35. /* Private variables ---------------------------------------------------------*/
  36. /* Private constants ---------------------------------------------------------*/
  37. /** @defgroup RTC_LL_Private_Constants RTC Private Constants
  38. * @{
  39. */
  40. /* Masks Definition */
  41. #define RTC_LL_INIT_MASK 0xFFFFFFFFU
  42. #define RTC_LL_RSF_MASK 0xFFFFFF5FU
  43. /* Write protection defines */
  44. #define RTC_WRITE_PROTECTION_DISABLE 0xFFU
  45. #define RTC_WRITE_PROTECTION_ENABLE_1 0xCAU
  46. #define RTC_WRITE_PROTECTION_ENABLE_2 0x53U
  47. /* Defines used to combine date & time */
  48. #define RTC_OFFSET_WEEKDAY 24U
  49. #define RTC_OFFSET_DAY 16U
  50. #define RTC_OFFSET_MONTH 8U
  51. #define RTC_OFFSET_HOUR 16U
  52. #define RTC_OFFSET_MINUTE 8U
  53. /**
  54. * @}
  55. */
  56. /* Private macros ------------------------------------------------------------*/
  57. #if defined(USE_FULL_LL_DRIVER)
  58. /** @defgroup RTC_LL_Private_Macros RTC Private Macros
  59. * @{
  60. */
  61. /**
  62. * @}
  63. */
  64. #endif /*USE_FULL_LL_DRIVER*/
  65. /* Exported types ------------------------------------------------------------*/
  66. #if defined(USE_FULL_LL_DRIVER)
  67. /** @defgroup RTC_LL_ES_INIT RTC Exported Init structure
  68. * @{
  69. */
  70. /**
  71. * @brief RTC Init structures definition
  72. */
  73. typedef struct
  74. {
  75. uint32_t HourFormat; /*!< Specifies the RTC Hours Format.
  76. This parameter can be a value of @ref RTC_LL_EC_HOURFORMAT
  77. This feature can be modified afterwards using unitary function
  78. @ref LL_RTC_SetHourFormat(). */
  79. uint32_t AsynchPrescaler; /*!< Specifies the RTC Asynchronous Predivider value.
  80. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F
  81. This feature can be modified afterwards using unitary function
  82. @ref LL_RTC_SetAsynchPrescaler(). */
  83. uint32_t SynchPrescaler; /*!< Specifies the RTC Synchronous Predivider value.
  84. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF
  85. This feature can be modified afterwards using unitary function
  86. @ref LL_RTC_SetSynchPrescaler(). */
  87. } LL_RTC_InitTypeDef;
  88. /**
  89. * @brief RTC Time structure definition
  90. */
  91. typedef struct
  92. {
  93. uint32_t TimeFormat; /*!< Specifies the RTC AM/PM Time.
  94. This parameter can be a value of @ref RTC_LL_EC_TIME_FORMAT
  95. This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetFormat(). */
  96. uint8_t Hours; /*!< Specifies the RTC Time Hours.
  97. This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the @ref LL_RTC_TIME_FORMAT_PM is selected.
  98. 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.
  99. This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetHour(). */
  100. uint8_t Minutes; /*!< Specifies the RTC Time Minutes.
  101. This parameter must be a number between Min_Data = 0 and Max_Data = 59
  102. This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetMinute(). */
  103. uint8_t Seconds; /*!< Specifies the RTC Time Seconds.
  104. This parameter must be a number between Min_Data = 0 and Max_Data = 59
  105. This feature can be modified afterwards using unitary function @ref LL_RTC_TIME_SetSecond(). */
  106. } LL_RTC_TimeTypeDef;
  107. /**
  108. * @brief RTC Date structure definition
  109. */
  110. typedef struct
  111. {
  112. uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay.
  113. This parameter can be a value of @ref RTC_LL_EC_WEEKDAY
  114. This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetWeekDay(). */
  115. uint8_t Month; /*!< Specifies the RTC Date Month.
  116. This parameter can be a value of @ref RTC_LL_EC_MONTH
  117. This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetMonth(). */
  118. uint8_t Day; /*!< Specifies the RTC Date Day.
  119. This parameter must be a number between Min_Data = 1 and Max_Data = 31
  120. This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetDay(). */
  121. uint8_t Year; /*!< Specifies the RTC Date Year.
  122. This parameter must be a number between Min_Data = 0 and Max_Data = 99
  123. This feature can be modified afterwards using unitary function @ref LL_RTC_DATE_SetYear(). */
  124. } LL_RTC_DateTypeDef;
  125. /**
  126. * @brief RTC Alarm structure definition
  127. */
  128. typedef struct
  129. {
  130. LL_RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members. */
  131. uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks.
  132. 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.
  133. This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetMask() for ALARM A
  134. or @ref LL_RTC_ALMB_SetMask() for ALARM B
  135. */
  136. uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on day or WeekDay.
  137. 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
  138. This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_EnableWeekday() or @ref LL_RTC_ALMA_DisableWeekday()
  139. for ALARM A or @ref LL_RTC_ALMB_EnableWeekday() or @ref LL_RTC_ALMB_DisableWeekday() for ALARM B
  140. */
  141. uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Day/WeekDay.
  142. If AlarmDateWeekDaySel set to day, this parameter must be a number between Min_Data = 1 and Max_Data = 31.
  143. This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetDay()
  144. for ALARM A or @ref LL_RTC_ALMB_SetDay() for ALARM B.
  145. If AlarmDateWeekDaySel set to Weekday, this parameter can be a value of @ref RTC_LL_EC_WEEKDAY.
  146. This feature can be modified afterwards using unitary function @ref LL_RTC_ALMA_SetWeekDay()
  147. for ALARM A or @ref LL_RTC_ALMB_SetWeekDay() for ALARM B.
  148. */
  149. } LL_RTC_AlarmTypeDef;
  150. /**
  151. * @}
  152. */
  153. #endif /* USE_FULL_LL_DRIVER */
  154. /* Exported constants --------------------------------------------------------*/
  155. /** @defgroup RTC_LL_Exported_Constants RTC Exported Constants
  156. * @{
  157. */
  158. #if defined(USE_FULL_LL_DRIVER)
  159. /** @defgroup RTC_LL_EC_FORMAT FORMAT
  160. * @{
  161. */
  162. #define LL_RTC_FORMAT_BIN 0x00000000U /*!< Binary data format */
  163. #define LL_RTC_FORMAT_BCD 0x00000001U /*!< BCD data format */
  164. /**
  165. * @}
  166. */
  167. /** @defgroup RTC_LL_EC_ALMA_WEEKDAY_SELECTION RTC Alarm A Date WeekDay
  168. * @{
  169. */
  170. #define LL_RTC_ALMA_DATEWEEKDAYSEL_DATE 0x00000000U /*!< Alarm A Date is selected */
  171. #define LL_RTC_ALMA_DATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL /*!< Alarm A WeekDay is selected */
  172. /**
  173. * @}
  174. */
  175. /** @defgroup RTC_LL_EC_ALMB_WEEKDAY_SELECTION RTC Alarm B Date WeekDay
  176. * @{
  177. */
  178. #define LL_RTC_ALMB_DATEWEEKDAYSEL_DATE 0x00000000U /*!< Alarm B Date is selected */
  179. #define LL_RTC_ALMB_DATEWEEKDAYSEL_WEEKDAY RTC_ALRMBR_WDSEL /*!< Alarm B WeekDay is selected */
  180. /**
  181. * @}
  182. */
  183. #endif /* USE_FULL_LL_DRIVER */
  184. /** @defgroup RTC_LL_EC_GET_FLAG Get Flags Defines
  185. * @brief Flags defines which can be used with LL_RTC_ReadReg function
  186. * @{
  187. */
  188. #if defined(RTC_SCR_CALRAF)
  189. #define LL_RTC_SCR_ITSF RTC_SCR_CITSF
  190. #define LL_RTC_SCR_TSOVF RTC_SCR_CTSOVF
  191. #define LL_RTC_SCR_TSF RTC_SCR_CTSF
  192. #define LL_RTC_SCR_WUTF RTC_SCR_CWUTF
  193. #define LL_RTC_SCR_ALRBF RTC_SCR_CALRBF
  194. #define LL_RTC_SCR_ALRAF RTC_SCR_CALRAF
  195. #endif /* RTC_SCR_CALRAF */
  196. #if defined(RTC_ICSR_ALRAWF)
  197. #define LL_RTC_ICSR_RECALPF RTC_ICSR_RECALPF
  198. #define LL_RTC_ICSR_INITF RTC_ICSR_INITF
  199. #define LL_RTC_ICSR_RSF RTC_ICSR_RSF
  200. #define LL_RTC_ICSR_INITS RTC_ICSR_INITS
  201. #define LL_RTC_ICSR_SHPF RTC_ICSR_SHPF
  202. #define LL_RTC_ICSR_WUTWF RTC_ICSR_WUTWF
  203. #endif /* RTC_ICSR_ALRAWF */
  204. #if defined(RTC_ISR_ALRAWF)
  205. #define LL_RTC_ISR_ITSF RTC_ISR_ITSF
  206. #define LL_RTC_ISR_RECALPF RTC_ISR_RECALPF
  207. #define LL_RTC_ISR_TAMP3F RTC_ISR_TAMP3F
  208. #define LL_RTC_ISR_TAMP2F RTC_ISR_TAMP2F
  209. #define LL_RTC_ISR_TAMP1F RTC_ISR_TAMP1F
  210. #define LL_RTC_ISR_TSOVF RTC_ISR_TSOVF
  211. #define LL_RTC_ISR_TSF RTC_ISR_TSF
  212. #define LL_RTC_ISR_WUTF RTC_ISR_WUTF
  213. #define LL_RTC_ISR_ALRBF RTC_ISR_ALRBF
  214. #define LL_RTC_ISR_ALRAF RTC_ISR_ALRAF
  215. #define LL_RTC_ISR_INITF RTC_ISR_INITF
  216. #define LL_RTC_ISR_RSF RTC_ISR_RSF
  217. #define LL_RTC_ISR_INITS RTC_ISR_INITS
  218. #define LL_RTC_ISR_SHPF RTC_ISR_SHPF
  219. #define LL_RTC_ISR_WUTWF RTC_ISR_WUTWF
  220. #define LL_RTC_ISR_ALRBWF RTC_ISR_ALRBWF
  221. #define LL_RTC_ISR_ALRAWF RTC_ISR_ALRAWF
  222. #endif /* RTC_ISR_ALRAWF */
  223. /**
  224. * @}
  225. */
  226. /** @defgroup RTC_LL_EC_IT IT Defines
  227. * @brief IT defines which can be used with LL_RTC_ReadReg and LL_RTC_WriteReg functions
  228. * @{
  229. */
  230. #define LL_RTC_CR_TSIE RTC_CR_TSIE
  231. #define LL_RTC_CR_WUTIE RTC_CR_WUTIE
  232. #define LL_RTC_CR_ALRBIE RTC_CR_ALRBIE
  233. #define LL_RTC_CR_ALRAIE RTC_CR_ALRAIE
  234. #if defined(RTC_TAMPCR_TAMP3E)
  235. #define LL_RTC_TAMPCR_TAMP3IE RTC_TAMPCR_TAMP3IE
  236. #endif /* RTC_TAMPCR_TAMP3E */
  237. #if defined(RTC_TAMPCR_TAMP2E)
  238. #define LL_RTC_TAMPCR_TAMP2IE RTC_TAMPCR_TAMP2IE
  239. #endif /* RTC_TAMPCR_TAMP2E */
  240. #if defined(RTC_TAMPCR_TAMP1E)
  241. #define LL_RTC_TAMPCR_TAMP1IE RTC_TAMPCR_TAMP1IE
  242. #endif /* RTC_TAMPCR_TAMP1E */
  243. #if defined(RTC_TAMPCR_TAMPIE)
  244. #define LL_RTC_TAMPCR_TAMPIE RTC_TAMPCR_TAMPIE
  245. #endif /* RTC_TAMPCR_TAMPIE */
  246. /**
  247. * @}
  248. */
  249. /** @defgroup RTC_LL_EC_WEEKDAY WEEK DAY
  250. * @{
  251. */
  252. #define LL_RTC_WEEKDAY_MONDAY (uint8_t)0x01 /*!< Monday */
  253. #define LL_RTC_WEEKDAY_TUESDAY (uint8_t)0x02 /*!< Tuesday */
  254. #define LL_RTC_WEEKDAY_WEDNESDAY (uint8_t)0x03 /*!< Wednesday */
  255. #define LL_RTC_WEEKDAY_THURSDAY (uint8_t)0x04 /*!< Thrusday */
  256. #define LL_RTC_WEEKDAY_FRIDAY (uint8_t)0x05 /*!< Friday */
  257. #define LL_RTC_WEEKDAY_SATURDAY (uint8_t)0x06 /*!< Saturday */
  258. #define LL_RTC_WEEKDAY_SUNDAY (uint8_t)0x07 /*!< Sunday */
  259. /**
  260. * @}
  261. */
  262. /** @defgroup RTC_LL_EC_MONTH MONTH
  263. * @{
  264. */
  265. #define LL_RTC_MONTH_JANUARY (uint8_t)0x01 /*!< January */
  266. #define LL_RTC_MONTH_FEBRUARY (uint8_t)0x02 /*!< February */
  267. #define LL_RTC_MONTH_MARCH (uint8_t)0x03 /*!< March */
  268. #define LL_RTC_MONTH_APRIL (uint8_t)0x04 /*!< April */
  269. #define LL_RTC_MONTH_MAY (uint8_t)0x05 /*!< May */
  270. #define LL_RTC_MONTH_JUNE (uint8_t)0x06 /*!< June */
  271. #define LL_RTC_MONTH_JULY (uint8_t)0x07 /*!< July */
  272. #define LL_RTC_MONTH_AUGUST (uint8_t)0x08 /*!< August */
  273. #define LL_RTC_MONTH_SEPTEMBER (uint8_t)0x09 /*!< September */
  274. #define LL_RTC_MONTH_OCTOBER (uint8_t)0x10 /*!< October */
  275. #define LL_RTC_MONTH_NOVEMBER (uint8_t)0x11 /*!< November */
  276. #define LL_RTC_MONTH_DECEMBER (uint8_t)0x12 /*!< December */
  277. /**
  278. * @}
  279. */
  280. /** @defgroup RTC_LL_EC_HOURFORMAT HOUR FORMAT
  281. * @{
  282. */
  283. #define LL_RTC_HOURFORMAT_24HOUR 0x00000000U /*!< 24 hour/day format */
  284. #define LL_RTC_HOURFORMAT_AMPM RTC_CR_FMT /*!< AM/PM hour format */
  285. /**
  286. * @}
  287. */
  288. /** @defgroup RTC_LL_EC_ALARMOUT ALARM OUTPUT
  289. * @{
  290. */
  291. #define LL_RTC_ALARMOUT_DISABLE 0x00000000U /*!< Output disabled */
  292. #define LL_RTC_ALARMOUT_ALMA RTC_CR_OSEL_0 /*!< Alarm A output enabled */
  293. #define LL_RTC_ALARMOUT_ALMB RTC_CR_OSEL_1 /*!< Alarm B output enabled */
  294. #define LL_RTC_ALARMOUT_WAKEUP RTC_CR_OSEL /*!< Wakeup output enabled */
  295. /**
  296. * @}
  297. */
  298. /** @defgroup RTC_LL_EC_ALARM_OUTPUTTYPE ALARM OUTPUT TYPE
  299. * @{
  300. */
  301. #if defined(RTC_CR_TAMPALRM_TYPE)
  302. #define LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN RTC_CR_TAMPALRM_TYPE /*!< RTC_ALARM is open-drain output */
  303. #define LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL 0x00000000U /*!< RTC_ALARM is push-pull output */
  304. #endif /* RTC_CR_TAMPALRM_TYPE */
  305. #if defined(RTC_OR_ALARMOUTTYPE)
  306. #define LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN 0x00000000U /*!< RTC_ALARM, when mapped on PC13, is open-drain output */
  307. #define LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL RTC_OR_ALARMOUTTYPE /*!< RTC_ALARM, when mapped on PC13, is push-pull output */
  308. #endif /* RTC_OR_ALARMOUTTYPE */
  309. /**
  310. * @}
  311. */
  312. /** @defgroup RTC_LL_EC_OUTPUTPOLARITY_PIN OUTPUT POLARITY PIN
  313. * @{
  314. */
  315. #define LL_RTC_OUTPUTPOLARITY_PIN_HIGH 0x00000000U /*!< Pin is high when ALRAF/ALRBF/WUTF is asserted (depending on OSEL)*/
  316. #define LL_RTC_OUTPUTPOLARITY_PIN_LOW RTC_CR_POL /*!< Pin is low when ALRAF/ALRBF/WUTF is asserted (depending on OSEL) */
  317. /**
  318. * @}
  319. */
  320. /** @defgroup RTC_LL_EC_TIME_FORMAT TIME FORMAT
  321. * @{
  322. */
  323. #define LL_RTC_TIME_FORMAT_AM_OR_24 0x00000000U /*!< AM or 24-hour format */
  324. #define LL_RTC_TIME_FORMAT_PM RTC_TR_PM /*!< PM */
  325. /**
  326. * @}
  327. */
  328. /** @defgroup RTC_LL_EC_SHIFT_SECOND SHIFT SECOND
  329. * @{
  330. */
  331. #define LL_RTC_SHIFT_SECOND_DELAY 0x00000000U /* Delay (seconds) = SUBFS / (PREDIV_S + 1) */
  332. #define LL_RTC_SHIFT_SECOND_ADVANCE RTC_SHIFTR_ADD1S /* Advance (seconds) = (1 - (SUBFS / (PREDIV_S + 1))) */
  333. /**
  334. * @}
  335. */
  336. /** @defgroup RTC_LL_EC_ALMA_MASK ALARMA MASK
  337. * @{
  338. */
  339. #define LL_RTC_ALMA_MASK_NONE 0x00000000U /*!< No masks applied on Alarm A*/
  340. #define LL_RTC_ALMA_MASK_DATEWEEKDAY RTC_ALRMAR_MSK4 /*!< Date/day do not care in Alarm A comparison */
  341. #define LL_RTC_ALMA_MASK_HOURS RTC_ALRMAR_MSK3 /*!< Hours do not care in Alarm A comparison */
  342. #define LL_RTC_ALMA_MASK_MINUTES RTC_ALRMAR_MSK2 /*!< Minutes do not care in Alarm A comparison */
  343. #define LL_RTC_ALMA_MASK_SECONDS RTC_ALRMAR_MSK1 /*!< Seconds do not care in Alarm A comparison */
  344. #define LL_RTC_ALMA_MASK_ALL (RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1) /*!< Masks all */
  345. /**
  346. * @}
  347. */
  348. /** @defgroup RTC_LL_EC_ALMA_TIME_FORMAT ALARMA TIME FORMAT
  349. * @{
  350. */
  351. #define LL_RTC_ALMA_TIME_FORMAT_AM 0x00000000U /*!< AM or 24-hour format */
  352. #define LL_RTC_ALMA_TIME_FORMAT_PM RTC_ALRMAR_PM /*!< PM */
  353. /**
  354. * @}
  355. */
  356. /** @defgroup RTC_LL_EC_ALMB_MASK ALARMB MASK
  357. * @{
  358. */
  359. #define LL_RTC_ALMB_MASK_NONE 0x00000000U /*!< No masks applied on Alarm B*/
  360. #define LL_RTC_ALMB_MASK_DATEWEEKDAY RTC_ALRMBR_MSK4 /*!< Date/day do not care in Alarm B comparison */
  361. #define LL_RTC_ALMB_MASK_HOURS RTC_ALRMBR_MSK3 /*!< Hours do not care in Alarm B comparison */
  362. #define LL_RTC_ALMB_MASK_MINUTES RTC_ALRMBR_MSK2 /*!< Minutes do not care in Alarm B comparison */
  363. #define LL_RTC_ALMB_MASK_SECONDS RTC_ALRMBR_MSK1 /*!< Seconds do not care in Alarm B comparison */
  364. #define LL_RTC_ALMB_MASK_ALL (RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1) /*!< Masks all */
  365. /**
  366. * @}
  367. */
  368. /** @defgroup RTC_LL_EC_ALMB_TIME_FORMAT ALARMB TIME FORMAT
  369. * @{
  370. */
  371. #define LL_RTC_ALMB_TIME_FORMAT_AM 0x00000000U /*!< AM or 24-hour format */
  372. #define LL_RTC_ALMB_TIME_FORMAT_PM RTC_ALRMBR_PM /*!< PM */
  373. /**
  374. * @}
  375. */
  376. /** @defgroup RTC_LL_EC_TIMESTAMP_EDGE TIMESTAMP EDGE
  377. * @{
  378. */
  379. #define LL_RTC_TIMESTAMP_EDGE_RISING 0x00000000U /*!< RTC_TS input rising edge generates a time-stamp event */
  380. #define LL_RTC_TIMESTAMP_EDGE_FALLING RTC_CR_TSEDGE /*!< RTC_TS input falling edge generates a time-stamp even */
  381. /**
  382. * @}
  383. */
  384. /** @defgroup RTC_LL_EC_TS_TIME_FORMAT TIMESTAMP TIME FORMAT
  385. * @{
  386. */
  387. #define LL_RTC_TS_TIME_FORMAT_AM 0x00000000U /*!< AM or 24-hour format */
  388. #define LL_RTC_TS_TIME_FORMAT_PM RTC_TSTR_PM /*!< PM */
  389. /**
  390. * @}
  391. */
  392. #if defined(TAMP_CR1_TAMP1E)
  393. /** @defgroup RTC_LL_EC_TAMPER TAMPER
  394. * @{
  395. */
  396. #define LL_RTC_TAMPER_1 TAMP_CR1_TAMP1E /*!< Tamper 1 input detection */
  397. #endif /* TAMP_CR1_TAMP1E */
  398. #if defined(TAMP_CR1_TAMP2E)
  399. #define LL_RTC_TAMPER_2 TAMP_CR1_TAMP2E /*!< Tamper 2 input detection */
  400. #endif /* TAMP_CR1_TAMP2E */
  401. #if defined(TAMP_CR1_TAMP3E)
  402. #define LL_RTC_TAMPER_3 TAMP_CR1_TAMP3E /*!< Tamper 3 input detection */
  403. #endif /* TAMP_CR1_TAMP3E */
  404. /**
  405. * @}
  406. */
  407. #if defined(TAMP_CR1_TAMP1E)
  408. /** @defgroup RTC_LL_EC_TAMPER_MASK TAMPER MASK
  409. * @{
  410. */
  411. #define LL_RTC_TAMPER_MASK_TAMPER1 TAMP_CR2_TAMP1MSK /*!< Tamper 1 event generates a trigger event. TAMP1F is masked and internally cleared by hardware. The backup registers are not erased */
  412. #endif /* TAMP_CR1_TAMP1E */
  413. #if defined(TAMP_CR1_TAMP2E)
  414. #define LL_RTC_TAMPER_MASK_TAMPER2 TAMP_CR2_TAMP2MSK /*!< Tamper 2 event generates a trigger event. TAMP2F is masked and internally cleared by hardware. The backup registers are not erased. */
  415. #endif /* TAMP_CR1_TAMP2E */
  416. #if defined(TAMP_CR1_TAMP3E)
  417. #define LL_RTC_TAMPER_MASK_TAMPER3 TAMP_CR2_TAMP3MSK /*!< Tamper 3 event generates a trigger event. TAMP3F is masked and internally cleared by hardware. The backup registers are not erased. */
  418. #endif /* TAMP_CR1_TAMP3E */
  419. /**
  420. * @}
  421. */
  422. #if defined(TAMP_CR1_TAMP1E)
  423. /** @defgroup RTC_LL_EC_TAMPER_NOERASE TAMPER NO ERASE
  424. * @{
  425. */
  426. #define LL_RTC_TAMPER_NOERASE_TAMPER1 TAMP_CR2_TAMP1NOERASE /*!< Tamper 1 event does not erase the backup registers. */
  427. #endif /* TAMP_CR1_TAMP1E */
  428. #if defined(TAMP_CR1_TAMP2E)
  429. #define LL_RTC_TAMPER_NOERASE_TAMPER2 TAMP_CR2_TAMP2NOERASE /*!< Tamper 2 event does not erase the backup registers. */
  430. #endif /* TAMP_CR1_TAMP2E */
  431. #if defined(TAMP_CR1_TAMP3E)
  432. #define LL_RTC_TAMPER_NOERASE_TAMPER3 TAMP_CR2_TAMP3NOERASE /*!< Tamper 3 event does not erase the backup registers. */
  433. #endif /* TAMP_CR1_TAMP3E */
  434. /**
  435. * @}
  436. */
  437. #if defined(TAMP_FLTCR_TAMPPRCH)
  438. /** @defgroup RTC_LL_EC_TAMPER_DURATION TAMPER DURATION
  439. * @{
  440. */
  441. #define LL_RTC_TAMPER_DURATION_1RTCCLK 0x00000000U /*!< Tamper pins are pre-charged before sampling during 1 RTCCLK cycle */
  442. #define LL_RTC_TAMPER_DURATION_2RTCCLK TAMP_FLTCR_TAMPPRCH_0 /*!< Tamper pins are pre-charged before sampling during 2 RTCCLK cycles */
  443. #define LL_RTC_TAMPER_DURATION_4RTCCLK TAMP_FLTCR_TAMPPRCH_1 /*!< Tamper pins are pre-charged before sampling during 4 RTCCLK cycles */
  444. #define LL_RTC_TAMPER_DURATION_8RTCCLK TAMP_FLTCR_TAMPPRCH /*!< Tamper pins are pre-charged before sampling during 8 RTCCLK cycles */
  445. /**
  446. * @}
  447. */
  448. #endif /* TAMP_FLTCR_TAMPPRCH */
  449. #if defined(TAMP_FLTCR_TAMPFLT)
  450. /** @defgroup RTC_LL_EC_TAMPER_FILTER TAMPER FILTER
  451. * @{
  452. */
  453. #define LL_RTC_TAMPER_FILTER_DISABLE 0x00000000U /*!< Tamper filter is disabled */
  454. #define LL_RTC_TAMPER_FILTER_2SAMPLE TAMP_FLTCR_TAMPFLT_0 /*!< Tamper is activated after 2 consecutive samples at the active level */
  455. #define LL_RTC_TAMPER_FILTER_4SAMPLE TAMP_FLTCR_TAMPFLT_1 /*!< Tamper is activated after 4 consecutive samples at the active level */
  456. #define LL_RTC_TAMPER_FILTER_8SAMPLE TAMP_FLTCR_TAMPFLT /*!< Tamper is activated after 8 consecutive samples at the active level. */
  457. /**
  458. * @}
  459. */
  460. #endif /* TAMP_FLTCR_TAMPFLT */
  461. #if defined(TAMP_FLTCR_TAMPFREQ)
  462. /** @defgroup RTC_LL_EC_TAMPER_SAMPLFREQDIV TAMPER SAMPLING FREQUENCY DIVIDER
  463. * @{
  464. */
  465. #define LL_RTC_TAMPER_SAMPLFREQDIV_32768 0x00000000U /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 32768 */
  466. #define LL_RTC_TAMPER_SAMPLFREQDIV_16384 TAMP_FLTCR_TAMPFREQ_0 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 16384 */
  467. #define LL_RTC_TAMPER_SAMPLFREQDIV_8192 TAMP_FLTCR_TAMPFREQ_1 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 8192 */
  468. #define LL_RTC_TAMPER_SAMPLFREQDIV_4096 (TAMP_FLTCR_TAMPFREQ_1 | TAMP_FLTCR_TAMPFREQ_0) /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 4096 */
  469. #define LL_RTC_TAMPER_SAMPLFREQDIV_2048 TAMP_FLTCR_TAMPFREQ_2 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 2048 */
  470. #define LL_RTC_TAMPER_SAMPLFREQDIV_1024 (TAMP_FLTCR_TAMPFREQ_2 | TAMP_FLTCR_TAMPFREQ_0) /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 1024 */
  471. #define LL_RTC_TAMPER_SAMPLFREQDIV_512 (TAMP_FLTCR_TAMPFREQ_2 | TAMP_FLTCR_TAMPFREQ_1) /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 512 */
  472. #define LL_RTC_TAMPER_SAMPLFREQDIV_256 TAMP_FLTCR_TAMPFREQ /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 256 */
  473. /**
  474. * @}
  475. */
  476. #endif /* TAMP_FLTCR_TAMPFREQ */
  477. #if defined(TAMP_CR1_TAMP1E)
  478. /** @defgroup RTC_LL_EC_TAMPER_ACTIVELEVEL TAMPER ACTIVE LEVEL
  479. * @{
  480. */
  481. #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP1 TAMP_CR2_TAMP1TRG /*!< Tamper 1 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
  482. #endif /* TAMP_CR1_TAMP1E */
  483. #if defined(TAMP_CR1_TAMP2E)
  484. #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP2 TAMP_CR2_TAMP2TRG /*!< Tamper 2 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
  485. #endif /* TAMP_CR1_TAMP2E */
  486. #if defined(TAMP_CR1_TAMP3E)
  487. #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP3 TAMP_CR2_TAMP3TRG /*!< Tamper 3 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event */
  488. #endif /* TAMP_CR1_TAMP3E */
  489. /**
  490. * @}
  491. */
  492. #if defined (RTC_TAMPCR_TAMP1E)
  493. /** @defgroup RTC_LL_EC_TAMPER TAMPER
  494. * @{
  495. */
  496. #define LL_RTC_TAMPER_1 RTC_TAMPCR_TAMP1E /*!< RTC_TAMP1 input detection */
  497. #endif /* RTC_TAMPCR_TAMP1E */
  498. #if defined (RTC_TAMPCR_TAMP2E)
  499. #define LL_RTC_TAMPER_2 RTC_TAMPCR_TAMP2E /*!< RTC_TAMP2 input detection */
  500. #endif /* RTC_TAMPCR_TAMP2E */
  501. #if defined (RTC_TAMPCR_TAMP3E)
  502. #define LL_RTC_TAMPER_3 RTC_TAMPCR_TAMP3E /*!< RTC_TAMP3 input detection */
  503. #endif /* RTC_TAMPCR_TAMP3E */
  504. /**
  505. * @}
  506. */
  507. #if defined (RTC_TAMPCR_TAMP1E)
  508. /** @defgroup RTC_LL_EC_TAMPER_MASK TAMPER MASK
  509. * @{
  510. */
  511. #define LL_RTC_TAMPER_MASK_TAMPER1 RTC_TAMPCR_TAMP1MF /*!< Tamper 1 event generates a trigger event. TAMP1F is masked and internally cleared by hardware.The backup registers are not erased */
  512. #endif /* RTC_TAMPCR_TAMP1E */
  513. #if defined (RTC_TAMPCR_TAMP2E)
  514. #define LL_RTC_TAMPER_MASK_TAMPER2 RTC_TAMPCR_TAMP2MF /*!< Tamper 2 event generates a trigger event. TAMP2F is masked and internally cleared by hardware. The backup registers are not erased. */
  515. #endif /* RTC_TAMPCR_TAMP2E */
  516. #if defined (RTC_TAMPCR_TAMP3E)
  517. #define LL_RTC_TAMPER_MASK_TAMPER3 RTC_TAMPCR_TAMP3MF /*!< Tamper 3 event generates a trigger event. TAMP3F is masked and internally cleared by hardware. The backup registers are not erased */
  518. #endif /* RTC_TAMPCR_TAMP3E */
  519. /**
  520. * @}
  521. */
  522. #if defined (RTC_TAMPCR_TAMP1E)
  523. /** @defgroup RTC_LL_EC_TAMPER_NOERASE TAMPER NO ERASE
  524. * @{
  525. */
  526. #define LL_RTC_TAMPER_NOERASE_TAMPER1 RTC_TAMPCR_TAMP1NOERASE /*!< Tamper 1 event does not erase the backup registers. */
  527. #endif /* RTC_TAMPCR_TAMP1E */
  528. #if defined (RTC_TAMPCR_TAMP2E)
  529. #define LL_RTC_TAMPER_NOERASE_TAMPER2 RTC_TAMPCR_TAMP2NOERASE /*!< Tamper 2 event does not erase the backup registers. */
  530. #endif /* RTC_TAMPCR_TAMP2E */
  531. #if defined (RTC_TAMPCR_TAMP3E)
  532. #define LL_RTC_TAMPER_NOERASE_TAMPER3 RTC_TAMPCR_TAMP3NOERASE /*!< Tamper 3 event does not erase the backup registers. */
  533. #endif /* RTC_TAMPCR_TAMP3E */
  534. /**
  535. * @}
  536. */
  537. #if defined(RTC_TAMPCR_TAMPPRCH)
  538. /** @defgroup RTC_LL_EC_TAMPER_DURATION TAMPER DURATION
  539. * @{
  540. */
  541. #define LL_RTC_TAMPER_DURATION_1RTCCLK 0x00000000U /*!< Tamper pins are pre-charged before sampling during 1 RTCCLK cycle */
  542. #define LL_RTC_TAMPER_DURATION_2RTCCLK RTC_TAMPCR_TAMPPRCH_0 /*!< Tamper pins are pre-charged before sampling during 2 RTCCLK cycles */
  543. #define LL_RTC_TAMPER_DURATION_4RTCCLK RTC_TAMPCR_TAMPPRCH_1 /*!< Tamper pins are pre-charged before sampling during 4 RTCCLK cycles */
  544. #define LL_RTC_TAMPER_DURATION_8RTCCLK RTC_TAMPCR_TAMPPRCH /*!< Tamper pins are pre-charged before sampling during 8 RTCCLK cycles */
  545. /**
  546. * @}
  547. */
  548. #endif /* RTC_TAMPCR_TAMPPRCH */
  549. #if defined(RTC_TAMPCR_TAMPFLT)
  550. /** @defgroup RTC_LL_EC_TAMPER_FILTER TAMPER FILTER
  551. * @{
  552. */
  553. #define LL_RTC_TAMPER_FILTER_DISABLE 0x00000000U /*!< Tamper filter is disabled */
  554. #define LL_RTC_TAMPER_FILTER_2SAMPLE RTC_TAMPCR_TAMPFLT_0 /*!< Tamper is activated after 2 consecutive samples at the active level */
  555. #define LL_RTC_TAMPER_FILTER_4SAMPLE RTC_TAMPCR_TAMPFLT_1 /*!< Tamper is activated after 4 consecutive samples at the active level */
  556. #define LL_RTC_TAMPER_FILTER_8SAMPLE RTC_TAMPCR_TAMPFLT /*!< Tamper is activated after 8 consecutive samples at the active level. */
  557. /**
  558. * @}
  559. */
  560. #endif /* RTC_TAMPCR_TAMPFLT */
  561. #if defined(RTC_TAMPCR_TAMPFREQ)
  562. /** @defgroup RTC_LL_EC_TAMPER_SAMPLFREQDIV TAMPER SAMPLING FREQUENCY DIVIDER
  563. * @{
  564. */
  565. #define LL_RTC_TAMPER_SAMPLFREQDIV_32768 0x00000000U /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 32768 */
  566. #define LL_RTC_TAMPER_SAMPLFREQDIV_16384 RTC_TAMPCR_TAMPFREQ_0 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 16384 */
  567. #define LL_RTC_TAMPER_SAMPLFREQDIV_8192 RTC_TAMPCR_TAMPFREQ_1 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 8192 */
  568. #define LL_RTC_TAMPER_SAMPLFREQDIV_4096 (RTC_TAMPCR_TAMPFREQ_1 | RTC_TAMPCR_TAMPFREQ_0) /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 4096 */
  569. #define LL_RTC_TAMPER_SAMPLFREQDIV_2048 RTC_TAMPCR_TAMPFREQ_2 /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 2048 */
  570. #define LL_RTC_TAMPER_SAMPLFREQDIV_1024 (RTC_TAMPCR_TAMPFREQ_2 | RTC_TAMPCR_TAMPFREQ_0) /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 1024 */
  571. #define LL_RTC_TAMPER_SAMPLFREQDIV_512 (RTC_TAMPCR_TAMPFREQ_2 | RTC_TAMPCR_TAMPFREQ_1) /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 512 */
  572. #define LL_RTC_TAMPER_SAMPLFREQDIV_256 RTC_TAMPCR_TAMPFREQ /*!< Each of the tamper inputs are sampled with a frequency = RTCCLK / 256 */
  573. /**
  574. * @}
  575. */
  576. #endif /* RTC_TAMPCR_TAMPFREQ */
  577. #if defined (RTC_TAMPCR_TAMP1E)
  578. /** @defgroup RTC_LL_EC_TAMPER_ACTIVELEVEL TAMPER ACTIVE LEVEL
  579. * @{
  580. */
  581. #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP1 RTC_TAMPCR_TAMP1TRG /*!< RTC_TAMP1 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event*/
  582. #endif /* RTC_TAMPCR_TAMP1E */
  583. #if defined (RTC_TAMPCR_TAMP2E)
  584. #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP2 RTC_TAMPCR_TAMP2TRG /*!< RTC_TAMP2 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event*/
  585. #endif /* RTC_TAMPCR_TAMP2E */
  586. #if defined (RTC_TAMPCR_TAMP3E)
  587. #define LL_RTC_TAMPER_ACTIVELEVEL_TAMP3 RTC_TAMPCR_TAMP3TRG /*!< RTC_TAMP3 input falling edge (if TAMPFLT = 00) or staying high (if TAMPFLT != 00) triggers a tamper detection event*/
  588. #endif /* RTC_TAMPCR_TAMP3E */
  589. /**
  590. * @}
  591. */
  592. #if defined(TAMP_ATCR1_TAMP1AM)
  593. /** @defgroup RTC_LL_EC_ACTIVE_MODE ACTIVE TAMPER MODE
  594. * @{
  595. */
  596. #define LL_RTC_TAMPER_ATAMP_TAMP1AM TAMP_ATCR1_TAMP1AM /*!< tamper 1 is active */
  597. #endif /* TAMP_ATCR1_TAMP1AM */
  598. #if defined(TAMP_ATCR1_TAMP2AM)
  599. #define LL_RTC_TAMPER_ATAMP_TAMP2AM TAMP_ATCR1_TAMP2AM /*!< tamper 2 is active */
  600. #endif /* TAMP_ATCR1_TAMP2AM */
  601. #if defined(TAMP_ATCR1_TAMP3AM)
  602. #define LL_RTC_TAMPER_ATAMP_TAMP3AM TAMP_ATCR1_TAMP3AM /*!< tamper 3 is active */
  603. #endif /* TAMP_ATCR1_TAMP3AM */
  604. /**
  605. * @}
  606. */
  607. #if defined(TAMP_ATCR1_ATCKSEL)
  608. /** @defgroup RTC_LL_EC_ACTIVE_ASYNC_PRESCALER ACTIVE TAMPER ASYNCHRONOUS PRESCALER CLOCK
  609. * @{
  610. */
  611. #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK 0U /*!< RTCCLK */
  612. #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_2 TAMP_ATCR1_ATCKSEL_0 /*!< RTCCLK/2 */
  613. #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_4 TAMP_ATCR1_ATCKSEL_1 /*!< RTCCLK/4 */
  614. #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_8 (TAMP_ATCR1_ATCKSEL_1 | TAMP_ATCR1_ATCKSEL_0) /*!< RTCCLK/8 */
  615. #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_16 TAMP_ATCR1_ATCKSEL_2 /*!< RTCCLK/16 */
  616. #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_32 (TAMP_ATCR1_ATCKSEL_2 | TAMP_ATCR1_ATCKSEL_0) /*!< RTCCLK/32 */
  617. #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_64 (TAMP_ATCR1_ATCKSEL_2 | TAMP_ATCR1_ATCKSEL_1) /*!< RTCCLK/64 */
  618. #define LL_RTC_TAMPER_ATAMP_ASYNCPRES_RTCCLK_128 (TAMP_ATCR1_ATCKSEL_2 | TAMP_ATCR1_ATCKSEL_1 | TAMP_ATCR1_ATCKSEL_0) /*!< RTCCLK/128 */
  619. /**
  620. * @}
  621. */
  622. #endif /* TAMP_ATCR1_ATCKSEL */
  623. #if defined(TAMP_ATCR1_TAMP1AM)
  624. /** @defgroup RTC_LL_EC_ACTIVE_OUTPUT_SELECTION ACTIVE TAMPER OUTPUT SELECTION
  625. * @{
  626. */
  627. #define LL_RTC_TAMPER_ATAMP1IN_ATAMP1OUT (0UL << TAMP_ATCR2_ATOSEL1_Pos)
  628. #define LL_RTC_TAMPER_ATAMP1IN_ATAMP2OUT (1UL << TAMP_ATCR2_ATOSEL1_Pos)
  629. #define LL_RTC_TAMPER_ATAMP1IN_ATAMP3OUT (2UL << TAMP_ATCR2_ATOSEL1_Pos)
  630. #endif /* TAMP_ATCR1_TAMP1AM */
  631. #if defined(TAMP_ATCR1_TAMP2AM)
  632. #define LL_RTC_TAMPER_ATAMP2IN_ATAMP1OUT (0UL << TAMP_ATCR2_ATOSEL2_Pos)
  633. #define LL_RTC_TAMPER_ATAMP2IN_ATAMP2OUT (1UL << TAMP_ATCR2_ATOSEL2_Pos)
  634. #define LL_RTC_TAMPER_ATAMP2IN_ATAMP3OUT (2UL << TAMP_ATCR2_ATOSEL2_Pos)
  635. #endif /* TAMP_ATCR1_TAMP2AM */
  636. #if defined(TAMP_ATCR1_TAMP3AM)
  637. #define LL_RTC_TAMPER_ATAMP3IN_ATAMP1OUT (0UL << TAMP_ATCR2_ATOSEL3_Pos)
  638. #define LL_RTC_TAMPER_ATAMP3IN_ATAMP2OUT (1UL << TAMP_ATCR2_ATOSEL3_Pos)
  639. #define LL_RTC_TAMPER_ATAMP3IN_ATAMP3OUT (2UL << TAMP_ATCR2_ATOSEL3_Pos)
  640. #endif /* TAMP_ATCR1_TAMP3AM */
  641. /**
  642. * @}
  643. */
  644. /** @defgroup RTC_LL_EC_WAKEUPCLOCK_DIV WAKEUP CLOCK DIV
  645. * @{
  646. */
  647. #define LL_RTC_WAKEUPCLOCK_DIV_16 0x00000000U /*!< RTC/16 clock is selected */
  648. #define LL_RTC_WAKEUPCLOCK_DIV_8 RTC_CR_WUCKSEL_0 /*!< RTC/8 clock is selected */
  649. #define LL_RTC_WAKEUPCLOCK_DIV_4 RTC_CR_WUCKSEL_1 /*!< RTC/4 clock is selected */
  650. #define LL_RTC_WAKEUPCLOCK_DIV_2 (RTC_CR_WUCKSEL_1 | RTC_CR_WUCKSEL_0) /*!< RTC/2 clock is selected */
  651. #define LL_RTC_WAKEUPCLOCK_CKSPRE RTC_CR_WUCKSEL_2 /*!< ck_spre (usually 1 Hz) clock is selected */
  652. #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*/
  653. /**
  654. * @}
  655. */
  656. /** @defgroup RTC_LL_EC_BKP BACKUP
  657. * @{
  658. */
  659. #define LL_RTC_BKP_DR0 0x00000000U
  660. #define LL_RTC_BKP_DR1 0x00000001U
  661. #define LL_RTC_BKP_DR2 0x00000002U
  662. #define LL_RTC_BKP_DR3 0x00000003U
  663. #define LL_RTC_BKP_DR4 0x00000004U
  664. #define LL_RTC_BKP_DR5 0x00000005U
  665. #define LL_RTC_BKP_DR6 0x00000006U
  666. #define LL_RTC_BKP_DR7 0x00000007U
  667. #define LL_RTC_BKP_DR8 0x00000008U
  668. #define LL_RTC_BKP_DR9 0x00000009U
  669. #define LL_RTC_BKP_DR10 0x0000000AU
  670. #define LL_RTC_BKP_DR11 0x0000000BU
  671. #define LL_RTC_BKP_DR12 0x0000000CU
  672. #define LL_RTC_BKP_DR13 0x0000000DU
  673. #define LL_RTC_BKP_DR14 0x0000000EU
  674. #define LL_RTC_BKP_DR15 0x0000000FU
  675. #define LL_RTC_BKP_DR16 0x00000010U
  676. #define LL_RTC_BKP_DR17 0x00000011U
  677. #define LL_RTC_BKP_DR18 0x00000012U
  678. #define LL_RTC_BKP_DR19 0x00000013U
  679. #define LL_RTC_BKP_DR20 0x00000014U
  680. #define LL_RTC_BKP_DR21 0x00000015U
  681. #define LL_RTC_BKP_DR22 0x00000016U
  682. #define LL_RTC_BKP_DR23 0x00000017U
  683. #define LL_RTC_BKP_DR24 0x00000018U
  684. #define LL_RTC_BKP_DR25 0x00000019U
  685. #define LL_RTC_BKP_DR26 0x0000001AU
  686. #define LL_RTC_BKP_DR27 0x0000001BU
  687. #define LL_RTC_BKP_DR28 0x0000001CU
  688. #define LL_RTC_BKP_DR29 0x0000001DU
  689. #define LL_RTC_BKP_DR30 0x0000001EU
  690. #define LL_RTC_BKP_DR31 0x0000001FU
  691. /**
  692. * @}
  693. */
  694. /** @defgroup RTC_LL_EC_CALIB_OUTPUT Calibration output
  695. * @{
  696. */
  697. #define LL_RTC_CALIB_OUTPUT_NONE 0x00000000U /*!< Calibration output disabled */
  698. #define LL_RTC_CALIB_OUTPUT_1HZ (RTC_CR_COE | RTC_CR_COSEL) /*!< Calibration output is 1 Hz */
  699. #define LL_RTC_CALIB_OUTPUT_512HZ RTC_CR_COE /*!< Calibration output is 512 Hz */
  700. /**
  701. * @}
  702. */
  703. /** @defgroup RTC_LL_EC_CALIB_INSERTPULSE Calibration pulse insertion
  704. * @{
  705. */
  706. #define LL_RTC_CALIB_INSERTPULSE_NONE 0x00000000U /*!< No RTCCLK pulses are added */
  707. #define LL_RTC_CALIB_INSERTPULSE_SET RTC_CALR_CALP /*!< One RTCCLK pulse is effectively inserted every 2exp11 pulses (frequency increased by 488.5 ppm) */
  708. /**
  709. * @}
  710. */
  711. /** @defgroup RTC_LL_EC_CALIB_PERIOD Calibration period
  712. * @{
  713. */
  714. #define LL_RTC_CALIB_PERIOD_32SEC 0x00000000U /*!< Use a 32-second calibration cycle period */
  715. #define LL_RTC_CALIB_PERIOD_16SEC RTC_CALR_CALW16 /*!< Use a 16-second calibration cycle period */
  716. #define LL_RTC_CALIB_PERIOD_8SEC RTC_CALR_CALW8 /*!< Use a 8-second calibration cycle period */
  717. /**
  718. * @}
  719. */
  720. /**
  721. * @}
  722. */
  723. /* Exported macro ------------------------------------------------------------*/
  724. /** @defgroup RTC_LL_Exported_Macros RTC Exported Macros
  725. * @{
  726. */
  727. /** @defgroup RTC_LL_EM_WRITE_READ Common Write and read registers Macros
  728. * @{
  729. */
  730. /**
  731. * @brief Write a value in RTC register
  732. * @param __INSTANCE__ RTC Instance
  733. * @param __REG__ Register to be written
  734. * @param __VALUE__ Value to be written in the register
  735. * @retval None
  736. */
  737. #define LL_RTC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG((__INSTANCE__)->__REG__, __VALUE__)
  738. /**
  739. * @brief Read a value in RTC register
  740. * @param __INSTANCE__ RTC Instance
  741. * @param __REG__ Register to be read
  742. * @retval Register value
  743. */
  744. #define LL_RTC_ReadReg(__INSTANCE__, __REG__) READ_REG((__INSTANCE__)->__REG__)
  745. /**
  746. * @}
  747. */
  748. /** @defgroup RTC_LL_EM_Convert Convert helper Macros
  749. * @{
  750. */
  751. /**
  752. * @brief Helper macro to convert a value from 2 digit decimal format to BCD format
  753. * @param __VALUE__ Byte to be converted
  754. * @retval Converted byte
  755. */
  756. #define __LL_RTC_CONVERT_BIN2BCD(__VALUE__) (uint8_t)((((__VALUE__) / 10U) << 4U) | ((__VALUE__) % 10U))
  757. /**
  758. * @brief Helper macro to convert a value from BCD format to 2 digit decimal format
  759. * @param __VALUE__ BCD value to be converted
  760. * @retval Converted byte
  761. */
  762. #define __LL_RTC_CONVERT_BCD2BIN(__VALUE__) ((uint8_t)((((uint8_t)((__VALUE__) & (uint8_t)0xF0) >> (uint8_t)0x4) * 10U) + ((__VALUE__) & (uint8_t)0x0F)))
  763. /**
  764. * @}
  765. */
  766. /** @defgroup RTC_LL_EM_Date Date helper Macros
  767. * @{
  768. */
  769. /**
  770. * @brief Helper macro to retrieve weekday.
  771. * @param __RTC_DATE__ Date returned by @ref LL_RTC_DATE_Get function.
  772. * @retval Returned value can be one of the following values:
  773. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  774. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  775. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  776. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  777. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  778. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  779. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  780. */
  781. #define __LL_RTC_GET_WEEKDAY(__RTC_DATE__) (((__RTC_DATE__) >> RTC_OFFSET_WEEKDAY) & 0x000000FFU)
  782. /**
  783. * @brief Helper macro to retrieve Year in BCD format
  784. * @param __RTC_DATE__ Value returned by @ref LL_RTC_DATE_Get
  785. * @retval Year in BCD format (0x00 . . . 0x99)
  786. */
  787. #define __LL_RTC_GET_YEAR(__RTC_DATE__) ((__RTC_DATE__) & 0x000000FFU)
  788. /**
  789. * @brief Helper macro to retrieve Month in BCD format
  790. * @param __RTC_DATE__ Value returned by @ref LL_RTC_DATE_Get
  791. * @retval Returned value can be one of the following values:
  792. * @arg @ref LL_RTC_MONTH_JANUARY
  793. * @arg @ref LL_RTC_MONTH_FEBRUARY
  794. * @arg @ref LL_RTC_MONTH_MARCH
  795. * @arg @ref LL_RTC_MONTH_APRIL
  796. * @arg @ref LL_RTC_MONTH_MAY
  797. * @arg @ref LL_RTC_MONTH_JUNE
  798. * @arg @ref LL_RTC_MONTH_JULY
  799. * @arg @ref LL_RTC_MONTH_AUGUST
  800. * @arg @ref LL_RTC_MONTH_SEPTEMBER
  801. * @arg @ref LL_RTC_MONTH_OCTOBER
  802. * @arg @ref LL_RTC_MONTH_NOVEMBER
  803. * @arg @ref LL_RTC_MONTH_DECEMBER
  804. */
  805. #define __LL_RTC_GET_MONTH(__RTC_DATE__) (((__RTC_DATE__) >>RTC_OFFSET_MONTH) & 0x000000FFU)
  806. /**
  807. * @brief Helper macro to retrieve Day in BCD format
  808. * @param __RTC_DATE__ Value returned by @ref LL_RTC_DATE_Get
  809. * @retval Day in BCD format (0x01 . . . 0x31)
  810. */
  811. #define __LL_RTC_GET_DAY(__RTC_DATE__) (((__RTC_DATE__) >>RTC_OFFSET_DAY) & 0x000000FFU)
  812. /**
  813. * @}
  814. */
  815. /** @defgroup RTC_LL_EM_Time Time helper Macros
  816. * @{
  817. */
  818. /**
  819. * @brief Helper macro to retrieve hour in BCD format
  820. * @param __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
  821. * @retval Hours in BCD format (0x01. . .0x12 or between Min_Data=0x00 and Max_Data=0x23)
  822. */
  823. #define __LL_RTC_GET_HOUR(__RTC_TIME__) (((__RTC_TIME__) >> RTC_OFFSET_HOUR) & 0x000000FFU)
  824. /**
  825. * @brief Helper macro to retrieve minute in BCD format
  826. * @param __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
  827. * @retval Minutes in BCD format (0x00. . .0x59)
  828. */
  829. #define __LL_RTC_GET_MINUTE(__RTC_TIME__) (((__RTC_TIME__) >> RTC_OFFSET_MINUTE) & 0x000000FFU)
  830. /**
  831. * @brief Helper macro to retrieve second in BCD format
  832. * @param __RTC_TIME__ RTC time returned by @ref LL_RTC_TIME_Get function
  833. * @retval Seconds in format (0x00. . .0x59)
  834. */
  835. #define __LL_RTC_GET_SECOND(__RTC_TIME__) ((__RTC_TIME__) & 0x000000FFU)
  836. /**
  837. * @}
  838. */
  839. /**
  840. * @}
  841. */
  842. /* Exported functions --------------------------------------------------------*/
  843. /** @defgroup RTC_LL_Exported_Functions RTC Exported Functions
  844. * @{
  845. */
  846. /** @defgroup RTC_LL_EF_Configuration Configuration
  847. * @{
  848. */
  849. /**
  850. * @brief Set Hours format (24 hour/day or AM/PM hour format)
  851. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  852. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  853. * @rmtoll RTC_CR FMT LL_RTC_SetHourFormat
  854. * @param RTCx RTC Instance
  855. * @param HourFormat This parameter can be one of the following values:
  856. * @arg @ref LL_RTC_HOURFORMAT_24HOUR
  857. * @arg @ref LL_RTC_HOURFORMAT_AMPM
  858. * @retval None
  859. */
  860. __STATIC_INLINE void LL_RTC_SetHourFormat(RTC_TypeDef *RTCx, uint32_t HourFormat)
  861. {
  862. MODIFY_REG(RTCx->CR, RTC_CR_FMT, HourFormat);
  863. }
  864. /**
  865. * @brief Get Hours format (24 hour/day or AM/PM hour format)
  866. * @rmtoll RTC_CR FMT LL_RTC_GetHourFormat
  867. * @param RTCx RTC Instance
  868. * @retval Returned value can be one of the following values:
  869. * @arg @ref LL_RTC_HOURFORMAT_24HOUR
  870. * @arg @ref LL_RTC_HOURFORMAT_AMPM
  871. */
  872. __STATIC_INLINE uint32_t LL_RTC_GetHourFormat(RTC_TypeDef *RTCx)
  873. {
  874. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_FMT));
  875. }
  876. /**
  877. * @brief Select the flag to be routed to RTC_ALARM output
  878. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  879. * @rmtoll RTC_CR OSEL LL_RTC_SetAlarmOutEvent
  880. * @param RTCx RTC Instance
  881. * @param AlarmOutput This parameter can be one of the following values:
  882. * @arg @ref LL_RTC_ALARMOUT_DISABLE
  883. * @arg @ref LL_RTC_ALARMOUT_ALMA
  884. * @arg @ref LL_RTC_ALARMOUT_ALMB
  885. * @arg @ref LL_RTC_ALARMOUT_WAKEUP
  886. * @retval None
  887. */
  888. __STATIC_INLINE void LL_RTC_SetAlarmOutEvent(RTC_TypeDef *RTCx, uint32_t AlarmOutput)
  889. {
  890. MODIFY_REG(RTCx->CR, RTC_CR_OSEL, AlarmOutput);
  891. }
  892. /**
  893. * @brief Get the flag to be routed to RTC_ALARM output
  894. * @rmtoll RTC_CR OSEL LL_RTC_GetAlarmOutEvent
  895. * @param RTCx RTC Instance
  896. * @retval Returned value can be one of the following values:
  897. * @arg @ref LL_RTC_ALARMOUT_DISABLE
  898. * @arg @ref LL_RTC_ALARMOUT_ALMA
  899. * @arg @ref LL_RTC_ALARMOUT_ALMB
  900. * @arg @ref LL_RTC_ALARMOUT_WAKEUP
  901. */
  902. __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutEvent(RTC_TypeDef *RTCx)
  903. {
  904. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_OSEL));
  905. }
  906. #if defined(RTC_CR_TAMPALRM_TYPE)
  907. /**
  908. * @brief Set RTC_ALARM output type (ALARM in push-pull or open-drain output)
  909. * @rmtoll RTC_CR TAMPALRM_TYPE LL_RTC_SetAlarmOutputType
  910. * @param RTCx RTC Instance
  911. * @param Output This parameter can be one of the following values:
  912. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
  913. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
  914. * @retval None
  915. */
  916. __STATIC_INLINE void LL_RTC_SetAlarmOutputType(RTC_TypeDef *RTCx, uint32_t Output)
  917. {
  918. MODIFY_REG(RTCx->CR, RTC_CR_TAMPALRM_TYPE, Output);
  919. }
  920. /**
  921. * @brief Get RTC_ALARM output type (ALARM in push-pull or open-drain output)
  922. * @rmtoll RTC_CR TAMPALRM_TYPE LL_RTC_SetAlarmOutputType
  923. * @param RTCx RTC Instance
  924. * @retval Returned value can be one of the following values:
  925. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
  926. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
  927. */
  928. __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutputType(RTC_TypeDef *RTCx)
  929. {
  930. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_TAMPALRM_TYPE));
  931. }
  932. #endif /* RTC_CR_TAMPALRM_TYPE */
  933. #if defined(RTC_ICSR_INIT)
  934. /**
  935. * @brief Enable initialization mode
  936. * @note Initialization mode is used to program time and date register (RTC_TR and RTC_DR)
  937. * and prescaler register (RTC_PRER).
  938. * Counters are stopped and start counting from the new value when INIT is reset.
  939. * @rmtoll RTC_ICSR INIT LL_RTC_EnableInitMode
  940. * @param RTCx RTC Instance
  941. * @retval None
  942. */
  943. __STATIC_INLINE void LL_RTC_EnableInitMode(RTC_TypeDef *RTCx)
  944. {
  945. /* Set the Initialization mode */
  946. WRITE_REG(RTCx->ICSR, RTC_LL_INIT_MASK);
  947. }
  948. /**
  949. * @brief Disable initialization mode (Free running mode)
  950. * @rmtoll RTC_ICSR INIT LL_RTC_DisableInitMode
  951. * @param RTCx RTC Instance
  952. * @retval None
  953. */
  954. __STATIC_INLINE void LL_RTC_DisableInitMode(RTC_TypeDef *RTCx)
  955. {
  956. /* Exit Initialization mode */
  957. WRITE_REG(RTCx->ICSR, (uint32_t)~RTC_ICSR_INIT);
  958. }
  959. #endif /* RTC_ICSR_INIT */
  960. #if defined(RTC_OR_ALARMOUTTYPE)
  961. /**
  962. * @brief Set RTC_ALARM output type (ALARM in push-pull or open-drain output)
  963. * @note Used only when RTC_ALARM is mapped on PC13
  964. * @rmtoll OR ALARMOUTTYPE LL_RTC_SetAlarmOutputType
  965. * @param RTCx RTC Instance
  966. * @param Output This parameter can be one of the following values:
  967. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
  968. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
  969. * @retval None
  970. */
  971. __STATIC_INLINE void LL_RTC_SetAlarmOutputType(RTC_TypeDef *RTCx, uint32_t Output)
  972. {
  973. MODIFY_REG(RTCx->OR, RTC_OR_ALARMOUTTYPE, Output);
  974. }
  975. /**
  976. * @brief Get RTC_ALARM output type (ALARM in push-pull or open-drain output)
  977. * @note used only when RTC_ALARM is mapped on PC13
  978. * @rmtoll OR ALARMOUTTYPE LL_RTC_GetAlarmOutputType
  979. * @param RTCx RTC Instance
  980. * @retval Returned value can be one of the following values:
  981. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_OPENDRAIN
  982. * @arg @ref LL_RTC_ALARM_OUTPUTTYPE_PUSHPULL
  983. */
  984. __STATIC_INLINE uint32_t LL_RTC_GetAlarmOutputType(RTC_TypeDef *RTCx)
  985. {
  986. return (uint32_t)(READ_BIT(RTCx->OR, RTC_OR_ALARMOUTTYPE));
  987. }
  988. #endif /* RTC_OR_ALARMOUTTYPE */
  989. #if defined(RTC_ISR_INIT)
  990. /**
  991. * @brief Enable initialization mode
  992. * @note Initialization mode is used to program time and date register (RTC_TR and RTC_DR)
  993. * and prescaler register (RTC_PRER).
  994. * Counters are stopped and start counting from the new value when INIT is reset.
  995. * @rmtoll ISR INIT LL_RTC_EnableInitMode
  996. * @param RTCx RTC Instance
  997. * @retval None
  998. */
  999. __STATIC_INLINE void LL_RTC_EnableInitMode(RTC_TypeDef *RTCx)
  1000. {
  1001. /* Set the Initialization mode */
  1002. WRITE_REG(RTCx->ISR, RTC_LL_INIT_MASK);
  1003. }
  1004. /**
  1005. * @brief Disable initialization mode (Free running mode)
  1006. * @rmtoll ISR INIT LL_RTC_DisableInitMode
  1007. * @param RTCx RTC Instance
  1008. * @retval None
  1009. */
  1010. __STATIC_INLINE void LL_RTC_DisableInitMode(RTC_TypeDef *RTCx)
  1011. {
  1012. /* Exit Initialization mode */
  1013. WRITE_REG(RTCx->ISR, (uint32_t)~RTC_ISR_INIT);
  1014. }
  1015. #endif /* RTC_ISR_INIT */
  1016. /**
  1017. * @brief Set Output polarity (pin is low when ALRAF/ALRBF/WUTF is asserted)
  1018. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1019. * @rmtoll RTC_CR POL LL_RTC_SetOutputPolarity
  1020. * @param RTCx RTC Instance
  1021. * @param Polarity This parameter can be one of the following values:
  1022. * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_HIGH
  1023. * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_LOW
  1024. * @retval None
  1025. */
  1026. __STATIC_INLINE void LL_RTC_SetOutputPolarity(RTC_TypeDef *RTCx, uint32_t Polarity)
  1027. {
  1028. MODIFY_REG(RTCx->CR, RTC_CR_POL, Polarity);
  1029. }
  1030. /**
  1031. * @brief Get Output polarity
  1032. * @rmtoll RTC_CR POL LL_RTC_GetOutputPolarity
  1033. * @param RTCx RTC Instance
  1034. * @retval Returned value can be one of the following values:
  1035. * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_HIGH
  1036. * @arg @ref LL_RTC_OUTPUTPOLARITY_PIN_LOW
  1037. */
  1038. __STATIC_INLINE uint32_t LL_RTC_GetOutputPolarity(RTC_TypeDef *RTCx)
  1039. {
  1040. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_POL));
  1041. }
  1042. /**
  1043. * @brief Enable Bypass the shadow registers
  1044. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1045. * @rmtoll RTC_CR BYPSHAD LL_RTC_EnableShadowRegBypass
  1046. * @param RTCx RTC Instance
  1047. * @retval None
  1048. */
  1049. __STATIC_INLINE void LL_RTC_EnableShadowRegBypass(RTC_TypeDef *RTCx)
  1050. {
  1051. SET_BIT(RTCx->CR, RTC_CR_BYPSHAD);
  1052. }
  1053. /**
  1054. * @brief Disable Bypass the shadow registers
  1055. * @rmtoll RTC_CR BYPSHAD LL_RTC_DisableShadowRegBypass
  1056. * @param RTCx RTC Instance
  1057. * @retval None
  1058. */
  1059. __STATIC_INLINE void LL_RTC_DisableShadowRegBypass(RTC_TypeDef *RTCx)
  1060. {
  1061. CLEAR_BIT(RTCx->CR, RTC_CR_BYPSHAD);
  1062. }
  1063. /**
  1064. * @brief Check if Shadow registers bypass is enabled or not.
  1065. * @rmtoll RTC_CR BYPSHAD LL_RTC_IsShadowRegBypassEnabled
  1066. * @param RTCx RTC Instance
  1067. * @retval State of bit (1 or 0).
  1068. */
  1069. __STATIC_INLINE uint32_t LL_RTC_IsShadowRegBypassEnabled(RTC_TypeDef *RTCx)
  1070. {
  1071. return ((READ_BIT(RTCx->CR, RTC_CR_BYPSHAD) == (RTC_CR_BYPSHAD)) ? 1UL : 0UL);
  1072. }
  1073. /**
  1074. * @brief Enable RTC_REFIN reference clock detection (50 or 60 Hz)
  1075. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1076. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1077. * @rmtoll RTC_CR REFCKON LL_RTC_EnableRefClock
  1078. * @param RTCx RTC Instance
  1079. * @retval None
  1080. */
  1081. __STATIC_INLINE void LL_RTC_EnableRefClock(RTC_TypeDef *RTCx)
  1082. {
  1083. SET_BIT(RTCx->CR, RTC_CR_REFCKON);
  1084. }
  1085. /**
  1086. * @brief Disable RTC_REFIN reference clock detection (50 or 60 Hz)
  1087. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1088. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1089. * @rmtoll RTC_CR REFCKON LL_RTC_DisableRefClock
  1090. * @param RTCx RTC Instance
  1091. * @retval None
  1092. */
  1093. __STATIC_INLINE void LL_RTC_DisableRefClock(RTC_TypeDef *RTCx)
  1094. {
  1095. CLEAR_BIT(RTCx->CR, RTC_CR_REFCKON);
  1096. }
  1097. /**
  1098. * @brief Set Asynchronous prescaler factor
  1099. * @rmtoll RTC_PRER PREDIV_A LL_RTC_SetAsynchPrescaler
  1100. * @param RTCx RTC Instance
  1101. * @param AsynchPrescaler Value between Min_Data = 0 and Max_Data = 0x7F
  1102. * @retval None
  1103. */
  1104. __STATIC_INLINE void LL_RTC_SetAsynchPrescaler(RTC_TypeDef *RTCx, uint32_t AsynchPrescaler)
  1105. {
  1106. MODIFY_REG(RTCx->PRER, RTC_PRER_PREDIV_A, AsynchPrescaler << RTC_PRER_PREDIV_A_Pos);
  1107. }
  1108. /**
  1109. * @brief Set Synchronous prescaler factor
  1110. * @rmtoll RTC_PRER PREDIV_S LL_RTC_SetSynchPrescaler
  1111. * @param RTCx RTC Instance
  1112. * @param SynchPrescaler Value between Min_Data = 0 and Max_Data = 0x7FFF
  1113. * @retval None
  1114. */
  1115. __STATIC_INLINE void LL_RTC_SetSynchPrescaler(RTC_TypeDef *RTCx, uint32_t SynchPrescaler)
  1116. {
  1117. MODIFY_REG(RTCx->PRER, RTC_PRER_PREDIV_S, SynchPrescaler);
  1118. }
  1119. /**
  1120. * @brief Get Asynchronous prescaler factor
  1121. * @rmtoll RTC_PRER PREDIV_A LL_RTC_GetAsynchPrescaler
  1122. * @param RTCx RTC Instance
  1123. * @retval Value between Min_Data = 0 and Max_Data = 0x7F
  1124. */
  1125. __STATIC_INLINE uint32_t LL_RTC_GetAsynchPrescaler(RTC_TypeDef *RTCx)
  1126. {
  1127. return (uint32_t)(READ_BIT(RTCx->PRER, RTC_PRER_PREDIV_A) >> RTC_PRER_PREDIV_A_Pos);
  1128. }
  1129. /**
  1130. * @brief Get Synchronous prescaler factor
  1131. * @rmtoll RTC_PRER PREDIV_S LL_RTC_GetSynchPrescaler
  1132. * @param RTCx RTC Instance
  1133. * @retval Value between Min_Data = 0 and Max_Data = 0x7FFF
  1134. */
  1135. __STATIC_INLINE uint32_t LL_RTC_GetSynchPrescaler(RTC_TypeDef *RTCx)
  1136. {
  1137. return (uint32_t)(READ_BIT(RTCx->PRER, RTC_PRER_PREDIV_S));
  1138. }
  1139. /**
  1140. * @brief Enable the write protection for RTC registers.
  1141. * @rmtoll RTC_WPR KEY LL_RTC_EnableWriteProtection
  1142. * @param RTCx RTC Instance
  1143. * @retval None
  1144. */
  1145. __STATIC_INLINE void LL_RTC_EnableWriteProtection(RTC_TypeDef *RTCx)
  1146. {
  1147. WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_DISABLE);
  1148. }
  1149. /**
  1150. * @brief Disable the write protection for RTC registers.
  1151. * @rmtoll RTC_WPR KEY LL_RTC_DisableWriteProtection
  1152. * @param RTCx RTC Instance
  1153. * @retval None
  1154. */
  1155. __STATIC_INLINE void LL_RTC_DisableWriteProtection(RTC_TypeDef *RTCx)
  1156. {
  1157. WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_ENABLE_1);
  1158. WRITE_REG(RTCx->WPR, RTC_WRITE_PROTECTION_ENABLE_2);
  1159. }
  1160. #if defined(RTC_CR_TAMPOE)
  1161. /**
  1162. * @brief Enable tamper output.
  1163. * @note When the tamper output is enabled, all external and internal tamper flags
  1164. * are ORed and routed to the TAMPALRM output.
  1165. * @rmtoll RTC_CR TAMPOE LL_RTC_EnableTamperOutput
  1166. * @param RTCx RTC Instance
  1167. * @retval None
  1168. */
  1169. __STATIC_INLINE void LL_RTC_EnableTamperOutput(RTC_TypeDef *RTCx)
  1170. {
  1171. SET_BIT(RTCx->CR, RTC_CR_TAMPOE);
  1172. }
  1173. /**
  1174. * @brief Disable tamper output.
  1175. * @rmtoll RTC_CR TAMPOE LL_RTC_DisableTamperOutput
  1176. * @param RTCx RTC Instance
  1177. * @retval None
  1178. */
  1179. __STATIC_INLINE void LL_RTC_DisableTamperOutput(RTC_TypeDef *RTCx)
  1180. {
  1181. CLEAR_BIT(RTCx->CR, RTC_CR_TAMPOE);
  1182. }
  1183. /**
  1184. * @brief Check if tamper output is enabled or not.
  1185. * @rmtoll RTC_CR TAMPOE LL_RTC_IsTamperOutputEnabled
  1186. * @param RTCx RTC Instance
  1187. * @retval State of bit (1 or 0).
  1188. */
  1189. __STATIC_INLINE uint32_t LL_RTC_IsTamperOutputEnabled(RTC_TypeDef *RTCx)
  1190. {
  1191. return ((READ_BIT(RTCx->CR, RTC_CR_TAMPOE) == (RTC_CR_TAMPOE)) ? 1UL : 0UL);
  1192. }
  1193. #endif /* RTC_CR_TAMPOE */
  1194. #if defined(RTC_CR_TAMPALRM_PU)
  1195. /**
  1196. * @brief Enable internal pull-up in output mode.
  1197. * @rmtoll RTC_CR TAMPALRM_PU LL_RTC_EnableAlarmPullUp
  1198. * @param RTCx RTC Instance
  1199. * @retval None
  1200. */
  1201. __STATIC_INLINE void LL_RTC_EnableAlarmPullUp(RTC_TypeDef *RTCx)
  1202. {
  1203. SET_BIT(RTCx->CR, RTC_CR_TAMPALRM_PU);
  1204. }
  1205. /**
  1206. * @brief Disable internal pull-up in output mode.
  1207. * @rmtoll RTC_CR TAMPALRM_PU LL_RTC_EnableAlarmPullUp
  1208. * @param RTCx RTC Instance
  1209. * @retval None
  1210. */
  1211. __STATIC_INLINE void LL_RTC_DisableAlarmPullUp(RTC_TypeDef *RTCx)
  1212. {
  1213. CLEAR_BIT(RTCx->CR, RTC_CR_TAMPALRM_PU);
  1214. }
  1215. /**
  1216. * @brief Check if internal pull-up in output mode is enabled or not.
  1217. * @rmtoll RTC_CR TAMPALRM_PU LL_RTC_IsAlarmPullUpEnabled
  1218. * @param RTCx RTC Instance
  1219. * @retval State of bit (1 or 0).
  1220. */
  1221. __STATIC_INLINE uint32_t LL_RTC_IsAlarmPullUpEnabled(RTC_TypeDef *RTCx)
  1222. {
  1223. return ((READ_BIT(RTCx->CR, RTC_CR_TAMPALRM_PU) == (RTC_CR_TAMPALRM_PU)) ? 1UL : 0UL);
  1224. }
  1225. #endif /* RTC_CR_TAMPALRM_PU */
  1226. #if defined(RTC_CR_OUT2EN)
  1227. /**
  1228. * @brief Enable RTC_OUT2 output
  1229. * @note RTC_OUT2 mapping depends on both OSEL (@ref LL_RTC_SetAlarmOutEvent)
  1230. * and COE (@ref LL_RTC_CAL_SetOutputFreq) settings.
  1231. * @note RTC_OUT2 isn't available ins VBAT mode.
  1232. * @rmtoll RTC_CR OUT2EN LL_RTC_EnableOutput2
  1233. * @param RTCx RTC Instance
  1234. * @retval None
  1235. */
  1236. __STATIC_INLINE void LL_RTC_EnableOutput2(RTC_TypeDef *RTCx)
  1237. {
  1238. SET_BIT(RTCx->CR, RTC_CR_OUT2EN);
  1239. }
  1240. /**
  1241. * @brief Disable RTC_OUT2 output
  1242. * @rmtoll RTC_CR OUT2EN LL_RTC_DisableOutput2
  1243. * @param RTCx RTC Instance
  1244. * @retval None
  1245. */
  1246. __STATIC_INLINE void LL_RTC_DisableOutput2(RTC_TypeDef *RTCx)
  1247. {
  1248. CLEAR_BIT(RTCx->CR, RTC_CR_OUT2EN);
  1249. }
  1250. /**
  1251. * @brief Check if RTC_OUT2 output is enabled or not.
  1252. * @rmtoll RTC_CR OUT2EN LL_RTC_IsOutput2Enabled
  1253. * @param RTCx RTC Instance
  1254. * @retval State of bit (1 or 0).
  1255. */
  1256. __STATIC_INLINE uint32_t LL_RTC_IsOutput2Enabled(RTC_TypeDef *RTCx)
  1257. {
  1258. return ((READ_BIT(RTCx->CR, RTC_CR_OUT2EN) == (RTC_CR_OUT2EN)) ? 1UL : 0UL);
  1259. }
  1260. #endif /* RTC_CR_OUT2EN */
  1261. #if defined(RTC_OR_OUT_RMP)
  1262. /**
  1263. * @brief Enable RTC_OUT remap
  1264. * @rmtoll OR OUT_RMP LL_RTC_EnableOutRemap
  1265. * @param RTCx RTC Instance
  1266. * @retval None
  1267. */
  1268. __STATIC_INLINE void LL_RTC_EnableOutRemap(RTC_TypeDef *RTCx)
  1269. {
  1270. SET_BIT(RTCx->OR, RTC_OR_OUT_RMP);
  1271. }
  1272. /**
  1273. * @brief Disable RTC_OUT remap
  1274. * @rmtoll OR OUT_RMP LL_RTC_DisableOutRemap
  1275. * @param RTCx RTC Instance
  1276. * @retval None
  1277. */
  1278. __STATIC_INLINE void LL_RTC_DisableOutRemap(RTC_TypeDef *RTCx)
  1279. {
  1280. CLEAR_BIT(RTCx->OR, RTC_OR_OUT_RMP);
  1281. }
  1282. #endif /* RTC_OR_OUT_RMP */
  1283. /**
  1284. * @}
  1285. */
  1286. /** @defgroup RTC_LL_EF_Time Time
  1287. * @{
  1288. */
  1289. /**
  1290. * @brief Set time format (AM/24-hour or PM notation)
  1291. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1292. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1293. * @rmtoll RTC_TR PM LL_RTC_TIME_SetFormat
  1294. * @param RTCx RTC Instance
  1295. * @param TimeFormat This parameter can be one of the following values:
  1296. * @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
  1297. * @arg @ref LL_RTC_TIME_FORMAT_PM
  1298. * @retval None
  1299. */
  1300. __STATIC_INLINE void LL_RTC_TIME_SetFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
  1301. {
  1302. MODIFY_REG(RTCx->TR, RTC_TR_PM, TimeFormat);
  1303. }
  1304. /**
  1305. * @brief Get time format (AM or PM notation)
  1306. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1307. * before reading this bit
  1308. * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  1309. * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  1310. * @rmtoll RTC_TR PM LL_RTC_TIME_GetFormat
  1311. * @param RTCx RTC Instance
  1312. * @retval Returned value can be one of the following values:
  1313. * @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
  1314. * @arg @ref LL_RTC_TIME_FORMAT_PM
  1315. */
  1316. __STATIC_INLINE uint32_t LL_RTC_TIME_GetFormat(RTC_TypeDef *RTCx)
  1317. {
  1318. return (uint32_t)(READ_BIT(RTCx->TR, RTC_TR_PM));
  1319. }
  1320. /**
  1321. * @brief Set Hours in BCD format
  1322. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1323. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1324. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert hour from binary to BCD format
  1325. * @rmtoll RTC_TR HT LL_RTC_TIME_SetHour
  1326. * RTC_TR HU LL_RTC_TIME_SetHour
  1327. * @param RTCx RTC Instance
  1328. * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1329. * @retval None
  1330. */
  1331. __STATIC_INLINE void LL_RTC_TIME_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
  1332. {
  1333. MODIFY_REG(RTCx->TR, (RTC_TR_HT | RTC_TR_HU),
  1334. (((Hours & 0xF0U) << (RTC_TR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos)));
  1335. }
  1336. /**
  1337. * @brief Get Hours in BCD format
  1338. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1339. * before reading this bit
  1340. * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  1341. * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  1342. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert hour from BCD to
  1343. * Binary format
  1344. * @rmtoll RTC_TR HT LL_RTC_TIME_GetHour
  1345. * RTC_TR HU LL_RTC_TIME_GetHour
  1346. * @param RTCx RTC Instance
  1347. * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1348. */
  1349. __STATIC_INLINE uint32_t LL_RTC_TIME_GetHour(RTC_TypeDef *RTCx)
  1350. {
  1351. return (uint32_t)((READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU))) >> RTC_TR_HU_Pos);
  1352. }
  1353. /**
  1354. * @brief Set Minutes in BCD format
  1355. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1356. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1357. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
  1358. * @rmtoll RTC_TR MNT LL_RTC_TIME_SetMinute
  1359. * RTC_TR MNU LL_RTC_TIME_SetMinute
  1360. * @param RTCx RTC Instance
  1361. * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
  1362. * @retval None
  1363. */
  1364. __STATIC_INLINE void LL_RTC_TIME_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
  1365. {
  1366. MODIFY_REG(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU),
  1367. (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)));
  1368. }
  1369. /**
  1370. * @brief Get Minutes in BCD format
  1371. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1372. * before reading this bit
  1373. * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  1374. * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  1375. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert minute from BCD
  1376. * to Binary format
  1377. * @rmtoll RTC_TR MNT LL_RTC_TIME_GetMinute
  1378. * RTC_TR MNU LL_RTC_TIME_GetMinute
  1379. * @param RTCx RTC Instance
  1380. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  1381. */
  1382. __STATIC_INLINE uint32_t LL_RTC_TIME_GetMinute(RTC_TypeDef *RTCx)
  1383. {
  1384. return (uint32_t)(READ_BIT(RTCx->TR, (RTC_TR_MNT | RTC_TR_MNU)) >> RTC_TR_MNU_Pos);
  1385. }
  1386. /**
  1387. * @brief Set Seconds in BCD format
  1388. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1389. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1390. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
  1391. * @rmtoll RTC_TR ST LL_RTC_TIME_SetSecond
  1392. * RTC_TR SU LL_RTC_TIME_SetSecond
  1393. * @param RTCx RTC Instance
  1394. * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
  1395. * @retval None
  1396. */
  1397. __STATIC_INLINE void LL_RTC_TIME_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
  1398. {
  1399. MODIFY_REG(RTCx->TR, (RTC_TR_ST | RTC_TR_SU),
  1400. (((Seconds & 0xF0U) << (RTC_TR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos)));
  1401. }
  1402. /**
  1403. * @brief Get Seconds in BCD format
  1404. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1405. * before reading this bit
  1406. * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  1407. * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  1408. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD
  1409. * to Binary format
  1410. * @rmtoll RTC_TR ST LL_RTC_TIME_GetSecond
  1411. * RTC_TR SU LL_RTC_TIME_GetSecond
  1412. * @param RTCx RTC Instance
  1413. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  1414. */
  1415. __STATIC_INLINE uint32_t LL_RTC_TIME_GetSecond(RTC_TypeDef *RTCx)
  1416. {
  1417. return (uint32_t)(READ_BIT(RTCx->TR, (RTC_TR_ST | RTC_TR_SU)) >> RTC_TR_SU_Pos);
  1418. }
  1419. /**
  1420. * @brief Set time (hour, minute and second) in BCD format
  1421. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1422. * @note It can be written in initialization mode only (@ref LL_RTC_EnableInitMode function)
  1423. * @note TimeFormat and Hours should follow the same format
  1424. * @rmtoll RTC_TR PM LL_RTC_TIME_Config
  1425. * RTC_TR HT LL_RTC_TIME_Config
  1426. * RTC_TR HU LL_RTC_TIME_Config
  1427. * RTC_TR MNT LL_RTC_TIME_Config
  1428. * RTC_TR MNU LL_RTC_TIME_Config
  1429. * RTC_TR ST LL_RTC_TIME_Config
  1430. * RTC_TR SU LL_RTC_TIME_Config
  1431. * @param RTCx RTC Instance
  1432. * @param Format12_24 This parameter can be one of the following values:
  1433. * @arg @ref LL_RTC_TIME_FORMAT_AM_OR_24
  1434. * @arg @ref LL_RTC_TIME_FORMAT_PM
  1435. * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1436. * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
  1437. * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
  1438. * @retval None
  1439. */
  1440. __STATIC_INLINE void LL_RTC_TIME_Config(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
  1441. {
  1442. register uint32_t temp;
  1443. temp = Format12_24 | \
  1444. (((Hours & 0xF0U) << (RTC_TR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_TR_HU_Pos)) | \
  1445. (((Minutes & 0xF0U) << (RTC_TR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_TR_MNU_Pos)) | \
  1446. (((Seconds & 0xF0U) << (RTC_TR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_TR_SU_Pos));
  1447. 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);
  1448. }
  1449. /**
  1450. * @brief Get time (hour, minute and second) in BCD format
  1451. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1452. * before reading this bit
  1453. * @note Read either RTC_SSR or RTC_TR locks the values in the higher-order calendar
  1454. * shadow registers until RTC_DR is read (LL_RTC_ReadReg(RTC, DR)).
  1455. * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
  1456. * are available to get independently each parameter.
  1457. * @rmtoll RTC_TR HT LL_RTC_TIME_Get
  1458. * RTC_TR HU LL_RTC_TIME_Get
  1459. * RTC_TR MNT LL_RTC_TIME_Get
  1460. * RTC_TR MNU LL_RTC_TIME_Get
  1461. * RTC_TR ST LL_RTC_TIME_Get
  1462. * RTC_TR SU LL_RTC_TIME_Get
  1463. * @param RTCx RTC Instance
  1464. * @retval Combination of hours, minutes and seconds (Format: 0x00HHMMSS).
  1465. */
  1466. __STATIC_INLINE uint32_t LL_RTC_TIME_Get(RTC_TypeDef *RTCx)
  1467. {
  1468. register uint32_t temp;
  1469. temp = READ_BIT(RTCx->TR, (RTC_TR_HT | RTC_TR_HU | RTC_TR_MNT | RTC_TR_MNU | RTC_TR_ST | RTC_TR_SU));
  1470. return (uint32_t)((((((temp & RTC_TR_HT) >> RTC_TR_HT_Pos) << 4U) | ((temp & RTC_TR_HU) >> RTC_TR_HU_Pos)) << RTC_OFFSET_HOUR) | \
  1471. (((((temp & RTC_TR_MNT) >> RTC_TR_MNT_Pos) << 4U) | ((temp & RTC_TR_MNU) >> RTC_TR_MNU_Pos)) << RTC_OFFSET_MINUTE) | \
  1472. ((((temp & RTC_TR_ST) >> RTC_TR_ST_Pos) << 4U) | ((temp & RTC_TR_SU) >> RTC_TR_SU_Pos)));
  1473. }
  1474. /**
  1475. * @brief Memorize whether the daylight saving time change has been performed
  1476. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1477. * @rmtoll RTC_CR BKP LL_RTC_TIME_EnableDayLightStore
  1478. * @param RTCx RTC Instance
  1479. * @retval None
  1480. */
  1481. __STATIC_INLINE void LL_RTC_TIME_EnableDayLightStore(RTC_TypeDef *RTCx)
  1482. {
  1483. SET_BIT(RTCx->CR, RTC_CR_BKP);
  1484. }
  1485. /**
  1486. * @brief Disable memorization whether the daylight saving time change has been performed.
  1487. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1488. * @rmtoll RTC_CR BKP LL_RTC_TIME_DisableDayLightStore
  1489. * @param RTCx RTC Instance
  1490. * @retval None
  1491. */
  1492. __STATIC_INLINE void LL_RTC_TIME_DisableDayLightStore(RTC_TypeDef *RTCx)
  1493. {
  1494. CLEAR_BIT(RTCx->CR, RTC_CR_BKP);
  1495. }
  1496. /**
  1497. * @brief Check if RTC Day Light Saving stored operation has been enabled or not
  1498. * @rmtoll RTC_CR BKP LL_RTC_TIME_IsDayLightStoreEnabled
  1499. * @param RTCx RTC Instance
  1500. * @retval State of bit (1 or 0).
  1501. */
  1502. __STATIC_INLINE uint32_t LL_RTC_TIME_IsDayLightStoreEnabled(RTC_TypeDef *RTCx)
  1503. {
  1504. return ((READ_BIT(RTCx->CR, RTC_CR_BKP) == (RTC_CR_BKP)) ? 1UL : 0UL);
  1505. }
  1506. /**
  1507. * @brief Subtract 1 hour (winter time change)
  1508. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1509. * @rmtoll RTC_CR SUB1H LL_RTC_TIME_DecHour
  1510. * @param RTCx RTC Instance
  1511. * @retval None
  1512. */
  1513. __STATIC_INLINE void LL_RTC_TIME_DecHour(RTC_TypeDef *RTCx)
  1514. {
  1515. SET_BIT(RTCx->CR, RTC_CR_SUB1H);
  1516. }
  1517. /**
  1518. * @brief Add 1 hour (summer time change)
  1519. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1520. * @rmtoll RTC_CR ADD1H LL_RTC_TIME_IncHour
  1521. * @param RTCx RTC Instance
  1522. * @retval None
  1523. */
  1524. __STATIC_INLINE void LL_RTC_TIME_IncHour(RTC_TypeDef *RTCx)
  1525. {
  1526. SET_BIT(RTCx->CR, RTC_CR_ADD1H);
  1527. }
  1528. /**
  1529. * @brief Get Sub second value in the synchronous prescaler counter.
  1530. * @note You can use both SubSeconds value and SecondFraction (PREDIV_S through
  1531. * LL_RTC_GetSynchPrescaler function) terms returned to convert Calendar
  1532. * SubSeconds value in second fraction ratio with time unit following
  1533. * generic formula:
  1534. * ==> Seconds fraction ratio * time_unit= [(SecondFraction-SubSeconds)/(SecondFraction+1)] * time_unit
  1535. * This conversion can be performed only if no shift operation is pending
  1536. * (ie. SHFP=0) when PREDIV_S >= SS.
  1537. * @rmtoll RTC_SSR SS LL_RTC_TIME_GetSubSecond
  1538. * @param RTCx RTC Instance
  1539. * @retval Sub second value (number between 0 and 65535)
  1540. */
  1541. __STATIC_INLINE uint32_t LL_RTC_TIME_GetSubSecond(RTC_TypeDef *RTCx)
  1542. {
  1543. return (uint32_t)(READ_BIT(RTCx->SSR, RTC_SSR_SS));
  1544. }
  1545. /**
  1546. * @brief Synchronize to a remote clock with a high degree of precision.
  1547. * @note This operation effectively subtracts from (delays) or advance the clock of a fraction of a second.
  1548. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1549. * @note When REFCKON is set, firmware must not write to Shift control register.
  1550. * @rmtoll RTC_SHIFTR ADD1S LL_RTC_TIME_Synchronize
  1551. * RTC_SHIFTR SUBFS LL_RTC_TIME_Synchronize
  1552. * @param RTCx RTC Instance
  1553. * @param ShiftSecond This parameter can be one of the following values:
  1554. * @arg @ref LL_RTC_SHIFT_SECOND_DELAY
  1555. * @arg @ref LL_RTC_SHIFT_SECOND_ADVANCE
  1556. * @param Fraction Number of Seconds Fractions (any value from 0 to 0x7FFF)
  1557. * @retval None
  1558. */
  1559. __STATIC_INLINE void LL_RTC_TIME_Synchronize(RTC_TypeDef *RTCx, uint32_t ShiftSecond, uint32_t Fraction)
  1560. {
  1561. WRITE_REG(RTCx->SHIFTR, ShiftSecond | Fraction);
  1562. }
  1563. /**
  1564. * @}
  1565. */
  1566. /** @defgroup RTC_LL_EF_Date Date
  1567. * @{
  1568. */
  1569. /**
  1570. * @brief Set Year in BCD format
  1571. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Year from binary to BCD format
  1572. * @rmtoll RTC_DR YT LL_RTC_DATE_SetYear
  1573. * RTC_DR YU LL_RTC_DATE_SetYear
  1574. * @param RTCx RTC Instance
  1575. * @param Year Value between Min_Data=0x00 and Max_Data=0x99
  1576. * @retval None
  1577. */
  1578. __STATIC_INLINE void LL_RTC_DATE_SetYear(RTC_TypeDef *RTCx, uint32_t Year)
  1579. {
  1580. MODIFY_REG(RTCx->DR, (RTC_DR_YT | RTC_DR_YU),
  1581. (((Year & 0xF0U) << (RTC_DR_YT_Pos - 4U)) | ((Year & 0x0FU) << RTC_DR_YU_Pos)));
  1582. }
  1583. /**
  1584. * @brief Get Year in BCD format
  1585. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1586. * before reading this bit
  1587. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Year from BCD to Binary format
  1588. * @rmtoll RTC_DR YT LL_RTC_DATE_GetYear
  1589. * RTC_DR YU LL_RTC_DATE_GetYear
  1590. * @param RTCx RTC Instance
  1591. * @retval Value between Min_Data=0x00 and Max_Data=0x99
  1592. */
  1593. __STATIC_INLINE uint32_t LL_RTC_DATE_GetYear(RTC_TypeDef *RTCx)
  1594. {
  1595. return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_YT | RTC_DR_YU))) >> RTC_DR_YU_Pos);
  1596. }
  1597. /**
  1598. * @brief Set Week day
  1599. * @rmtoll RTC_DR WDU LL_RTC_DATE_SetWeekDay
  1600. * @param RTCx RTC Instance
  1601. * @param WeekDay This parameter can be one of the following values:
  1602. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  1603. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1604. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1605. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1606. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1607. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1608. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1609. * @retval None
  1610. */
  1611. __STATIC_INLINE void LL_RTC_DATE_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
  1612. {
  1613. MODIFY_REG(RTCx->DR, RTC_DR_WDU, WeekDay << RTC_DR_WDU_Pos);
  1614. }
  1615. /**
  1616. * @brief Get Week day
  1617. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1618. * before reading this bit
  1619. * @rmtoll RTC_DR WDU LL_RTC_DATE_GetWeekDay
  1620. * @param RTCx RTC Instance
  1621. * @retval Returned value can be one of the following values:
  1622. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  1623. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1624. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1625. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1626. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1627. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1628. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1629. */
  1630. __STATIC_INLINE uint32_t LL_RTC_DATE_GetWeekDay(RTC_TypeDef *RTCx)
  1631. {
  1632. return (uint32_t)(READ_BIT(RTCx->DR, RTC_DR_WDU) >> RTC_DR_WDU_Pos);
  1633. }
  1634. /**
  1635. * @brief Set Month in BCD format
  1636. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Month from binary to BCD format
  1637. * @rmtoll RTC_DR MT LL_RTC_DATE_SetMonth
  1638. * RTC_DR MU LL_RTC_DATE_SetMonth
  1639. * @param RTCx RTC Instance
  1640. * @param Month This parameter can be one of the following values:
  1641. * @arg @ref LL_RTC_MONTH_JANUARY
  1642. * @arg @ref LL_RTC_MONTH_FEBRUARY
  1643. * @arg @ref LL_RTC_MONTH_MARCH
  1644. * @arg @ref LL_RTC_MONTH_APRIL
  1645. * @arg @ref LL_RTC_MONTH_MAY
  1646. * @arg @ref LL_RTC_MONTH_JUNE
  1647. * @arg @ref LL_RTC_MONTH_JULY
  1648. * @arg @ref LL_RTC_MONTH_AUGUST
  1649. * @arg @ref LL_RTC_MONTH_SEPTEMBER
  1650. * @arg @ref LL_RTC_MONTH_OCTOBER
  1651. * @arg @ref LL_RTC_MONTH_NOVEMBER
  1652. * @arg @ref LL_RTC_MONTH_DECEMBER
  1653. * @retval None
  1654. */
  1655. __STATIC_INLINE void LL_RTC_DATE_SetMonth(RTC_TypeDef *RTCx, uint32_t Month)
  1656. {
  1657. MODIFY_REG(RTCx->DR, (RTC_DR_MT | RTC_DR_MU),
  1658. (((Month & 0xF0U) << (RTC_DR_MT_Pos - 4U)) | ((Month & 0x0FU) << RTC_DR_MU_Pos)));
  1659. }
  1660. /**
  1661. * @brief Get Month in BCD format
  1662. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1663. * before reading this bit
  1664. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Month from BCD to Binary format
  1665. * @rmtoll RTC_DR MT LL_RTC_DATE_GetMonth
  1666. * RTC_DR MU LL_RTC_DATE_GetMonth
  1667. * @param RTCx RTC Instance
  1668. * @retval Returned value can be one of the following values:
  1669. * @arg @ref LL_RTC_MONTH_JANUARY
  1670. * @arg @ref LL_RTC_MONTH_FEBRUARY
  1671. * @arg @ref LL_RTC_MONTH_MARCH
  1672. * @arg @ref LL_RTC_MONTH_APRIL
  1673. * @arg @ref LL_RTC_MONTH_MAY
  1674. * @arg @ref LL_RTC_MONTH_JUNE
  1675. * @arg @ref LL_RTC_MONTH_JULY
  1676. * @arg @ref LL_RTC_MONTH_AUGUST
  1677. * @arg @ref LL_RTC_MONTH_SEPTEMBER
  1678. * @arg @ref LL_RTC_MONTH_OCTOBER
  1679. * @arg @ref LL_RTC_MONTH_NOVEMBER
  1680. * @arg @ref LL_RTC_MONTH_DECEMBER
  1681. */
  1682. __STATIC_INLINE uint32_t LL_RTC_DATE_GetMonth(RTC_TypeDef *RTCx)
  1683. {
  1684. return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_MT | RTC_DR_MU))) >> RTC_DR_MU_Pos);
  1685. }
  1686. /**
  1687. * @brief Set Day in BCD format
  1688. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
  1689. * @rmtoll RTC_DR DT LL_RTC_DATE_SetDay
  1690. * RTC_DR DU LL_RTC_DATE_SetDay
  1691. * @param RTCx RTC Instance
  1692. * @param Day Value between Min_Data=0x01 and Max_Data=0x31
  1693. * @retval None
  1694. */
  1695. __STATIC_INLINE void LL_RTC_DATE_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
  1696. {
  1697. MODIFY_REG(RTCx->DR, (RTC_DR_DT | RTC_DR_DU),
  1698. (((Day & 0xF0U) << (RTC_DR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_DR_DU_Pos)));
  1699. }
  1700. /**
  1701. * @brief Get Day in BCD format
  1702. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1703. * before reading this bit
  1704. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
  1705. * @rmtoll RTC_DR DT LL_RTC_DATE_GetDay
  1706. * RTC_DR DU LL_RTC_DATE_GetDay
  1707. * @param RTCx RTC Instance
  1708. * @retval Value between Min_Data=0x01 and Max_Data=0x31
  1709. */
  1710. __STATIC_INLINE uint32_t LL_RTC_DATE_GetDay(RTC_TypeDef *RTCx)
  1711. {
  1712. return (uint32_t)((READ_BIT(RTCx->DR, (RTC_DR_DT | RTC_DR_DU))) >> RTC_DR_DU_Pos);
  1713. }
  1714. /**
  1715. * @brief Set date (WeekDay, Day, Month and Year) in BCD format
  1716. * @rmtoll RTC_DR WDU LL_RTC_DATE_Config
  1717. * RTC_DR MT LL_RTC_DATE_Config
  1718. * RTC_DR MU LL_RTC_DATE_Config
  1719. * RTC_DR DT LL_RTC_DATE_Config
  1720. * RTC_DR DU LL_RTC_DATE_Config
  1721. * RTC_DR YT LL_RTC_DATE_Config
  1722. * RTC_DR YU LL_RTC_DATE_Config
  1723. * @param RTCx RTC Instance
  1724. * @param WeekDay This parameter can be one of the following values:
  1725. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  1726. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1727. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1728. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1729. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1730. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1731. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1732. * @param Day Value between Min_Data=0x01 and Max_Data=0x31
  1733. * @param Month This parameter can be one of the following values:
  1734. * @arg @ref LL_RTC_MONTH_JANUARY
  1735. * @arg @ref LL_RTC_MONTH_FEBRUARY
  1736. * @arg @ref LL_RTC_MONTH_MARCH
  1737. * @arg @ref LL_RTC_MONTH_APRIL
  1738. * @arg @ref LL_RTC_MONTH_MAY
  1739. * @arg @ref LL_RTC_MONTH_JUNE
  1740. * @arg @ref LL_RTC_MONTH_JULY
  1741. * @arg @ref LL_RTC_MONTH_AUGUST
  1742. * @arg @ref LL_RTC_MONTH_SEPTEMBER
  1743. * @arg @ref LL_RTC_MONTH_OCTOBER
  1744. * @arg @ref LL_RTC_MONTH_NOVEMBER
  1745. * @arg @ref LL_RTC_MONTH_DECEMBER
  1746. * @param Year Value between Min_Data=0x00 and Max_Data=0x99
  1747. * @retval None
  1748. */
  1749. __STATIC_INLINE void LL_RTC_DATE_Config(RTC_TypeDef *RTCx, uint32_t WeekDay, uint32_t Day, uint32_t Month, uint32_t Year)
  1750. {
  1751. register uint32_t temp;
  1752. temp = (WeekDay << RTC_DR_WDU_Pos) | \
  1753. (((Year & 0xF0U) << (RTC_DR_YT_Pos - 4U)) | ((Year & 0x0FU) << RTC_DR_YU_Pos)) | \
  1754. (((Month & 0xF0U) << (RTC_DR_MT_Pos - 4U)) | ((Month & 0x0FU) << RTC_DR_MU_Pos)) | \
  1755. (((Day & 0xF0U) << (RTC_DR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_DR_DU_Pos));
  1756. 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);
  1757. }
  1758. /**
  1759. * @brief Get date (WeekDay, Day, Month and Year) in BCD format
  1760. * @note if shadow mode is disabled (BYPSHAD=0), need to check if RSF flag is set
  1761. * before reading this bit
  1762. * @note helper macros __LL_RTC_GET_WEEKDAY, __LL_RTC_GET_YEAR, __LL_RTC_GET_MONTH,
  1763. * and __LL_RTC_GET_DAY are available to get independently each parameter.
  1764. * @rmtoll RTC_DR WDU LL_RTC_DATE_Get
  1765. * RTC_DR MT LL_RTC_DATE_Get
  1766. * RTC_DR MU LL_RTC_DATE_Get
  1767. * RTC_DR DT LL_RTC_DATE_Get
  1768. * RTC_DR DU LL_RTC_DATE_Get
  1769. * RTC_DR YT LL_RTC_DATE_Get
  1770. * RTC_DR YU LL_RTC_DATE_Get
  1771. * @param RTCx RTC Instance
  1772. * @retval Combination of WeekDay, Day, Month and Year (Format: 0xWWDDMMYY).
  1773. */
  1774. __STATIC_INLINE uint32_t LL_RTC_DATE_Get(RTC_TypeDef *RTCx)
  1775. {
  1776. register uint32_t temp;
  1777. 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));
  1778. return (uint32_t)((((temp & RTC_DR_WDU) >> RTC_DR_WDU_Pos) << RTC_OFFSET_WEEKDAY) | \
  1779. (((((temp & RTC_DR_DT) >> RTC_DR_DT_Pos) << 4U) | ((temp & RTC_DR_DU) >> RTC_DR_DU_Pos)) << RTC_OFFSET_DAY) | \
  1780. (((((temp & RTC_DR_MT) >> RTC_DR_MT_Pos) << 4U) | ((temp & RTC_DR_MU) >> RTC_DR_MU_Pos)) << RTC_OFFSET_MONTH) | \
  1781. ((((temp & RTC_DR_YT) >> RTC_DR_YT_Pos) << 4U) | ((temp & RTC_DR_YU) >> RTC_DR_YU_Pos)));
  1782. }
  1783. /**
  1784. * @}
  1785. */
  1786. /** @defgroup RTC_LL_EF_ALARMA ALARMA
  1787. * @{
  1788. */
  1789. /**
  1790. * @brief Enable Alarm A
  1791. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1792. * @rmtoll RTC_CR ALRAE LL_RTC_ALMA_Enable
  1793. * @param RTCx RTC Instance
  1794. * @retval None
  1795. */
  1796. __STATIC_INLINE void LL_RTC_ALMA_Enable(RTC_TypeDef *RTCx)
  1797. {
  1798. SET_BIT(RTCx->CR, RTC_CR_ALRAE);
  1799. }
  1800. /**
  1801. * @brief Disable Alarm A
  1802. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  1803. * @rmtoll RTC_CR ALRAE LL_RTC_ALMA_Disable
  1804. * @param RTCx RTC Instance
  1805. * @retval None
  1806. */
  1807. __STATIC_INLINE void LL_RTC_ALMA_Disable(RTC_TypeDef *RTCx)
  1808. {
  1809. CLEAR_BIT(RTCx->CR, RTC_CR_ALRAE);
  1810. }
  1811. /**
  1812. * @brief Specify the Alarm A masks.
  1813. * @rmtoll RTC_ALRMAR MSK4 LL_RTC_ALMA_SetMask
  1814. * RTC_ALRMAR MSK3 LL_RTC_ALMA_SetMask
  1815. * RTC_ALRMAR MSK2 LL_RTC_ALMA_SetMask
  1816. * RTC_ALRMAR MSK1 LL_RTC_ALMA_SetMask
  1817. * @param RTCx RTC Instance
  1818. * @param Mask This parameter can be a combination of the following values:
  1819. * @arg @ref LL_RTC_ALMA_MASK_NONE
  1820. * @arg @ref LL_RTC_ALMA_MASK_DATEWEEKDAY
  1821. * @arg @ref LL_RTC_ALMA_MASK_HOURS
  1822. * @arg @ref LL_RTC_ALMA_MASK_MINUTES
  1823. * @arg @ref LL_RTC_ALMA_MASK_SECONDS
  1824. * @arg @ref LL_RTC_ALMA_MASK_ALL
  1825. * @retval None
  1826. */
  1827. __STATIC_INLINE void LL_RTC_ALMA_SetMask(RTC_TypeDef *RTCx, uint32_t Mask)
  1828. {
  1829. MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1, Mask);
  1830. }
  1831. /**
  1832. * @brief Get the Alarm A masks.
  1833. * @rmtoll RTC_ALRMAR MSK4 LL_RTC_ALMA_GetMask
  1834. * RTC_ALRMAR MSK3 LL_RTC_ALMA_GetMask
  1835. * RTC_ALRMAR MSK2 LL_RTC_ALMA_GetMask
  1836. * RTC_ALRMAR MSK1 LL_RTC_ALMA_GetMask
  1837. * @param RTCx RTC Instance
  1838. * @retval Returned value can be can be a combination of the following values:
  1839. * @arg @ref LL_RTC_ALMA_MASK_NONE
  1840. * @arg @ref LL_RTC_ALMA_MASK_DATEWEEKDAY
  1841. * @arg @ref LL_RTC_ALMA_MASK_HOURS
  1842. * @arg @ref LL_RTC_ALMA_MASK_MINUTES
  1843. * @arg @ref LL_RTC_ALMA_MASK_SECONDS
  1844. * @arg @ref LL_RTC_ALMA_MASK_ALL
  1845. */
  1846. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetMask(RTC_TypeDef *RTCx)
  1847. {
  1848. return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_MSK4 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK1));
  1849. }
  1850. /**
  1851. * @brief Enable AlarmA Week day selection (DU[3:0] represents the week day. DT[1:0] is do not care)
  1852. * @rmtoll RTC_ALRMAR WDSEL LL_RTC_ALMA_EnableWeekday
  1853. * @param RTCx RTC Instance
  1854. * @retval None
  1855. */
  1856. __STATIC_INLINE void LL_RTC_ALMA_EnableWeekday(RTC_TypeDef *RTCx)
  1857. {
  1858. SET_BIT(RTCx->ALRMAR, RTC_ALRMAR_WDSEL);
  1859. }
  1860. /**
  1861. * @brief Disable AlarmA Week day selection (DU[3:0] represents the date )
  1862. * @rmtoll RTC_ALRMAR WDSEL LL_RTC_ALMA_DisableWeekday
  1863. * @param RTCx RTC Instance
  1864. * @retval None
  1865. */
  1866. __STATIC_INLINE void LL_RTC_ALMA_DisableWeekday(RTC_TypeDef *RTCx)
  1867. {
  1868. CLEAR_BIT(RTCx->ALRMAR, RTC_ALRMAR_WDSEL);
  1869. }
  1870. /**
  1871. * @brief Set ALARM A Day in BCD format
  1872. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
  1873. * @rmtoll RTC_ALRMAR DT LL_RTC_ALMA_SetDay
  1874. * RTC_ALRMAR DU LL_RTC_ALMA_SetDay
  1875. * @param RTCx RTC Instance
  1876. * @param Day Value between Min_Data=0x01 and Max_Data=0x31
  1877. * @retval None
  1878. */
  1879. __STATIC_INLINE void LL_RTC_ALMA_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
  1880. {
  1881. MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_DT | RTC_ALRMAR_DU),
  1882. (((Day & 0xF0U) << (RTC_ALRMAR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_ALRMAR_DU_Pos)));
  1883. }
  1884. /**
  1885. * @brief Get ALARM A Day in BCD format
  1886. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
  1887. * @rmtoll RTC_ALRMAR DT LL_RTC_ALMA_GetDay
  1888. * RTC_ALRMAR DU LL_RTC_ALMA_GetDay
  1889. * @param RTCx RTC Instance
  1890. * @retval Value between Min_Data=0x01 and Max_Data=0x31
  1891. */
  1892. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetDay(RTC_TypeDef *RTCx)
  1893. {
  1894. return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_DT | RTC_ALRMAR_DU))) >> RTC_ALRMAR_DU_Pos);
  1895. }
  1896. /**
  1897. * @brief Set ALARM A Weekday
  1898. * @rmtoll RTC_ALRMAR DU LL_RTC_ALMA_SetWeekDay
  1899. * @param RTCx RTC Instance
  1900. * @param WeekDay This parameter can be one of the following values:
  1901. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  1902. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1903. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1904. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1905. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1906. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1907. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1908. * @retval None
  1909. */
  1910. __STATIC_INLINE void LL_RTC_ALMA_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
  1911. {
  1912. MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_DU, WeekDay << RTC_ALRMAR_DU_Pos);
  1913. }
  1914. /**
  1915. * @brief Get ALARM A Weekday
  1916. * @rmtoll RTC_ALRMAR DU LL_RTC_ALMA_GetWeekDay
  1917. * @param RTCx RTC Instance
  1918. * @retval Returned value can be one of the following values:
  1919. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  1920. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  1921. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  1922. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  1923. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  1924. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  1925. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  1926. */
  1927. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetWeekDay(RTC_TypeDef *RTCx)
  1928. {
  1929. return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_DU) >> RTC_ALRMAR_DU_Pos);
  1930. }
  1931. /**
  1932. * @brief Set Alarm A time format (AM/24-hour or PM notation)
  1933. * @rmtoll RTC_ALRMAR PM LL_RTC_ALMA_SetTimeFormat
  1934. * @param RTCx RTC Instance
  1935. * @param TimeFormat This parameter can be one of the following values:
  1936. * @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
  1937. * @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
  1938. * @retval None
  1939. */
  1940. __STATIC_INLINE void LL_RTC_ALMA_SetTimeFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
  1941. {
  1942. MODIFY_REG(RTCx->ALRMAR, RTC_ALRMAR_PM, TimeFormat);
  1943. }
  1944. /**
  1945. * @brief Get Alarm A time format (AM or PM notation)
  1946. * @rmtoll RTC_ALRMAR PM LL_RTC_ALMA_GetTimeFormat
  1947. * @param RTCx RTC Instance
  1948. * @retval Returned value can be one of the following values:
  1949. * @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
  1950. * @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
  1951. */
  1952. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetTimeFormat(RTC_TypeDef *RTCx)
  1953. {
  1954. return (uint32_t)(READ_BIT(RTCx->ALRMAR, RTC_ALRMAR_PM));
  1955. }
  1956. /**
  1957. * @brief Set ALARM A Hours in BCD format
  1958. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Hours from binary to BCD format
  1959. * @rmtoll RTC_ALRMAR HT LL_RTC_ALMA_SetHour
  1960. * RTC_ALRMAR HU LL_RTC_ALMA_SetHour
  1961. * @param RTCx RTC Instance
  1962. * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1963. * @retval None
  1964. */
  1965. __STATIC_INLINE void LL_RTC_ALMA_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
  1966. {
  1967. MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_HT | RTC_ALRMAR_HU),
  1968. (((Hours & 0xF0U) << (RTC_ALRMAR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMAR_HU_Pos)));
  1969. }
  1970. /**
  1971. * @brief Get ALARM A Hours in BCD format
  1972. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
  1973. * @rmtoll RTC_ALRMAR HT LL_RTC_ALMA_GetHour
  1974. * RTC_ALRMAR HU LL_RTC_ALMA_GetHour
  1975. * @param RTCx RTC Instance
  1976. * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  1977. */
  1978. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetHour(RTC_TypeDef *RTCx)
  1979. {
  1980. return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_HT | RTC_ALRMAR_HU))) >> RTC_ALRMAR_HU_Pos);
  1981. }
  1982. /**
  1983. * @brief Set ALARM A Minutes in BCD format
  1984. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
  1985. * @rmtoll RTC_ALRMAR MNT LL_RTC_ALMA_SetMinute
  1986. * RTC_ALRMAR MNU LL_RTC_ALMA_SetMinute
  1987. * @param RTCx RTC Instance
  1988. * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
  1989. * @retval None
  1990. */
  1991. __STATIC_INLINE void LL_RTC_ALMA_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
  1992. {
  1993. MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU),
  1994. (((Minutes & 0xF0U) << (RTC_ALRMAR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMAR_MNU_Pos)));
  1995. }
  1996. /**
  1997. * @brief Get ALARM A Minutes in BCD format
  1998. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
  1999. * @rmtoll RTC_ALRMAR MNT LL_RTC_ALMA_GetMinute
  2000. * RTC_ALRMAR MNU LL_RTC_ALMA_GetMinute
  2001. * @param RTCx RTC Instance
  2002. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  2003. */
  2004. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetMinute(RTC_TypeDef *RTCx)
  2005. {
  2006. return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU))) >> RTC_ALRMAR_MNU_Pos);
  2007. }
  2008. /**
  2009. * @brief Set ALARM A Seconds in BCD format
  2010. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
  2011. * @rmtoll RTC_ALRMAR ST LL_RTC_ALMA_SetSecond
  2012. * RTC_ALRMAR SU LL_RTC_ALMA_SetSecond
  2013. * @param RTCx RTC Instance
  2014. * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
  2015. * @retval None
  2016. */
  2017. __STATIC_INLINE void LL_RTC_ALMA_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
  2018. {
  2019. MODIFY_REG(RTCx->ALRMAR, (RTC_ALRMAR_ST | RTC_ALRMAR_SU),
  2020. (((Seconds & 0xF0U) << (RTC_ALRMAR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMAR_SU_Pos)));
  2021. }
  2022. /**
  2023. * @brief Get ALARM A Seconds in BCD format
  2024. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
  2025. * @rmtoll RTC_ALRMAR ST LL_RTC_ALMA_GetSecond
  2026. * RTC_ALRMAR SU LL_RTC_ALMA_GetSecond
  2027. * @param RTCx RTC Instance
  2028. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  2029. */
  2030. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSecond(RTC_TypeDef *RTCx)
  2031. {
  2032. return (uint32_t)((READ_BIT(RTCx->ALRMAR, (RTC_ALRMAR_ST | RTC_ALRMAR_SU))) >> RTC_ALRMAR_SU_Pos);
  2033. }
  2034. /**
  2035. * @brief Set Alarm A Time (hour, minute and second) in BCD format
  2036. * @rmtoll RTC_ALRMAR PM LL_RTC_ALMA_ConfigTime
  2037. * RTC_ALRMAR HT LL_RTC_ALMA_ConfigTime
  2038. * RTC_ALRMAR HU LL_RTC_ALMA_ConfigTime
  2039. * RTC_ALRMAR MNT LL_RTC_ALMA_ConfigTime
  2040. * RTC_ALRMAR MNU LL_RTC_ALMA_ConfigTime
  2041. * RTC_ALRMAR ST LL_RTC_ALMA_ConfigTime
  2042. * RTC_ALRMAR SU LL_RTC_ALMA_ConfigTime
  2043. * @param RTCx RTC Instance
  2044. * @param Format12_24 This parameter can be one of the following values:
  2045. * @arg @ref LL_RTC_ALMA_TIME_FORMAT_AM
  2046. * @arg @ref LL_RTC_ALMA_TIME_FORMAT_PM
  2047. * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  2048. * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
  2049. * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
  2050. * @retval None
  2051. */
  2052. __STATIC_INLINE void LL_RTC_ALMA_ConfigTime(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
  2053. {
  2054. register uint32_t temp;
  2055. temp = Format12_24 | (((Hours & 0xF0U) << (RTC_ALRMAR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMAR_HU_Pos)) | \
  2056. (((Minutes & 0xF0U) << (RTC_ALRMAR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMAR_MNU_Pos)) | \
  2057. (((Seconds & 0xF0U) << (RTC_ALRMAR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMAR_SU_Pos));
  2058. 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);
  2059. }
  2060. /**
  2061. * @brief Get Alarm B Time (hour, minute and second) in BCD format
  2062. * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
  2063. * are available to get independently each parameter.
  2064. * @rmtoll RTC_ALRMAR HT LL_RTC_ALMA_GetTime
  2065. * RTC_ALRMAR HU LL_RTC_ALMA_GetTime
  2066. * RTC_ALRMAR MNT LL_RTC_ALMA_GetTime
  2067. * RTC_ALRMAR MNU LL_RTC_ALMA_GetTime
  2068. * RTC_ALRMAR ST LL_RTC_ALMA_GetTime
  2069. * RTC_ALRMAR SU LL_RTC_ALMA_GetTime
  2070. * @param RTCx RTC Instance
  2071. * @retval Combination of hours, minutes and seconds.
  2072. */
  2073. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetTime(RTC_TypeDef *RTCx)
  2074. {
  2075. return (uint32_t)((LL_RTC_ALMA_GetHour(RTCx) << RTC_OFFSET_HOUR) | (LL_RTC_ALMA_GetMinute(RTCx) << RTC_OFFSET_MINUTE) | LL_RTC_ALMA_GetSecond(RTCx));
  2076. }
  2077. /**
  2078. * @brief Set Alarm A Mask the most-significant bits starting at this bit
  2079. * @note This register can be written only when ALRAE is reset in RTC_CR register,
  2080. * or in initialization mode.
  2081. * @rmtoll RTC_ALRMASSR MASKSS LL_RTC_ALMA_SetSubSecondMask
  2082. * @param RTCx RTC Instance
  2083. * @param Mask Value between Min_Data=0x00 and Max_Data=0xF
  2084. * @retval None
  2085. */
  2086. __STATIC_INLINE void LL_RTC_ALMA_SetSubSecondMask(RTC_TypeDef *RTCx, uint32_t Mask)
  2087. {
  2088. MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_MASKSS, Mask << RTC_ALRMASSR_MASKSS_Pos);
  2089. }
  2090. /**
  2091. * @brief Get Alarm A Mask the most-significant bits starting at this bit
  2092. * @rmtoll RTC_ALRMASSR MASKSS LL_RTC_ALMA_GetSubSecondMask
  2093. * @param RTCx RTC Instance
  2094. * @retval Value between Min_Data=0x00 and Max_Data=0xF
  2095. */
  2096. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecondMask(RTC_TypeDef *RTCx)
  2097. {
  2098. return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_MASKSS) >> RTC_ALRMASSR_MASKSS_Pos);
  2099. }
  2100. /**
  2101. * @brief Set Alarm A Sub seconds value
  2102. * @rmtoll RCT_ALRMASSR SS LL_RTC_ALMA_SetSubSecond
  2103. * @param RTCx RTC Instance
  2104. * @param Subsecond Value between Min_Data=0x00 and Max_Data=0x7FFF
  2105. * @retval None
  2106. */
  2107. __STATIC_INLINE void LL_RTC_ALMA_SetSubSecond(RTC_TypeDef *RTCx, uint32_t Subsecond)
  2108. {
  2109. MODIFY_REG(RTCx->ALRMASSR, RTC_ALRMASSR_SS, Subsecond);
  2110. }
  2111. /**
  2112. * @brief Get Alarm A Sub seconds value
  2113. * @rmtoll RCT_ALRMASSR SS LL_RTC_ALMA_GetSubSecond
  2114. * @param RTCx RTC Instance
  2115. * @retval Value between Min_Data=0x00 and Max_Data=0x7FFF
  2116. */
  2117. __STATIC_INLINE uint32_t LL_RTC_ALMA_GetSubSecond(RTC_TypeDef *RTCx)
  2118. {
  2119. return (uint32_t)(READ_BIT(RTCx->ALRMASSR, RTC_ALRMASSR_SS));
  2120. }
  2121. /**
  2122. * @}
  2123. */
  2124. /** @defgroup RTC_LL_EF_ALARMB ALARMB
  2125. * @{
  2126. */
  2127. /**
  2128. * @brief Enable Alarm B
  2129. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2130. * @rmtoll RTC_CR ALRBE LL_RTC_ALMB_Enable
  2131. * @param RTCx RTC Instance
  2132. * @retval None
  2133. */
  2134. __STATIC_INLINE void LL_RTC_ALMB_Enable(RTC_TypeDef *RTCx)
  2135. {
  2136. SET_BIT(RTCx->CR, RTC_CR_ALRBE);
  2137. }
  2138. /**
  2139. * @brief Disable Alarm B
  2140. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2141. * @rmtoll RTC_CR ALRBE LL_RTC_ALMB_Disable
  2142. * @param RTCx RTC Instance
  2143. * @retval None
  2144. */
  2145. __STATIC_INLINE void LL_RTC_ALMB_Disable(RTC_TypeDef *RTCx)
  2146. {
  2147. CLEAR_BIT(RTCx->CR, RTC_CR_ALRBE);
  2148. }
  2149. /**
  2150. * @brief Specify the Alarm B masks.
  2151. * @rmtoll RTC_ALRMBR MSK4 LL_RTC_ALMB_SetMask
  2152. * RTC_ALRMBR MSK3 LL_RTC_ALMB_SetMask
  2153. * RTC_ALRMBR MSK2 LL_RTC_ALMB_SetMask
  2154. * RTC_ALRMBR MSK1 LL_RTC_ALMB_SetMask
  2155. * @param RTCx RTC Instance
  2156. * @param Mask This parameter can be a combination of the following values:
  2157. * @arg @ref LL_RTC_ALMB_MASK_NONE
  2158. * @arg @ref LL_RTC_ALMB_MASK_DATEWEEKDAY
  2159. * @arg @ref LL_RTC_ALMB_MASK_HOURS
  2160. * @arg @ref LL_RTC_ALMB_MASK_MINUTES
  2161. * @arg @ref LL_RTC_ALMB_MASK_SECONDS
  2162. * @arg @ref LL_RTC_ALMB_MASK_ALL
  2163. * @retval None
  2164. */
  2165. __STATIC_INLINE void LL_RTC_ALMB_SetMask(RTC_TypeDef *RTCx, uint32_t Mask)
  2166. {
  2167. MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1, Mask);
  2168. }
  2169. /**
  2170. * @brief Get the Alarm B masks.
  2171. * @rmtoll RTC_ALRMBR MSK4 LL_RTC_ALMB_GetMask
  2172. * RTC_ALRMBR MSK3 LL_RTC_ALMB_GetMask
  2173. * RTC_ALRMBR MSK2 LL_RTC_ALMB_GetMask
  2174. * RTC_ALRMBR MSK1 LL_RTC_ALMB_GetMask
  2175. * @param RTCx RTC Instance
  2176. * @retval Returned value can be can be a combination of the following values:
  2177. * @arg @ref LL_RTC_ALMB_MASK_NONE
  2178. * @arg @ref LL_RTC_ALMB_MASK_DATEWEEKDAY
  2179. * @arg @ref LL_RTC_ALMB_MASK_HOURS
  2180. * @arg @ref LL_RTC_ALMB_MASK_MINUTES
  2181. * @arg @ref LL_RTC_ALMB_MASK_SECONDS
  2182. * @arg @ref LL_RTC_ALMB_MASK_ALL
  2183. */
  2184. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetMask(RTC_TypeDef *RTCx)
  2185. {
  2186. return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_MSK4 | RTC_ALRMBR_MSK3 | RTC_ALRMBR_MSK2 | RTC_ALRMBR_MSK1));
  2187. }
  2188. /**
  2189. * @brief Enable AlarmB Week day selection (DU[3:0] represents the week day. DT[1:0] is do not care)
  2190. * @rmtoll RTC_ALRMBR WDSEL LL_RTC_ALMB_EnableWeekday
  2191. * @param RTCx RTC Instance
  2192. * @retval None
  2193. */
  2194. __STATIC_INLINE void LL_RTC_ALMB_EnableWeekday(RTC_TypeDef *RTCx)
  2195. {
  2196. SET_BIT(RTCx->ALRMBR, RTC_ALRMBR_WDSEL);
  2197. }
  2198. /**
  2199. * @brief Disable AlarmB Week day selection (DU[3:0] represents the date )
  2200. * @rmtoll RTC_ALRMBR WDSEL LL_RTC_ALMB_DisableWeekday
  2201. * @param RTCx RTC Instance
  2202. * @retval None
  2203. */
  2204. __STATIC_INLINE void LL_RTC_ALMB_DisableWeekday(RTC_TypeDef *RTCx)
  2205. {
  2206. CLEAR_BIT(RTCx->ALRMBR, RTC_ALRMBR_WDSEL);
  2207. }
  2208. /**
  2209. * @brief Set ALARM B Day in BCD format
  2210. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Day from binary to BCD format
  2211. * @rmtoll RTC_ALRMBR DT LL_RTC_ALMB_SetDay
  2212. * RTC_ALRMBR DU LL_RTC_ALMB_SetDay
  2213. * @param RTCx RTC Instance
  2214. * @param Day Value between Min_Data=0x01 and Max_Data=0x31
  2215. * @retval None
  2216. */
  2217. __STATIC_INLINE void LL_RTC_ALMB_SetDay(RTC_TypeDef *RTCx, uint32_t Day)
  2218. {
  2219. MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_DT | RTC_ALRMBR_DU),
  2220. (((Day & 0xF0U) << (RTC_ALRMBR_DT_Pos - 4U)) | ((Day & 0x0FU) << RTC_ALRMBR_DU_Pos)));
  2221. }
  2222. /**
  2223. * @brief Get ALARM B Day in BCD format
  2224. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
  2225. * @rmtoll RTC_ALRMBR DT LL_RTC_ALMB_GetDay
  2226. * RTC_ALRMBR DU LL_RTC_ALMB_GetDay
  2227. * @param RTCx RTC Instance
  2228. * @retval Value between Min_Data=0x01 and Max_Data=0x31
  2229. */
  2230. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetDay(RTC_TypeDef *RTCx)
  2231. {
  2232. return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_DT | RTC_ALRMBR_DU))) >> RTC_ALRMBR_DU_Pos);
  2233. }
  2234. /**
  2235. * @brief Set ALARM B Weekday
  2236. * @rmtoll RTC_ALRMBR DU LL_RTC_ALMB_SetWeekDay
  2237. * @param RTCx RTC Instance
  2238. * @param WeekDay This parameter can be one of the following values:
  2239. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  2240. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  2241. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  2242. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  2243. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  2244. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  2245. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  2246. * @retval None
  2247. */
  2248. __STATIC_INLINE void LL_RTC_ALMB_SetWeekDay(RTC_TypeDef *RTCx, uint32_t WeekDay)
  2249. {
  2250. MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_DU, WeekDay << RTC_ALRMBR_DU_Pos);
  2251. }
  2252. /**
  2253. * @brief Get ALARM B Weekday
  2254. * @rmtoll RTC_ALRMBR DU LL_RTC_ALMB_GetWeekDay
  2255. * @param RTCx RTC Instance
  2256. * @retval Returned value can be one of the following values:
  2257. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  2258. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  2259. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  2260. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  2261. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  2262. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  2263. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  2264. */
  2265. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetWeekDay(RTC_TypeDef *RTCx)
  2266. {
  2267. return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_DU) >> RTC_ALRMBR_DU_Pos);
  2268. }
  2269. /**
  2270. * @brief Set ALARM B time format (AM/24-hour or PM notation)
  2271. * @rmtoll RTC_ALRMBR PM LL_RTC_ALMB_SetTimeFormat
  2272. * @param RTCx RTC Instance
  2273. * @param TimeFormat This parameter can be one of the following values:
  2274. * @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
  2275. * @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
  2276. * @retval None
  2277. */
  2278. __STATIC_INLINE void LL_RTC_ALMB_SetTimeFormat(RTC_TypeDef *RTCx, uint32_t TimeFormat)
  2279. {
  2280. MODIFY_REG(RTCx->ALRMBR, RTC_ALRMBR_PM, TimeFormat);
  2281. }
  2282. /**
  2283. * @brief Get ALARM B time format (AM or PM notation)
  2284. * @rmtoll RTC_ALRMBR PM LL_RTC_ALMB_GetTimeFormat
  2285. * @param RTCx RTC Instance
  2286. * @retval Returned value can be one of the following values:
  2287. * @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
  2288. * @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
  2289. */
  2290. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetTimeFormat(RTC_TypeDef *RTCx)
  2291. {
  2292. return (uint32_t)(READ_BIT(RTCx->ALRMBR, RTC_ALRMBR_PM));
  2293. }
  2294. /**
  2295. * @brief Set ALARM B Hours in BCD format
  2296. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Hours from binary to BCD format
  2297. * @rmtoll RTC_ALRMBR HT LL_RTC_ALMB_SetHour
  2298. * RTC_ALRMBR HU LL_RTC_ALMB_SetHour
  2299. * @param RTCx RTC Instance
  2300. * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  2301. * @retval None
  2302. */
  2303. __STATIC_INLINE void LL_RTC_ALMB_SetHour(RTC_TypeDef *RTCx, uint32_t Hours)
  2304. {
  2305. MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_HT | RTC_ALRMBR_HU),
  2306. (((Hours & 0xF0U) << (RTC_ALRMBR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMBR_HU_Pos)));
  2307. }
  2308. /**
  2309. * @brief Get ALARM B Hours in BCD format
  2310. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
  2311. * @rmtoll RTC_ALRMBR HT LL_RTC_ALMB_GetHour
  2312. * RTC_ALRMBR HU LL_RTC_ALMB_GetHour
  2313. * @param RTCx RTC Instance
  2314. * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  2315. */
  2316. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetHour(RTC_TypeDef *RTCx)
  2317. {
  2318. return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_HT | RTC_ALRMBR_HU))) >> RTC_ALRMBR_HU_Pos);
  2319. }
  2320. /**
  2321. * @brief Set ALARM B Minutes in BCD format
  2322. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Minutes from binary to BCD format
  2323. * @rmtoll RTC_ALRMBR MNT LL_RTC_ALMB_SetMinute
  2324. * RTC_ALRMBR MNU LL_RTC_ALMB_SetMinute
  2325. * @param RTCx RTC Instance
  2326. * @param Minutes between Min_Data=0x00 and Max_Data=0x59
  2327. * @retval None
  2328. */
  2329. __STATIC_INLINE void LL_RTC_ALMB_SetMinute(RTC_TypeDef *RTCx, uint32_t Minutes)
  2330. {
  2331. MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_MNT | RTC_ALRMBR_MNU),
  2332. (((Minutes & 0xF0U) << (RTC_ALRMBR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMBR_MNU_Pos)));
  2333. }
  2334. /**
  2335. * @brief Get ALARM B Minutes in BCD format
  2336. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
  2337. * @rmtoll RTC_ALRMBR MNT LL_RTC_ALMB_GetMinute
  2338. * RTC_ALRMBR MNU LL_RTC_ALMB_GetMinute
  2339. * @param RTCx RTC Instance
  2340. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  2341. */
  2342. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetMinute(RTC_TypeDef *RTCx)
  2343. {
  2344. return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_MNT | RTC_ALRMBR_MNU))) >> RTC_ALRMBR_MNU_Pos);
  2345. }
  2346. /**
  2347. * @brief Set ALARM B Seconds in BCD format
  2348. * @note helper macro __LL_RTC_CONVERT_BIN2BCD is available to convert Seconds from binary to BCD format
  2349. * @rmtoll RTC_ALRMBR ST LL_RTC_ALMB_SetSecond
  2350. * RTC_ALRMBR SU LL_RTC_ALMB_SetSecond
  2351. * @param RTCx RTC Instance
  2352. * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
  2353. * @retval None
  2354. */
  2355. __STATIC_INLINE void LL_RTC_ALMB_SetSecond(RTC_TypeDef *RTCx, uint32_t Seconds)
  2356. {
  2357. MODIFY_REG(RTCx->ALRMBR, (RTC_ALRMBR_ST | RTC_ALRMBR_SU),
  2358. (((Seconds & 0xF0U) << (RTC_ALRMBR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMBR_SU_Pos)));
  2359. }
  2360. /**
  2361. * @brief Get ALARM B Seconds in BCD format
  2362. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
  2363. * @rmtoll RTC_ALRMBR ST LL_RTC_ALMB_GetSecond
  2364. * RTC_ALRMBR SU LL_RTC_ALMB_GetSecond
  2365. * @param RTCx RTC Instance
  2366. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  2367. */
  2368. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSecond(RTC_TypeDef *RTCx)
  2369. {
  2370. return (uint32_t)((READ_BIT(RTCx->ALRMBR, (RTC_ALRMBR_ST | RTC_ALRMBR_SU))) >> RTC_ALRMBR_SU_Pos);
  2371. }
  2372. /**
  2373. * @brief Set Alarm B Time (hour, minute and second) in BCD format
  2374. * @rmtoll RTC_ALRMBR PM LL_RTC_ALMB_ConfigTime
  2375. * RTC_ALRMBR HT LL_RTC_ALMB_ConfigTime
  2376. * RTC_ALRMBR HU LL_RTC_ALMB_ConfigTime
  2377. * RTC_ALRMBR MNT LL_RTC_ALMB_ConfigTime
  2378. * RTC_ALRMBR MNU LL_RTC_ALMB_ConfigTime
  2379. * RTC_ALRMBR ST LL_RTC_ALMB_ConfigTime
  2380. * RTC_ALRMBR SU LL_RTC_ALMB_ConfigTime
  2381. * @param RTCx RTC Instance
  2382. * @param Format12_24 This parameter can be one of the following values:
  2383. * @arg @ref LL_RTC_ALMB_TIME_FORMAT_AM
  2384. * @arg @ref LL_RTC_ALMB_TIME_FORMAT_PM
  2385. * @param Hours Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  2386. * @param Minutes Value between Min_Data=0x00 and Max_Data=0x59
  2387. * @param Seconds Value between Min_Data=0x00 and Max_Data=0x59
  2388. * @retval None
  2389. */
  2390. __STATIC_INLINE void LL_RTC_ALMB_ConfigTime(RTC_TypeDef *RTCx, uint32_t Format12_24, uint32_t Hours, uint32_t Minutes, uint32_t Seconds)
  2391. {
  2392. register uint32_t temp;
  2393. temp = Format12_24 | (((Hours & 0xF0U) << (RTC_ALRMBR_HT_Pos - 4U)) | ((Hours & 0x0FU) << RTC_ALRMBR_HU_Pos)) | \
  2394. (((Minutes & 0xF0U) << (RTC_ALRMBR_MNT_Pos - 4U)) | ((Minutes & 0x0FU) << RTC_ALRMBR_MNU_Pos)) | \
  2395. (((Seconds & 0xF0U) << (RTC_ALRMBR_ST_Pos - 4U)) | ((Seconds & 0x0FU) << RTC_ALRMBR_SU_Pos));
  2396. 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);
  2397. }
  2398. /**
  2399. * @brief Get Alarm B Time (hour, minute and second) in BCD format
  2400. * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
  2401. * are available to get independently each parameter.
  2402. * @rmtoll RTC_ALRMBR HT LL_RTC_ALMB_GetTime
  2403. * RTC_ALRMBR HU LL_RTC_ALMB_GetTime
  2404. * RTC_ALRMBR MNT LL_RTC_ALMB_GetTime
  2405. * RTC_ALRMBR MNU LL_RTC_ALMB_GetTime
  2406. * RTC_ALRMBR ST LL_RTC_ALMB_GetTime
  2407. * RTC_ALRMBR SU LL_RTC_ALMB_GetTime
  2408. * @param RTCx RTC Instance
  2409. * @retval Combination of hours, minutes and seconds.
  2410. */
  2411. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetTime(RTC_TypeDef *RTCx)
  2412. {
  2413. return (uint32_t)((LL_RTC_ALMB_GetHour(RTCx) << RTC_OFFSET_HOUR) | (LL_RTC_ALMB_GetMinute(RTCx) << RTC_OFFSET_MINUTE) | LL_RTC_ALMB_GetSecond(RTCx));
  2414. }
  2415. /**
  2416. * @brief Set Alarm B Mask the most-significant bits starting at this bit
  2417. * @note This register can be written only when ALRBE is reset in RTC_CR register,
  2418. * or in initialization mode.
  2419. * @rmtoll RTC_ALRMBSSR MASKSS LL_RTC_ALMB_SetSubSecondMask
  2420. * @param RTCx RTC Instance
  2421. * @param Mask Value between Min_Data=0x00 and Max_Data=0xF
  2422. * @retval None
  2423. */
  2424. __STATIC_INLINE void LL_RTC_ALMB_SetSubSecondMask(RTC_TypeDef *RTCx, uint32_t Mask)
  2425. {
  2426. MODIFY_REG(RTCx->ALRMBSSR, RTC_ALRMBSSR_MASKSS, Mask << RTC_ALRMBSSR_MASKSS_Pos);
  2427. }
  2428. /**
  2429. * @brief Get Alarm B Mask the most-significant bits starting at this bit
  2430. * @rmtoll RTC_ALRMBSSR MASKSS LL_RTC_ALMB_GetSubSecondMask
  2431. * @param RTCx RTC Instance
  2432. * @retval Value between Min_Data=0x00 and Max_Data=0xF
  2433. */
  2434. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSubSecondMask(RTC_TypeDef *RTCx)
  2435. {
  2436. return (uint32_t)(READ_BIT(RTCx->ALRMBSSR, RTC_ALRMBSSR_MASKSS) >> RTC_ALRMBSSR_MASKSS_Pos);
  2437. }
  2438. /**
  2439. * @brief Set Alarm B Sub seconds value
  2440. * @rmtoll RTC_ALRMBSSR SS LL_RTC_ALMB_SetSubSecond
  2441. * @param RTCx RTC Instance
  2442. * @param Subsecond Value between Min_Data=0x00 and Max_Data=0x7FFF
  2443. * @retval None
  2444. */
  2445. __STATIC_INLINE void LL_RTC_ALMB_SetSubSecond(RTC_TypeDef *RTCx, uint32_t Subsecond)
  2446. {
  2447. MODIFY_REG(RTCx->ALRMBSSR, RTC_ALRMBSSR_SS, Subsecond);
  2448. }
  2449. /**
  2450. * @brief Get Alarm B Sub seconds value
  2451. * @rmtoll RTC_ALRMBSSR SS LL_RTC_ALMB_GetSubSecond
  2452. * @param RTCx RTC Instance
  2453. * @retval Value between Min_Data=0x00 and Max_Data=0x7FFF
  2454. */
  2455. __STATIC_INLINE uint32_t LL_RTC_ALMB_GetSubSecond(RTC_TypeDef *RTCx)
  2456. {
  2457. return (uint32_t)(READ_BIT(RTCx->ALRMBSSR, RTC_ALRMBSSR_SS));
  2458. }
  2459. /**
  2460. * @}
  2461. */
  2462. /** @defgroup RTC_LL_EF_Timestamp Timestamp
  2463. * @{
  2464. */
  2465. /**
  2466. * @brief Enable internal event timestamp
  2467. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2468. * @rmtoll RTC_CR ITSE LL_RTC_TS_EnableInternalEvent
  2469. * @param RTCx RTC Instance
  2470. * @retval None
  2471. */
  2472. __STATIC_INLINE void LL_RTC_TS_EnableInternalEvent(RTC_TypeDef *RTCx)
  2473. {
  2474. SET_BIT(RTCx->CR, RTC_CR_ITSE);
  2475. }
  2476. /**
  2477. * @brief Disable internal event timestamp
  2478. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2479. * @rmtoll RTC_CR ITSE LL_RTC_TS_DisableInternalEvent
  2480. * @param RTCx RTC Instance
  2481. * @retval None
  2482. */
  2483. __STATIC_INLINE void LL_RTC_TS_DisableInternalEvent(RTC_TypeDef *RTCx)
  2484. {
  2485. CLEAR_BIT(RTCx->CR, RTC_CR_ITSE);
  2486. }
  2487. /**
  2488. * @brief Enable Timestamp
  2489. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2490. * @rmtoll RTC_CR TSE LL_RTC_TS_Enable
  2491. * @param RTCx RTC Instance
  2492. * @retval None
  2493. */
  2494. __STATIC_INLINE void LL_RTC_TS_Enable(RTC_TypeDef *RTCx)
  2495. {
  2496. SET_BIT(RTCx->CR, RTC_CR_TSE);
  2497. }
  2498. /**
  2499. * @brief Disable Timestamp
  2500. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2501. * @rmtoll RTC_CR TSE LL_RTC_TS_Disable
  2502. * @param RTCx RTC Instance
  2503. * @retval None
  2504. */
  2505. __STATIC_INLINE void LL_RTC_TS_Disable(RTC_TypeDef *RTCx)
  2506. {
  2507. CLEAR_BIT(RTCx->CR, RTC_CR_TSE);
  2508. }
  2509. /**
  2510. * @brief Set Time-stamp event active edge
  2511. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2512. * @note TSE must be reset when TSEDGE is changed to avoid unwanted TSF setting
  2513. * @rmtoll RTC_CR TSEDGE LL_RTC_TS_SetActiveEdge
  2514. * @param RTCx RTC Instance
  2515. * @param Edge This parameter can be one of the following values:
  2516. * @arg @ref LL_RTC_TIMESTAMP_EDGE_RISING
  2517. * @arg @ref LL_RTC_TIMESTAMP_EDGE_FALLING
  2518. * @retval None
  2519. */
  2520. __STATIC_INLINE void LL_RTC_TS_SetActiveEdge(RTC_TypeDef *RTCx, uint32_t Edge)
  2521. {
  2522. MODIFY_REG(RTCx->CR, RTC_CR_TSEDGE, Edge);
  2523. }
  2524. /**
  2525. * @brief Get Time-stamp event active edge
  2526. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  2527. * @rmtoll RTC_CR TSEDGE LL_RTC_TS_GetActiveEdge
  2528. * @param RTCx RTC Instance
  2529. * @retval Returned value can be one of the following values:
  2530. * @arg @ref LL_RTC_TIMESTAMP_EDGE_RISING
  2531. * @arg @ref LL_RTC_TIMESTAMP_EDGE_FALLING
  2532. */
  2533. __STATIC_INLINE uint32_t LL_RTC_TS_GetActiveEdge(RTC_TypeDef *RTCx)
  2534. {
  2535. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_TSEDGE));
  2536. }
  2537. /**
  2538. * @brief Get Timestamp AM/PM notation (AM or 24-hour format)
  2539. * @rmtoll RTC_TSTR PM LL_RTC_TS_GetTimeFormat
  2540. * @param RTCx RTC Instance
  2541. * @retval Returned value can be one of the following values:
  2542. * @arg @ref LL_RTC_TS_TIME_FORMAT_AM
  2543. * @arg @ref LL_RTC_TS_TIME_FORMAT_PM
  2544. */
  2545. __STATIC_INLINE uint32_t LL_RTC_TS_GetTimeFormat(RTC_TypeDef *RTCx)
  2546. {
  2547. return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_PM));
  2548. }
  2549. /**
  2550. * @brief Get Timestamp Hours in BCD format
  2551. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Hours from BCD to Binary format
  2552. * @rmtoll RTC_TSTR HT LL_RTC_TS_GetHour
  2553. * RTC_TSTR HU LL_RTC_TS_GetHour
  2554. * @param RTCx RTC Instance
  2555. * @retval Value between Min_Data=0x01 and Max_Data=0x12 or between Min_Data=0x00 and Max_Data=0x23
  2556. */
  2557. __STATIC_INLINE uint32_t LL_RTC_TS_GetHour(RTC_TypeDef *RTCx)
  2558. {
  2559. return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_HT | RTC_TSTR_HU) >> RTC_TSTR_HU_Pos);
  2560. }
  2561. /**
  2562. * @brief Get Timestamp Minutes in BCD format
  2563. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Minutes from BCD to Binary format
  2564. * @rmtoll RTC_TSTR MNT LL_RTC_TS_GetMinute
  2565. * RTC_TSTR MNU LL_RTC_TS_GetMinute
  2566. * @param RTCx RTC Instance
  2567. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  2568. */
  2569. __STATIC_INLINE uint32_t LL_RTC_TS_GetMinute(RTC_TypeDef *RTCx)
  2570. {
  2571. return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_MNT | RTC_TSTR_MNU) >> RTC_TSTR_MNU_Pos);
  2572. }
  2573. /**
  2574. * @brief Get Timestamp Seconds in BCD format
  2575. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Seconds from BCD to Binary format
  2576. * @rmtoll RTC_TSTR ST LL_RTC_TS_GetSecond
  2577. * RTC_TSTR SU LL_RTC_TS_GetSecond
  2578. * @param RTCx RTC Instance
  2579. * @retval Value between Min_Data=0x00 and Max_Data=0x59
  2580. */
  2581. __STATIC_INLINE uint32_t LL_RTC_TS_GetSecond(RTC_TypeDef *RTCx)
  2582. {
  2583. return (uint32_t)(READ_BIT(RTCx->TSTR, RTC_TSTR_ST | RTC_TSTR_SU));
  2584. }
  2585. /**
  2586. * @brief Get Timestamp time (hour, minute and second) in BCD format
  2587. * @note helper macros __LL_RTC_GET_HOUR, __LL_RTC_GET_MINUTE and __LL_RTC_GET_SECOND
  2588. * are available to get independently each parameter.
  2589. * @rmtoll RTC_TSTR HT LL_RTC_TS_GetTime
  2590. * RTC_TSTR HU LL_RTC_TS_GetTime
  2591. * RTC_TSTR MNT LL_RTC_TS_GetTime
  2592. * RTC_TSTR MNU LL_RTC_TS_GetTime
  2593. * RTC_TSTR ST LL_RTC_TS_GetTime
  2594. * RTC_TSTR SU LL_RTC_TS_GetTime
  2595. * @param RTCx RTC Instance
  2596. * @retval Combination of hours, minutes and seconds.
  2597. */
  2598. __STATIC_INLINE uint32_t LL_RTC_TS_GetTime(RTC_TypeDef *RTCx)
  2599. {
  2600. return (uint32_t)(READ_BIT(RTCx->TSTR,
  2601. RTC_TSTR_HT | RTC_TSTR_HU | RTC_TSTR_MNT | RTC_TSTR_MNU | RTC_TSTR_ST | RTC_TSTR_SU));
  2602. }
  2603. /**
  2604. * @brief Get Timestamp Week day
  2605. * @rmtoll RTC_TSDR WDU LL_RTC_TS_GetWeekDay
  2606. * @param RTCx RTC Instance
  2607. * @retval Returned value can be one of the following values:
  2608. * @arg @ref LL_RTC_WEEKDAY_MONDAY
  2609. * @arg @ref LL_RTC_WEEKDAY_TUESDAY
  2610. * @arg @ref LL_RTC_WEEKDAY_WEDNESDAY
  2611. * @arg @ref LL_RTC_WEEKDAY_THURSDAY
  2612. * @arg @ref LL_RTC_WEEKDAY_FRIDAY
  2613. * @arg @ref LL_RTC_WEEKDAY_SATURDAY
  2614. * @arg @ref LL_RTC_WEEKDAY_SUNDAY
  2615. */
  2616. __STATIC_INLINE uint32_t LL_RTC_TS_GetWeekDay(RTC_TypeDef *RTCx)
  2617. {
  2618. return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_WDU) >> RTC_TSDR_WDU_Pos);
  2619. }
  2620. /**
  2621. * @brief Get Timestamp Month in BCD format
  2622. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Month from BCD to Binary format
  2623. * @rmtoll RTC_TSDR MT LL_RTC_TS_GetMonth
  2624. * RTC_TSDR MU LL_RTC_TS_GetMonth
  2625. * @param RTCx RTC Instance
  2626. * @retval Returned value can be one of the following values:
  2627. * @arg @ref LL_RTC_MONTH_JANUARY
  2628. * @arg @ref LL_RTC_MONTH_FEBRUARY
  2629. * @arg @ref LL_RTC_MONTH_MARCH
  2630. * @arg @ref LL_RTC_MONTH_APRIL
  2631. * @arg @ref LL_RTC_MONTH_MAY
  2632. * @arg @ref LL_RTC_MONTH_JUNE
  2633. * @arg @ref LL_RTC_MONTH_JULY
  2634. * @arg @ref LL_RTC_MONTH_AUGUST
  2635. * @arg @ref LL_RTC_MONTH_SEPTEMBER
  2636. * @arg @ref LL_RTC_MONTH_OCTOBER
  2637. * @arg @ref LL_RTC_MONTH_NOVEMBER
  2638. * @arg @ref LL_RTC_MONTH_DECEMBER
  2639. */
  2640. __STATIC_INLINE uint32_t LL_RTC_TS_GetMonth(RTC_TypeDef *RTCx)
  2641. {
  2642. return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_MT | RTC_TSDR_MU) >> RTC_TSDR_MU_Pos);
  2643. }
  2644. /**
  2645. * @brief Get Timestamp Day in BCD format
  2646. * @note helper macro __LL_RTC_CONVERT_BCD2BIN is available to convert Day from BCD to Binary format
  2647. * @rmtoll RTC_TSDR DT LL_RTC_TS_GetDay
  2648. * RTC_TSDR DU LL_RTC_TS_GetDay
  2649. * @param RTCx RTC Instance
  2650. * @retval Value between Min_Data=0x01 and Max_Data=0x31
  2651. */
  2652. __STATIC_INLINE uint32_t LL_RTC_TS_GetDay(RTC_TypeDef *RTCx)
  2653. {
  2654. return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_DT | RTC_TSDR_DU));
  2655. }
  2656. /**
  2657. * @brief Get Timestamp date (WeekDay, Day and Month) in BCD format
  2658. * @note helper macros __LL_RTC_GET_WEEKDAY, __LL_RTC_GET_MONTH,
  2659. * and __LL_RTC_GET_DAY are available to get independently each parameter.
  2660. * @rmtoll RTC_TSDR WDU LL_RTC_TS_GetDate
  2661. * RTC_TSDR MT LL_RTC_TS_GetDate
  2662. * RTC_TSDR MU LL_RTC_TS_GetDate
  2663. * RTC_TSDR DT LL_RTC_TS_GetDate
  2664. * RTC_TSDR DU LL_RTC_TS_GetDate
  2665. * @param RTCx RTC Instance
  2666. * @retval Combination of Weekday, Day and Month
  2667. */
  2668. __STATIC_INLINE uint32_t LL_RTC_TS_GetDate(RTC_TypeDef *RTCx)
  2669. {
  2670. return (uint32_t)(READ_BIT(RTCx->TSDR, RTC_TSDR_WDU | RTC_TSDR_MT | RTC_TSDR_MU | RTC_TSDR_DT | RTC_TSDR_DU));
  2671. }
  2672. /**
  2673. * @brief Get time-stamp sub second value
  2674. * @rmtoll RTC_TSSSR SS LL_RTC_TS_GetSubSecond
  2675. * @param RTCx RTC Instance
  2676. * @retval Value between Min_Data=0x00 and Max_Data=0xFFFF
  2677. */
  2678. __STATIC_INLINE uint32_t LL_RTC_TS_GetSubSecond(RTC_TypeDef *RTCx)
  2679. {
  2680. return (uint32_t)(READ_BIT(RTCx->TSSSR, RTC_TSSSR_SS));
  2681. }
  2682. /**
  2683. * @}
  2684. */
  2685. /** @defgroup RTC_LL_EF_Tamper_Timestamp Time-stamp on Tamper
  2686. * @{
  2687. */
  2688. #if defined(RTC_TAMPCR_TAMPTS)
  2689. /**
  2690. * @brief Activate timestamp on tamper detection event
  2691. * @rmtoll RTC_CR TAMPTS LL_RTC_TS_EnableOnTamper
  2692. * @param RTCx RTC Instance
  2693. * @retval None
  2694. */
  2695. __STATIC_INLINE void LL_RTC_TS_EnableOnTamper(RTC_TypeDef *RTCx)
  2696. {
  2697. SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPTS);
  2698. }
  2699. /**
  2700. * @brief Disable timestamp on tamper detection event
  2701. * @rmtoll RTC_CR TAMPTS LL_RTC_TS_DisableOnTamper
  2702. * @param RTCx RTC Instance
  2703. * @retval None
  2704. */
  2705. __STATIC_INLINE void LL_RTC_TS_DisableOnTamper(RTC_TypeDef *RTCx)
  2706. {
  2707. CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPTS);
  2708. }
  2709. #endif /* RTC_TAMPCR_TAMPTS */
  2710. #if defined(RTC_CR_TAMPTS)
  2711. /**
  2712. * @brief Activate timestamp on tamper detection event
  2713. * @rmtoll RTC_CR TAMPTS LL_RTC_TS_EnableOnTamper
  2714. * @param RTCx RTC Instance
  2715. * @retval None
  2716. */
  2717. __STATIC_INLINE void LL_RTC_TS_EnableOnTamper(RTC_TypeDef *RTCx)
  2718. {
  2719. SET_BIT(RTCx->CR, RTC_CR_TAMPTS);
  2720. }
  2721. /**
  2722. * @brief Disable timestamp on tamper detection event
  2723. * @rmtoll RTC_CR TAMPTS LL_RTC_TS_DisableOnTamper
  2724. * @param RTCx RTC Instance
  2725. * @retval None
  2726. */
  2727. __STATIC_INLINE void LL_RTC_TS_DisableOnTamper(RTC_TypeDef *RTCx)
  2728. {
  2729. CLEAR_BIT(RTCx->CR, RTC_CR_TAMPTS);
  2730. }
  2731. #endif /* RTC_CR_TAMPTS */
  2732. /**
  2733. * @}
  2734. */
  2735. /** @defgroup RTC_LL_EF_Tamper Tamper
  2736. * @{
  2737. */
  2738. #if defined(RTC_TAMPCR_TAMP1E)
  2739. /**
  2740. * @brief Enable RTC_TAMPx input detection
  2741. * @rmtoll TAMPCR TAMP1E LL_RTC_TAMPER_Enable
  2742. * TAMPCR TAMP2E LL_RTC_TAMPER_Enable
  2743. * TAMPCR TAMP3E LL_RTC_TAMPER_Enable
  2744. * @param RTCx RTC Instance
  2745. * @param Tamper This parameter can be a combination of the following values:
  2746. * @arg @ref LL_RTC_TAMPER_1
  2747. * @arg @ref LL_RTC_TAMPER_2
  2748. * @arg @ref LL_RTC_TAMPER_3
  2749. *
  2750. * @retval None
  2751. */
  2752. __STATIC_INLINE void LL_RTC_TAMPER_Enable(RTC_TypeDef *RTCx, uint32_t Tamper)
  2753. {
  2754. SET_BIT(RTCx->TAMPCR, Tamper);
  2755. }
  2756. /**
  2757. * @brief Clear RTC_TAMPx input detection
  2758. * @rmtoll TAMPCR TAMP1E LL_RTC_TAMPER_Disable
  2759. * TAMPCR TAMP2E LL_RTC_TAMPER_Disable
  2760. * TAMPCR TAMP3E LL_RTC_TAMPER_Disable
  2761. * @param RTCx RTC Instance
  2762. * @param Tamper This parameter can be a combination of the following values:
  2763. * @arg @ref LL_RTC_TAMPER_1
  2764. * @arg @ref LL_RTC_TAMPER_2
  2765. * @arg @ref LL_RTC_TAMPER_3
  2766. *
  2767. * @retval None
  2768. */
  2769. __STATIC_INLINE void LL_RTC_TAMPER_Disable(RTC_TypeDef *RTCx, uint32_t Tamper)
  2770. {
  2771. CLEAR_BIT(RTCx->TAMPCR, Tamper);
  2772. }
  2773. /**
  2774. * @brief Enable Tamper mask flag
  2775. * @note Associated Tamper IT must not enabled when tamper mask is set.
  2776. * @rmtoll TAMPCR TAMP1MF LL_RTC_TAMPER_EnableMask
  2777. * TAMPCR TAMP2MF LL_RTC_TAMPER_EnableMask
  2778. * TAMPCR TAMP3MF LL_RTC_TAMPER_EnableMask
  2779. * @param RTCx RTC Instance
  2780. * @param Mask This parameter can be a combination of the following values:
  2781. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER1
  2782. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER2
  2783. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER3
  2784. *
  2785. * @retval None
  2786. */
  2787. __STATIC_INLINE void LL_RTC_TAMPER_EnableMask(RTC_TypeDef *RTCx, uint32_t Mask)
  2788. {
  2789. SET_BIT(RTCx->TAMPCR, Mask);
  2790. }
  2791. /**
  2792. * @brief Disable Tamper mask flag
  2793. * @rmtoll TAMPCR TAMP1MF LL_RTC_TAMPER_DisableMask
  2794. * TAMPCR TAMP2MF LL_RTC_TAMPER_DisableMask
  2795. * TAMPCR TAMP3MF LL_RTC_TAMPER_DisableMask
  2796. * @param RTCx RTC Instance
  2797. * @param Mask This parameter can be a combination of the following values:
  2798. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER1
  2799. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER2
  2800. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER3
  2801. *
  2802. * @retval None
  2803. */
  2804. __STATIC_INLINE void LL_RTC_TAMPER_DisableMask(RTC_TypeDef *RTCx, uint32_t Mask)
  2805. {
  2806. CLEAR_BIT(RTCx->TAMPCR, Mask);
  2807. }
  2808. /**
  2809. * @brief Enable backup register erase after Tamper event detection
  2810. * @rmtoll TAMPCR TAMP1NOERASE LL_RTC_TAMPER_EnableEraseBKP
  2811. * TAMPCR TAMP2NOERASE LL_RTC_TAMPER_EnableEraseBKP
  2812. * TAMPCR TAMP3NOERASE LL_RTC_TAMPER_EnableEraseBKP
  2813. * @param RTCx RTC Instance
  2814. * @param Tamper This parameter can be a combination of the following values:
  2815. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER1
  2816. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER2
  2817. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER3
  2818. *
  2819. * @retval None
  2820. */
  2821. __STATIC_INLINE void LL_RTC_TAMPER_EnableEraseBKP(RTC_TypeDef *RTCx, uint32_t Tamper)
  2822. {
  2823. CLEAR_BIT(RTCx->TAMPCR, Tamper);
  2824. }
  2825. /**
  2826. * @brief Disable backup register erase after Tamper event detection
  2827. * @rmtoll TAMPCR TAMP1NOERASE LL_RTC_TAMPER_DisableEraseBKP
  2828. * TAMPCR TAMP2NOERASE LL_RTC_TAMPER_DisableEraseBKP
  2829. * TAMPCR TAMP3NOERASE LL_RTC_TAMPER_DisableEraseBKP
  2830. * @param RTCx RTC Instance
  2831. * @param Tamper This parameter can be a combination of the following values:
  2832. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER1
  2833. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER2
  2834. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER3
  2835. *
  2836. * @retval None
  2837. */
  2838. __STATIC_INLINE void LL_RTC_TAMPER_DisableEraseBKP(RTC_TypeDef *RTCx, uint32_t Tamper)
  2839. {
  2840. SET_BIT(RTCx->TAMPCR, Tamper);
  2841. }
  2842. #endif /* RTC_TAMPCR_TAMP1E */
  2843. #if defined(RTC_TAMPCR_TAMPPUDIS)
  2844. /**
  2845. * @brief Disable RTC_TAMPx pull-up disable (Disable precharge of RTC_TAMPx pins)
  2846. * @rmtoll TAMPCR TAMPPUDIS LL_RTC_TAMPER_DisablePullUp
  2847. * @param RTCx RTC Instance
  2848. * @retval None
  2849. */
  2850. __STATIC_INLINE void LL_RTC_TAMPER_DisablePullUp(RTC_TypeDef *RTCx)
  2851. {
  2852. SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPPUDIS);
  2853. }
  2854. /**
  2855. * @brief Enable RTC_TAMPx pull-up disable ( Precharge RTC_TAMPx pins before sampling)
  2856. * @rmtoll TAMPCR TAMPPUDIS LL_RTC_TAMPER_EnablePullUp
  2857. * @param RTCx RTC Instance
  2858. * @retval None
  2859. */
  2860. __STATIC_INLINE void LL_RTC_TAMPER_EnablePullUp(RTC_TypeDef *RTCx)
  2861. {
  2862. CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPPUDIS);
  2863. }
  2864. #endif /* RTC_TAMPCR_TAMPPUDIS */
  2865. #if defined(RTC_TAMPCR_TAMPPRCH)
  2866. /**
  2867. * @brief Set RTC_TAMPx precharge duration
  2868. * @rmtoll TAMPCR TAMPPRCH LL_RTC_TAMPER_SetPrecharge
  2869. * @param RTCx RTC Instance
  2870. * @param Duration This parameter can be one of the following values:
  2871. * @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
  2872. * @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
  2873. * @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
  2874. * @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
  2875. * @retval None
  2876. */
  2877. __STATIC_INLINE void LL_RTC_TAMPER_SetPrecharge(RTC_TypeDef *RTCx, uint32_t Duration)
  2878. {
  2879. MODIFY_REG(RTCx->TAMPCR, RTC_TAMPCR_TAMPPRCH, Duration);
  2880. }
  2881. /**
  2882. * @brief Get RTC_TAMPx precharge duration
  2883. * @rmtoll TAMPCR TAMPPRCH LL_RTC_TAMPER_GetPrecharge
  2884. * @param RTCx RTC Instance
  2885. * @retval Returned value can be one of the following values:
  2886. * @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
  2887. * @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
  2888. * @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
  2889. * @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
  2890. */
  2891. __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetPrecharge(RTC_TypeDef *RTCx)
  2892. {
  2893. return (uint32_t)(READ_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPPRCH));
  2894. }
  2895. #endif /* RTC_TAMPCR_TAMPPRCH */
  2896. #if defined(RTC_TAMPCR_TAMPFLT)
  2897. /**
  2898. * @brief Set RTC_TAMPx filter count
  2899. * @rmtoll TAMPCR TAMPFLT LL_RTC_TAMPER_SetFilterCount
  2900. * @param RTCx RTC Instance
  2901. * @param FilterCount This parameter can be one of the following values:
  2902. * @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
  2903. * @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
  2904. * @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
  2905. * @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
  2906. * @retval None
  2907. */
  2908. __STATIC_INLINE void LL_RTC_TAMPER_SetFilterCount(RTC_TypeDef *RTCx, uint32_t FilterCount)
  2909. {
  2910. MODIFY_REG(RTCx->TAMPCR, RTC_TAMPCR_TAMPFLT, FilterCount);
  2911. }
  2912. /**
  2913. * @brief Get RTC_TAMPx filter count
  2914. * @rmtoll TAMPCR TAMPFLT LL_RTC_TAMPER_GetFilterCount
  2915. * @param RTCx RTC Instance
  2916. * @retval Returned value can be one of the following values:
  2917. * @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
  2918. * @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
  2919. * @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
  2920. * @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
  2921. */
  2922. __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetFilterCount(RTC_TypeDef *RTCx)
  2923. {
  2924. return (uint32_t)(READ_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPFLT));
  2925. }
  2926. #endif /* RTC_TAMPCR_TAMPFLT */
  2927. #if defined(RTC_TAMPCR_TAMPFREQ)
  2928. /**
  2929. * @brief Set Tamper sampling frequency
  2930. * @rmtoll TAMPCR TAMPFREQ LL_RTC_TAMPER_SetSamplingFreq
  2931. * @param RTCx RTC Instance
  2932. * @param SamplingFreq This parameter can be one of the following values:
  2933. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
  2934. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
  2935. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
  2936. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
  2937. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
  2938. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
  2939. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
  2940. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
  2941. * @retval None
  2942. */
  2943. __STATIC_INLINE void LL_RTC_TAMPER_SetSamplingFreq(RTC_TypeDef *RTCx, uint32_t SamplingFreq)
  2944. {
  2945. MODIFY_REG(RTCx->TAMPCR, RTC_TAMPCR_TAMPFREQ, SamplingFreq);
  2946. }
  2947. /**
  2948. * @brief Get Tamper sampling frequency
  2949. * @rmtoll TAMPCR TAMPFREQ LL_RTC_TAMPER_GetSamplingFreq
  2950. * @param RTCx RTC Instance
  2951. * @retval Returned value can be one of the following values:
  2952. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
  2953. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
  2954. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
  2955. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
  2956. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
  2957. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
  2958. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
  2959. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
  2960. */
  2961. __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetSamplingFreq(RTC_TypeDef *RTCx)
  2962. {
  2963. return (uint32_t)(READ_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPFREQ));
  2964. }
  2965. #endif /* RTC_TAMPCR_TAMPFREQ */
  2966. #if defined(RTC_TAMPCR_TAMP1E)
  2967. /**
  2968. * @brief Enable Active level for Tamper input
  2969. * @rmtoll TAMPCR TAMP1TRG LL_RTC_TAMPER_EnableActiveLevel
  2970. * TAMPCR TAMP2TRG LL_RTC_TAMPER_EnableActiveLevel
  2971. * TAMPCR TAMP3TRG LL_RTC_TAMPER_EnableActiveLevel
  2972. * @param RTCx RTC Instance
  2973. * @param Tamper This parameter can be a combination of the following values:
  2974. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP1
  2975. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP2
  2976. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP3
  2977. *
  2978. * @retval None
  2979. */
  2980. __STATIC_INLINE void LL_RTC_TAMPER_EnableActiveLevel(RTC_TypeDef *RTCx, uint32_t Tamper)
  2981. {
  2982. SET_BIT(RTCx->TAMPCR, Tamper);
  2983. }
  2984. /**
  2985. * @brief Disable Active level for Tamper input
  2986. * @rmtoll TAMPCR TAMP1TRG LL_RTC_TAMPER_DisableActiveLevel
  2987. * TAMPCR TAMP2TRG LL_RTC_TAMPER_DisableActiveLevel
  2988. * TAMPCR TAMP3TRG LL_RTC_TAMPER_DisableActiveLevel
  2989. * @param RTCx RTC Instance
  2990. * @param Tamper This parameter can be a combination of the following values:
  2991. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP1
  2992. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP2
  2993. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP3
  2994. *
  2995. * @retval None
  2996. */
  2997. __STATIC_INLINE void LL_RTC_TAMPER_DisableActiveLevel(RTC_TypeDef *RTCx, uint32_t Tamper)
  2998. {
  2999. CLEAR_BIT(RTCx->TAMPCR, Tamper);
  3000. }
  3001. #endif /* RTC_TAMPCR_TAMP1E */
  3002. #if defined(TAMP_CR1_TAMP1E)
  3003. /**
  3004. * @brief Enable TAMPx input detection
  3005. * @rmtoll TAMP_CR1 TAMP1E LL_RTC_TAMPER_Enable
  3006. * TAMP_CR1 TAMP2E LL_RTC_TAMPER_Enable
  3007. * TAMP_CR1 TAMP3E LL_RTC_TAMPER_Enable
  3008. * @param TAMPx TAMP Instance
  3009. * @param Tamper This parameter can be a combination of the following values:
  3010. * @arg @ref LL_RTC_TAMPER_1
  3011. * @arg @ref LL_RTC_TAMPER_2
  3012. * @arg @ref LL_RTC_TAMPER_3
  3013. *
  3014. * @retval None
  3015. */
  3016. __STATIC_INLINE void LL_RTC_TAMPER_Enable(TAMP_TypeDef *TAMPx, uint32_t Tamper)
  3017. {
  3018. SET_BIT(TAMPx->CR1, Tamper);
  3019. }
  3020. /**
  3021. * @brief Clear TAMPx input detection
  3022. * @rmtoll TAMP_CR1 TAMP1E LL_RTC_TAMPER_Disable
  3023. * TAMP_CR1 TAMP2E LL_RTC_TAMPER_Disable
  3024. * TAMP_CR1 TAMP3E LL_RTC_TAMPER_Disable
  3025. * @param TAMPx TAMP Instance
  3026. * @param Tamper This parameter can be a combination of the following values:
  3027. * @arg @ref LL_RTC_TAMPER_1
  3028. * @arg @ref LL_RTC_TAMPER_2
  3029. * @arg @ref LL_RTC_TAMPER_3
  3030. *
  3031. * @retval None
  3032. */
  3033. __STATIC_INLINE void LL_RTC_TAMPER_Disable(TAMP_TypeDef *TAMPx, uint32_t Tamper)
  3034. {
  3035. CLEAR_BIT(TAMPx->CR1, Tamper);
  3036. }
  3037. #endif /* TAMP_CR1_TAMP1E */
  3038. #if defined(TAMP_CR2_TAMP1MSK)
  3039. /**
  3040. * @brief Enable Tamper mask flag
  3041. * @note Associated Tamper IT must not enabled when tamper mask is set.
  3042. * @rmtoll TAMP_CR2 TAMP1MF LL_RTC_TAMPER_EnableMask
  3043. * TAMP_CR2 TAMP2MF LL_RTC_TAMPER_EnableMask
  3044. * TAMP_CR2 TAMP3MF LL_RTC_TAMPER_EnableMask
  3045. * @param TAMPx TAMP Instance
  3046. * @param Mask This parameter can be a combination of the following values:
  3047. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER1
  3048. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER2
  3049. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER3
  3050. *
  3051. * @retval None
  3052. */
  3053. __STATIC_INLINE void LL_RTC_TAMPER_EnableMask(TAMP_TypeDef *TAMPx, uint32_t Mask)
  3054. {
  3055. SET_BIT(TAMPx->CR2, Mask);
  3056. }
  3057. /**
  3058. * @brief Disable Tamper mask flag
  3059. * @rmtoll TAMP_CR2 TAMP1MF LL_RTC_TAMPER_DisableMask
  3060. * TAMP_CR2 TAMP2MF LL_RTC_TAMPER_DisableMask
  3061. * TAMP_CR2 TAMP3MF LL_RTC_TAMPER_DisableMask
  3062. * @param TAMPx TAMP Instance
  3063. * @param Mask This parameter can be a combination of the following values:
  3064. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER1
  3065. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER2
  3066. * @arg @ref LL_RTC_TAMPER_MASK_TAMPER3
  3067. *
  3068. * @retval None
  3069. */
  3070. __STATIC_INLINE void LL_RTC_TAMPER_DisableMask(TAMP_TypeDef *TAMPx, uint32_t Mask)
  3071. {
  3072. CLEAR_BIT(TAMPx->CR2, Mask);
  3073. }
  3074. /**
  3075. * @brief Enable backup register erase after Tamper event detection
  3076. * @rmtoll TAMP_CR2 TAMP1NOERASE LL_RTC_TAMPER_EnableEraseBKP
  3077. * TAMP_CR2 TAMP2NOERASE LL_RTC_TAMPER_EnableEraseBKP
  3078. * TAMP_CR2 TAMP3NOERASE LL_RTC_TAMPER_EnableEraseBKP
  3079. * @param TAMPx TAMP Instance
  3080. * @param Tamper This parameter can be a combination of the following values:
  3081. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER1
  3082. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER2
  3083. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER3
  3084. *
  3085. * @retval None
  3086. */
  3087. __STATIC_INLINE void LL_RTC_TAMPER_EnableEraseBKP(TAMP_TypeDef *TAMPx, uint32_t Tamper)
  3088. {
  3089. CLEAR_BIT(TAMPx->CR2, Tamper);
  3090. }
  3091. /**
  3092. * @brief Disable backup register erase after Tamper event detection
  3093. * @rmtoll TAMP_CR2 TAMP1NOERASE LL_RTC_TAMPER_DisableEraseBKP
  3094. * TAMP_CR2 TAMP2NOERASE LL_RTC_TAMPER_DisableEraseBKP
  3095. * TAMP_CR2 TAMP3NOERASE LL_RTC_TAMPER_DisableEraseBKP
  3096. * @param TAMPx TAMP Instance
  3097. * @param Tamper This parameter can be a combination of the following values:
  3098. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER1
  3099. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER2
  3100. * @arg @ref LL_RTC_TAMPER_NOERASE_TAMPER3
  3101. *
  3102. * @retval None
  3103. */
  3104. __STATIC_INLINE void LL_RTC_TAMPER_DisableEraseBKP(TAMP_TypeDef *TAMPx, uint32_t Tamper)
  3105. {
  3106. SET_BIT(TAMPx->CR2, Tamper);
  3107. }
  3108. /**
  3109. * @brief Enable Active level for Tamper input
  3110. * @rmtoll TAMP_CR2 TAMP1TRG LL_RTC_TAMPER_EnableActiveLevel
  3111. * TAMP_CR2 TAMP2TRG LL_RTC_TAMPER_EnableActiveLevel
  3112. * TAMP_CR2 TAMP3TRG LL_RTC_TAMPER_EnableActiveLevel
  3113. * @param TAMPx TAMP Instance
  3114. * @param Tamper This parameter can be a combination of the following values:
  3115. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP1
  3116. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP2
  3117. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP3
  3118. *
  3119. * @retval None
  3120. */
  3121. __STATIC_INLINE void LL_RTC_TAMPER_EnableActiveLevel(TAMP_TypeDef *TAMPx, uint32_t Tamper)
  3122. {
  3123. SET_BIT(TAMPx->CR2, Tamper);
  3124. }
  3125. /**
  3126. * @brief Disable Active level for Tamper input
  3127. * @rmtoll TAMP_CR2 TAMP1TRG LL_RTC_TAMPER_DisableActiveLevel
  3128. * TAMP_CR2 TAMP2TRG LL_RTC_TAMPER_DisableActiveLevel
  3129. * TAMP_CR2 TAMP3TRG LL_RTC_TAMPER_DisableActiveLevel
  3130. * @param TAMPx TAMP Instance
  3131. * @param Tamper This parameter can be a combination of the following values:
  3132. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP1
  3133. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP2
  3134. * @arg @ref LL_RTC_TAMPER_ACTIVELEVEL_TAMP3
  3135. *
  3136. * @retval None
  3137. */
  3138. __STATIC_INLINE void LL_RTC_TAMPER_DisableActiveLevel(TAMP_TypeDef *TAMPx, uint32_t Tamper)
  3139. {
  3140. CLEAR_BIT(TAMPx->CR2, Tamper);
  3141. }
  3142. #endif /* TAMP_CR2_TAMP1MSK */
  3143. #if defined(TAMP_FLTCR_TAMPPUDIS)
  3144. /**
  3145. * @brief Disable RTC_TAMPx pull-up disable (Disable precharge of RTC_TAMPx pins)
  3146. * @rmtoll TAMP_FLTCR TAMPPUDIS LL_RTC_TAMPER_DisablePullUp
  3147. * @param TAMPx TAMP Instance
  3148. * @retval None
  3149. */
  3150. __STATIC_INLINE void LL_RTC_TAMPER_DisablePullUp(TAMP_TypeDef *TAMPx)
  3151. {
  3152. SET_BIT(TAMPx->FLTCR, TAMP_FLTCR_TAMPPUDIS);
  3153. }
  3154. /**
  3155. * @brief Enable RTC_TAMPx pull-up disable (Precharge RTC_TAMPx pins before sampling)
  3156. * @rmtoll TAMP_FLTCR TAMPPUDIS LL_RTC_TAMPER_EnablePullUp
  3157. * @param TAMPx TAMP Instance
  3158. * @retval None
  3159. */
  3160. __STATIC_INLINE void LL_RTC_TAMPER_EnablePullUp(TAMP_TypeDef *TAMPx)
  3161. {
  3162. CLEAR_BIT(TAMPx->FLTCR, TAMP_FLTCR_TAMPPUDIS);
  3163. }
  3164. /**
  3165. * @brief Set RTC_TAMPx precharge duration
  3166. * @rmtoll TAMP_FLTCR TAMPPRCH LL_RTC_TAMPER_SetPrecharge
  3167. * @param TAMPx TAMP Instance
  3168. * @param Duration This parameter can be one of the following values:
  3169. * @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
  3170. * @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
  3171. * @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
  3172. * @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
  3173. * @retval None
  3174. */
  3175. __STATIC_INLINE void LL_RTC_TAMPER_SetPrecharge(TAMP_TypeDef *TAMPx, uint32_t Duration)
  3176. {
  3177. MODIFY_REG(TAMPx->FLTCR, TAMP_FLTCR_TAMPPRCH, Duration);
  3178. }
  3179. /**
  3180. * @brief Get RTC_TAMPx precharge duration
  3181. * @rmtoll TAMP_FLTCR TAMPPRCH LL_RTC_TAMPER_GetPrecharge
  3182. * @param TAMPx TAMP Instance
  3183. * @retval Returned value can be one of the following values:
  3184. * @arg @ref LL_RTC_TAMPER_DURATION_1RTCCLK
  3185. * @arg @ref LL_RTC_TAMPER_DURATION_2RTCCLK
  3186. * @arg @ref LL_RTC_TAMPER_DURATION_4RTCCLK
  3187. * @arg @ref LL_RTC_TAMPER_DURATION_8RTCCLK
  3188. */
  3189. __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetPrecharge(TAMP_TypeDef *TAMPx)
  3190. {
  3191. return (uint32_t)(READ_BIT(TAMPx->FLTCR, TAMP_FLTCR_TAMPPRCH));
  3192. }
  3193. /**
  3194. * @brief Set RTC_TAMPx filter count
  3195. * @rmtoll TAMP_FLTCR TAMPFLT LL_RTC_TAMPER_SetFilterCount
  3196. * @param TAMPx TAMP Instance
  3197. * @param FilterCount This parameter can be one of the following values:
  3198. * @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
  3199. * @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
  3200. * @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
  3201. * @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
  3202. * @retval None
  3203. */
  3204. __STATIC_INLINE void LL_RTC_TAMPER_SetFilterCount(TAMP_TypeDef *TAMPx, uint32_t FilterCount)
  3205. {
  3206. MODIFY_REG(TAMPx->FLTCR, TAMP_FLTCR_TAMPFLT, FilterCount);
  3207. }
  3208. /**
  3209. * @brief Get RTC_TAMPx filter count
  3210. * @rmtoll TAMP_FLTCR TAMPFLT LL_RTC_TAMPER_GetFilterCount
  3211. * @param TAMPx TAMP Instance
  3212. * @retval Returned value can be one of the following values:
  3213. * @arg @ref LL_RTC_TAMPER_FILTER_DISABLE
  3214. * @arg @ref LL_RTC_TAMPER_FILTER_2SAMPLE
  3215. * @arg @ref LL_RTC_TAMPER_FILTER_4SAMPLE
  3216. * @arg @ref LL_RTC_TAMPER_FILTER_8SAMPLE
  3217. */
  3218. __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetFilterCount(TAMP_TypeDef *TAMPx)
  3219. {
  3220. return (uint32_t)(READ_BIT(TAMPx->FLTCR, TAMP_FLTCR_TAMPFLT));
  3221. }
  3222. /**
  3223. * @brief Set Tamper sampling frequency
  3224. * @rmtoll TAMP_FLTCR TAMPFREQ LL_RTC_TAMPER_SetSamplingFreq
  3225. * @param TAMPx TAMP Instance
  3226. * @param SamplingFreq This parameter can be one of the following values:
  3227. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
  3228. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
  3229. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
  3230. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
  3231. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
  3232. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
  3233. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
  3234. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
  3235. * @retval None
  3236. */
  3237. __STATIC_INLINE void LL_RTC_TAMPER_SetSamplingFreq(TAMP_TypeDef *TAMPx, uint32_t SamplingFreq)
  3238. {
  3239. MODIFY_REG(TAMPx->FLTCR, TAMP_FLTCR_TAMPFREQ, SamplingFreq);
  3240. }
  3241. /**
  3242. * @brief Get Tamper sampling frequency
  3243. * @rmtoll TAMP_FLTCR TAMPFREQ LL_RTC_TAMPER_GetSamplingFreq
  3244. * @param TAMPx TAMP Instance
  3245. * @retval Returned value can be one of the following values:
  3246. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_32768
  3247. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_16384
  3248. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_8192
  3249. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_4096
  3250. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_2048
  3251. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_1024
  3252. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_512
  3253. * @arg @ref LL_RTC_TAMPER_SAMPLFREQDIV_256
  3254. */
  3255. __STATIC_INLINE uint32_t LL_RTC_TAMPER_GetSamplingFreq(TAMP_TypeDef *TAMPx)
  3256. {
  3257. return (uint32_t)(READ_BIT(TAMPx->FLTCR, TAMP_FLTCR_TAMPFREQ));
  3258. }
  3259. #endif /* TAMP_FLTCR_TAMPPUDIS */
  3260. /**
  3261. * @}
  3262. */
  3263. /** @defgroup RTC_LL_EF_Wakeup Wakeup
  3264. * @{
  3265. */
  3266. /**
  3267. * @brief Enable Wakeup timer
  3268. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3269. * @rmtoll RTC_CR WUTE LL_RTC_WAKEUP_Enable
  3270. * @param RTCx RTC Instance
  3271. * @retval None
  3272. */
  3273. __STATIC_INLINE void LL_RTC_WAKEUP_Enable(RTC_TypeDef *RTCx)
  3274. {
  3275. SET_BIT(RTCx->CR, RTC_CR_WUTE);
  3276. }
  3277. /**
  3278. * @brief Disable Wakeup timer
  3279. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3280. * @rmtoll RTC_CR WUTE LL_RTC_WAKEUP_Disable
  3281. * @param RTCx RTC Instance
  3282. * @retval None
  3283. */
  3284. __STATIC_INLINE void LL_RTC_WAKEUP_Disable(RTC_TypeDef *RTCx)
  3285. {
  3286. CLEAR_BIT(RTCx->CR, RTC_CR_WUTE);
  3287. }
  3288. /**
  3289. * @brief Check if Wakeup timer is enabled or not
  3290. * @rmtoll RTC_CR WUTE LL_RTC_WAKEUP_IsEnabled
  3291. * @param RTCx RTC Instance
  3292. * @retval State of bit (1 or 0).
  3293. */
  3294. __STATIC_INLINE uint32_t LL_RTC_WAKEUP_IsEnabled(RTC_TypeDef *RTCx)
  3295. {
  3296. return ((READ_BIT(RTCx->CR, RTC_CR_WUTE) == (RTC_CR_WUTE)) ? 1UL : 0UL);
  3297. }
  3298. /**
  3299. * @brief Select Wakeup clock
  3300. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3301. * @note Bit can be written only when RTC_CR WUTE bit = 0 and RTC_ISR WUTWF bit = 1
  3302. * @rmtoll RTC_CR WUCKSEL LL_RTC_WAKEUP_SetClock
  3303. * @param RTCx RTC Instance
  3304. * @param WakeupClock This parameter can be one of the following values:
  3305. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_16
  3306. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_8
  3307. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_4
  3308. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_2
  3309. * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE
  3310. * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE_WUT
  3311. * @retval None
  3312. */
  3313. __STATIC_INLINE void LL_RTC_WAKEUP_SetClock(RTC_TypeDef *RTCx, uint32_t WakeupClock)
  3314. {
  3315. MODIFY_REG(RTCx->CR, RTC_CR_WUCKSEL, WakeupClock);
  3316. }
  3317. /**
  3318. * @brief Get Wakeup clock
  3319. * @rmtoll RTC_CR WUCKSEL LL_RTC_WAKEUP_GetClock
  3320. * @param RTCx RTC Instance
  3321. * @retval Returned value can be one of the following values:
  3322. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_16
  3323. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_8
  3324. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_4
  3325. * @arg @ref LL_RTC_WAKEUPCLOCK_DIV_2
  3326. * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE
  3327. * @arg @ref LL_RTC_WAKEUPCLOCK_CKSPRE_WUT
  3328. */
  3329. __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetClock(RTC_TypeDef *RTCx)
  3330. {
  3331. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_WUCKSEL));
  3332. }
  3333. /**
  3334. * @brief Set Wakeup auto-reload value
  3335. * @note Bit can be written only when WUTWF is set to 1 in RTC_ISR
  3336. * @rmtoll RTC_WUTR WUT LL_RTC_WAKEUP_SetAutoReload
  3337. * @param RTCx RTC Instance
  3338. * @param Value Value between Min_Data=0x00 and Max_Data=0xFFFF
  3339. * @retval None
  3340. */
  3341. __STATIC_INLINE void LL_RTC_WAKEUP_SetAutoReload(RTC_TypeDef *RTCx, uint32_t Value)
  3342. {
  3343. MODIFY_REG(RTCx->WUTR, RTC_WUTR_WUT, Value);
  3344. }
  3345. /**
  3346. * @brief Get Wakeup auto-reload value
  3347. * @rmtoll RTC_WUTR WUT LL_RTC_WAKEUP_GetAutoReload
  3348. * @param RTCx RTC Instance
  3349. * @retval Value between Min_Data=0x00 and Max_Data=0xFFFF
  3350. */
  3351. __STATIC_INLINE uint32_t LL_RTC_WAKEUP_GetAutoReload(RTC_TypeDef *RTCx)
  3352. {
  3353. return (uint32_t)(READ_BIT(RTCx->WUTR, RTC_WUTR_WUT));
  3354. }
  3355. /**
  3356. * @}
  3357. */
  3358. /** @defgroup RTC_LL_EF_Backup_Registers Backup_Registers
  3359. * @{
  3360. */
  3361. #if defined(RTC_BKP0R)
  3362. /**
  3363. * @brief Writes a data in a specified RTC Backup data register.
  3364. * @rmtoll BKPxR BKP LL_RTC_BAK_SetRegister
  3365. * @param RTCx RTC Instance
  3366. * @param BackupRegister This parameter can be one of the following values:
  3367. * @arg @ref LL_RTC_BKP_DR0
  3368. * @arg @ref LL_RTC_BKP_DR1
  3369. * @arg @ref LL_RTC_BKP_DR2
  3370. * @arg @ref LL_RTC_BKP_DR3
  3371. * @arg @ref LL_RTC_BKP_DR4
  3372. * @arg @ref LL_RTC_BKP_DR5
  3373. * @arg @ref LL_RTC_BKP_DR6
  3374. * @arg @ref LL_RTC_BKP_DR7
  3375. * @arg @ref LL_RTC_BKP_DR8
  3376. * @arg @ref LL_RTC_BKP_DR9
  3377. * @arg @ref LL_RTC_BKP_DR10
  3378. * @arg @ref LL_RTC_BKP_DR11
  3379. * @arg @ref LL_RTC_BKP_DR12
  3380. * @arg @ref LL_RTC_BKP_DR13
  3381. * @arg @ref LL_RTC_BKP_DR14
  3382. * @arg @ref LL_RTC_BKP_DR15
  3383. * @arg @ref LL_RTC_BKP_DR16
  3384. * @arg @ref LL_RTC_BKP_DR17
  3385. * @arg @ref LL_RTC_BKP_DR18
  3386. * @arg @ref LL_RTC_BKP_DR19
  3387. * @arg @ref LL_RTC_BKP_DR20
  3388. * @arg @ref LL_RTC_BKP_DR21
  3389. * @arg @ref LL_RTC_BKP_DR22
  3390. * @arg @ref LL_RTC_BKP_DR23
  3391. * @arg @ref LL_RTC_BKP_DR24
  3392. * @arg @ref LL_RTC_BKP_DR25
  3393. * @arg @ref LL_RTC_BKP_DR26
  3394. * @arg @ref LL_RTC_BKP_DR27
  3395. * @arg @ref LL_RTC_BKP_DR28
  3396. * @arg @ref LL_RTC_BKP_DR29
  3397. * @arg @ref LL_RTC_BKP_DR30
  3398. * @arg @ref LL_RTC_BKP_DR31
  3399. * @param Data Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
  3400. * @retval None
  3401. */
  3402. __STATIC_INLINE void LL_RTC_BAK_SetRegister(RTC_TypeDef *RTCx, uint32_t BackupRegister, uint32_t Data)
  3403. {
  3404. register uint32_t tmp;
  3405. tmp = (uint32_t)(&(RTCx->BKP0R));
  3406. tmp += (BackupRegister * 4U);
  3407. /* Write the specified register */
  3408. *(__IO uint32_t *)tmp = (uint32_t)Data;
  3409. }
  3410. /**
  3411. * @brief Reads data from the specified RTC Backup data Register.
  3412. * @rmtoll BKPxR BKP LL_RTC_BAK_GetRegister
  3413. * @param RTCx RTC Instance
  3414. * @param BackupRegister This parameter can be one of the following values:
  3415. * @arg @ref LL_RTC_BKP_DR0
  3416. * @arg @ref LL_RTC_BKP_DR1
  3417. * @arg @ref LL_RTC_BKP_DR2
  3418. * @arg @ref LL_RTC_BKP_DR3
  3419. * @arg @ref LL_RTC_BKP_DR4
  3420. * @arg @ref LL_RTC_BKP_DR5
  3421. * @arg @ref LL_RTC_BKP_DR6
  3422. * @arg @ref LL_RTC_BKP_DR7
  3423. * @arg @ref LL_RTC_BKP_DR8
  3424. * @arg @ref LL_RTC_BKP_DR9
  3425. * @arg @ref LL_RTC_BKP_DR10
  3426. * @arg @ref LL_RTC_BKP_DR11
  3427. * @arg @ref LL_RTC_BKP_DR12
  3428. * @arg @ref LL_RTC_BKP_DR13
  3429. * @arg @ref LL_RTC_BKP_DR14
  3430. * @arg @ref LL_RTC_BKP_DR15
  3431. * @arg @ref LL_RTC_BKP_DR16
  3432. * @arg @ref LL_RTC_BKP_DR17
  3433. * @arg @ref LL_RTC_BKP_DR18
  3434. * @arg @ref LL_RTC_BKP_DR19
  3435. * @arg @ref LL_RTC_BKP_DR20
  3436. * @arg @ref LL_RTC_BKP_DR21
  3437. * @arg @ref LL_RTC_BKP_DR22
  3438. * @arg @ref LL_RTC_BKP_DR23
  3439. * @arg @ref LL_RTC_BKP_DR24
  3440. * @arg @ref LL_RTC_BKP_DR25
  3441. * @arg @ref LL_RTC_BKP_DR26
  3442. * @arg @ref LL_RTC_BKP_DR27
  3443. * @arg @ref LL_RTC_BKP_DR28
  3444. * @arg @ref LL_RTC_BKP_DR29
  3445. * @arg @ref LL_RTC_BKP_DR30
  3446. * @arg @ref LL_RTC_BKP_DR31
  3447. * @retval Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
  3448. */
  3449. __STATIC_INLINE uint32_t LL_RTC_BAK_GetRegister(RTC_TypeDef *RTCx, uint32_t BackupRegister)
  3450. {
  3451. register uint32_t tmp;
  3452. tmp = (uint32_t)(&(RTCx->BKP0R));
  3453. tmp += (BackupRegister * 4U);
  3454. /* Read the specified register */
  3455. return (*(__IO uint32_t *)tmp);
  3456. }
  3457. #endif /* RTC_BKP0R */
  3458. #if defined(TAMP_BKP0R_BKP)
  3459. /**
  3460. * @brief Writes a data in a specified Backup data register.
  3461. * @rmtoll TAMP_BKPxR BKP LL_RTC_BKP_SetRegister
  3462. * @param TAMPx RTC Instance
  3463. * @param BackupRegister This parameter can be one of the following values:
  3464. * @arg @ref LL_RTC_BKP_DR0
  3465. * @arg @ref LL_RTC_BKP_DR1
  3466. * @arg @ref LL_RTC_BKP_DR2
  3467. * @arg @ref LL_RTC_BKP_DR3
  3468. * @arg @ref LL_RTC_BKP_DR4
  3469. * @arg @ref LL_RTC_BKP_DR5
  3470. * @arg @ref LL_RTC_BKP_DR6
  3471. * @arg @ref LL_RTC_BKP_DR7
  3472. * @arg @ref LL_RTC_BKP_DR8
  3473. * @arg @ref LL_RTC_BKP_DR9
  3474. * @arg @ref LL_RTC_BKP_DR10
  3475. * @arg @ref LL_RTC_BKP_DR11
  3476. * @arg @ref LL_RTC_BKP_DR12
  3477. * @arg @ref LL_RTC_BKP_DR13
  3478. * @arg @ref LL_RTC_BKP_DR14
  3479. * @arg @ref LL_RTC_BKP_DR15
  3480. * @arg @ref LL_RTC_BKP_DR16
  3481. * @arg @ref LL_RTC_BKP_DR17
  3482. * @arg @ref LL_RTC_BKP_DR18
  3483. * @arg @ref LL_RTC_BKP_DR19
  3484. * @arg @ref LL_RTC_BKP_DR20
  3485. * @arg @ref LL_RTC_BKP_DR21
  3486. * @arg @ref LL_RTC_BKP_DR22
  3487. * @arg @ref LL_RTC_BKP_DR23
  3488. * @arg @ref LL_RTC_BKP_DR24
  3489. * @arg @ref LL_RTC_BKP_DR25
  3490. * @arg @ref LL_RTC_BKP_DR26
  3491. * @arg @ref LL_RTC_BKP_DR27
  3492. * @arg @ref LL_RTC_BKP_DR28
  3493. * @arg @ref LL_RTC_BKP_DR29
  3494. * @arg @ref LL_RTC_BKP_DR30
  3495. * @arg @ref LL_RTC_BKP_DR31
  3496. * @param Data Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
  3497. * @retval None
  3498. */
  3499. __STATIC_INLINE void LL_RTC_BKP_SetRegister(TAMP_TypeDef *TAMPx, uint32_t BackupRegister, uint32_t Data)
  3500. {
  3501. register uint32_t tmp = 0U;
  3502. tmp = (uint32_t)(&(TAMPx->BKP0R));
  3503. tmp += (BackupRegister * 4U);
  3504. /* Write the specified register */
  3505. *(__IO uint32_t *)tmp = (uint32_t)Data;
  3506. }
  3507. /**
  3508. * @brief Reads data from the specified RTC Backup data Register.
  3509. * @rmtoll TAMP_BKPxR BKP LL_RTC_BKP_GetRegister
  3510. * @param TAMPx RTC Instance
  3511. * @param BackupRegister This parameter can be one of the following values:
  3512. * @arg @ref LL_RTC_BKP_DR0
  3513. * @arg @ref LL_RTC_BKP_DR1
  3514. * @arg @ref LL_RTC_BKP_DR2
  3515. * @arg @ref LL_RTC_BKP_DR3
  3516. * @arg @ref LL_RTC_BKP_DR4
  3517. * @arg @ref LL_RTC_BKP_DR5
  3518. * @arg @ref LL_RTC_BKP_DR6
  3519. * @arg @ref LL_RTC_BKP_DR7
  3520. * @arg @ref LL_RTC_BKP_DR8
  3521. * @arg @ref LL_RTC_BKP_DR9
  3522. * @arg @ref LL_RTC_BKP_DR10
  3523. * @arg @ref LL_RTC_BKP_DR11
  3524. * @arg @ref LL_RTC_BKP_DR12
  3525. * @arg @ref LL_RTC_BKP_DR13
  3526. * @arg @ref LL_RTC_BKP_DR14
  3527. * @arg @ref LL_RTC_BKP_DR15
  3528. * @arg @ref LL_RTC_BKP_DR16
  3529. * @arg @ref LL_RTC_BKP_DR17
  3530. * @arg @ref LL_RTC_BKP_DR18
  3531. * @arg @ref LL_RTC_BKP_DR19
  3532. * @arg @ref LL_RTC_BKP_DR20
  3533. * @arg @ref LL_RTC_BKP_DR21
  3534. * @arg @ref LL_RTC_BKP_DR22
  3535. * @arg @ref LL_RTC_BKP_DR23
  3536. * @arg @ref LL_RTC_BKP_DR24
  3537. * @arg @ref LL_RTC_BKP_DR25
  3538. * @arg @ref LL_RTC_BKP_DR26
  3539. * @arg @ref LL_RTC_BKP_DR27
  3540. * @arg @ref LL_RTC_BKP_DR28
  3541. * @arg @ref LL_RTC_BKP_DR29
  3542. * @arg @ref LL_RTC_BKP_DR30
  3543. * @arg @ref LL_RTC_BKP_DR31
  3544. * @retval Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
  3545. */
  3546. __STATIC_INLINE uint32_t LL_RTC_BKP_GetRegister(TAMP_TypeDef *TAMPx, uint32_t BackupRegister)
  3547. {
  3548. register uint32_t tmp = 0U;
  3549. tmp = (uint32_t)(&(TAMPx->BKP0R));
  3550. tmp += (BackupRegister * 4U);
  3551. /* Read the specified register */
  3552. return (*(__IO uint32_t *)tmp);
  3553. }
  3554. #endif /* TAMP_BKP0R_BKP */
  3555. /**
  3556. * @}
  3557. */
  3558. /** @defgroup RTC_LL_EF_Calibration Calibration
  3559. * @{
  3560. */
  3561. /**
  3562. * @brief Set Calibration output frequency (1 Hz or 512 Hz)
  3563. * @note Bits are write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3564. * @rmtoll RTC_CR COE LL_RTC_CAL_SetOutputFreq
  3565. * RTC_CR COSEL LL_RTC_CAL_SetOutputFreq
  3566. * @param RTCx RTC Instance
  3567. * @param Frequency This parameter can be one of the following values:
  3568. * @arg @ref LL_RTC_CALIB_OUTPUT_NONE
  3569. * @arg @ref LL_RTC_CALIB_OUTPUT_1HZ
  3570. * @arg @ref LL_RTC_CALIB_OUTPUT_512HZ
  3571. * @retval None
  3572. */
  3573. __STATIC_INLINE void LL_RTC_CAL_SetOutputFreq(RTC_TypeDef *RTCx, uint32_t Frequency)
  3574. {
  3575. MODIFY_REG(RTCx->CR, RTC_CR_COE | RTC_CR_COSEL, Frequency);
  3576. }
  3577. /**
  3578. * @brief Get Calibration output frequency (1 Hz or 512 Hz)
  3579. * @rmtoll RTC_CR COE LL_RTC_CAL_GetOutputFreq
  3580. * RTC_CR COSEL LL_RTC_CAL_GetOutputFreq
  3581. * @param RTCx RTC Instance
  3582. * @retval Returned value can be one of the following values:
  3583. * @arg @ref LL_RTC_CALIB_OUTPUT_NONE
  3584. * @arg @ref LL_RTC_CALIB_OUTPUT_1HZ
  3585. * @arg @ref LL_RTC_CALIB_OUTPUT_512HZ
  3586. */
  3587. __STATIC_INLINE uint32_t LL_RTC_CAL_GetOutputFreq(RTC_TypeDef *RTCx)
  3588. {
  3589. return (uint32_t)(READ_BIT(RTCx->CR, RTC_CR_COE | RTC_CR_COSEL));
  3590. }
  3591. /**
  3592. * @brief Insert or not One RTCCLK pulse every 2exp11 pulses (frequency increased by 488.5 ppm)
  3593. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3594. * @note Bit can be written only when RECALPF is set to 0 in RTC_ISR
  3595. * @rmtoll RTC_CALR CALP LL_RTC_CAL_SetPulse
  3596. * @param RTCx RTC Instance
  3597. * @param Pulse This parameter can be one of the following values:
  3598. * @arg @ref LL_RTC_CALIB_INSERTPULSE_NONE
  3599. * @arg @ref LL_RTC_CALIB_INSERTPULSE_SET
  3600. * @retval None
  3601. */
  3602. __STATIC_INLINE void LL_RTC_CAL_SetPulse(RTC_TypeDef *RTCx, uint32_t Pulse)
  3603. {
  3604. MODIFY_REG(RTCx->CALR, RTC_CALR_CALP, Pulse);
  3605. }
  3606. /**
  3607. * @brief Check if one RTCCLK has been inserted or not every 2exp11 pulses (frequency increased by 488.5 ppm)
  3608. * @rmtoll RTC_CALR CALP LL_RTC_CAL_IsPulseInserted
  3609. * @param RTCx RTC Instance
  3610. * @retval State of bit (1 or 0).
  3611. */
  3612. __STATIC_INLINE uint32_t LL_RTC_CAL_IsPulseInserted(RTC_TypeDef *RTCx)
  3613. {
  3614. return ((READ_BIT(RTCx->CALR, RTC_CALR_CALP) == (RTC_CALR_CALP)) ? 1UL : 0UL);
  3615. }
  3616. /**
  3617. * @brief Set the calibration cycle period
  3618. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3619. * @note Bit can be written only when RECALPF is set to 0 in RTC_ISR
  3620. * @rmtoll RTC_CALR CALW8 LL_RTC_CAL_SetPeriod
  3621. * RTC_CALR CALW16 LL_RTC_CAL_SetPeriod
  3622. * @param RTCx RTC Instance
  3623. * @param Period This parameter can be one of the following values:
  3624. * @arg @ref LL_RTC_CALIB_PERIOD_32SEC
  3625. * @arg @ref LL_RTC_CALIB_PERIOD_16SEC
  3626. * @arg @ref LL_RTC_CALIB_PERIOD_8SEC
  3627. * @retval None
  3628. */
  3629. __STATIC_INLINE void LL_RTC_CAL_SetPeriod(RTC_TypeDef *RTCx, uint32_t Period)
  3630. {
  3631. MODIFY_REG(RTCx->CALR, RTC_CALR_CALW8 | RTC_CALR_CALW16, Period);
  3632. }
  3633. /**
  3634. * @brief Get the calibration cycle period
  3635. * @rmtoll RTC_CALR CALW8 LL_RTC_CAL_GetPeriod
  3636. * RTC_CALR CALW16 LL_RTC_CAL_GetPeriod
  3637. * @param RTCx RTC Instance
  3638. * @retval Returned value can be one of the following values:
  3639. * @arg @ref LL_RTC_CALIB_PERIOD_32SEC
  3640. * @arg @ref LL_RTC_CALIB_PERIOD_16SEC
  3641. * @arg @ref LL_RTC_CALIB_PERIOD_8SEC
  3642. */
  3643. __STATIC_INLINE uint32_t LL_RTC_CAL_GetPeriod(RTC_TypeDef *RTCx)
  3644. {
  3645. return (uint32_t)(READ_BIT(RTCx->CALR, RTC_CALR_CALW8 | RTC_CALR_CALW16));
  3646. }
  3647. /**
  3648. * @brief Set Calibration minus
  3649. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  3650. * @note Bit can be written only when RECALPF is set to 0 in RTC_ISR
  3651. * @rmtoll RTC_CALR CALM LL_RTC_CAL_SetMinus
  3652. * @param RTCx RTC Instance
  3653. * @param CalibMinus Value between Min_Data=0x00 and Max_Data=0x1FF
  3654. * @retval None
  3655. */
  3656. __STATIC_INLINE void LL_RTC_CAL_SetMinus(RTC_TypeDef *RTCx, uint32_t CalibMinus)
  3657. {
  3658. MODIFY_REG(RTCx->CALR, RTC_CALR_CALM, CalibMinus);
  3659. }
  3660. /**
  3661. * @brief Get Calibration minus
  3662. * @rmtoll RTC_CALR CALM LL_RTC_CAL_GetMinus
  3663. * @param RTCx RTC Instance
  3664. * @retval Value between Min_Data=0x00 and Max_Data= 0x1FF
  3665. */
  3666. __STATIC_INLINE uint32_t LL_RTC_CAL_GetMinus(RTC_TypeDef *RTCx)
  3667. {
  3668. return (uint32_t)(READ_BIT(RTCx->CALR, RTC_CALR_CALM));
  3669. }
  3670. /**
  3671. * @}
  3672. */
  3673. /** @defgroup RTC_LL_EF_FLAG_Management FLAG_Management
  3674. * @{
  3675. */
  3676. #if defined(RTC_ISR_ITSF)
  3677. /**
  3678. * @brief Get Internal Time-stamp flag
  3679. * @rmtoll RTC_ISR ITSF LL_RTC_IsActiveFlag_ITS
  3680. * @param RTCx RTC Instance
  3681. * @retval State of bit (1 or 0).
  3682. */
  3683. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITS(RTC_TypeDef *RTCx)
  3684. {
  3685. return ((READ_BIT(RTCx->ISR, RTC_ISR_ITSF) == (RTC_ISR_ITSF)) ? 1UL : 0UL);
  3686. }
  3687. /**
  3688. * @brief Get Recalibration pending Flag
  3689. * @rmtoll ISR RECALPF LL_RTC_IsActiveFlag_RECALP
  3690. * @param RTCx RTC Instance
  3691. * @retval State of bit (1 or 0).
  3692. */
  3693. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RECALP(RTC_TypeDef *RTCx)
  3694. {
  3695. return ((READ_BIT(RTCx->ISR, RTC_ISR_RECALPF) == (RTC_ISR_RECALPF)) ? 1UL : 0UL);
  3696. }
  3697. /**
  3698. * @brief Get RTC_TAMP3 detection flag
  3699. * @rmtoll ISR TAMP3F LL_RTC_IsActiveFlag_TAMP3
  3700. * @param RTCx RTC Instance
  3701. * @retval State of bit (1 or 0).
  3702. */
  3703. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP3(RTC_TypeDef *RTCx)
  3704. {
  3705. return ((READ_BIT(RTCx->ISR, RTC_ISR_TAMP3F) == (RTC_ISR_TAMP3F)) ? 1UL : 0UL);
  3706. }
  3707. /**
  3708. * @brief Get RTC_TAMP2 detection flag
  3709. * @rmtoll ISR TAMP2F LL_RTC_IsActiveFlag_TAMP2
  3710. * @param RTCx RTC Instance
  3711. * @retval State of bit (1 or 0).
  3712. */
  3713. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP2(RTC_TypeDef *RTCx)
  3714. {
  3715. return ((READ_BIT(RTCx->ISR, RTC_ISR_TAMP2F) == (RTC_ISR_TAMP2F)) ? 1UL : 0UL);
  3716. }
  3717. /**
  3718. * @brief Get RTC_TAMP1 detection flag
  3719. * @rmtoll ISR TAMP1F LL_RTC_IsActiveFlag_TAMP1
  3720. * @param RTCx RTC Instance
  3721. * @retval State of bit (1 or 0).
  3722. */
  3723. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP1(RTC_TypeDef *RTCx)
  3724. {
  3725. return ((READ_BIT(RTCx->ISR, RTC_ISR_TAMP1F) == (RTC_ISR_TAMP1F)) ? 1UL : 0UL);
  3726. }
  3727. /**
  3728. * @brief Get Time-stamp overflow flag
  3729. * @rmtoll ISR TSOVF LL_RTC_IsActiveFlag_TSOV
  3730. * @param RTCx RTC Instance
  3731. * @retval State of bit (1 or 0).
  3732. */
  3733. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TSOV(RTC_TypeDef *RTCx)
  3734. {
  3735. return ((READ_BIT(RTCx->ISR, RTC_ISR_TSOVF) == (RTC_ISR_TSOVF)) ? 1UL : 0UL);
  3736. }
  3737. /**
  3738. * @brief Get Time-stamp flag
  3739. * @rmtoll ISR TSF LL_RTC_IsActiveFlag_TS
  3740. * @param RTCx RTC Instance
  3741. * @retval State of bit (1 or 0).
  3742. */
  3743. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TS(RTC_TypeDef *RTCx)
  3744. {
  3745. return ((READ_BIT(RTCx->ISR, RTC_ISR_TSF) == (RTC_ISR_TSF)) ? 1UL : 0UL);
  3746. }
  3747. /**
  3748. * @brief Get Wakeup timer flag
  3749. * @rmtoll ISR WUTF LL_RTC_IsActiveFlag_WUT
  3750. * @param RTCx RTC Instance
  3751. * @retval State of bit (1 or 0).
  3752. */
  3753. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUT(RTC_TypeDef *RTCx)
  3754. {
  3755. return ((READ_BIT(RTCx->ISR, RTC_ISR_WUTF) == (RTC_ISR_WUTF)) ? 1UL : 0UL);
  3756. }
  3757. /**
  3758. * @brief Get Alarm B flag
  3759. * @rmtoll ISR ALRBF LL_RTC_IsActiveFlag_ALRB
  3760. * @param RTCx RTC Instance
  3761. * @retval State of bit (1 or 0).
  3762. */
  3763. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRB(RTC_TypeDef *RTCx)
  3764. {
  3765. return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRBF) == (RTC_ISR_ALRBF)) ? 1UL : 0UL);
  3766. }
  3767. /**
  3768. * @brief Get Alarm A flag
  3769. * @rmtoll ISR ALRAF LL_RTC_IsActiveFlag_ALRA
  3770. * @param RTCx RTC Instance
  3771. * @retval State of bit (1 or 0).
  3772. */
  3773. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRA(RTC_TypeDef *RTCx)
  3774. {
  3775. return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRAF) == (RTC_ISR_ALRAF)) ? 1UL : 0UL);
  3776. }
  3777. /**
  3778. * @brief Clear Internal Time-stamp flag
  3779. * @rmtoll ISR ITSF LL_RTC_ClearFlag_ITS
  3780. * @param RTCx RTC Instance
  3781. * @retval None
  3782. */
  3783. __STATIC_INLINE void LL_RTC_ClearFlag_ITS(RTC_TypeDef *RTCx)
  3784. {
  3785. WRITE_REG(RTCx->ISR, (~((RTC_ISR_ITSF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3786. }
  3787. /**
  3788. * @brief Clear RTC_TAMP3 detection flag
  3789. * @rmtoll ISR TAMP3F LL_RTC_ClearFlag_TAMP3
  3790. * @param RTCx RTC Instance
  3791. * @retval None
  3792. */
  3793. __STATIC_INLINE void LL_RTC_ClearFlag_TAMP3(RTC_TypeDef *RTCx)
  3794. {
  3795. WRITE_REG(RTCx->ISR, (~((RTC_ISR_TAMP3F | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3796. }
  3797. /**
  3798. * @brief Clear RTC_TAMP2 detection flag
  3799. * @rmtoll ISR TAMP2F LL_RTC_ClearFlag_TAMP2
  3800. * @param RTCx RTC Instance
  3801. * @retval None
  3802. */
  3803. __STATIC_INLINE void LL_RTC_ClearFlag_TAMP2(RTC_TypeDef *RTCx)
  3804. {
  3805. WRITE_REG(RTCx->ISR, (~((RTC_ISR_TAMP2F | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3806. }
  3807. /**
  3808. * @brief Clear RTC_TAMP1 detection flag
  3809. * @rmtoll ISR TAMP1F LL_RTC_ClearFlag_TAMP1
  3810. * @param RTCx RTC Instance
  3811. * @retval None
  3812. */
  3813. __STATIC_INLINE void LL_RTC_ClearFlag_TAMP1(RTC_TypeDef *RTCx)
  3814. {
  3815. WRITE_REG(RTCx->ISR, (~((RTC_ISR_TAMP1F | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3816. }
  3817. /**
  3818. * @brief Clear Time-stamp overflow flag
  3819. * @rmtoll ISR TSOVF LL_RTC_ClearFlag_TSOV
  3820. * @param RTCx RTC Instance
  3821. * @retval None
  3822. */
  3823. __STATIC_INLINE void LL_RTC_ClearFlag_TSOV(RTC_TypeDef *RTCx)
  3824. {
  3825. WRITE_REG(RTCx->ISR, (~((RTC_ISR_TSOVF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3826. }
  3827. /**
  3828. * @brief Clear Time-stamp flag
  3829. * @rmtoll ISR TSF LL_RTC_ClearFlag_TS
  3830. * @param RTCx RTC Instance
  3831. * @retval None
  3832. */
  3833. __STATIC_INLINE void LL_RTC_ClearFlag_TS(RTC_TypeDef *RTCx)
  3834. {
  3835. WRITE_REG(RTCx->ISR, (~((RTC_ISR_TSF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3836. }
  3837. /**
  3838. * @brief Clear Wakeup timer flag
  3839. * @rmtoll ISR WUTF LL_RTC_ClearFlag_WUT
  3840. * @param RTCx RTC Instance
  3841. * @retval None
  3842. */
  3843. __STATIC_INLINE void LL_RTC_ClearFlag_WUT(RTC_TypeDef *RTCx)
  3844. {
  3845. WRITE_REG(RTCx->ISR, (~((RTC_ISR_WUTF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3846. }
  3847. /**
  3848. * @brief Clear Alarm B flag
  3849. * @rmtoll ISR ALRBF LL_RTC_ClearFlag_ALRB
  3850. * @param RTCx RTC Instance
  3851. * @retval None
  3852. */
  3853. __STATIC_INLINE void LL_RTC_ClearFlag_ALRB(RTC_TypeDef *RTCx)
  3854. {
  3855. WRITE_REG(RTCx->ISR, (~((RTC_ISR_ALRBF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3856. }
  3857. /**
  3858. * @brief Clear Alarm A flag
  3859. * @rmtoll ISR ALRAF LL_RTC_ClearFlag_ALRA
  3860. * @param RTCx RTC Instance
  3861. * @retval None
  3862. */
  3863. __STATIC_INLINE void LL_RTC_ClearFlag_ALRA(RTC_TypeDef *RTCx)
  3864. {
  3865. WRITE_REG(RTCx->ISR, (~((RTC_ISR_ALRAF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3866. }
  3867. /**
  3868. * @brief Get Initialization flag
  3869. * @rmtoll ISR INITF LL_RTC_IsActiveFlag_INIT
  3870. * @param RTCx RTC Instance
  3871. * @retval State of bit (1 or 0).
  3872. */
  3873. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INIT(RTC_TypeDef *RTCx)
  3874. {
  3875. return ((READ_BIT(RTCx->ISR, RTC_ISR_INITF) == (RTC_ISR_INITF)) ? 1UL : 0UL);
  3876. }
  3877. /**
  3878. * @brief Get Registers synchronization flag
  3879. * @rmtoll ISR RSF LL_RTC_IsActiveFlag_RS
  3880. * @param RTCx RTC Instance
  3881. * @retval State of bit (1 or 0).
  3882. */
  3883. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RS(RTC_TypeDef *RTCx)
  3884. {
  3885. return ((READ_BIT(RTCx->ISR, RTC_ISR_RSF) == (RTC_ISR_RSF)) ? 1UL : 0UL);
  3886. }
  3887. /**
  3888. * @brief Clear Registers synchronization flag
  3889. * @rmtoll ISR RSF LL_RTC_ClearFlag_RS
  3890. * @param RTCx RTC Instance
  3891. * @retval None
  3892. */
  3893. __STATIC_INLINE void LL_RTC_ClearFlag_RS(RTC_TypeDef *RTCx)
  3894. {
  3895. WRITE_REG(RTCx->ISR, (~((RTC_ISR_RSF | RTC_ISR_INIT) & 0x0000FFFFU) | (RTCx->ISR & RTC_ISR_INIT)));
  3896. }
  3897. /**
  3898. * @brief Get Initialization status flag
  3899. * @rmtoll ISR INITS LL_RTC_IsActiveFlag_INITS
  3900. * @param RTCx RTC Instance
  3901. * @retval State of bit (1 or 0).
  3902. */
  3903. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INITS(RTC_TypeDef *RTCx)
  3904. {
  3905. return ((READ_BIT(RTCx->ISR, RTC_ISR_INITS) == (RTC_ISR_INITS)) ? 1UL : 0UL);
  3906. }
  3907. /**
  3908. * @brief Get Shift operation pending flag
  3909. * @rmtoll ISR SHPF LL_RTC_IsActiveFlag_SHP
  3910. * @param RTCx RTC Instance
  3911. * @retval State of bit (1 or 0).
  3912. */
  3913. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SHP(RTC_TypeDef *RTCx)
  3914. {
  3915. return ((READ_BIT(RTCx->ISR, RTC_ISR_SHPF) == (RTC_ISR_SHPF)) ? 1UL : 0UL);
  3916. }
  3917. /**
  3918. * @brief Get Wakeup timer write flag
  3919. * @rmtoll ISR WUTWF LL_RTC_IsActiveFlag_WUTW
  3920. * @param RTCx RTC Instance
  3921. * @retval State of bit (1 or 0).
  3922. */
  3923. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUTW(RTC_TypeDef *RTCx)
  3924. {
  3925. return ((READ_BIT(RTCx->ISR, RTC_ISR_WUTWF) == (RTC_ISR_WUTWF)) ? 1UL : 0UL);
  3926. }
  3927. /**
  3928. * @brief Get Alarm B write flag
  3929. * @rmtoll ISR ALRBWF LL_RTC_IsActiveFlag_ALRBW
  3930. * @param RTCx RTC Instance
  3931. * @retval State of bit (1 or 0).
  3932. */
  3933. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRBW(RTC_TypeDef *RTCx)
  3934. {
  3935. return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRBWF) == (RTC_ISR_ALRBWF)) ? 1UL : 0UL);
  3936. }
  3937. /**
  3938. * @brief Get Alarm A write flag
  3939. * @rmtoll ISR ALRAWF LL_RTC_IsActiveFlag_ALRAW
  3940. * @param RTCx RTC Instance
  3941. * @retval State of bit (1 or 0).
  3942. */
  3943. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRAW(RTC_TypeDef *RTCx)
  3944. {
  3945. return ((READ_BIT(RTCx->ISR, RTC_ISR_ALRAWF) == (RTC_ISR_ALRAWF)) ? 1UL : 0UL);
  3946. }
  3947. #endif /* RTC_ISR_ITSF */
  3948. #if defined(RTC_SR_ITSF)
  3949. /**
  3950. * @brief Get Internal Time-stamp flag
  3951. * @rmtoll RTC_SR ITSF LL_RTC_IsActiveFlag_ITS
  3952. * @param RTCx RTC Instance
  3953. * @retval State of bit (1 or 0).
  3954. */
  3955. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITS(RTC_TypeDef *RTCx)
  3956. {
  3957. return ((READ_BIT(RTCx->SR, RTC_SR_ITSF) == (RTC_SR_ITSF)) ? 1UL : 0UL);
  3958. }
  3959. /**
  3960. * @brief Get Time-stamp overflow flag
  3961. * @rmtoll RTC_SR TSOVF LL_RTC_IsActiveFlag_TSOV
  3962. * @param RTCx RTC Instance
  3963. * @retval State of bit (1 or 0).
  3964. */
  3965. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TSOV(RTC_TypeDef *RTCx)
  3966. {
  3967. return ((READ_BIT(RTCx->SR, RTC_SR_TSOVF) == (RTC_SR_TSOVF)) ? 1UL : 0UL);
  3968. }
  3969. /**
  3970. * @brief Get Time-stamp flag
  3971. * @rmtoll RTC_SR TSF LL_RTC_IsActiveFlag_TS
  3972. * @param RTCx RTC Instance
  3973. * @retval State of bit (1 or 0).
  3974. */
  3975. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TS(RTC_TypeDef *RTCx)
  3976. {
  3977. return ((READ_BIT(RTCx->SR, RTC_SR_TSF) == (RTC_SR_TSF)) ? 1UL : 0UL);
  3978. }
  3979. /**
  3980. * @brief Get Wakeup timer flag
  3981. * @rmtoll RTC_SR WUTF LL_RTC_IsActiveFlag_WUT
  3982. * @param RTCx RTC Instance
  3983. * @retval State of bit (1 or 0).
  3984. */
  3985. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUT(RTC_TypeDef *RTCx)
  3986. {
  3987. return ((READ_BIT(RTCx->SR, RTC_SR_WUTF) == (RTC_SR_WUTF)) ? 1UL : 0UL);
  3988. }
  3989. /**
  3990. * @brief Get Alarm B flag
  3991. * @rmtoll RTC_SR ALRBF LL_RTC_IsActiveFlag_ALRB
  3992. * @param RTCx RTC Instance
  3993. * @retval State of bit (1 or 0).
  3994. */
  3995. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRB(RTC_TypeDef *RTCx)
  3996. {
  3997. return ((READ_BIT(RTCx->SR, RTC_SR_ALRBF) == (RTC_SR_ALRBF)) ? 1UL : 0UL);
  3998. }
  3999. /**
  4000. * @brief Get Alarm A flag
  4001. * @rmtoll RTC_SR ALRAF LL_RTC_IsActiveFlag_ALRA
  4002. * @param RTCx RTC Instance
  4003. * @retval State of bit (1 or 0).
  4004. */
  4005. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRA(RTC_TypeDef *RTCx)
  4006. {
  4007. return ((READ_BIT(RTCx->SR, RTC_SR_ALRAF) == (RTC_SR_ALRAF)) ? 1UL : 0UL);
  4008. }
  4009. #endif /* RTC_SR_ITSF */
  4010. #if defined(RTC_SCR_CITSF)
  4011. /**
  4012. * @brief Clear Internal Time-stamp flag
  4013. * @rmtoll RTC_SCR CITSF LL_RTC_ClearFlag_ITS
  4014. * @param RTCx RTC Instance
  4015. * @retval None
  4016. */
  4017. __STATIC_INLINE void LL_RTC_ClearFlag_ITS(RTC_TypeDef *RTCx)
  4018. {
  4019. SET_BIT(RTCx->SCR, RTC_SCR_CITSF);
  4020. }
  4021. /**
  4022. * @brief Clear Time-stamp overflow flag
  4023. * @rmtoll RTC_SCR CTSOVF LL_RTC_ClearFlag_TSOV
  4024. * @param RTCx RTC Instance
  4025. * @retval None
  4026. */
  4027. __STATIC_INLINE void LL_RTC_ClearFlag_TSOV(RTC_TypeDef *RTCx)
  4028. {
  4029. SET_BIT(RTCx->SCR, RTC_SCR_CTSOVF);
  4030. }
  4031. /**
  4032. * @brief Clear Time-stamp flag
  4033. * @rmtoll RTC_SCR CTSF LL_RTC_ClearFlag_TS
  4034. * @param RTCx RTC Instance
  4035. * @retval None
  4036. */
  4037. __STATIC_INLINE void LL_RTC_ClearFlag_TS(RTC_TypeDef *RTCx)
  4038. {
  4039. SET_BIT(RTCx->SCR, RTC_SCR_CTSF);
  4040. }
  4041. /**
  4042. * @brief Clear Wakeup timer flag
  4043. * @rmtoll RTC_SCR CWUTF LL_RTC_ClearFlag_WUT
  4044. * @param RTCx RTC Instance
  4045. * @retval None
  4046. */
  4047. __STATIC_INLINE void LL_RTC_ClearFlag_WUT(RTC_TypeDef *RTCx)
  4048. {
  4049. SET_BIT(RTCx->SCR, RTC_SCR_CWUTF);
  4050. }
  4051. /**
  4052. * @brief Clear Alarm B flag
  4053. * @rmtoll RTC_SCR CALRBF LL_RTC_ClearFlag_ALRB
  4054. * @param RTCx RTC Instance
  4055. * @retval None
  4056. */
  4057. __STATIC_INLINE void LL_RTC_ClearFlag_ALRB(RTC_TypeDef *RTCx)
  4058. {
  4059. SET_BIT(RTCx->SCR, RTC_SCR_CALRBF);
  4060. }
  4061. /**
  4062. * @brief Clear Alarm A flag
  4063. * @rmtoll RTC_SCR CALRAF LL_RTC_ClearFlag_ALRA
  4064. * @param RTCx RTC Instance
  4065. * @retval None
  4066. */
  4067. __STATIC_INLINE void LL_RTC_ClearFlag_ALRA(RTC_TypeDef *RTCx)
  4068. {
  4069. SET_BIT(RTCx->SCR, RTC_SCR_CALRAF);
  4070. }
  4071. #endif /* RTC_SCR_CITSF */
  4072. #if defined(RTC_ICSR_RECALPF)
  4073. /**
  4074. * @brief Get Recalibration pending Flag
  4075. * @rmtoll RTC_ICSR RECALPF LL_RTC_IsActiveFlag_RECALP
  4076. * @param RTCx RTC Instance
  4077. * @retval State of bit (1 or 0).
  4078. */
  4079. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RECALP(RTC_TypeDef *RTCx)
  4080. {
  4081. return ((READ_BIT(RTCx->ICSR, RTC_ICSR_RECALPF) == (RTC_ICSR_RECALPF)) ? 1UL : 0UL);
  4082. }
  4083. /**
  4084. * @brief Get Initialization flag
  4085. * @rmtoll RTC_ICSR INITF LL_RTC_IsActiveFlag_INIT
  4086. * @param RTCx RTC Instance
  4087. * @retval State of bit (1 or 0).
  4088. */
  4089. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INIT(RTC_TypeDef *RTCx)
  4090. {
  4091. return ((READ_BIT(RTCx->ICSR, RTC_ICSR_INITF) == (RTC_ICSR_INITF)) ? 1UL : 0UL);
  4092. }
  4093. /**
  4094. * @brief Get Registers synchronization flag
  4095. * @rmtoll RTC_ICSR RSF LL_RTC_IsActiveFlag_RS
  4096. * @param RTCx RTC Instance
  4097. * @retval State of bit (1 or 0).
  4098. */
  4099. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RS(RTC_TypeDef *RTCx)
  4100. {
  4101. return ((READ_BIT(RTCx->ICSR, RTC_ICSR_RSF) == (RTC_ICSR_RSF)) ? 1UL : 0UL);
  4102. }
  4103. /**
  4104. * @brief Clear Registers synchronization flag
  4105. * @rmtoll RTC_ICSR RSF LL_RTC_ClearFlag_RS
  4106. * @param RTCx RTC Instance
  4107. * @retval None
  4108. */
  4109. __STATIC_INLINE void LL_RTC_ClearFlag_RS(RTC_TypeDef *RTCx)
  4110. {
  4111. WRITE_REG(RTCx->ICSR, (~((RTC_ICSR_RSF | RTC_ICSR_INIT) & 0x000000FFU) | (RTCx->ICSR & RTC_ICSR_INIT)));
  4112. }
  4113. /**
  4114. * @brief Get Initialization status flag
  4115. * @rmtoll RTC_ICSR INITS LL_RTC_IsActiveFlag_INITS
  4116. * @param RTCx RTC Instance
  4117. * @retval State of bit (1 or 0).
  4118. */
  4119. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_INITS(RTC_TypeDef *RTCx)
  4120. {
  4121. return ((READ_BIT(RTCx->ICSR, RTC_ICSR_INITS) == (RTC_ICSR_INITS)) ? 1UL : 0UL);
  4122. }
  4123. /**
  4124. * @brief Get Shift operation pending flag
  4125. * @rmtoll RTC_ICSR SHPF LL_RTC_IsActiveFlag_SHP
  4126. * @param RTCx RTC Instance
  4127. * @retval State of bit (1 or 0).
  4128. */
  4129. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SHP(RTC_TypeDef *RTCx)
  4130. {
  4131. return ((READ_BIT(RTCx->ICSR, RTC_ICSR_SHPF) == (RTC_ICSR_SHPF)) ? 1UL : 0UL);
  4132. }
  4133. /**
  4134. * @brief Get Wakeup timer write flag
  4135. * @rmtoll RTC_ICSR WUTWF LL_RTC_IsActiveFlag_WUTW
  4136. * @param RTCx RTC Instance
  4137. * @retval State of bit (1 or 0).
  4138. */
  4139. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUTW(RTC_TypeDef *RTCx)
  4140. {
  4141. return ((READ_BIT(RTCx->ICSR, RTC_ICSR_WUTWF) == (RTC_ICSR_WUTWF)) ? 1UL : 0UL);
  4142. }
  4143. /**
  4144. * @brief Get Alarm B write flag
  4145. * @rmtoll RTC_ICSR ALRBWF LL_RTC_IsActiveFlag_ALRBW
  4146. * @param RTCx RTC Instance
  4147. * @retval State of bit (1 or 0).
  4148. */
  4149. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRBW(RTC_TypeDef *RTCx)
  4150. {
  4151. return ((READ_BIT(RTCx->ICSR, RTC_ICSR_ALRBWF) == (RTC_ICSR_ALRBWF)) ? 1UL : 0UL);
  4152. }
  4153. /**
  4154. * @brief Get Alarm A write flag
  4155. * @rmtoll RTC_ICSR ALRAWF LL_RTC_IsActiveFlag_ALRAW
  4156. * @param RTCx RTC Instance
  4157. * @retval State of bit (1 or 0).
  4158. */
  4159. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRAW(RTC_TypeDef *RTCx)
  4160. {
  4161. return ((READ_BIT(RTCx->ICSR, RTC_ICSR_ALRAWF) == (RTC_ICSR_ALRAWF)) ? 1UL : 0UL);
  4162. }
  4163. #endif /* RTC_ICSR_RECALPF */
  4164. #if defined(RTC_MISR_ALRAMF)
  4165. /**
  4166. * @brief Get Alarm A masked flag.
  4167. * @rmtoll RTC_MISR ALRAMF LL_RTC_IsActiveFlag_ALRAM
  4168. * @param RTCx RTC Instance
  4169. * @retval State of bit (1 or 0).
  4170. */
  4171. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRAM(RTC_TypeDef *RTCx)
  4172. {
  4173. return ((READ_BIT(RTCx->MISR, RTC_MISR_ALRAMF) == (RTC_MISR_ALRAMF)) ? 1UL : 0UL);
  4174. }
  4175. /**
  4176. * @brief Get Alarm B masked flag.
  4177. * @rmtoll RTC_MISR ALRBMF LL_RTC_IsActiveFlag_ALRBM
  4178. * @param RTCx RTC Instance
  4179. * @retval State of bit (1 or 0).
  4180. */
  4181. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALRBM(RTC_TypeDef *RTCx)
  4182. {
  4183. return ((READ_BIT(RTCx->MISR, RTC_MISR_ALRBMF) == (RTC_MISR_ALRBMF)) ? 1UL : 0UL);
  4184. }
  4185. /**
  4186. * @brief Get Wakeup timer masked flag.
  4187. * @rmtoll RTC_MISR WUTMF LL_RTC_IsActiveFlag_WUTM
  4188. * @param RTCx RTC Instance
  4189. * @retval State of bit (1 or 0).
  4190. */
  4191. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_WUTM(RTC_TypeDef *RTCx)
  4192. {
  4193. return ((READ_BIT(RTCx->MISR, RTC_MISR_WUTMF) == (RTC_MISR_WUTMF)) ? 1UL : 0UL);
  4194. }
  4195. /**
  4196. * @brief Get Time-stamp masked flag.
  4197. * @rmtoll RTC_MISR TSMF LL_RTC_IsActiveFlag_TSM
  4198. * @param RTCx RTC Instance
  4199. * @retval State of bit (1 or 0).
  4200. */
  4201. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TSM(RTC_TypeDef *RTCx)
  4202. {
  4203. return ((READ_BIT(RTCx->MISR, RTC_MISR_TSMF) == (RTC_MISR_TSMF)) ? 1UL : 0UL);
  4204. }
  4205. /**
  4206. * @brief Get Time-stamp overflow masked flag.
  4207. * @rmtoll RTC_MISR TSOVMF LL_RTC_IsActiveFlag_TSOVM
  4208. * @param RTCx RTC Instance
  4209. * @retval State of bit (1 or 0).
  4210. */
  4211. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TSOVM(RTC_TypeDef *RTCx)
  4212. {
  4213. return ((READ_BIT(RTCx->MISR, RTC_MISR_TSOVMF) == (RTC_MISR_TSOVMF)) ? 1UL : 0UL);
  4214. }
  4215. /**
  4216. * @brief Get Internal Time-stamp masked flag.
  4217. * @rmtoll RTC_MISR ITSMF LL_RTC_IsActiveFlag_ITSM
  4218. * @param RTCx RTC Instance
  4219. * @retval State of bit (1 or 0).
  4220. */
  4221. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ITSM(RTC_TypeDef *RTCx)
  4222. {
  4223. return ((READ_BIT(RTCx->MISR, RTC_MISR_ITSMF) == (RTC_MISR_ITSMF)) ? 1UL : 0UL);
  4224. }
  4225. #endif /* RTC_MISR_ALRAMF */
  4226. #if defined(TAMP_CR1_TAMP1E)
  4227. /**
  4228. * @brief Get tamper 1 detection flag.
  4229. * @rmtoll TAMP_SR TAMP1F LL_RTC_IsActiveFlag_TAMP1
  4230. * @param TAMPx TAMP Instance
  4231. * @retval State of bit (1 or 0).
  4232. */
  4233. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP1(TAMP_TypeDef *TAMPx)
  4234. {
  4235. return ((READ_BIT(TAMPx->SR, TAMP_SR_TAMP1F) == (TAMP_SR_TAMP1F)) ? 1UL : 0UL);
  4236. }
  4237. #endif /* TAMP_CR1_TAMP1E */
  4238. #if defined(TAMP_CR1_TAMP2E)
  4239. /**
  4240. * @brief Get tamper 2 detection flag.
  4241. * @rmtoll TAMP_SR TAMP2F LL_RTC_IsActiveFlag_TAMP2
  4242. * @param TAMPx TAMP Instance
  4243. * @retval State of bit (1 or 0).
  4244. */
  4245. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP2(TAMP_TypeDef *TAMPx)
  4246. {
  4247. return ((READ_BIT(TAMPx->SR, TAMP_SR_TAMP2F) == (TAMP_SR_TAMP2F)) ? 1UL : 0UL);
  4248. }
  4249. #endif /* TAMP_CR1_TAMP2E */
  4250. #if defined(TAMP_CR1_TAMP3E)
  4251. /**
  4252. * @brief Get tamper 3 detection flag.
  4253. * @rmtoll TAMP_SR TAMP3F LL_RTC_IsActiveFlag_TAMP3
  4254. * @param TAMPx TAMP Instance
  4255. * @retval State of bit (1 or 0).
  4256. */
  4257. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP3(TAMP_TypeDef *TAMPx)
  4258. {
  4259. return ((READ_BIT(TAMPx->SR, TAMP_SR_TAMP3F) == (TAMP_SR_TAMP3F)) ? 1UL : 0UL);
  4260. }
  4261. #endif /* TAMP_CR1_TAMP3E */
  4262. #if defined(TAMP_CR1_TAMP1E)
  4263. /**
  4264. * @brief Get tamper 1 interrupt masked flag.
  4265. * @rmtoll TAMP_MISR TAMP1MF LL_RTC_IsActiveFlag_TAMP1M
  4266. * @param TAMPx TAMP Instance
  4267. * @retval State of bit (1 or 0).
  4268. */
  4269. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP1M(TAMP_TypeDef *TAMPx)
  4270. {
  4271. return ((READ_BIT(TAMPx->MISR, TAMP_MISR_TAMP1MF) == (TAMP_MISR_TAMP1MF)) ? 1UL : 0UL);
  4272. }
  4273. #endif /* TAMP_CR1_TAMP1E */
  4274. #if defined(TAMP_CR1_TAMP2E)
  4275. /**
  4276. * @brief Get tamper 2 interrupt masked flag.
  4277. * @rmtoll TAMP_MISR TAMP2MF LL_RTC_IsActiveFlag_TAMP2M
  4278. * @param TAMPx TAMP Instance
  4279. * @retval State of bit (1 or 0).
  4280. */
  4281. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP2M(TAMP_TypeDef *TAMPx)
  4282. {
  4283. return ((READ_BIT(TAMPx->MISR, TAMP_MISR_TAMP2MF) == (TAMP_MISR_TAMP2MF)) ? 1UL : 0UL);
  4284. }
  4285. #endif /* TAMP_CR1_TAMP2E */
  4286. #if defined(TAMP_CR1_TAMP3E)
  4287. /**
  4288. * @brief Get tamper 3 interrupt masked flag.
  4289. * @rmtoll TAMP_MISR TAMP3MF LL_RTC_IsActiveFlag_TAMP3M
  4290. * @param TAMPx TAMP Instance
  4291. * @retval State of bit (1 or 0).
  4292. */
  4293. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_TAMP3M(TAMP_TypeDef *TAMPx)
  4294. {
  4295. return ((READ_BIT(TAMPx->MISR, TAMP_MISR_TAMP3MF) == (TAMP_MISR_TAMP3MF)) ? 1UL : 0UL);
  4296. }
  4297. #endif /* TAMP_CR1_TAMP3E */
  4298. #if defined(TAMP_CR1_TAMP1E)
  4299. /**
  4300. * @brief Clear tamper 1 detection flag.
  4301. * @rmtoll TAMP_SCR CTAMP1F LL_RTC_ClearFlag_TAMP1
  4302. * @param TAMPx TAMP Instance
  4303. * @retval None
  4304. */
  4305. __STATIC_INLINE void LL_RTC_ClearFlag_TAMP1(TAMP_TypeDef *TAMPx)
  4306. {
  4307. SET_BIT(TAMPx->SCR, TAMP_SCR_CTAMP1F);
  4308. }
  4309. #endif /* TAMP_CR1_TAMP1E */
  4310. #if defined(TAMP_CR1_TAMP2E)
  4311. /**
  4312. * @brief Clear tamper 2 detection flag.
  4313. * @rmtoll TAMP_SCR CTAMP2F LL_RTC_ClearFlag_TAMP2
  4314. * @param TAMPx TAMP Instance
  4315. * @retval None
  4316. */
  4317. __STATIC_INLINE void LL_RTC_ClearFlag_TAMP2(TAMP_TypeDef *TAMPx)
  4318. {
  4319. SET_BIT(TAMPx->SCR, TAMP_SCR_CTAMP2F);
  4320. }
  4321. #endif /* TAMP_CR1_TAMP2E */
  4322. #if defined(TAMP_CR1_TAMP3E)
  4323. /**
  4324. * @brief Clear tamper 3 detection flag.
  4325. * @rmtoll TAMP_SCR CTAMP3F LL_RTC_ClearFlag_TAMP3
  4326. * @param TAMPx TAMP Instance
  4327. * @retval None
  4328. */
  4329. __STATIC_INLINE void LL_RTC_ClearFlag_TAMP3(TAMP_TypeDef *TAMPx)
  4330. {
  4331. SET_BIT(TAMPx->SCR, TAMP_SCR_CTAMP3F);
  4332. }
  4333. #endif /* TAMP_CR1_TAMP3E */
  4334. /**
  4335. * @}
  4336. */
  4337. /** @defgroup RTC_LL_EF_IT_Management IT_Management
  4338. * @{
  4339. */
  4340. /**
  4341. * @brief Enable Time-stamp interrupt
  4342. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  4343. * @rmtoll RTC_CR TSIE LL_RTC_EnableIT_TS
  4344. * @param RTCx RTC Instance
  4345. * @retval None
  4346. */
  4347. __STATIC_INLINE void LL_RTC_EnableIT_TS(RTC_TypeDef *RTCx)
  4348. {
  4349. SET_BIT(RTCx->CR, RTC_CR_TSIE);
  4350. }
  4351. /**
  4352. * @brief Disable Time-stamp interrupt
  4353. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  4354. * @rmtoll RTC_CR TSIE LL_RTC_DisableIT_TS
  4355. * @param RTCx RTC Instance
  4356. * @retval None
  4357. */
  4358. __STATIC_INLINE void LL_RTC_DisableIT_TS(RTC_TypeDef *RTCx)
  4359. {
  4360. CLEAR_BIT(RTCx->CR, RTC_CR_TSIE);
  4361. }
  4362. /**
  4363. * @brief Enable Wakeup timer interrupt
  4364. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  4365. * @rmtoll RTC_CR WUTIE LL_RTC_EnableIT_WUT
  4366. * @param RTCx RTC Instance
  4367. * @retval None
  4368. */
  4369. __STATIC_INLINE void LL_RTC_EnableIT_WUT(RTC_TypeDef *RTCx)
  4370. {
  4371. SET_BIT(RTCx->CR, RTC_CR_WUTIE);
  4372. }
  4373. /**
  4374. * @brief Disable Wakeup timer interrupt
  4375. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  4376. * @rmtoll RTC_CR WUTIE LL_RTC_DisableIT_WUT
  4377. * @param RTCx RTC Instance
  4378. * @retval None
  4379. */
  4380. __STATIC_INLINE void LL_RTC_DisableIT_WUT(RTC_TypeDef *RTCx)
  4381. {
  4382. CLEAR_BIT(RTCx->CR, RTC_CR_WUTIE);
  4383. }
  4384. /**
  4385. * @brief Enable Alarm B interrupt
  4386. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  4387. * @rmtoll RTC_CR ALRBIE LL_RTC_EnableIT_ALRB
  4388. * @param RTCx RTC Instance
  4389. * @retval None
  4390. */
  4391. __STATIC_INLINE void LL_RTC_EnableIT_ALRB(RTC_TypeDef *RTCx)
  4392. {
  4393. SET_BIT(RTCx->CR, RTC_CR_ALRBIE);
  4394. }
  4395. /**
  4396. * @brief Disable Alarm B interrupt
  4397. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  4398. * @rmtoll RTC_CR ALRBIE LL_RTC_DisableIT_ALRB
  4399. * @param RTCx RTC Instance
  4400. * @retval None
  4401. */
  4402. __STATIC_INLINE void LL_RTC_DisableIT_ALRB(RTC_TypeDef *RTCx)
  4403. {
  4404. CLEAR_BIT(RTCx->CR, RTC_CR_ALRBIE);
  4405. }
  4406. /**
  4407. * @brief Enable Alarm A interrupt
  4408. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  4409. * @rmtoll RTC_CR ALRAIE LL_RTC_EnableIT_ALRA
  4410. * @param RTCx RTC Instance
  4411. * @retval None
  4412. */
  4413. __STATIC_INLINE void LL_RTC_EnableIT_ALRA(RTC_TypeDef *RTCx)
  4414. {
  4415. SET_BIT(RTCx->CR, RTC_CR_ALRAIE);
  4416. }
  4417. /**
  4418. * @brief Disable Alarm A interrupt
  4419. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  4420. * @rmtoll RTC_CR ALRAIE LL_RTC_DisableIT_ALRA
  4421. * @param RTCx RTC Instance
  4422. * @retval None
  4423. */
  4424. __STATIC_INLINE void LL_RTC_DisableIT_ALRA(RTC_TypeDef *RTCx)
  4425. {
  4426. CLEAR_BIT(RTCx->CR, RTC_CR_ALRAIE);
  4427. }
  4428. #if defined(RTC_TAMPCR_TAMP3E)
  4429. /**
  4430. * @brief Enable Tamper 3 interrupt
  4431. * @rmtoll TAMPCR TAMP3IE LL_RTC_EnableIT_TAMP3
  4432. * @param RTCx RTC Instance
  4433. * @retval None
  4434. */
  4435. __STATIC_INLINE void LL_RTC_EnableIT_TAMP3(RTC_TypeDef *RTCx)
  4436. {
  4437. SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP3IE);
  4438. }
  4439. /**
  4440. * @brief Disable Tamper 3 interrupt
  4441. * @rmtoll TAMPCR TAMP3IE LL_RTC_DisableIT_TAMP3
  4442. * @param RTCx RTC Instance
  4443. * @retval None
  4444. */
  4445. __STATIC_INLINE void LL_RTC_DisableIT_TAMP3(RTC_TypeDef *RTCx)
  4446. {
  4447. CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP3IE);
  4448. }
  4449. #endif /* RTC_TAMPCR_TAMP3E */
  4450. #if defined(RTC_TAMPCR_TAMP2E)
  4451. /**
  4452. * @brief Enable Tamper 2 interrupt
  4453. * @rmtoll TAMPCR TAMP2IE LL_RTC_EnableIT_TAMP2
  4454. * @param RTCx RTC Instance
  4455. * @retval None
  4456. */
  4457. __STATIC_INLINE void LL_RTC_EnableIT_TAMP2(RTC_TypeDef *RTCx)
  4458. {
  4459. SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP2IE);
  4460. }
  4461. /**
  4462. * @brief Disable Tamper 2 interrupt
  4463. * @rmtoll TAMPCR TAMP2IE LL_RTC_DisableIT_TAMP2
  4464. * @param RTCx RTC Instance
  4465. * @retval None
  4466. */
  4467. __STATIC_INLINE void LL_RTC_DisableIT_TAMP2(RTC_TypeDef *RTCx)
  4468. {
  4469. CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP2IE);
  4470. }
  4471. #endif /* RTC_TAMPCR_TAMP2E */
  4472. #if defined(RTC_TAMPCR_TAMP1E)
  4473. /**
  4474. * @brief Enable Tamper 1 interrupt
  4475. * @rmtoll TAMPCR TAMP1IE LL_RTC_EnableIT_TAMP1
  4476. * @param RTCx RTC Instance
  4477. * @retval None
  4478. */
  4479. __STATIC_INLINE void LL_RTC_EnableIT_TAMP1(RTC_TypeDef *RTCx)
  4480. {
  4481. SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP1IE);
  4482. }
  4483. /**
  4484. * @brief Disable Tamper 1 interrupt
  4485. * @rmtoll TAMPCR TAMP1IE LL_RTC_DisableIT_TAMP1
  4486. * @param RTCx RTC Instance
  4487. * @retval None
  4488. */
  4489. __STATIC_INLINE void LL_RTC_DisableIT_TAMP1(RTC_TypeDef *RTCx)
  4490. {
  4491. CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP1IE);
  4492. }
  4493. #endif /* RTC_TAMPCR_TAMP1E */
  4494. #if defined(RTC_TAMPCR_TAMPIE)
  4495. /**
  4496. * @brief Enable all Tamper Interrupt
  4497. * @rmtoll TAMPCR TAMPIE LL_RTC_EnableIT_TAMP
  4498. * @param RTCx RTC Instance
  4499. * @retval None
  4500. */
  4501. __STATIC_INLINE void LL_RTC_EnableIT_TAMP(RTC_TypeDef *RTCx)
  4502. {
  4503. SET_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPIE);
  4504. }
  4505. /**
  4506. * @brief Disable all Tamper Interrupt
  4507. * @rmtoll TAMPCR TAMPIE LL_RTC_DisableIT_TAMP
  4508. * @param RTCx RTC Instance
  4509. * @retval None
  4510. */
  4511. __STATIC_INLINE void LL_RTC_DisableIT_TAMP(RTC_TypeDef *RTCx)
  4512. {
  4513. CLEAR_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPIE);
  4514. }
  4515. #endif /* RTC_TAMPCR_TAMPIE */
  4516. /**
  4517. * @brief Check if Time-stamp interrupt is enabled or not
  4518. * @rmtoll CR TSIE LL_RTC_IsEnabledIT_TS
  4519. * @param RTCx RTC Instance
  4520. * @retval State of bit (1 or 0).
  4521. */
  4522. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TS(RTC_TypeDef *RTCx)
  4523. {
  4524. return ((READ_BIT(RTCx->CR, RTC_CR_TSIE) == (RTC_CR_TSIE)) ? 1UL : 0UL);
  4525. }
  4526. /**
  4527. * @brief Check if Wakeup timer interrupt is enabled or not
  4528. * @rmtoll CR WUTIE LL_RTC_IsEnabledIT_WUT
  4529. * @param RTCx RTC Instance
  4530. * @retval State of bit (1 or 0).
  4531. */
  4532. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_WUT(RTC_TypeDef *RTCx)
  4533. {
  4534. return ((READ_BIT(RTCx->CR, RTC_CR_WUTIE) == (RTC_CR_WUTIE)) ? 1UL : 0UL);
  4535. }
  4536. /**
  4537. * @brief Check if Alarm B interrupt is enabled or not
  4538. * @rmtoll CR ALRBIE LL_RTC_IsEnabledIT_ALRB
  4539. * @param RTCx RTC Instance
  4540. * @retval State of bit (1 or 0).
  4541. */
  4542. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALRB(RTC_TypeDef *RTCx)
  4543. {
  4544. return ((READ_BIT(RTCx->CR, RTC_CR_ALRBIE) == (RTC_CR_ALRBIE)) ? 1UL : 0UL);
  4545. }
  4546. /**
  4547. * @brief Check if Alarm A interrupt is enabled or not
  4548. * @rmtoll CR ALRAIE LL_RTC_IsEnabledIT_ALRA
  4549. * @param RTCx RTC Instance
  4550. * @retval State of bit (1 or 0).
  4551. */
  4552. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALRA(RTC_TypeDef *RTCx)
  4553. {
  4554. return ((READ_BIT(RTCx->CR, RTC_CR_ALRAIE) == (RTC_CR_ALRAIE)) ? 1UL : 0UL);
  4555. }
  4556. #if defined(RTC_TAMPCR_TAMP3E)
  4557. /**
  4558. * @brief Check if Tamper 3 interrupt is enabled or not
  4559. * @rmtoll TAMPCR TAMP3IE LL_RTC_IsEnabledIT_TAMP3
  4560. * @param RTCx RTC Instance
  4561. * @retval State of bit (1 or 0).
  4562. */
  4563. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP3(RTC_TypeDef *RTCx)
  4564. {
  4565. return ((READ_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP3IE) == (RTC_TAMPCR_TAMP3IE)) ? 1UL : 0UL);
  4566. }
  4567. #endif /* RTC_TAMPCR_TAMP3E */
  4568. #if defined(RTC_TAMPCR_TAMP2E)
  4569. /**
  4570. * @brief Check if Tamper 2 interrupt is enabled or not
  4571. * @rmtoll TAMPCR TAMP2IE LL_RTC_IsEnabledIT_TAMP2
  4572. * @param RTCx RTC Instance
  4573. * @retval State of bit (1 or 0).
  4574. */
  4575. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP2(RTC_TypeDef *RTCx)
  4576. {
  4577. return ((READ_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP2IE) == (RTC_TAMPCR_TAMP2IE)) ? 1UL : 0UL);
  4578. }
  4579. #endif /* RTC_TAMPCR_TAMP2E */
  4580. #if defined(RTC_TAMPCR_TAMP1E)
  4581. /**
  4582. * @brief Check if Tamper 1 interrupt is enabled or not
  4583. * @rmtoll TAMPCR TAMP1IE LL_RTC_IsEnabledIT_TAMP1
  4584. * @param RTCx RTC Instance
  4585. * @retval State of bit (1 or 0).
  4586. */
  4587. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP1(RTC_TypeDef *RTCx)
  4588. {
  4589. return ((READ_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMP1IE) == (RTC_TAMPCR_TAMP1IE)) ? 1UL : 0UL);
  4590. }
  4591. #endif /* RTC_TAMPCR_TAMP1E */
  4592. #if defined(RTC_TAMPCR_TAMPIE)
  4593. /**
  4594. * @brief Check if all the TAMPER interrupts are enabled or not
  4595. * @rmtoll TAMPCR TAMPIE LL_RTC_IsEnabledIT_TAMP
  4596. * @param RTCx RTC Instance
  4597. * @retval State of bit (1 or 0).
  4598. */
  4599. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP(RTC_TypeDef *RTCx)
  4600. {
  4601. return ((READ_BIT(RTCx->TAMPCR, RTC_TAMPCR_TAMPIE) == (RTC_TAMPCR_TAMPIE)) ? 1UL : 0UL);
  4602. }
  4603. #endif /* RTC_TAMPCR_TAMPIE */
  4604. #if defined(TAMP_CR1_TAMP1E)
  4605. /**
  4606. * @brief Enable tamper 1 interrupt.
  4607. * @rmtoll TAMP_IER TAMP1IE LL_RTC_EnableIT_TAMP1
  4608. * @param TAMPx TAMP Instance
  4609. * @retval None
  4610. */
  4611. __STATIC_INLINE void LL_RTC_EnableIT_TAMP1(TAMP_TypeDef *TAMPx)
  4612. {
  4613. SET_BIT(TAMPx->IER, TAMP_IER_TAMP1IE);
  4614. }
  4615. /**
  4616. * @brief Disable tamper 1 interrupt.
  4617. * @rmtoll TAMP_IER TAMP1IE LL_RTC_DisableIT_TAMP1
  4618. * @param TAMPx TAMP Instance
  4619. * @retval None
  4620. */
  4621. __STATIC_INLINE void LL_RTC_DisableIT_TAMP1(TAMP_TypeDef *TAMPx)
  4622. {
  4623. CLEAR_BIT(TAMPx->IER, TAMP_IER_TAMP1IE);
  4624. }
  4625. #endif /* TAMP_CR1_TAMP1E */
  4626. #if defined(TAMP_CR1_TAMP2E)
  4627. /**
  4628. * @brief Enable tamper 2 interrupt.
  4629. * @rmtoll TAMP_IER TAMP2IE LL_RTC_EnableIT_TAMP2
  4630. * @param TAMPx TAMP Instance
  4631. * @retval None
  4632. */
  4633. __STATIC_INLINE void LL_RTC_EnableIT_TAMP2(TAMP_TypeDef *TAMPx)
  4634. {
  4635. SET_BIT(TAMPx->IER, TAMP_IER_TAMP2IE);
  4636. }
  4637. /**
  4638. * @brief Disable tamper 2 interrupt.
  4639. * @rmtoll TAMP_IER TAMP2IE LL_RTC_DisableIT_TAMP2
  4640. * @param TAMPx TAMP Instance
  4641. * @retval None
  4642. */
  4643. __STATIC_INLINE void LL_RTC_DisableIT_TAMP2(TAMP_TypeDef *TAMPx)
  4644. {
  4645. CLEAR_BIT(TAMPx->IER, TAMP_IER_TAMP2IE);
  4646. }
  4647. #endif /* TAMP_CR1_TAMP2E */
  4648. #if defined(TAMP_CR1_TAMP3E)
  4649. /**
  4650. * @brief Enable tamper 3 interrupt.
  4651. * @rmtoll TAMP_IER TAMP3IE LL_RTC_EnableIT_TAMP3
  4652. * @param TAMPx TAMP Instance
  4653. * @retval None
  4654. */
  4655. __STATIC_INLINE void LL_RTC_EnableIT_TAMP3(TAMP_TypeDef *TAMPx)
  4656. {
  4657. SET_BIT(TAMPx->IER, TAMP_IER_TAMP3IE);
  4658. }
  4659. /**
  4660. * @brief Disable tamper 3 interrupt.
  4661. * @rmtoll TAMP_IER TAMP3IE LL_RTC_DisableIT_TAMP3
  4662. * @param TAMPx TAMP Instance
  4663. * @retval None
  4664. */
  4665. __STATIC_INLINE void LL_RTC_DisableIT_TAMP3(TAMP_TypeDef *TAMPx)
  4666. {
  4667. CLEAR_BIT(TAMPx->IER, TAMP_IER_TAMP3IE);
  4668. }
  4669. #endif /* TAMP_CR1_TAMP3E */
  4670. #if defined(TAMP_CR1_TAMP1E)
  4671. /**
  4672. * @brief Check if tamper 1 interrupt is enabled or not.
  4673. * @rmtoll TAMP_IER TAMP1IE LL_RTC_IsEnabledIT_TAMP1
  4674. * @param TAMPx TAMP Instance
  4675. * @retval State of bit (1 or 0).
  4676. */
  4677. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP1(TAMP_TypeDef *TAMPx)
  4678. {
  4679. return ((READ_BIT(TAMPx->IER, TAMP_IER_TAMP1IE) == (TAMP_IER_TAMP1IE)) ? 1UL : 0UL);
  4680. }
  4681. #endif /* TAMP_CR1_TAMP1E */
  4682. #if defined(TAMP_CR1_TAMP2E)
  4683. /**
  4684. * @brief Check if tamper 2 interrupt is enabled or not.
  4685. * @rmtoll TAMP_IER TAMP2IE LL_RTC_IsEnabledIT_TAMP2
  4686. * @param TAMPx TAMP Instance
  4687. * @retval State of bit (1 or 0).
  4688. */
  4689. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP2(TAMP_TypeDef *TAMPx)
  4690. {
  4691. return ((READ_BIT(TAMPx->IER, TAMP_IER_TAMP2IE) == (TAMP_IER_TAMP2IE)) ? 1UL : 0UL);
  4692. }
  4693. #endif /* TAMP_CR1_TAMP2E */
  4694. #if defined(TAMP_CR1_TAMP3E)
  4695. /**
  4696. * @brief Check if tamper 3 interrupt is enabled or not.
  4697. * @rmtoll TAMP_IER TAMP3IE LL_RTC_IsEnabledIT_TAMP3
  4698. * @param TAMPx TAMP Instance
  4699. * @retval State of bit (1 or 0).
  4700. */
  4701. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_TAMP3(TAMP_TypeDef *TAMPx)
  4702. {
  4703. return ((READ_BIT(TAMPx->IER, TAMP_IER_TAMP3IE) == (TAMP_IER_TAMP3IE)) ? 1UL : 0UL);
  4704. }
  4705. #endif /* TAMP_CR1_TAMP3E */
  4706. /**
  4707. * @}
  4708. */
  4709. #if defined (TAMP_ATCR1_TAMP1AM)
  4710. /** @defgroup RTC_LL_EF_Active_Tamper Active Tamper
  4711. * @{
  4712. */
  4713. /**
  4714. * @brief Enable tamper active mode.
  4715. * @rmtoll TAMP_ATCR1 TAMP1AM LL_RTC_TAMPER_ATAMP_EnableActiveMode
  4716. * @rmtoll TAMP_ATCR1 TAMP2AM LL_RTC_TAMPER_ATAMP_EnableActiveMode
  4717. * @rmtoll TAMP_ATCR1 TAMPxAM LL_RTC_TAMPER_ATAMP_EnableActiveMode
  4718. * @param Tamper to configure as active. This parameter can be a combination of the following values:
  4719. * @arg @ref RTC_LL_EC_ACTIVE_MODE
  4720. *
  4721. * @retval None
  4722. */
  4723. __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_EnableActiveMode(uint32_t Tamper)
  4724. {
  4725. SET_BIT(TAMP->ATCR1, Tamper);
  4726. }
  4727. /**
  4728. * @brief Disable tamper active mode.
  4729. * @rmtoll TAMP_ATCR1 TAMP1AM LL_RTC_TAMPER_ATAMP_DisableActiveMode
  4730. * @rmtoll TAMP_ATCR1 TAMP2AM LL_RTC_TAMPER_ATAMP_DisableActiveMode
  4731. * @rmtoll TAMP_ATCR1 TAMPxAM LL_RTC_TAMPER_ATAMP_DisableActiveMode
  4732. * @param Tamper to configure as active. This parameter can be a combination of the following values:
  4733. * @arg @ref RTC_LL_EC_ACTIVE_MODE
  4734. *
  4735. * @retval None
  4736. */
  4737. __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_DisableActiveMode(uint32_t Tamper)
  4738. {
  4739. CLEAR_BIT(TAMP->ATCR1, Tamper);
  4740. }
  4741. /**
  4742. * @brief Enable active tamper filter.
  4743. * @rmtoll TAMP_ATCR1 FLTEN LL_RTC_TAMPER_ATAMP_EnableFilter
  4744. * @retval None
  4745. */
  4746. __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_EnableFilter(void)
  4747. {
  4748. SET_BIT(TAMP->ATCR1, TAMP_ATCR1_FLTEN);
  4749. }
  4750. /**
  4751. * @brief Disable active tamper filter.
  4752. * @rmtoll TAMP_ATCR1 FLTEN LL_RTC_TAMPER_ATAMP_DisableFilter
  4753. * @retval None
  4754. */
  4755. __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_DisableFilter(void)
  4756. {
  4757. CLEAR_BIT(TAMP->ATCR1, TAMP_ATCR1_FLTEN);
  4758. }
  4759. /**
  4760. * @brief Set Active tamper output change period.
  4761. * @rmtoll TAMP_ATCR1 ATPER LL_RTC_TAMPER_ATAMP_SetOutputChangePeriod
  4762. * @param ActiveOutputChangePeriod This parameter can be a value from 0 to 7
  4763. * @retval None
  4764. */
  4765. __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_SetOutputChangePeriod(uint32_t ActiveOutputChangePeriod)
  4766. {
  4767. MODIFY_REG(TAMP->ATCR1, TAMP_ATCR1_ATPER, (ActiveOutputChangePeriod << TAMP_ATCR1_ATPER_Pos));
  4768. }
  4769. /**
  4770. * @brief Get Active tamper output change period.
  4771. * @rmtoll TAMP_ATCR1 ATPER LL_RTC_TAMPER_ATAMP_GetOutputChangePeriod
  4772. * @retval Output change period. This parameter can be a value from 0 to 7.
  4773. */
  4774. __STATIC_INLINE uint32_t LL_RTC_TAMPER_ATAMP_GetOutputChangePeriod(void)
  4775. {
  4776. return (READ_BIT(TAMP->ATCR1, TAMP_ATCR1_ATPER) >> TAMP_ATCR1_ATPER_Pos);
  4777. }
  4778. /**
  4779. * @brief Set Active tamper asynchronous prescaler clock selection.
  4780. * @rmtoll TAMP_ATCR1 ATCKSEL LL_RTC_TAMPER_ATAMP_SetAsyncPrescaler
  4781. * @param ActiveAsynvPrescaler Specifies the Active Tamper asynchronous Prescaler clock.
  4782. This parameter can be a value of the following values:
  4783. * @arg @ref RTC_LL_EC_ACTIVE_ASYNC_PRESCALER
  4784. * @retval None
  4785. */
  4786. __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_SetAsyncPrescaler(uint32_t ActiveAsynvPrescaler)
  4787. {
  4788. MODIFY_REG(TAMP->ATCR1, TAMP_ATCR1_ATCKSEL, ActiveAsynvPrescaler);
  4789. }
  4790. /**
  4791. * @brief Get Active tamper asynchronous prescaler clock selection.
  4792. * @rmtoll TAMP_ATCR1 ATCKSEL LL_RTC_TAMPER_ATAMP_GetAsyncPrescaler
  4793. * @retval One of @arg @ref RTC_LL_EC_ACTIVE_ASYNC_PRESCALER
  4794. */
  4795. __STATIC_INLINE uint32_t LL_RTC_TAMPER_ATAMP_GetAsyncPrescaler(void)
  4796. {
  4797. return (READ_BIT(TAMP->ATCR1, TAMP_ATCR1_ATCKSEL));
  4798. }
  4799. /**
  4800. * @brief Enable active tamper output sharing.
  4801. * @rmtoll TAMP_ATCR1 ATOSHARE LL_RTC_TAMPER_ATAMP_EnableOutputSharing
  4802. * @retval None
  4803. */
  4804. __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_EnableOutputSharing(void)
  4805. {
  4806. SET_BIT(TAMP->ATCR1, TAMP_ATCR1_ATOSHARE);
  4807. }
  4808. /**
  4809. * @brief Disable active tamper output sharing.
  4810. * @rmtoll TAMP_ATCR1 ATOSHARE LL_RTC_TAMPER_ATAMP_DisableOutputSharing
  4811. * @retval None
  4812. */
  4813. __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_DisableOutputSharing(void)
  4814. {
  4815. CLEAR_BIT(TAMP->ATCR1, TAMP_ATCR1_ATOSHARE);
  4816. }
  4817. /**
  4818. * @brief Set Active tamper output selection.
  4819. * @rmtoll TAMP_ATCR1 ATCKSEL LL_RTC_TAMPER_ATAMP_SetSharedOuputSelection
  4820. * @param OutputSelection Specifies all the output selection of the Active Tamper.
  4821. This parameter is a combinasation of the following values:
  4822. * One of @arg @ref RTC_LL_EC_ACTIVE_OUTPUT_SELECTION
  4823. * @retval None
  4824. */
  4825. __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_SetSharedOuputSelection(uint32_t OutputSelection)
  4826. {
  4827. MODIFY_REG(TAMP->ATCR1, (TAMP_ATCR1_ATOSEL1 | TAMP_ATCR1_ATOSEL2 | TAMP_ATCR1_ATOSEL3), \
  4828. OutputSelection);
  4829. }
  4830. /**
  4831. * @brief Get Active tamper asynchronous prescaler clock selection.
  4832. * @rmtoll TAMP_ATCR2 ATCKSEL LL_RTC_TAMPER_ATAMP_GetAsyncPrescaler
  4833. * @retval A combination of @arg @ref RTC_LL_EC_ACTIVE_OUTPUT_SELECTION
  4834. */
  4835. __STATIC_INLINE uint32_t LL_RTC_TAMPER_ATAMP_GetSharedOuputSelection(void)
  4836. {
  4837. return (READ_BIT(TAMP->ATCR1, (TAMP_ATCR1_ATOSEL1 | TAMP_ATCR1_ATOSEL2 | TAMP_ATCR1_ATOSEL3)));
  4838. }
  4839. #endif /* TAMP_ATCR1_TAMP1AM */
  4840. #if defined(ATSEEDR)
  4841. /**
  4842. * @brief Write active tamper seed.
  4843. * @rmtoll TAMP_ATSEEDR SEED LL_RTC_TAMPER_ATAMP_WriteSeed
  4844. * @param Seed
  4845. * @retval None
  4846. */
  4847. __STATIC_INLINE void LL_RTC_TAMPER_ATAMP_WriteSeed(uint32_t Seed)
  4848. {
  4849. WRITE_REG(TAMP->ATSEEDR, Seed);
  4850. }
  4851. #endif /* ATSEEDR */
  4852. #if defined(TAMP_ATOR_INITS)
  4853. /**
  4854. * @brief Get active tamper initialization status flag.
  4855. * @rmtoll TAMP_ATOR INITS LL_RTC_IsActiveFlag_ATAMP_INITS
  4856. * @retval State of bit (1 or 0).
  4857. */
  4858. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ATAMP_INITS(void)
  4859. {
  4860. return ((READ_BIT(TAMP->ATOR, TAMP_ATOR_INITS) == (TAMP_ATOR_INITS)) ? 1U : 0U);
  4861. }
  4862. /**
  4863. * @brief Get active tamper seed running status flag.
  4864. * @rmtoll TAMP_ATOR INITS LL_RTC_IsActiveFlag_ATAMP_INITS
  4865. * @retval State of bit (1 or 0).
  4866. */
  4867. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ATAMP_SEEDF(void)
  4868. {
  4869. return ((READ_BIT(TAMP->ATOR, TAMP_ATOR_SEEDF) == (TAMP_ATOR_SEEDF)) ? 1U : 0U);
  4870. }
  4871. #endif /* TAMP_ATOR_INITS */
  4872. /**
  4873. * @}
  4874. */
  4875. #if defined(USE_FULL_LL_DRIVER)
  4876. /** @defgroup RTC_LL_EF_Init Initialization and de-initialization functions
  4877. * @{
  4878. */
  4879. ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx);
  4880. ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct);
  4881. void LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct);
  4882. ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct);
  4883. void LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct);
  4884. ErrorStatus LL_RTC_DATE_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_DateTypeDef *RTC_DateStruct);
  4885. void LL_RTC_DATE_StructInit(LL_RTC_DateTypeDef *RTC_DateStruct);
  4886. ErrorStatus LL_RTC_ALMA_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
  4887. ErrorStatus LL_RTC_ALMB_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
  4888. void LL_RTC_ALMA_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
  4889. void LL_RTC_ALMB_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
  4890. ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx);
  4891. ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx);
  4892. ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx);
  4893. /**
  4894. * @}
  4895. */
  4896. #endif /* USE_FULL_LL_DRIVER */
  4897. /**
  4898. * @}
  4899. */
  4900. /**
  4901. * @}
  4902. */
  4903. #endif /* defined(RTC) */
  4904. /**
  4905. * @}
  4906. */
  4907. #ifdef __cplusplus
  4908. }
  4909. #endif
  4910. #endif /* STM32H7xx_LL_RTC_H */
  4911. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/