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.
 
 
 

3216 lines
119 KiB

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