stm32f1xx_hal_rtc.h 21 KB

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