py32f0xx_ll_rtc.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. /**
  2. ******************************************************************************
  3. * @file py32f0xx_ll_rtc.h
  4. * @author MCU Application Team
  5. * @brief Header file of RTC LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2023 Puya Semiconductor Co.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by Puya under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. * @attention
  19. *
  20. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  21. * All rights reserved.</center></h2>
  22. *
  23. * This software component is licensed by ST under BSD 3-Clause license,
  24. * the "License"; You may not use this file except in compliance with the
  25. * License. You may obtain a copy of the License at:
  26. * opensource.org/licenses/BSD-3-Clause
  27. *
  28. ******************************************************************************
  29. */
  30. /* Define to prevent recursive inclusion -------------------------------------*/
  31. #ifndef __PY32F0xx_LL_RTC_H
  32. #define __PY32F0xx_LL_RTC_H
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /* Includes ------------------------------------------------------------------*/
  37. #include "py32f0xx.h"
  38. /** @addtogroup PY32F0xx_LL_Driver
  39. * @{
  40. */
  41. #if defined(RTC)
  42. /** @defgroup RTC_LL RTC
  43. * @{
  44. */
  45. /* Private types -------------------------------------------------------------*/
  46. /* Private variables ---------------------------------------------------------*/
  47. /* Private constants ---------------------------------------------------------*/
  48. /* Private macros ------------------------------------------------------------*/
  49. #if defined(USE_FULL_LL_DRIVER)
  50. /** @defgroup RTC_LL_Private_Macros RTC Private Macros
  51. * @{
  52. */
  53. /**
  54. * @}
  55. */
  56. #endif /*USE_FULL_LL_DRIVER*/
  57. /* Exported types ------------------------------------------------------------*/
  58. #if defined(USE_FULL_LL_DRIVER)
  59. /** @defgroup RTC_LL_ES_INIT RTC Exported Init structure
  60. * @{
  61. */
  62. /**
  63. * @brief RTC Init structures definition
  64. */
  65. typedef struct
  66. {
  67. uint32_t AsynchPrescaler; /*!< Specifies the RTC Asynchronous Predivider value.
  68. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFFFFF
  69. This feature can be modified afterwards using unitary function
  70. @ref LL_RTC_SetAsynchPrescaler(). */
  71. uint32_t OutPutSource; /*!< Specifies which signal will be routed to the RTC Tamper pin.
  72. This parameter can be a value of @ref LL_RTC_Output_Source
  73. This feature can be modified afterwards using unitary function
  74. @ref LL_RTC_SetOutputSource(). */
  75. } LL_RTC_InitTypeDef;
  76. /**
  77. * @brief RTC Time structure definition
  78. */
  79. typedef struct
  80. {
  81. uint8_t Hours; /*!< Specifies the RTC Time Hours.
  82. This parameter must be a number between Min_Data = 0 and Max_Data = 23 */
  83. uint8_t Minutes; /*!< Specifies the RTC Time Minutes.
  84. This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
  85. uint8_t Seconds; /*!< Specifies the RTC Time Seconds.
  86. This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
  87. } LL_RTC_TimeTypeDef;
  88. /**
  89. * @brief RTC Alarm structure definition
  90. */
  91. typedef struct
  92. {
  93. LL_RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members. */
  94. } LL_RTC_AlarmTypeDef;
  95. /**
  96. * @}
  97. */
  98. #endif /* USE_FULL_LL_DRIVER */
  99. /* Exported constants --------------------------------------------------------*/
  100. /** @defgroup RTC_LL_Exported_Constants RTC Exported Constants
  101. * @{
  102. */
  103. #if defined(USE_FULL_LL_DRIVER)
  104. /** @defgroup RTC_LL_EC_FORMAT FORMAT
  105. * @{
  106. */
  107. #define LL_RTC_FORMAT_BIN (0x000000000U) /*!< Binary data format */
  108. #define LL_RTC_FORMAT_BCD (0x000000001U) /*!< BCD data format */
  109. /**
  110. * @}
  111. */
  112. #endif /* USE_FULL_LL_DRIVER */
  113. /** @defgroup LL_RTC_Output_Source Clock Source to output on the Tamper Pin
  114. * @{
  115. */
  116. #define LL_RTC_CALIB_OUTPUT_NONE (0x00000000U) /*!< Calibration output disabled */
  117. #define LL_RTC_CALIB_OUTPUT_RTCCLOCK BKP_RTCCR_CCO /*!< Calibration output is RTC Clock with a frequency divided by 64 on the TAMPER Pin */
  118. #define LL_RTC_CALIB_OUTPUT_ALARM BKP_RTCCR_ASOE /*!< Calibration output is Alarm pulse signal on the TAMPER pin */
  119. #define LL_RTC_CALIB_OUTPUT_SECOND (BKP_RTCCR_ASOS | BKP_RTCCR_ASOE) /*!< Calibration output is Second pulse signal on the TAMPER pin*/
  120. /**
  121. * @}
  122. */
  123. /**
  124. * @}
  125. */
  126. /* Exported macro ------------------------------------------------------------*/
  127. /** @defgroup RTC_LL_Exported_Macros RTC Exported Macros
  128. * @{
  129. */
  130. /** @defgroup RTC_LL_EM_WRITE_READ Common Write and read registers Macros
  131. * @{
  132. */
  133. /**
  134. * @brief Write a value in RTC register
  135. * @param __INSTANCE__ RTC Instance
  136. * @param __REG__ Register to be written
  137. * @param __VALUE__ Value to be written in the register
  138. * @retval None
  139. */
  140. #define LL_RTC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  141. /**
  142. * @brief Read a value in RTC register
  143. * @param __INSTANCE__ RTC Instance
  144. * @param __REG__ Register to be read
  145. * @retval Register value
  146. */
  147. #define LL_RTC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  148. /**
  149. * @}
  150. */
  151. /** @defgroup RTC_LL_EM_Convert Convert helper Macros
  152. * @{
  153. */
  154. /**
  155. * @brief Helper macro to convert a value from 2 digit decimal format to BCD format
  156. * @param __VALUE__ Byte to be converted
  157. * @retval Converted byte
  158. */
  159. #define __LL_RTC_CONVERT_BIN2BCD(__VALUE__) (uint8_t)((((__VALUE__) / 10U) << 4U) | ((__VALUE__) % 10U))
  160. /**
  161. * @brief Helper macro to convert a value from BCD format to 2 digit decimal format
  162. * @param __VALUE__ BCD value to be converted
  163. * @retval Converted byte
  164. */
  165. #define __LL_RTC_CONVERT_BCD2BIN(__VALUE__) (uint8_t)(((uint8_t)((__VALUE__) & (uint8_t)0xF0U) >> (uint8_t)0x4U) * 10U + ((__VALUE__) & (uint8_t)0x0FU))
  166. /**
  167. * @}
  168. */
  169. /**
  170. * @}
  171. */
  172. /* Exported functions --------------------------------------------------------*/
  173. /** @defgroup RTC_LL_Exported_Functions RTC Exported Functions
  174. * @{
  175. */
  176. /** @defgroup RTC_LL_EF_Configuration Configuration
  177. * @{
  178. */
  179. /**
  180. * @brief Set Asynchronous prescaler factor
  181. * @rmtoll PRLH PRL LL_RTC_SetAsynchPrescaler\n
  182. * @rmtoll PRLL PRL LL_RTC_SetAsynchPrescaler\n
  183. * @param RTCx RTC Instance
  184. * @param AsynchPrescaler Value between Min_Data = 0 and Max_Data = 0xFFFFF
  185. * @retval None
  186. */
  187. __STATIC_INLINE void LL_RTC_SetAsynchPrescaler(RTC_TypeDef *RTCx, uint32_t AsynchPrescaler)
  188. {
  189. MODIFY_REG(RTCx->PRLH, RTC_PRLH_PRL, (AsynchPrescaler >> 16));
  190. MODIFY_REG(RTCx->PRLL, RTC_PRLL_PRL, (AsynchPrescaler & RTC_PRLL_PRL));
  191. }
  192. /**
  193. * @brief Get Asynchronous prescaler factor
  194. * @rmtoll DIVH DIV LL_RTC_GetDivider\n
  195. * @rmtoll DIVL DIV LL_RTC_GetDivider\n
  196. * @param RTCx RTC Instance
  197. * @retval Value between Min_Data = 0 and Max_Data = 0xFFFFF
  198. */
  199. __STATIC_INLINE uint32_t LL_RTC_GetDivider(RTC_TypeDef *RTCx)
  200. {
  201. register uint16_t Highprescaler = 0, Lowprescaler = 0;
  202. Highprescaler = READ_REG(RTCx->DIVH & RTC_DIVH_RTC_DIV);
  203. Lowprescaler = READ_REG(RTCx->DIVL & RTC_DIVL_RTC_DIV);
  204. return (((uint32_t) Highprescaler << 16U) | Lowprescaler);
  205. }
  206. /**
  207. * @brief Set Output Source
  208. * @rmtoll RTCCR CCO LL_RTC_SetOutputSource
  209. * @rmtoll RTCCR ASOE LL_RTC_SetOutputSource
  210. * @rmtoll RTCCR ASOS LL_RTC_SetOutputSource
  211. * @param RTCx RTC Instance
  212. * @param OutputSource This parameter can be one of the following values:
  213. * @arg @ref LL_RTC_CALIB_OUTPUT_NONE
  214. * @arg @ref LL_RTC_CALIB_OUTPUT_RTCCLOCK
  215. * @arg @ref LL_RTC_CALIB_OUTPUT_ALARM
  216. * @arg @ref LL_RTC_CALIB_OUTPUT_SECOND
  217. * @retval None
  218. */
  219. __STATIC_INLINE void LL_RTC_SetOutputSource(RTC_TypeDef *RTCx, uint32_t OutputSource)
  220. {
  221. MODIFY_REG(RTCx->BKP_RTCCR, (BKP_RTCCR_CCO | BKP_RTCCR_ASOE | BKP_RTCCR_ASOS), OutputSource);
  222. }
  223. /**
  224. * @brief Get Output Source
  225. * @rmtoll RTCCR CCO LL_RTC_GetOutPutSource
  226. * @rmtoll RTCCR ASOE LL_RTC_GetOutPutSource
  227. * @rmtoll RTCCR ASOS LL_RTC_GetOutPutSource
  228. * @param RTCx RTC Instance
  229. * @retval Returned value can be one of the following values:
  230. * @arg @ref LL_RTC_CALIB_OUTPUT_NONE
  231. * @arg @ref LL_RTC_CALIB_OUTPUT_RTCCLOCK
  232. * @arg @ref LL_RTC_CALIB_OUTPUT_ALARM
  233. * @arg @ref LL_RTC_CALIB_OUTPUT_SECOND
  234. */
  235. __STATIC_INLINE uint32_t LL_RTC_GetOutPutSource(RTC_TypeDef *RTCx)
  236. {
  237. return (uint32_t)(READ_BIT(RTCx->BKP_RTCCR, (BKP_RTCCR_CCO | BKP_RTCCR_ASOE | BKP_RTCCR_ASOS)));
  238. }
  239. /**
  240. * @brief Enable the write protection for RTC registers.
  241. * @rmtoll CRL CNF LL_RTC_EnableWriteProtection
  242. * @param RTCx RTC Instance
  243. * @retval None
  244. */
  245. __STATIC_INLINE void LL_RTC_EnableWriteProtection(RTC_TypeDef *RTCx)
  246. {
  247. CLEAR_BIT(RTCx->CRL, RTC_CRL_CNF);
  248. }
  249. /**
  250. * @brief Disable the write protection for RTC registers.
  251. * @rmtoll CRL RTC_CRL_CNF LL_RTC_DisableWriteProtection
  252. * @param RTCx RTC Instance
  253. * @retval None
  254. */
  255. __STATIC_INLINE void LL_RTC_DisableWriteProtection(RTC_TypeDef *RTCx)
  256. {
  257. SET_BIT(RTCx->CRL, RTC_CRL_CNF);
  258. }
  259. /**
  260. * @}
  261. */
  262. /** @defgroup RTC_LL_EF_Time Time
  263. * @{
  264. */
  265. /**
  266. * @brief Set time counter in BCD format
  267. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  268. * @note It can be written in initialization mode only (@ref LL_RTC_EnterInitMode function)
  269. * @rmtoll CNTH CNT LL_RTC_TIME_Set\n
  270. * CNTL CNT LL_RTC_TIME_Set\n
  271. * @param RTCx RTC Instance
  272. * @param TimeCounter Value between Min_Data=0x00 and Max_Data=0xFFFFFFFF
  273. * @retval None
  274. */
  275. __STATIC_INLINE void LL_RTC_TIME_Set(RTC_TypeDef *RTCx, uint32_t TimeCounter)
  276. {
  277. /* Set RTC COUNTER MSB word */
  278. WRITE_REG(RTCx->CNTH, (TimeCounter >> 16U));
  279. /* Set RTC COUNTER LSB word */
  280. WRITE_REG(RTCx->CNTL, (TimeCounter & RTC_CNTL_RTC_CNT));
  281. }
  282. /**
  283. * @brief Get time counter in BCD format
  284. * @rmtoll CNTH CNT LL_RTC_TIME_Get\n
  285. * CNTL CNT LL_RTC_TIME_Get\n
  286. * @param RTCx RTC Instance
  287. * @retval Value between Min_Data = 0 and Max_Data = 0xFFFFFFFF
  288. */
  289. __STATIC_INLINE uint32_t LL_RTC_TIME_Get(RTC_TypeDef *RTCx)
  290. {
  291. register uint16_t high = 0, low = 0;
  292. high = READ_REG(RTCx->CNTH & RTC_CNTH_RTC_CNT);
  293. low = READ_REG(RTCx->CNTL & RTC_CNTL_RTC_CNT);
  294. return ((uint32_t)(((uint32_t) high << 16U) | low));
  295. }
  296. /**
  297. * @}
  298. */
  299. /** @defgroup RTC_LL_EF_ALARM ALARM
  300. * @{
  301. */
  302. /**
  303. * @brief Set Alarm Counter
  304. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  305. * @rmtoll ALRH ALR LL_RTC_ALARM_Set\n
  306. * @rmtoll ALRL ALR LL_RTC_ALARM_Set\n
  307. * @param RTCx RTC Instance
  308. * @param AlarmCounter Value between Min_Data=0x00 and Max_Data=0xFFFFF
  309. * @retval None
  310. */
  311. __STATIC_INLINE void LL_RTC_ALARM_Set(RTC_TypeDef *RTCx, uint32_t AlarmCounter)
  312. {
  313. /* Set RTC COUNTER MSB word */
  314. WRITE_REG(RTCx->ALRH, (AlarmCounter >> 16));
  315. /* Set RTC COUNTER LSB word */
  316. WRITE_REG(RTCx->ALRL, (AlarmCounter & RTC_ALRL_RTC_ALR));
  317. }
  318. /** @defgroup RTC_LL_EF_Calibration Calibration
  319. * @{
  320. */
  321. /**
  322. * @brief Set the coarse digital calibration
  323. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  324. * @note It can be written in initialization mode only (@ref LL_RTC_EnterInitMode function)
  325. * @rmtoll RTCCR CAL LL_RTC_CAL_SetCoarseDigital\n
  326. * @param RTCx RTC Instance
  327. * @param Value value of coarse calibration expressed in ppm
  328. * @retval None
  329. */
  330. __STATIC_INLINE void LL_RTC_CAL_SetCoarseDigital(RTC_TypeDef *RTCx, uint32_t Value)
  331. {
  332. MODIFY_REG(RTCx->BKP_RTCCR, BKP_RTCCR_CAL, Value);
  333. }
  334. /**
  335. * @brief Get the coarse digital calibration value
  336. * @rmtoll RTCCR CAL LL_RTC_CAL_SetCoarseDigital\n
  337. * @param RTCx RTC Instance
  338. * @retval value of coarse calibration expressed in ppm
  339. */
  340. __STATIC_INLINE uint32_t LL_RTC_CAL_GetCoarseDigital(RTC_TypeDef *RTCx)
  341. {
  342. return (uint32_t)(READ_BIT(RTCx->BKP_RTCCR, BKP_RTCCR_CAL));
  343. }
  344. /**
  345. * @}
  346. */
  347. /** @defgroup RTC_LL_EF_FLAG_Management FLAG Management
  348. * @{
  349. */
  350. /**
  351. * @brief Get Alarm flag
  352. * @rmtoll CRL ALRF LL_RTC_IsActiveFlag_ALR
  353. * @param RTCx RTC Instance
  354. * @retval State of bit (1 or 0).
  355. */
  356. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_ALR(RTC_TypeDef *RTCx)
  357. {
  358. return (READ_BIT(RTCx->CRL, RTC_CRL_ALRF) == (RTC_CRL_ALRF));
  359. }
  360. /**
  361. * @brief Clear Alarm flag
  362. * @rmtoll CRL ALRF LL_RTC_ClearFlag_ALR
  363. * @param RTCx RTC Instance
  364. * @retval None
  365. */
  366. __STATIC_INLINE void LL_RTC_ClearFlag_ALR(RTC_TypeDef *RTCx)
  367. {
  368. CLEAR_BIT(RTCx->CRL, RTC_CRL_ALRF);
  369. }
  370. /**
  371. * @brief Get Registers synchronization flag
  372. * @rmtoll CRL RSF LL_RTC_IsActiveFlag_RS
  373. * @param RTCx RTC Instance
  374. * @retval State of bit (1 or 0).
  375. */
  376. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RS(RTC_TypeDef *RTCx)
  377. {
  378. return (READ_BIT(RTCx->CRL, RTC_CRL_RSF) == (RTC_CRL_RSF));
  379. }
  380. /**
  381. * @brief Clear Registers synchronization flag
  382. * @rmtoll CRL RSF LL_RTC_ClearFlag_RS
  383. * @param RTCx RTC Instance
  384. * @retval None
  385. */
  386. __STATIC_INLINE void LL_RTC_ClearFlag_RS(RTC_TypeDef *RTCx)
  387. {
  388. CLEAR_BIT(RTCx->CRL, RTC_CRL_RSF);
  389. }
  390. /**
  391. * @brief Get Registers OverFlow flag
  392. * @rmtoll CRL OWF LL_RTC_IsActiveFlag_OW
  393. * @param RTCx RTC Instance
  394. * @retval State of bit (1 or 0).
  395. */
  396. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_OW(RTC_TypeDef *RTCx)
  397. {
  398. return (READ_BIT(RTCx->CRL, RTC_CRL_OWF) == (RTC_CRL_OWF));
  399. }
  400. /**
  401. * @brief Clear Registers OverFlow flag
  402. * @rmtoll CRL OWF LL_RTC_ClearFlag_OW
  403. * @param RTCx RTC Instance
  404. * @retval None
  405. */
  406. __STATIC_INLINE void LL_RTC_ClearFlag_OW(RTC_TypeDef *RTCx)
  407. {
  408. CLEAR_BIT(RTCx->CRL, RTC_CRL_OWF);
  409. }
  410. /**
  411. * @brief Get Registers synchronization flag
  412. * @rmtoll CRL SECF LL_RTC_IsActiveFlag_SEC
  413. * @param RTCx RTC Instance
  414. * @retval State of bit (1 or 0).
  415. */
  416. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_SEC(RTC_TypeDef *RTCx)
  417. {
  418. return (READ_BIT(RTCx->CRL, RTC_CRL_SECF) == (RTC_CRL_SECF));
  419. }
  420. /**
  421. * @brief Clear Registers synchronization flag
  422. * @rmtoll CRL SECF LL_RTC_ClearFlag_SEC
  423. * @param RTCx RTC Instance
  424. * @retval None
  425. */
  426. __STATIC_INLINE void LL_RTC_ClearFlag_SEC(RTC_TypeDef *RTCx)
  427. {
  428. CLEAR_BIT(RTCx->CRL, RTC_CRL_SECF);
  429. }
  430. /**
  431. * @brief Get RTC Operation OFF status flag
  432. * @rmtoll CRL RTOFF LL_RTC_IsActiveFlag_RTOF
  433. * @param RTCx RTC Instance
  434. * @retval State of bit (1 or 0).
  435. */
  436. __STATIC_INLINE uint32_t LL_RTC_IsActiveFlag_RTOF(RTC_TypeDef *RTCx)
  437. {
  438. return (READ_BIT(RTCx->CRL, RTC_CRL_RTOFF) == (RTC_CRL_RTOFF));
  439. }
  440. /**
  441. * @}
  442. */
  443. /** @defgroup RTC_LL_EF_IT_Management IT Management
  444. * @{
  445. */
  446. /**
  447. * @brief Enable Alarm interrupt
  448. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  449. * @rmtoll CRH ALRIE LL_RTC_EnableIT_ALR
  450. * @param RTCx RTC Instance
  451. * @retval None
  452. */
  453. __STATIC_INLINE void LL_RTC_EnableIT_ALR(RTC_TypeDef *RTCx)
  454. {
  455. SET_BIT(RTCx->CRH, RTC_CRH_ALRIE);
  456. }
  457. /**
  458. * @brief Disable Alarm interrupt
  459. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  460. * @rmtoll CRH ALRIE LL_RTC_DisableIT_ALR
  461. * @param RTCx RTC Instance
  462. * @retval None
  463. */
  464. __STATIC_INLINE void LL_RTC_DisableIT_ALR(RTC_TypeDef *RTCx)
  465. {
  466. CLEAR_BIT(RTCx->CRH, RTC_CRH_ALRIE);
  467. }
  468. /**
  469. * @brief Check if Alarm interrupt is enabled or not
  470. * @rmtoll CRH ALRIE LL_RTC_IsEnabledIT_ALR
  471. * @param RTCx RTC Instance
  472. * @retval State of bit (1 or 0).
  473. */
  474. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_ALR(RTC_TypeDef *RTCx)
  475. {
  476. return (READ_BIT(RTCx->CRH, RTC_CRH_ALRIE) == (RTC_CRH_ALRIE));
  477. }
  478. /**
  479. * @brief Enable Second Interrupt interrupt
  480. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  481. * @rmtoll CRH SECIE LL_RTC_EnableIT_SEC
  482. * @param RTCx RTC Instance
  483. * @retval None
  484. */
  485. __STATIC_INLINE void LL_RTC_EnableIT_SEC(RTC_TypeDef *RTCx)
  486. {
  487. SET_BIT(RTCx->CRH, RTC_CRH_SECIE);
  488. }
  489. /**
  490. * @brief Disable Second interrupt
  491. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  492. * @rmtoll CRH SECIE LL_RTC_DisableIT_SEC
  493. * @param RTCx RTC Instance
  494. * @retval None
  495. */
  496. __STATIC_INLINE void LL_RTC_DisableIT_SEC(RTC_TypeDef *RTCx)
  497. {
  498. CLEAR_BIT(RTCx->CRH, RTC_CRH_SECIE);
  499. }
  500. /**
  501. * @brief Check if Second interrupt is enabled or not
  502. * @rmtoll CRH SECIE LL_RTC_IsEnabledIT_SEC
  503. * @param RTCx RTC Instance
  504. * @retval State of bit (1 or 0).
  505. */
  506. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_SEC(RTC_TypeDef *RTCx)
  507. {
  508. return (READ_BIT(RTCx->CRH, RTC_CRH_SECIE) == (RTC_CRH_SECIE));
  509. }
  510. /**
  511. * @brief Enable OverFlow interrupt
  512. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  513. * @rmtoll CRH OWIE LL_RTC_EnableIT_OW
  514. * @param RTCx RTC Instance
  515. * @retval None
  516. */
  517. __STATIC_INLINE void LL_RTC_EnableIT_OW(RTC_TypeDef *RTCx)
  518. {
  519. SET_BIT(RTCx->CRH, RTC_CRH_OWIE);
  520. }
  521. /**
  522. * @brief Disable OverFlow interrupt
  523. * @note Bit is write-protected. @ref LL_RTC_DisableWriteProtection function should be called before.
  524. * @rmtoll CRH OWIE LL_RTC_DisableIT_OW
  525. * @param RTCx RTC Instance
  526. * @retval None
  527. */
  528. __STATIC_INLINE void LL_RTC_DisableIT_OW(RTC_TypeDef *RTCx)
  529. {
  530. CLEAR_BIT(RTCx->CRH, RTC_CRH_OWIE);
  531. }
  532. /**
  533. * @brief Check if OverFlow interrupt is enabled or not
  534. * @rmtoll CRH OWIE LL_RTC_IsEnabledIT_OW
  535. * @param RTCx RTC Instance
  536. * @retval State of bit (1 or 0).
  537. */
  538. __STATIC_INLINE uint32_t LL_RTC_IsEnabledIT_OW(RTC_TypeDef *RTCx)
  539. {
  540. return (READ_BIT(RTCx->CRH, RTC_CRH_OWIE) == (RTC_CRH_OWIE));
  541. }
  542. /**
  543. * @}
  544. */
  545. #if defined(USE_FULL_LL_DRIVER)
  546. /** @defgroup RTC_LL_EF_Init Initialization and de-initialization functions
  547. * @{
  548. */
  549. ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx);
  550. ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct);
  551. void LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct);
  552. ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct);
  553. void LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct);
  554. ErrorStatus LL_RTC_ALARM_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
  555. void LL_RTC_ALARM_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct);
  556. ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx);
  557. ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx);
  558. ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx);
  559. ErrorStatus LL_RTC_TIME_SetCounter(RTC_TypeDef *RTCx, uint32_t TimeCounter);
  560. ErrorStatus LL_RTC_ALARM_SetCounter(RTC_TypeDef *RTCx, uint32_t AlarmCounter);
  561. /**
  562. * @}
  563. */
  564. #endif /* USE_FULL_LL_DRIVER */
  565. /**
  566. * @}
  567. */
  568. /**
  569. * @}
  570. */
  571. /**
  572. * @}
  573. */
  574. #endif /* defined(RTC) */
  575. /**
  576. * @}
  577. */
  578. #ifdef __cplusplus
  579. }
  580. #endif
  581. #endif /* __PY32F0xx_LL_RTC_H */
  582. /************************ (C) COPYRIGHT Puya *****END OF FILE****/