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.
 
 
 

3928 lines
143 KiB

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