stm32l1xx_hal_rtc.h 23 KB

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