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.
 
 
 

3851 lines
143 KiB

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