stm32f1xx_hal_rtc.h 21 KB

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