stm32l1xx_hal_rtc.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. /**
  2. ******************************************************************************
  3. * @file stm32l1xx_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) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32L1xx_HAL_RTC_H
  37. #define __STM32L1xx_HAL_RTC_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32l1xx_hal_def.h"
  43. /** @addtogroup STM32L1xx_HAL_Driver
  44. * @{
  45. */
  46. /** @addtogroup RTC
  47. * @{
  48. */
  49. /* Exported types ------------------------------------------------------------*/
  50. /** @defgroup RTC_Exported_Types RTC Exported Types
  51. * @{
  52. */
  53. /**
  54. * @brief HAL State structures definition
  55. */
  56. typedef enum
  57. {
  58. HAL_RTC_STATE_RESET = 0x00, /*!< RTC not yet initialized or disabled */
  59. HAL_RTC_STATE_READY = 0x01, /*!< RTC initialized and ready for use */
  60. HAL_RTC_STATE_BUSY = 0x02, /*!< RTC process is ongoing */
  61. HAL_RTC_STATE_TIMEOUT = 0x03, /*!< RTC timeout state */
  62. HAL_RTC_STATE_ERROR = 0x04 /*!< RTC error state */
  63. }HAL_RTCStateTypeDef;
  64. /**
  65. * @brief RTC Configuration Structure definition
  66. */
  67. typedef struct
  68. {
  69. uint32_t HourFormat; /*!< Specifies the RTC Hour Format.
  70. This parameter can be a value of @ref RTC_Hour_Formats */
  71. uint32_t AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value.
  72. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */
  73. uint32_t SynchPrediv; /*!< Specifies the RTC Synchronous Predivider value.
  74. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF */
  75. uint32_t OutPut; /*!< Specifies which signal will be routed to the RTC output.
  76. This parameter can be a value of @ref RTCEx_Output_selection_Definitions */
  77. uint32_t OutPutPolarity; /*!< Specifies the polarity of the output signal.
  78. This parameter can be a value of @ref RTC_Output_Polarity_Definitions */
  79. uint32_t OutPutType; /*!< Specifies the RTC Output Pin mode.
  80. This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */
  81. }RTC_InitTypeDef;
  82. /**
  83. * @brief RTC Date structure definition
  84. */
  85. typedef struct
  86. {
  87. uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay.
  88. This parameter can be a value of @ref RTC_WeekDay_Definitions */
  89. uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format).
  90. This parameter can be a value of @ref RTC_Month_Date_Definitions */
  91. uint8_t Date; /*!< Specifies the RTC Date.
  92. This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
  93. uint8_t Year; /*!< Specifies the RTC Date Year.
  94. This parameter must be a number between Min_Data = 0 and Max_Data = 99 */
  95. }RTC_DateTypeDef;
  96. /**
  97. * @brief Time Handle Structure definition
  98. */
  99. typedef struct
  100. {
  101. RTC_TypeDef *Instance; /*!< Register base address */
  102. RTC_InitTypeDef Init; /*!< RTC required parameters */
  103. HAL_LockTypeDef Lock; /*!< RTC locking object */
  104. __IO HAL_RTCStateTypeDef State; /*!< Time communication state */
  105. }RTC_HandleTypeDef;
  106. /**
  107. * @}
  108. */
  109. /* Exported constants --------------------------------------------------------*/
  110. /** @defgroup RTC_Exported_Constants RTC Exported Constants
  111. * @{
  112. */
  113. /** @defgroup RTC_Timeout_Value Default Timeout Value
  114. * @{
  115. */
  116. #define RTC_TIMEOUT_VALUE 1000
  117. /**
  118. * @}
  119. */
  120. /** @defgroup RTC_Hour_Formats Hour Formats
  121. * @{
  122. */
  123. #define RTC_HOURFORMAT_24 (0x00000000U)
  124. #define RTC_HOURFORMAT_12 (0x00000040U)
  125. #define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HOURFORMAT_12) || \
  126. ((FORMAT) == RTC_HOURFORMAT_24))
  127. /**
  128. * @}
  129. */
  130. /** @defgroup RTC_Output_Polarity_Definitions Outpout Polarity
  131. * @{
  132. */
  133. #define RTC_OUTPUT_POLARITY_HIGH (0x00000000U)
  134. #define RTC_OUTPUT_POLARITY_LOW (0x00100000U)
  135. #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \
  136. ((POL) == RTC_OUTPUT_POLARITY_LOW))
  137. /**
  138. * @}
  139. */
  140. /** @defgroup RTC_Output_Type_ALARM_OUT Alarm Output Type
  141. * @{
  142. */
  143. #define RTC_OUTPUT_TYPE_OPENDRAIN (0x00000000U)
  144. #define RTC_OUTPUT_TYPE_PUSHPULL (0x00040000U)
  145. #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \
  146. ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL))
  147. /**
  148. * @}
  149. */
  150. /** @defgroup RTC_Asynchronous_Predivider Asynchronous Predivider
  151. * @{
  152. */
  153. #define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7FU)
  154. /**
  155. * @}
  156. */
  157. /** @defgroup RTC_Time_Definitions Time Definitions
  158. * @{
  159. */
  160. #define IS_RTC_HOUR12(HOUR) (((HOUR) > 0U) && ((HOUR) <= 12U))
  161. #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23U)
  162. #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59U)
  163. #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59U)
  164. /**
  165. * @}
  166. */
  167. /** @defgroup RTC_AM_PM_Definitions AM PM Definitions
  168. * @{
  169. */
  170. #define RTC_HOURFORMAT12_AM ((uint8_t)0x00)
  171. #define RTC_HOURFORMAT12_PM ((uint8_t)0x40)
  172. #define IS_RTC_HOURFORMAT12(PM) (((PM) == RTC_HOURFORMAT12_AM) || ((PM) == RTC_HOURFORMAT12_PM))
  173. /**
  174. * @}
  175. */
  176. /** @defgroup RTC_DayLightSaving_Definitions DayLightSaving
  177. * @{
  178. */
  179. #define RTC_DAYLIGHTSAVING_SUB1H (0x00020000U)
  180. #define RTC_DAYLIGHTSAVING_ADD1H (0x00010000U)
  181. #define RTC_DAYLIGHTSAVING_NONE (0x00000000U)
  182. #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \
  183. ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \
  184. ((SAVE) == RTC_DAYLIGHTSAVING_NONE))
  185. /**
  186. * @}
  187. */
  188. /** @defgroup RTC_StoreOperation_Definitions StoreOperation
  189. * @{
  190. */
  191. #define RTC_STOREOPERATION_RESET (0x00000000U)
  192. #define RTC_STOREOPERATION_SET (0x00040000U)
  193. #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \
  194. ((OPERATION) == RTC_STOREOPERATION_SET))
  195. /**
  196. * @}
  197. */
  198. /** @defgroup RTC_Input_parameter_format_definitions Input Parameter Format
  199. * @{
  200. */
  201. #define RTC_FORMAT_BIN (0x000000000U)
  202. #define RTC_FORMAT_BCD (0x000000001U)
  203. #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || ((FORMAT) == RTC_FORMAT_BCD))
  204. /**
  205. * @}
  206. */
  207. /** @defgroup RTC_Year_Date_Definitions Year Definitions
  208. * @{
  209. */
  210. #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99U)
  211. /**
  212. * @}
  213. */
  214. /** @defgroup RTC_Month_Date_Definitions Month Definitions
  215. * @{
  216. */
  217. /* Coded in BCD format */
  218. #define RTC_MONTH_JANUARY ((uint8_t)0x01)
  219. #define RTC_MONTH_FEBRUARY ((uint8_t)0x02)
  220. #define RTC_MONTH_MARCH ((uint8_t)0x03)
  221. #define RTC_MONTH_APRIL ((uint8_t)0x04)
  222. #define RTC_MONTH_MAY ((uint8_t)0x05)
  223. #define RTC_MONTH_JUNE ((uint8_t)0x06)
  224. #define RTC_MONTH_JULY ((uint8_t)0x07)
  225. #define RTC_MONTH_AUGUST ((uint8_t)0x08)
  226. #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09)
  227. #define RTC_MONTH_OCTOBER ((uint8_t)0x10)
  228. #define RTC_MONTH_NOVEMBER ((uint8_t)0x11)
  229. #define RTC_MONTH_DECEMBER ((uint8_t)0x12)
  230. #define IS_RTC_MONTH(MONTH) (((MONTH) >= 1U) && ((MONTH) <= 12U))
  231. #define IS_RTC_DATE(DATE) (((DATE) >= 1U) && ((DATE) <= 31U))
  232. /**
  233. * @}
  234. */
  235. /** @defgroup RTC_WeekDay_Definitions WeekDay Definitions
  236. * @{
  237. */
  238. #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01)
  239. #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02)
  240. #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03)
  241. #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04)
  242. #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05)
  243. #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06)
  244. #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07)
  245. #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \
  246. ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \
  247. ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
  248. ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \
  249. ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \
  250. ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \
  251. ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
  252. /**
  253. * @}
  254. */
  255. /** @defgroup RTC_Alarm_Definitions Alarm Definitions
  256. * @{
  257. */
  258. #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0U) && ((DATE) <= 31U))
  259. #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \
  260. ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \
  261. ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
  262. ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \
  263. ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \
  264. ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \
  265. ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
  266. /**
  267. * @}
  268. */
  269. /** @defgroup RTC_AlarmDateWeekDay_Definitions AlarmDateWeekDay Definitions
  270. * @{
  271. */
  272. #define RTC_ALARMDATEWEEKDAYSEL_DATE (0x00000000U)
  273. #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY (0x40000000U)
  274. #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \
  275. ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY))
  276. /**
  277. * @}
  278. */
  279. /** @defgroup RTC_AlarmMask_Definitions Alarm Mask Definitions
  280. * @{
  281. */
  282. #define RTC_ALARMMASK_NONE (0x00000000U)
  283. #define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4
  284. #define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3
  285. #define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2
  286. #define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1
  287. #define RTC_ALARMMASK_ALL (0x80808080U)
  288. #define IS_RTC_ALARM_MASK(MASK) (((MASK) & 0x7F7F7F7F) == (uint32_t)RESET)
  289. /**
  290. * @}
  291. */
  292. /** @defgroup RTC_Alarms_Definitions Alarms Definitions
  293. * @{
  294. */
  295. #define RTC_ALARM_A RTC_CR_ALRAE
  296. #define RTC_ALARM_B RTC_CR_ALRBE
  297. #define IS_RTC_ALARM(ALARM) (((ALARM) == RTC_ALARM_A) || ((ALARM) == RTC_ALARM_B))
  298. /**
  299. * @}
  300. */
  301. /**
  302. * @}
  303. */
  304. /* Exported macro ------------------------------------------------------------*/
  305. /** @defgroup RTC_Exported_macros RTC Exported Macros
  306. * @{
  307. */
  308. /** @brief Reset RTC handle state
  309. * @param __HANDLE__: RTC handle.
  310. * @retval None
  311. */
  312. #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
  313. /**
  314. * @brief Disable the write protection for RTC registers.
  315. * @param __HANDLE__: specifies the RTC handle.
  316. * @retval None
  317. */
  318. #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) \
  319. do{ \
  320. (__HANDLE__)->Instance->WPR = 0xCA; \
  321. (__HANDLE__)->Instance->WPR = 0x53; \
  322. } while(0)
  323. /**
  324. * @brief Enable the write protection for RTC registers.
  325. * @param __HANDLE__: specifies the RTC handle.
  326. * @retval None
  327. */
  328. #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) \
  329. do{ \
  330. (__HANDLE__)->Instance->WPR = 0xFF; \
  331. } while(0)
  332. /**
  333. * @brief Enable the RTC ALARMA peripheral.
  334. * @param __HANDLE__: specifies the RTC handle.
  335. * @retval None
  336. */
  337. #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE))
  338. /**
  339. * @brief Disable the RTC ALARMA peripheral.
  340. * @param __HANDLE__: specifies the RTC handle.
  341. * @retval None
  342. */
  343. #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE))
  344. /**
  345. * @brief Enable the RTC ALARMB peripheral.
  346. * @param __HANDLE__: specifies the RTC handle.
  347. * @retval None
  348. */
  349. #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE))
  350. /**
  351. * @brief Disable the RTC ALARMB peripheral.
  352. * @param __HANDLE__: specifies the RTC handle.
  353. * @retval None
  354. */
  355. #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE))
  356. /**
  357. * @brief Enable the RTC Alarm interrupt.
  358. * @param __HANDLE__: specifies the RTC handle.
  359. * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled.
  360. * This parameter can be any combination of the following values:
  361. * @arg RTC_IT_ALRA: Alarm A interrupt
  362. * @arg RTC_IT_ALRB: Alarm B interrupt
  363. * @retval None
  364. */
  365. #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  366. /**
  367. * @brief Disable the RTC Alarm interrupt.
  368. * @param __HANDLE__: specifies the RTC handle.
  369. * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled.
  370. * This parameter can be any combination of the following values:
  371. * @arg RTC_IT_ALRA: Alarm A interrupt
  372. * @arg RTC_IT_ALRB: Alarm B interrupt
  373. * @retval None
  374. */
  375. #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  376. /**
  377. * @brief Check whether the specified RTC Alarm interrupt has occurred or not.
  378. * @param __HANDLE__: specifies the RTC handle.
  379. * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to check.
  380. * This parameter can be:
  381. * @arg RTC_IT_ALRA: Alarm A interrupt
  382. * @arg RTC_IT_ALRB: Alarm B interrupt
  383. * @retval None
  384. */
  385. #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR)& ((__INTERRUPT__)>> 4)) != RESET)? SET : RESET)
  386. /**
  387. * @brief Check whether the specified RTC Alarm interrupt has been enabled or not.
  388. * @param __HANDLE__: specifies the RTC handle.
  389. * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to check.
  390. * This parameter can be:
  391. * @arg RTC_IT_ALRA: Alarm A interrupt
  392. * @arg RTC_IT_ALRB: Alarm B interrupt
  393. * @retval None
  394. */
  395. #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != RESET) ? SET : RESET)
  396. /**
  397. * @brief Get the selected RTC Alarm's flag status.
  398. * @param __HANDLE__: specifies the RTC handle.
  399. * @param __FLAG__: specifies the RTC Alarm Flag sources to check.
  400. * This parameter can be:
  401. * @arg RTC_FLAG_ALRAF
  402. * @arg RTC_FLAG_ALRBF
  403. * @arg RTC_FLAG_ALRAWF
  404. * @arg RTC_FLAG_ALRBWF
  405. * @retval None
  406. */
  407. #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
  408. /**
  409. * @brief Clear the RTC Alarm's pending flags.
  410. * @param __HANDLE__: specifies the RTC handle.
  411. * @param __FLAG__: specifies the RTC Alarm Flag sources to clear.
  412. * This parameter can be:
  413. * @arg RTC_FLAG_ALRAF
  414. * @arg RTC_FLAG_ALRBF
  415. * @retval None
  416. */
  417. #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT) | ((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  418. /**
  419. * @brief Enable interrupt on the RTC Alarm associated Exti line.
  420. * @retval None
  421. */
  422. #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_ALARM_EVENT)
  423. /**
  424. * @brief Disable interrupt on the RTC Alarm associated Exti line.
  425. * @retval None
  426. */
  427. #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI->IMR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
  428. /**
  429. * @brief Enable event on the RTC Alarm associated Exti line.
  430. * @retval None.
  431. */
  432. #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_ALARM_EVENT)
  433. /**
  434. * @brief Disable event on the RTC Alarm associated Exti line.
  435. * @retval None.
  436. */
  437. #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
  438. /**
  439. * @brief Enable falling edge trigger on the RTC Alarm associated Exti line.
  440. * @retval None.
  441. */
  442. #define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_ALARM_EVENT)
  443. /**
  444. * @brief Disable falling edge trigger on the RTC Alarm associated Exti line.
  445. * @retval None.
  446. */
  447. #define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
  448. /**
  449. * @brief Enable rising edge trigger on the RTC Alarm associated Exti line.
  450. * @retval None.
  451. */
  452. #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_ALARM_EVENT)
  453. /**
  454. * @brief Disable rising edge trigger on the RTC Alarm associated Exti line.
  455. * @retval None.
  456. */
  457. #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
  458. /**
  459. * @brief Enable rising & falling edge trigger on the RTC Alarm associated Exti line.
  460. * @retval None.
  461. */
  462. #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() do { __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE();__HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE(); } while(0);
  463. /**
  464. * @brief Disable rising & falling edge trigger on the RTC Alarm associated Exti line.
  465. * @retval None.
  466. */
  467. #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() do { __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE();__HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE(); } while(0);
  468. /**
  469. * @brief Check whether the RTC Alarm associated Exti line interrupt flag is set or not.
  470. * @retval Line Status.
  471. */
  472. #define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_ALARM_EVENT)
  473. /**
  474. * @brief Clear the RTC Alarm associated Exti line flag.
  475. * @retval None.
  476. */
  477. #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_ALARM_EVENT)
  478. /**
  479. * @brief Generate a Software interrupt on RTC Alarm associated Exti line.
  480. * @retval None.
  481. */
  482. #define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_ALARM_EVENT)
  483. /**
  484. * @}
  485. */
  486. /* Include RTC HAL Extension module */
  487. #include "stm32l1xx_hal_rtc_ex.h"
  488. /* Exported functions --------------------------------------------------------*/
  489. /** @addtogroup RTC_Exported_Functions
  490. * @{
  491. */
  492. /* Initialization and de-initialization functions ****************************/
  493. /** @addtogroup RTC_Exported_Functions_Group1
  494. * @{
  495. */
  496. HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc);
  497. HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc);
  498. void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc);
  499. void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc);
  500. /**
  501. * @}
  502. */
  503. /* RTC Time and Date functions ************************************************/
  504. /** @addtogroup RTC_Exported_Functions_Group1
  505. * @{
  506. */
  507. HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
  508. HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
  509. HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
  510. HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
  511. /**
  512. * @}
  513. */
  514. /* RTC Alarm functions ********************************************************/
  515. /** @addtogroup RTC_Exported_Functions_Group2
  516. * @{
  517. */
  518. HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
  519. HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
  520. HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm);
  521. HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format);
  522. void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc);
  523. HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  524. void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc);
  525. /**
  526. * @}
  527. */
  528. /* Peripheral Control functions ***********************************************/
  529. /** @addtogroup RTC_Exported_Functions_Group3
  530. * @{
  531. */
  532. HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef* hrtc);
  533. /**
  534. * @}
  535. */
  536. /* Peripheral State functions *************************************************/
  537. /** @addtogroup RTC_Exported_Functions_Group5
  538. * @{
  539. */
  540. HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc);
  541. /**
  542. * @}
  543. */
  544. /**
  545. * @}
  546. */
  547. /* Private functions **********************************************************/
  548. /** @addtogroup RTC_Internal_Functions
  549. * @{
  550. */
  551. /* Private types -------------------------------------------------------------*/
  552. /* Private variables ---------------------------------------------------------*/
  553. /* Private constants ---------------------------------------------------------*/
  554. /** @defgroup RTC_Private_Constants RTC Private Constants
  555. * @{
  556. */
  557. #define RTC_EXTI_LINE_ALARM_EVENT ((uint32_t)EXTI_IMR_MR17) /*!< External interrupt line 17 Connected to the RTC Alarm event */
  558. /**
  559. * @}
  560. */
  561. /* Private macros ------------------------------------------------------------*/
  562. /** @defgroup RTC_Private_Macros RTC Private Macros
  563. * @{
  564. */
  565. /**
  566. * @}
  567. */
  568. /* Private functions ---------------------------------------------------------*/
  569. /** @defgroup RTC_Private_Functions RTC Private Functions
  570. * @{
  571. */
  572. HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef* hrtc);
  573. uint8_t RTC_ByteToBcd2(uint8_t Value);
  574. uint8_t RTC_Bcd2ToByte(uint8_t Value);
  575. /**
  576. * @}
  577. */
  578. /**
  579. * @}
  580. */
  581. /**
  582. * @}
  583. */
  584. /**
  585. * @}
  586. */
  587. #ifdef __cplusplus
  588. }
  589. #endif
  590. #endif /* __STM32L1xx_HAL_RTC_H */
  591. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/