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.
 
 
 

3810 lines
139 KiB

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