py32f0xx_hal_rtc.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. /**
  2. ******************************************************************************
  3. * @file py32f0xx_hal_rtc.h
  4. * @author MCU Application Team
  5. * @brief Header file of RTC HAL 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_HAL_RTC_H
  32. #define __PY32F0xx_HAL_RTC_H
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /* Includes ------------------------------------------------------------------*/
  37. #include "py32f0xx_hal_def.h"
  38. /** @addtogroup PY32F0xx_HAL_Driver
  39. * @{
  40. */
  41. /** @addtogroup RTC
  42. * @{
  43. */
  44. /** @addtogroup RTC_Private_Macros
  45. * @{
  46. */
  47. #define IS_RTC_ASYNCH_PREDIV(PREDIV) (((PREDIV) <= 0xFFFFFU) || ((PREDIV) == RTC_AUTO_1_SECOND))
  48. #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23U)
  49. #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59U)
  50. #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59U)
  51. #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || ((FORMAT) == RTC_FORMAT_BCD))
  52. #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99U)
  53. #define IS_RTC_MONTH(MONTH) (((MONTH) >= 1U) && ((MONTH) <= 12U))
  54. #define IS_RTC_DATE(DATE) (((DATE) >= 1U) && ((DATE) <= 31U))
  55. #define IS_RTC_CALIB_OUTPUT(__OUTPUT__) (((__OUTPUT__) == RTC_OUTPUTSOURCE_NONE) || \
  56. ((__OUTPUT__) == RTC_OUTPUTSOURCE_CALIBCLOCK) || \
  57. ((__OUTPUT__) == RTC_OUTPUTSOURCE_ALARM) || \
  58. ((__OUTPUT__) == RTC_OUTPUTSOURCE_SECOND))
  59. /**
  60. * @}
  61. */
  62. /** @addtogroup RTC_Private_Constants
  63. * @{
  64. */
  65. /** @defgroup RTC_Timeout_Value Default Timeout Value
  66. * @{
  67. */
  68. #define RTC_TIMEOUT_VALUE 2000U
  69. #define RTC_RTOFF_RESET_TIMEOUT_VALUE 4U
  70. /**
  71. * @}
  72. */
  73. /** @defgroup RTC_EXTI_Line_Event RTC EXTI Line event
  74. * @{
  75. */
  76. #define RTC_EXTI_LINE_ALARM_EVENT ((uint32_t)EXTI_IMR_IM19) /*!< External interrupt line 19 Connected to the RTC Alarm event */
  77. /**
  78. * @}
  79. */
  80. /**
  81. * @}
  82. */
  83. /* Exported types ------------------------------------------------------------*/
  84. /** @defgroup RTC_Exported_Types RTC Exported Types
  85. * @{
  86. */
  87. /**
  88. * @brief RTC Time structure definition
  89. */
  90. typedef struct
  91. {
  92. uint8_t Hours; /*!< Specifies the RTC Time Hour.
  93. This parameter must be a number between Min_Data = 0 and Max_Data = 23 */
  94. uint8_t Minutes; /*!< Specifies the RTC Time Minutes.
  95. This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
  96. uint8_t Seconds; /*!< Specifies the RTC Time Seconds.
  97. This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
  98. } RTC_TimeTypeDef;
  99. /**
  100. * @brief RTC Alarm structure definition
  101. */
  102. typedef struct
  103. {
  104. RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */
  105. } RTC_AlarmTypeDef;
  106. /**
  107. * @brief HAL State structures definition
  108. */
  109. typedef enum
  110. {
  111. HAL_RTC_STATE_RESET = 0x00U, /*!< RTC not yet initialized or disabled */
  112. HAL_RTC_STATE_READY = 0x01U, /*!< RTC initialized and ready for use */
  113. HAL_RTC_STATE_BUSY = 0x02U, /*!< RTC process is ongoing */
  114. HAL_RTC_STATE_TIMEOUT = 0x03U, /*!< RTC timeout state */
  115. HAL_RTC_STATE_ERROR = 0x04U /*!< RTC error state */
  116. } HAL_RTCStateTypeDef;
  117. /**
  118. * @brief RTC Configuration Structure definition
  119. */
  120. typedef struct
  121. {
  122. uint32_t AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value.
  123. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFFFFF or RTC_AUTO_1_SECOND
  124. If RTC_AUTO_1_SECOND is selected, AsynchPrediv will be set automatically to get 1sec timebase */
  125. uint32_t OutPut; /*!< Specifies which signal will be routed to the RTC Tamper pin.
  126. This parameter can be a value of @ref RTC_output_source_to_output_pin */
  127. } RTC_InitTypeDef;
  128. /**
  129. * @brief RTC Date structure definition
  130. */
  131. typedef struct
  132. {
  133. uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay (not necessary for HAL_RTC_SetDate).
  134. This parameter can be a value of @ref RTC_WeekDay_Definitions */
  135. uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format).
  136. This parameter can be a value of @ref RTC_Month_Date_Definitions */
  137. uint8_t Date; /*!< Specifies the RTC Date.
  138. This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
  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. } RTC_DateTypeDef;
  142. /**
  143. * @brief Time Handle Structure definition
  144. */
  145. #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
  146. typedef struct __RTC_HandleTypeDef
  147. #else
  148. typedef struct
  149. #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
  150. {
  151. RTC_TypeDef *Instance; /*!< Register base address */
  152. RTC_InitTypeDef Init; /*!< RTC required parameters */
  153. RTC_DateTypeDef DateToUpdate; /*!< Current date set by user and updated automatically */
  154. HAL_LockTypeDef Lock; /*!< RTC locking object */
  155. __IO HAL_RTCStateTypeDef State; /*!< Time communication state */
  156. #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
  157. void (* AlarmAEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Alarm A Event callback */
  158. void (* MspInitCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp Init callback */
  159. void (* MspDeInitCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp DeInit callback */
  160. #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
  161. } RTC_HandleTypeDef;
  162. #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
  163. /**
  164. * @brief HAL RTC Callback ID enumeration definition
  165. */
  166. typedef enum
  167. {
  168. HAL_RTC_ALARM_A_EVENT_CB_ID = 0x00u, /*!< RTC Alarm A Event Callback ID */
  169. HAL_RTC_TAMPER1_EVENT_CB_ID = 0x04u, /*!< RTC Tamper 1 Callback ID */
  170. HAL_RTC_MSPINIT_CB_ID = 0x0Eu, /*!< RTC Msp Init callback ID */
  171. HAL_RTC_MSPDEINIT_CB_ID = 0x0Fu /*!< RTC Msp DeInit callback ID */
  172. } HAL_RTC_CallbackIDTypeDef;
  173. /**
  174. * @brief HAL RTC Callback pointer definition
  175. */
  176. typedef void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef *hrtc); /*!< pointer to an RTC callback function */
  177. #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
  178. /**
  179. * @}
  180. */
  181. /* Exported constants --------------------------------------------------------*/
  182. /** @defgroup RTC_Exported_Constants RTC Exported Constants
  183. * @{
  184. */
  185. /** @defgroup RTC_Automatic_Prediv_1_Second Automatic calculation of prediv for 1sec timebase
  186. * @{
  187. */
  188. #define RTC_AUTO_1_SECOND 0xFFFFFFFFU
  189. /**
  190. * @}
  191. */
  192. /** @defgroup RTC_Input_parameter_format_definitions Input Parameter Format
  193. * @{
  194. */
  195. #define RTC_FORMAT_BIN 0x000000000U
  196. #define RTC_FORMAT_BCD 0x000000001U
  197. /**
  198. * @}
  199. */
  200. /** @defgroup RTC_Month_Date_Definitions Month Definitions
  201. * @{
  202. */
  203. /* Coded in BCD format */
  204. #define RTC_MONTH_JANUARY ((uint8_t)0x01)
  205. #define RTC_MONTH_FEBRUARY ((uint8_t)0x02)
  206. #define RTC_MONTH_MARCH ((uint8_t)0x03)
  207. #define RTC_MONTH_APRIL ((uint8_t)0x04)
  208. #define RTC_MONTH_MAY ((uint8_t)0x05)
  209. #define RTC_MONTH_JUNE ((uint8_t)0x06)
  210. #define RTC_MONTH_JULY ((uint8_t)0x07)
  211. #define RTC_MONTH_AUGUST ((uint8_t)0x08)
  212. #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09)
  213. #define RTC_MONTH_OCTOBER ((uint8_t)0x10)
  214. #define RTC_MONTH_NOVEMBER ((uint8_t)0x11)
  215. #define RTC_MONTH_DECEMBER ((uint8_t)0x12)
  216. /**
  217. * @}
  218. */
  219. /** @defgroup RTC_WeekDay_Definitions WeekDay Definitions
  220. * @{
  221. */
  222. #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01)
  223. #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02)
  224. #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03)
  225. #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04)
  226. #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05)
  227. #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06)
  228. #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x00)
  229. /**
  230. * @}
  231. */
  232. /** @defgroup RTC_Alarms_Definitions Alarms Definitions
  233. * @{
  234. */
  235. #define RTC_ALARM_A 0U /*!< Specify alarm ID (mainly for legacy purposes) */
  236. /**
  237. * @}
  238. */
  239. /** @defgroup RTC_output_source_to_output_pin Output source to output pin
  240. * @{
  241. */
  242. #define RTC_OUTPUTSOURCE_NONE 0x00000000U /*!< No output on the TAMPER pin */
  243. #define RTC_OUTPUTSOURCE_CALIBCLOCK BKP_RTCCR_CCO /*!< RTC clock with a frequency divided by 64 on the TAMPER pin */
  244. #define RTC_OUTPUTSOURCE_ALARM BKP_RTCCR_ASOE /*!< Alarm pulse signal on the TAMPER pin */
  245. #define RTC_OUTPUTSOURCE_SECOND (BKP_RTCCR_ASOS | BKP_RTCCR_ASOE) /*!< Second pulse signal on the TAMPER pin */
  246. /**
  247. * @}
  248. */
  249. /** @defgroup RTC_Interrupts_Definitions Interrupts Definitions
  250. * @{
  251. */
  252. #define RTC_IT_OW RTC_CRH_OWIE /*!< Overflow interrupt */
  253. #define RTC_IT_ALRA RTC_CRH_ALRIE /*!< Alarm interrupt */
  254. #define RTC_IT_SEC RTC_CRH_SECIE /*!< Second interrupt */
  255. /**
  256. * @}
  257. */
  258. /** @defgroup RTC_Flags_Definitions Flags Definitions
  259. * @{
  260. */
  261. #define RTC_FLAG_RTOFF RTC_CRL_RTOFF /*!< RTC Operation OFF flag */
  262. #define RTC_FLAG_RSF RTC_CRL_RSF /*!< Registers Synchronized flag */
  263. #define RTC_FLAG_OW RTC_CRL_OWF /*!< Overflow flag */
  264. #define RTC_FLAG_ALRAF RTC_CRL_ALRF /*!< Alarm flag */
  265. #define RTC_FLAG_SEC RTC_CRL_SECF /*!< Second flag */
  266. /**
  267. * @}
  268. */
  269. /**
  270. * @}
  271. */
  272. /* Exported macro ------------------------------------------------------------*/
  273. /** @defgroup RTC_Exported_macros RTC Exported Macros
  274. * @{
  275. */
  276. /** @brief Reset RTC handle state
  277. * @param __HANDLE__: RTC handle.
  278. * @retval None
  279. */
  280. #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
  281. #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{\
  282. (__HANDLE__)->State = HAL_RTC_STATE_RESET;\
  283. (__HANDLE__)->MspInitCallback = NULL;\
  284. (__HANDLE__)->MspDeInitCallback = NULL;\
  285. }while(0u)
  286. #else
  287. #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
  288. #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
  289. /**
  290. * @brief Disable the write protection for RTC registers.
  291. * @param __HANDLE__: specifies the RTC handle.
  292. * @retval None
  293. */
  294. #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CRL, RTC_CRL_CNF)
  295. /**
  296. * @brief Enable the write protection for RTC registers.
  297. * @param __HANDLE__: specifies the RTC handle.
  298. * @retval None
  299. */
  300. #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CRL, RTC_CRL_CNF)
  301. /**
  302. * @brief Enable the RTC Alarm interrupt.
  303. * @param __HANDLE__: specifies the RTC handle.
  304. * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled.
  305. * This parameter can be any combination of the following values:
  306. * @arg RTC_IT_ALRA: Alarm A interrupt
  307. * @retval None
  308. */
  309. #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CRH, (__INTERRUPT__))
  310. /**
  311. * @brief Disable the RTC Alarm interrupt.
  312. * @param __HANDLE__: specifies the RTC handle.
  313. * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled.
  314. * This parameter can be any combination of the following values:
  315. * @arg RTC_IT_ALRA: Alarm A interrupt
  316. * @retval None
  317. */
  318. #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CRH, (__INTERRUPT__))
  319. /**
  320. * @brief Check whether the specified RTC Alarm interrupt has been enabled or not.
  321. * @param __HANDLE__: specifies the RTC handle.
  322. * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be checked
  323. * This parameter can be:
  324. * @arg RTC_IT_ALRA: Alarm A interrupt
  325. * @retval None
  326. */
  327. #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((__HANDLE__)->Instance->CRH)& ((__INTERRUPT__)))) != RESET)? SET : RESET)
  328. /**
  329. * @brief Get the selected RTC Alarm's flag status.
  330. * @param __HANDLE__: specifies the RTC handle.
  331. * @param __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled.
  332. * This parameter can be:
  333. * @arg RTC_FLAG_ALRAF
  334. * @retval None
  335. */
  336. #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->CRL) & (__FLAG__)) != RESET)? SET : RESET)
  337. /**
  338. * @brief Check whether the specified RTC Alarm interrupt has occurred or not.
  339. * @param __HANDLE__: specifies the RTC handle.
  340. * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to check.
  341. * This parameter can be:
  342. * @arg RTC_IT_ALRA: Alarm A interrupt
  343. * @retval None
  344. */
  345. #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CRL) & (__INTERRUPT__)) != RESET)? SET : RESET)
  346. /**
  347. * @brief Clear the RTC Alarm's pending flags.
  348. * @param __HANDLE__: specifies the RTC handle.
  349. * @param __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled.
  350. * This parameter can be:
  351. * @arg RTC_FLAG_ALRAF
  352. * @retval None
  353. */
  354. #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) CLEAR_BIT((__HANDLE__)->Instance->CRL,(__FLAG__))
  355. /**
  356. * @brief Enable interrupt on ALARM Exti Line 17.
  357. * @retval None.
  358. */
  359. #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, RTC_EXTI_LINE_ALARM_EVENT)
  360. /**
  361. * @brief Disable interrupt on ALARM Exti Line 17.
  362. * @retval None.
  363. */
  364. #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, RTC_EXTI_LINE_ALARM_EVENT)
  365. /**
  366. * @brief Enable event on ALARM Exti Line 17.
  367. * @retval None.
  368. */
  369. #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, RTC_EXTI_LINE_ALARM_EVENT)
  370. /**
  371. * @brief Disable event on ALARM Exti Line 17.
  372. * @retval None.
  373. */
  374. #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, RTC_EXTI_LINE_ALARM_EVENT)
  375. /**
  376. * @brief ALARM EXTI line configuration: set falling edge trigger.
  377. * @retval None.
  378. */
  379. #define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, RTC_EXTI_LINE_ALARM_EVENT)
  380. /**
  381. * @brief Disable the ALARM Extended Interrupt Falling Trigger.
  382. * @retval None.
  383. */
  384. #define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, RTC_EXTI_LINE_ALARM_EVENT)
  385. /**
  386. * @brief ALARM EXTI line configuration: set rising edge trigger.
  387. * @retval None.
  388. */
  389. #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, RTC_EXTI_LINE_ALARM_EVENT)
  390. /**
  391. * @brief Disable the ALARM Extended Interrupt Rising Trigger.
  392. * This parameter can be:
  393. * @retval None.
  394. */
  395. #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, RTC_EXTI_LINE_ALARM_EVENT)
  396. /**
  397. * @brief ALARM EXTI line configuration: set rising & falling edge trigger.
  398. * @retval None.
  399. */
  400. #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() \
  401. do{ \
  402. __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE(); \
  403. __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE(); \
  404. } while(0U)
  405. /**
  406. * @brief Disable the ALARM Extended Interrupt Rising & Falling Trigger.
  407. * This parameter can be:
  408. * @retval None.
  409. */
  410. #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() \
  411. do{ \
  412. __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE(); \
  413. __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE(); \
  414. } while(0U)
  415. /**
  416. * @brief Check whether the specified ALARM EXTI interrupt flag is set or not.
  417. * @retval EXTI ALARM Line Status.
  418. */
  419. #define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR & (RTC_EXTI_LINE_ALARM_EVENT))
  420. /**
  421. * @brief Clear the ALARM EXTI flag.
  422. * @retval None.
  423. */
  424. #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR = (RTC_EXTI_LINE_ALARM_EVENT))
  425. /**
  426. * @brief Generate a Software interrupt on selected EXTI line.
  427. * @retval None.
  428. */
  429. #define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, RTC_EXTI_LINE_ALARM_EVENT)
  430. /**
  431. * @}
  432. */
  433. /* Include RTC HAL Extension module */
  434. #include "py32f0xx_hal_rtc_ex.h"
  435. /* Exported functions --------------------------------------------------------*/
  436. /** @addtogroup RTC_Exported_Functions
  437. * @{
  438. */
  439. /* Initialization and de-initialization functions ****************************/
  440. /** @addtogroup RTC_Exported_Functions_Group1
  441. * @{
  442. */
  443. HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc);
  444. HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc);
  445. void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc);
  446. void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc);
  447. /* Callbacks Register/UnRegister functions ***********************************/
  448. #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
  449. HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback);
  450. HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID);
  451. #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
  452. /**
  453. * @}
  454. */
  455. /* RTC Time and Date functions ************************************************/
  456. /** @addtogroup RTC_Exported_Functions_Group2
  457. * @{
  458. */
  459. HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
  460. HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
  461. HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
  462. HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
  463. /**
  464. * @}
  465. */
  466. /* RTC Alarm functions ********************************************************/
  467. /** @addtogroup RTC_Exported_Functions_Group3
  468. * @{
  469. */
  470. HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
  471. HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
  472. HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc);
  473. HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
  474. void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc);
  475. HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  476. void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc);
  477. /**
  478. * @}
  479. */
  480. /* Peripheral State functions *************************************************/
  481. /** @addtogroup RTC_Exported_Functions_Group4
  482. * @{
  483. */
  484. HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc);
  485. /**
  486. * @}
  487. */
  488. /* Peripheral Control functions ***********************************************/
  489. /** @addtogroup RTC_Exported_Functions_Group5
  490. * @{
  491. */
  492. HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc);
  493. /**
  494. * @}
  495. */
  496. /**
  497. * @}
  498. */
  499. /**
  500. * @}
  501. */
  502. /**
  503. * @}
  504. */
  505. #ifdef __cplusplus
  506. }
  507. #endif
  508. #endif /* __PY32F0xx_HAL_RTC_H */
  509. /************************ (C) COPYRIGHT Puya *****END OF FILE****/