stm32l0xx_hal_rtc.h 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947
  1. /**
  2. ******************************************************************************
  3. * @file stm32l0xx_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 STM32L0xx_HAL_RTC_H
  20. #define STM32L0xx_HAL_RTC_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32l0xx_hal_def.h"
  26. /** @addtogroup STM32L0xx_HAL_Driver
  27. * @{
  28. */
  29. /** @addtogroup RTC
  30. * @{
  31. */
  32. /* Exported types ------------------------------------------------------------*/
  33. /** @defgroup RTC_Exported_Types RTC Exported Types
  34. * @{
  35. */
  36. /**
  37. * @brief HAL State structures definition
  38. */
  39. typedef enum
  40. {
  41. HAL_RTC_STATE_RESET = 0x00U, /*!< RTC not yet initialized or disabled */
  42. HAL_RTC_STATE_READY = 0x01U, /*!< RTC initialized and ready for use */
  43. HAL_RTC_STATE_BUSY = 0x02U, /*!< RTC process is ongoing */
  44. HAL_RTC_STATE_TIMEOUT = 0x03U, /*!< RTC timeout state */
  45. HAL_RTC_STATE_ERROR = 0x04U /*!< RTC error state */
  46. } HAL_RTCStateTypeDef;
  47. /**
  48. * @brief RTC Configuration Structure definition
  49. */
  50. typedef struct
  51. {
  52. uint32_t HourFormat; /*!< Specifies the RTC Hour Format.
  53. This parameter can be a value of @ref RTC_Hour_Formats */
  54. uint32_t AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value.
  55. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */
  56. uint32_t SynchPrediv; /*!< Specifies the RTC Synchronous Predivider value.
  57. This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0x7FFF */
  58. uint32_t OutPut; /*!< Specifies which signal will be routed to the RTC output.
  59. This parameter can be a value of @ref RTC_Output_selection_Definitions */
  60. uint32_t OutPutRemap; /*!< Specifies the remap for RTC output.
  61. This parameter can be a value of @ref RTC_Output_ALARM_OUT_Remap */
  62. uint32_t OutPutPolarity; /*!< Specifies the polarity of the output signal.
  63. This parameter can be a value of @ref RTC_Output_Polarity_Definitions */
  64. uint32_t OutPutType; /*!< Specifies the RTC Output Pin mode.
  65. This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */
  66. } RTC_InitTypeDef;
  67. /**
  68. * @brief RTC Time structure definition
  69. */
  70. typedef struct
  71. {
  72. uint8_t Hours; /*!< Specifies the RTC Time Hour.
  73. This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected
  74. This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */
  75. uint8_t Minutes; /*!< Specifies the RTC Time Minutes.
  76. This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
  77. uint8_t Seconds; /*!< Specifies the RTC Time Seconds.
  78. This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
  79. uint8_t TimeFormat; /*!< Specifies the RTC AM/PM Time.
  80. This parameter can be a value of @ref RTC_AM_PM_Definitions */
  81. uint32_t SubSeconds; /*!< Specifies the RTC_SSR RTC Sub Second register content.
  82. This parameter corresponds to a time unit range between [0-1] Second
  83. with [1 Sec / SecondFraction +1] granularity */
  84. uint32_t SecondFraction; /*!< Specifies the range or granularity of Sub Second register content
  85. corresponding to Synchronous prescaler factor value (PREDIV_S)
  86. This parameter corresponds to a time unit range between [0-1] Second
  87. with [1 Sec / SecondFraction +1] granularity.
  88. This field will be used only by HAL_RTC_GetTime function */
  89. uint32_t DayLightSaving; /*!< This interface is deprecated. To manage Daylight
  90. Saving Time, please use HAL_RTC_DST_xxx functions */
  91. uint32_t StoreOperation; /*!< This interface is deprecated. To manage Daylight
  92. Saving Time, please use HAL_RTC_DST_xxx functions */
  93. } RTC_TimeTypeDef;
  94. /**
  95. * @brief RTC Date structure definition
  96. */
  97. typedef struct
  98. {
  99. uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay.
  100. This parameter can be a value of @ref RTC_WeekDay_Definitions */
  101. uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format).
  102. This parameter can be a value of @ref RTC_Month_Date_Definitions */
  103. uint8_t Date; /*!< Specifies the RTC Date.
  104. This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
  105. uint8_t Year; /*!< Specifies the RTC Date Year.
  106. This parameter must be a number between Min_Data = 0 and Max_Data = 99 */
  107. } RTC_DateTypeDef;
  108. /**
  109. * @brief RTC Alarm structure definition
  110. */
  111. typedef struct
  112. {
  113. RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */
  114. uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks.
  115. This parameter can be a value of @ref RTC_AlarmMask_Definitions */
  116. uint32_t AlarmSubSecondMask; /*!< Specifies the RTC Alarm SubSeconds Masks.
  117. This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */
  118. uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay.
  119. This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */
  120. uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay.
  121. If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range.
  122. If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */
  123. uint32_t Alarm; /*!< Specifies the alarm .
  124. This parameter can be a value of @ref RTC_Alarms_Definitions */
  125. } RTC_AlarmTypeDef;
  126. /**
  127. * @brief RTC Handle Structure definition
  128. */
  129. #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
  130. typedef struct __RTC_HandleTypeDef
  131. #else
  132. typedef struct
  133. #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
  134. {
  135. RTC_TypeDef *Instance; /*!< Register base address */
  136. RTC_InitTypeDef Init; /*!< RTC required parameters */
  137. HAL_LockTypeDef Lock; /*!< RTC locking object */
  138. __IO HAL_RTCStateTypeDef State; /*!< Time communication state */
  139. #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
  140. void (* AlarmAEventCallback) (struct __RTC_HandleTypeDef *hrtc); /*!< RTC Alarm A Event callback */
  141. void (* AlarmBEventCallback) (struct __RTC_HandleTypeDef *hrtc); /*!< RTC Alarm B Event callback */
  142. void (* TimeStampEventCallback) (struct __RTC_HandleTypeDef *hrtc); /*!< RTC Timestamp Event callback */
  143. void (* WakeUpTimerEventCallback) (struct __RTC_HandleTypeDef *hrtc); /*!< RTC WakeUpTimer Event callback */
  144. #if defined(RTC_TAMPER1_SUPPORT)
  145. void (* Tamper1EventCallback) (struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 1 Event callback */
  146. #endif /* RTC_TAMPER1_SUPPORT */
  147. void (* Tamper2EventCallback) (struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 2 Event callback */
  148. #if defined(RTC_TAMPER3_SUPPORT)
  149. void (* Tamper3EventCallback) (struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 3 Event callback */
  150. #endif /* RTC_TAMPER3_SUPPORT */
  151. void (* MspInitCallback) (struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp Init callback */
  152. void (* MspDeInitCallback) (struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp DeInit callback */
  153. #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
  154. } RTC_HandleTypeDef;
  155. #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
  156. /**
  157. * @brief HAL RTC Callback ID enumeration definition
  158. */
  159. typedef enum
  160. {
  161. HAL_RTC_ALARM_A_EVENT_CB_ID = 0x00U, /*!< RTC Alarm A Event Callback ID */
  162. HAL_RTC_ALARM_B_EVENT_CB_ID = 0x01U, /*!< RTC Alarm B Event Callback ID */
  163. HAL_RTC_TIMESTAMP_EVENT_CB_ID = 0x02U, /*!< RTC Timestamp Event Callback ID */
  164. HAL_RTC_WAKEUPTIMER_EVENT_CB_ID = 0x03U, /*!< RTC Wakeup Timer Event Callback ID */
  165. #if defined(RTC_TAMPER1_SUPPORT)
  166. HAL_RTC_TAMPER1_EVENT_CB_ID = 0x04U, /*!< RTC Tamper 1 Callback ID */
  167. #endif /* RTC_TAMPER1_SUPPORT */
  168. HAL_RTC_TAMPER2_EVENT_CB_ID = 0x05U, /*!< RTC Tamper 2 Callback ID */
  169. #if defined(RTC_TAMPER3_SUPPORT)
  170. HAL_RTC_TAMPER3_EVENT_CB_ID = 0x06U, /*!< RTC Tamper 3 Callback ID */
  171. #endif /* RTC_TAMPER3_SUPPORT */
  172. HAL_RTC_MSPINIT_CB_ID = 0x0EU, /*!< RTC Msp Init callback ID */
  173. HAL_RTC_MSPDEINIT_CB_ID = 0x0FU /*!< RTC Msp DeInit callback ID */
  174. } HAL_RTC_CallbackIDTypeDef;
  175. /**
  176. * @brief HAL RTC Callback pointer definition
  177. */
  178. typedef void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef *hrtc); /*!< pointer to an RTC callback function */
  179. #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
  180. /**
  181. * @}
  182. */
  183. /* Exported constants --------------------------------------------------------*/
  184. /** @defgroup RTC_Exported_Constants RTC Exported Constants
  185. * @{
  186. */
  187. /** @defgroup RTC_Hour_Formats RTC Hour Formats
  188. * @{
  189. */
  190. #define RTC_HOURFORMAT_24 0x00000000U
  191. #define RTC_HOURFORMAT_12 RTC_CR_FMT
  192. /**
  193. * @}
  194. */
  195. /** @defgroup RTC_Output_selection_Definitions RTC Output Selection Definitions
  196. * @{
  197. */
  198. #define RTC_OUTPUT_DISABLE 0x00000000U
  199. #define RTC_OUTPUT_ALARMA RTC_CR_OSEL_0
  200. #define RTC_OUTPUT_ALARMB RTC_CR_OSEL_1
  201. #define RTC_OUTPUT_WAKEUP RTC_CR_OSEL
  202. /**
  203. * @}
  204. */
  205. /** @defgroup RTC_Output_ALARM_OUT_Remap RTC Output ALARM OUT Remap
  206. * @{
  207. */
  208. #define RTC_OUTPUT_REMAP_NONE 0x00000000U
  209. #define RTC_OUTPUT_REMAP_POS1 RTC_OR_OUT_RMP
  210. /**
  211. * @}
  212. */
  213. /** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions
  214. * @{
  215. */
  216. #define RTC_OUTPUT_POLARITY_HIGH 0x00000000U
  217. #define RTC_OUTPUT_POLARITY_LOW RTC_CR_POL
  218. /**
  219. * @}
  220. */
  221. /** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT
  222. * @{
  223. */
  224. #define RTC_OUTPUT_TYPE_OPENDRAIN 0x00000000U
  225. #define RTC_OUTPUT_TYPE_PUSHPULL RTC_OR_ALARMOUTTYPE
  226. /**
  227. * @}
  228. */
  229. /** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions
  230. * @{
  231. */
  232. #define RTC_HOURFORMAT12_AM ((uint8_t)0x00)
  233. #define RTC_HOURFORMAT12_PM ((uint8_t)0x01)
  234. /**
  235. * @}
  236. */
  237. /** @defgroup RTC_DayLightSaving_Definitions RTC DayLight Saving Definitions
  238. * @{
  239. */
  240. #define RTC_DAYLIGHTSAVING_SUB1H RTC_CR_SUB1H
  241. #define RTC_DAYLIGHTSAVING_ADD1H RTC_CR_ADD1H
  242. #define RTC_DAYLIGHTSAVING_NONE 0x00000000U
  243. /**
  244. * @}
  245. */
  246. /** @defgroup RTC_StoreOperation_Definitions RTC Store Operation Definitions
  247. * @{
  248. */
  249. #define RTC_STOREOPERATION_RESET 0x00000000U
  250. #define RTC_STOREOPERATION_SET RTC_CR_BKP
  251. /**
  252. * @}
  253. */
  254. /** @defgroup RTC_Input_parameter_format_definitions RTC Input Parameter Format Definitions
  255. * @{
  256. */
  257. #define RTC_FORMAT_BIN 0x00000000U
  258. #define RTC_FORMAT_BCD 0x00000001U
  259. /**
  260. * @}
  261. */
  262. /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions (in BCD format)
  263. * @{
  264. */
  265. #define RTC_MONTH_JANUARY ((uint8_t)0x01)
  266. #define RTC_MONTH_FEBRUARY ((uint8_t)0x02)
  267. #define RTC_MONTH_MARCH ((uint8_t)0x03)
  268. #define RTC_MONTH_APRIL ((uint8_t)0x04)
  269. #define RTC_MONTH_MAY ((uint8_t)0x05)
  270. #define RTC_MONTH_JUNE ((uint8_t)0x06)
  271. #define RTC_MONTH_JULY ((uint8_t)0x07)
  272. #define RTC_MONTH_AUGUST ((uint8_t)0x08)
  273. #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09)
  274. #define RTC_MONTH_OCTOBER ((uint8_t)0x10)
  275. #define RTC_MONTH_NOVEMBER ((uint8_t)0x11)
  276. #define RTC_MONTH_DECEMBER ((uint8_t)0x12)
  277. /**
  278. * @}
  279. */
  280. /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions
  281. * @{
  282. */
  283. #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01)
  284. #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02)
  285. #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03)
  286. #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04)
  287. #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05)
  288. #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06)
  289. #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07)
  290. /**
  291. * @}
  292. */
  293. /** @defgroup RTC_AlarmDateWeekDay_Definitions RTC Alarm Date WeekDay Definitions
  294. * @{
  295. */
  296. #define RTC_ALARMDATEWEEKDAYSEL_DATE 0x00000000U
  297. #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL
  298. /**
  299. * @}
  300. */
  301. /** @defgroup RTC_AlarmMask_Definitions RTC Alarm Mask Definitions
  302. * @{
  303. */
  304. #define RTC_ALARMMASK_NONE 0x00000000U
  305. #define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4
  306. #define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3
  307. #define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2
  308. #define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1
  309. #define RTC_ALARMMASK_ALL (RTC_ALARMMASK_DATEWEEKDAY | \
  310. RTC_ALARMMASK_HOURS | \
  311. RTC_ALARMMASK_MINUTES | \
  312. RTC_ALARMMASK_SECONDS)
  313. /**
  314. * @}
  315. */
  316. /** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions
  317. * @{
  318. */
  319. #define RTC_ALARM_A RTC_CR_ALRAE
  320. #define RTC_ALARM_B RTC_CR_ALRBE
  321. /**
  322. * @}
  323. */
  324. /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions RTC Alarm Sub Seconds Masks Definitions
  325. * @{
  326. */
  327. /*!< All Alarm SS fields are masked. There is no comparison on sub seconds for Alarm */
  328. #define RTC_ALARMSUBSECONDMASK_ALL 0x00000000U
  329. /*!< SS[14:1] are don't care in Alarm comparison. Only SS[0] is compared. */
  330. #define RTC_ALARMSUBSECONDMASK_SS14_1 RTC_ALRMASSR_MASKSS_0
  331. /*!< SS[14:2] are don't care in Alarm comparison. Only SS[1:0] are compared. */
  332. #define RTC_ALARMSUBSECONDMASK_SS14_2 RTC_ALRMASSR_MASKSS_1
  333. /*!< SS[14:3] are don't care in Alarm comparison. Only SS[2:0] are compared. */
  334. #define RTC_ALARMSUBSECONDMASK_SS14_3 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1)
  335. /*!< SS[14:4] are don't care in Alarm comparison. Only SS[3:0] are compared. */
  336. #define RTC_ALARMSUBSECONDMASK_SS14_4 RTC_ALRMASSR_MASKSS_2
  337. /*!< SS[14:5] are don't care in Alarm comparison. Only SS[4:0] are compared. */
  338. #define RTC_ALARMSUBSECONDMASK_SS14_5 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2)
  339. /*!< SS[14:6] are don't care in Alarm comparison. Only SS[5:0] are compared. */
  340. #define RTC_ALARMSUBSECONDMASK_SS14_6 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)
  341. /*!< SS[14:7] are don't care in Alarm comparison. Only SS[6:0] are compared. */
  342. #define RTC_ALARMSUBSECONDMASK_SS14_7 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)
  343. /*!< SS[14:8] are don't care in Alarm comparison. Only SS[7:0] are compared. */
  344. #define RTC_ALARMSUBSECONDMASK_SS14_8 RTC_ALRMASSR_MASKSS_3
  345. /*!< SS[14:9] are don't care in Alarm comparison. Only SS[8:0] are compared. */
  346. #define RTC_ALARMSUBSECONDMASK_SS14_9 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_3)
  347. /*!< SS[14:10] are don't care in Alarm comparison. Only SS[9:0] are compared. */
  348. #define RTC_ALARMSUBSECONDMASK_SS14_10 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)
  349. /*!< SS[14:11] are don't care in Alarm comparison. Only SS[10:0] are compared. */
  350. #define RTC_ALARMSUBSECONDMASK_SS14_11 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)
  351. /*!< SS[14:12] are don't care in Alarm comparison. Only SS[11:0] are compared. */
  352. #define RTC_ALARMSUBSECONDMASK_SS14_12 (RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)
  353. /*!< SS[14:13] are don't care in Alarm comparison. Only SS[12:0] are compared. */
  354. #define RTC_ALARMSUBSECONDMASK_SS14_13 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)
  355. /*!< SS[14] is don't care in Alarm comparison. Only SS[13:0] are compared. */
  356. #define RTC_ALARMSUBSECONDMASK_SS14 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)
  357. /*!< SS[14:0] are compared and must match to activate alarm. */
  358. #define RTC_ALARMSUBSECONDMASK_NONE RTC_ALRMASSR_MASKSS
  359. /**
  360. * @}
  361. */
  362. /** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions
  363. * @{
  364. */
  365. #define RTC_IT_TS RTC_CR_TSIE /*!< Enable Timestamp Interrupt */
  366. #define RTC_IT_WUT RTC_CR_WUTIE /*!< Enable Wakeup timer Interrupt */
  367. #define RTC_IT_ALRB RTC_CR_ALRBIE /*!< Enable Alarm B Interrupt */
  368. #define RTC_IT_ALRA RTC_CR_ALRAIE /*!< Enable Alarm A Interrupt */
  369. /**
  370. * @}
  371. */
  372. /** @defgroup RTC_Flags_Definitions RTC Flags Definitions
  373. * @{
  374. */
  375. #define RTC_FLAG_RECALPF RTC_ISR_RECALPF /*!< Recalibration pending flag */
  376. #if defined(RTC_TAMPER3_SUPPORT)
  377. #define RTC_FLAG_TAMP3F RTC_ISR_TAMP3F /*!< Tamper 3 event flag */
  378. #endif /* RTC_TAMPER3_SUPPORT */
  379. #define RTC_FLAG_TAMP2F RTC_ISR_TAMP2F /*!< Tamper 2 event flag */
  380. #if defined(RTC_TAMPER1_SUPPORT)
  381. #define RTC_FLAG_TAMP1F RTC_ISR_TAMP1F /*!< Tamper 1 event flag */
  382. #endif /* RTC_TAMPER1_SUPPORT */
  383. #define RTC_FLAG_TSOVF RTC_ISR_TSOVF /*!< Timestamp overflow flag */
  384. #define RTC_FLAG_TSF RTC_ISR_TSF /*!< Timestamp event flag */
  385. #define RTC_FLAG_WUTF RTC_ISR_WUTF /*!< Wakeup timer event flag */
  386. #define RTC_FLAG_ALRBF RTC_ISR_ALRBF /*!< Alarm B event flag */
  387. #define RTC_FLAG_ALRAF RTC_ISR_ALRAF /*!< Alarm A event flag */
  388. #define RTC_FLAG_INITF RTC_ISR_INITF /*!< RTC in initialization mode flag */
  389. #define RTC_FLAG_RSF RTC_ISR_RSF /*!< Register synchronization flag */
  390. #define RTC_FLAG_INITS RTC_ISR_INITS /*!< RTC initialization status flag */
  391. #define RTC_FLAG_SHPF RTC_ISR_SHPF /*!< Shift operation pending flag */
  392. #define RTC_FLAG_WUTWF RTC_ISR_WUTWF /*!< WUTR register write allowance flag */
  393. #define RTC_FLAG_ALRBWF RTC_ISR_ALRBWF /*!< ALRMBR register write allowance flag */
  394. #define RTC_FLAG_ALRAWF RTC_ISR_ALRAWF /*!< ALRMAR register write allowance flag */
  395. /**
  396. * @}
  397. */
  398. /**
  399. * @}
  400. */
  401. /* Exported macros -----------------------------------------------------------*/
  402. /** @defgroup RTC_Exported_Macros RTC Exported Macros
  403. * @{
  404. */
  405. /** @brief Reset RTC handle state
  406. * @param __HANDLE__ specifies the RTC handle.
  407. * @retval None
  408. */
  409. #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
  410. #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do { \
  411. (__HANDLE__)->State = HAL_RTC_STATE_RESET; \
  412. (__HANDLE__)->MspInitCallback = NULL; \
  413. (__HANDLE__)->MspDeInitCallback = NULL; \
  414. } while(0U)
  415. #else
  416. #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
  417. #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
  418. /**
  419. * @brief Disable the write protection for RTC registers.
  420. * @param __HANDLE__ specifies the RTC handle.
  421. * @retval None
  422. */
  423. #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) do { \
  424. (__HANDLE__)->Instance->WPR = 0xCAU; \
  425. (__HANDLE__)->Instance->WPR = 0x53U; \
  426. } while(0U)
  427. /**
  428. * @brief Enable the write protection for RTC registers.
  429. * @param __HANDLE__ specifies the RTC handle.
  430. * @retval None
  431. */
  432. #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) do { \
  433. (__HANDLE__)->Instance->WPR = 0xFFU; \
  434. } while(0U)
  435. /**
  436. * @brief Check whether the RTC Calendar is initialized.
  437. * @param __HANDLE__ specifies the RTC handle.
  438. * @retval None
  439. */
  440. #define __HAL_RTC_IS_CALENDAR_INITIALIZED(__HANDLE__) (((((__HANDLE__)->Instance->ISR) & (RTC_FLAG_INITS)) == RTC_FLAG_INITS) ? 1U : 0U)
  441. /**
  442. * @brief Enable the RTC ALARMA peripheral.
  443. * @param __HANDLE__ specifies the RTC handle.
  444. * @retval None
  445. */
  446. #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE))
  447. /**
  448. * @brief Disable the RTC ALARMA peripheral.
  449. * @param __HANDLE__ specifies the RTC handle.
  450. * @retval None
  451. */
  452. #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE))
  453. /**
  454. * @brief Enable the RTC ALARMB peripheral.
  455. * @param __HANDLE__ specifies the RTC handle.
  456. * @retval None
  457. */
  458. #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE))
  459. /**
  460. * @brief Disable the RTC ALARMB peripheral.
  461. * @param __HANDLE__ specifies the RTC handle.
  462. * @retval None
  463. */
  464. #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE))
  465. /**
  466. * @brief Enable the RTC Alarm interrupt.
  467. * @param __HANDLE__ specifies the RTC handle.
  468. * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
  469. * This parameter can be any combination of the following values:
  470. * @arg RTC_IT_ALRA: Alarm A interrupt
  471. * @arg RTC_IT_ALRB: Alarm B interrupt
  472. * @retval None
  473. */
  474. #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  475. /**
  476. * @brief Disable the RTC Alarm interrupt.
  477. * @param __HANDLE__ specifies the RTC handle.
  478. * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
  479. * This parameter can be any combination of the following values:
  480. * @arg RTC_IT_ALRA: Alarm A interrupt
  481. * @arg RTC_IT_ALRB: Alarm B interrupt
  482. * @retval None
  483. */
  484. #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  485. /**
  486. * @brief Check whether the specified RTC Alarm interrupt has occurred or not.
  487. * @param __HANDLE__ specifies the RTC handle.
  488. * @param __INTERRUPT__ specifies the RTC Alarm interrupt to check.
  489. * This parameter can be:
  490. * @arg RTC_IT_ALRA: Alarm A interrupt
  491. * @arg RTC_IT_ALRB: Alarm B interrupt
  492. * @retval None
  493. */
  494. #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__) >> 4U)) != 0U) ? 1U : 0U)
  495. /**
  496. * @brief Get the selected RTC Alarm's flag status.
  497. * @param __HANDLE__ specifies the RTC handle.
  498. * @param __FLAG__ specifies the RTC Alarm Flag to check.
  499. * This parameter can be:
  500. * @arg RTC_FLAG_ALRAF: Alarm A interrupt flag
  501. * @arg RTC_FLAG_ALRAWF: Alarm A 'write allowed' flag
  502. * @arg RTC_FLAG_ALRBF: Alarm B interrupt flag
  503. * @arg RTC_FLAG_ALRBWF: Alarm B 'write allowed' flag
  504. * @retval None
  505. */
  506. #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U)
  507. /**
  508. * @brief Clear the RTC Alarm's pending flags.
  509. * @param __HANDLE__ specifies the RTC handle.
  510. * @param __FLAG__ specifies the RTC Alarm flag to be cleared.
  511. * This parameter can be:
  512. * @arg RTC_FLAG_ALRAF
  513. * @arg RTC_FLAG_ALRBF
  514. * @retval None
  515. */
  516. #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  517. /**
  518. * @brief Check whether the specified RTC Alarm interrupt has been enabled or not.
  519. * @param __HANDLE__ specifies the RTC handle.
  520. * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check.
  521. * This parameter can be:
  522. * @arg RTC_IT_ALRA: Alarm A interrupt
  523. * @arg RTC_IT_ALRB: Alarm B interrupt
  524. * @retval None
  525. */
  526. #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
  527. /**
  528. * @brief Enable interrupt on the RTC Alarm associated EXTI line.
  529. * @retval None
  530. */
  531. #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_ALARM_EVENT)
  532. /**
  533. * @brief Disable interrupt on the RTC Alarm associated EXTI line.
  534. * @retval None
  535. */
  536. #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI->IMR &= ~RTC_EXTI_LINE_ALARM_EVENT)
  537. /**
  538. * @brief Enable event on the RTC Alarm associated EXTI line.
  539. * @retval None.
  540. */
  541. #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_ALARM_EVENT)
  542. /**
  543. * @brief Disable event on the RTC Alarm associated EXTI line.
  544. * @retval None.
  545. */
  546. #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~RTC_EXTI_LINE_ALARM_EVENT)
  547. /**
  548. * @brief Enable falling edge trigger on the RTC Alarm associated EXTI line.
  549. * @retval None.
  550. */
  551. #define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_ALARM_EVENT)
  552. /**
  553. * @brief Disable falling edge trigger on the RTC Alarm associated EXTI line.
  554. * @retval None.
  555. */
  556. #define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~RTC_EXTI_LINE_ALARM_EVENT)
  557. /**
  558. * @brief Enable rising edge trigger on the RTC Alarm associated EXTI line.
  559. * @retval None.
  560. */
  561. #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_ALARM_EVENT)
  562. /**
  563. * @brief Disable rising edge trigger on the RTC Alarm associated EXTI line.
  564. * @retval None.
  565. */
  566. #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~RTC_EXTI_LINE_ALARM_EVENT)
  567. /**
  568. * @brief Enable rising & falling edge trigger on the RTC Alarm associated EXTI line.
  569. * @retval None.
  570. */
  571. #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  572. __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE(); \
  573. __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE(); \
  574. } while(0U)
  575. /**
  576. * @brief Disable rising & falling edge trigger on the RTC Alarm associated EXTI line.
  577. * @retval None.
  578. */
  579. #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  580. __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE(); \
  581. __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE(); \
  582. } while(0U)
  583. /**
  584. * @brief Check whether the RTC Alarm associated EXTI line interrupt flag is set or not.
  585. * @retval Line Status.
  586. */
  587. #define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_ALARM_EVENT)
  588. /**
  589. * @brief Clear the RTC Alarm associated EXTI line flag.
  590. * @retval None.
  591. */
  592. #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_ALARM_EVENT)
  593. /**
  594. * @brief Generate a Software interrupt on RTC Alarm associated EXTI line.
  595. * @retval None.
  596. */
  597. #define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_ALARM_EVENT)
  598. /**
  599. * @}
  600. */
  601. /* Include RTC HAL Extended module */
  602. #include "stm32l0xx_hal_rtc_ex.h"
  603. /* Exported functions --------------------------------------------------------*/
  604. /** @addtogroup RTC_Exported_Functions
  605. * @{
  606. */
  607. /** @addtogroup RTC_Exported_Functions_Group1
  608. * @{
  609. */
  610. /* Initialization and de-initialization functions ****************************/
  611. HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc);
  612. HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc);
  613. void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc);
  614. void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc);
  615. /* Callbacks Register/UnRegister functions ***********************************/
  616. #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
  617. HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback);
  618. HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID);
  619. #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
  620. /**
  621. * @}
  622. */
  623. /** @addtogroup RTC_Exported_Functions_Group2
  624. * @{
  625. */
  626. /* RTC Time and Date functions ************************************************/
  627. HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
  628. HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
  629. HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
  630. HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
  631. /**
  632. * @}
  633. */
  634. /** @addtogroup RTC_Exported_Functions_Group3
  635. * @{
  636. */
  637. /* RTC Alarm functions ********************************************************/
  638. HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
  639. HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
  640. HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm);
  641. HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format);
  642. void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc);
  643. HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  644. void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc);
  645. /**
  646. * @}
  647. */
  648. /** @addtogroup RTC_Exported_Functions_Group4
  649. * @{
  650. */
  651. /* Peripheral Control functions ***********************************************/
  652. HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc);
  653. /* RTC Daylight Saving Time functions *****************************************/
  654. void HAL_RTC_DST_Add1Hour(RTC_HandleTypeDef *hrtc);
  655. void HAL_RTC_DST_Sub1Hour(RTC_HandleTypeDef *hrtc);
  656. void HAL_RTC_DST_SetStoreOperation(RTC_HandleTypeDef *hrtc);
  657. void HAL_RTC_DST_ClearStoreOperation(RTC_HandleTypeDef *hrtc);
  658. uint32_t HAL_RTC_DST_ReadStoreOperation(RTC_HandleTypeDef *hrtc);
  659. /**
  660. * @}
  661. */
  662. /** @addtogroup RTC_Exported_Functions_Group5
  663. * @{
  664. */
  665. /* Peripheral State functions *************************************************/
  666. HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc);
  667. /**
  668. * @}
  669. */
  670. /**
  671. * @}
  672. */
  673. /* Private types -------------------------------------------------------------*/
  674. /* Private variables ---------------------------------------------------------*/
  675. /* Private constants ---------------------------------------------------------*/
  676. /** @defgroup RTC_Private_Constants RTC Private Constants
  677. * @{
  678. */
  679. /* Masks Definition */
  680. #define RTC_TR_RESERVED_MASK ((uint32_t)(RTC_TR_HT | RTC_TR_HU | \
  681. RTC_TR_MNT | RTC_TR_MNU | \
  682. RTC_TR_ST | RTC_TR_SU | \
  683. RTC_TR_PM))
  684. #define RTC_DR_RESERVED_MASK ((uint32_t)(RTC_DR_YT | RTC_DR_YU | \
  685. RTC_DR_MT | RTC_DR_MU | \
  686. RTC_DR_DT | RTC_DR_DU | \
  687. RTC_DR_WDU))
  688. #define RTC_ISR_RESERVED_MASK ((uint32_t)(RTC_FLAGS_MASK | RTC_ISR_INIT))
  689. #define RTC_INIT_MASK 0xFFFFFFFFU
  690. #define RTC_RSF_MASK ((uint32_t)~(RTC_ISR_INIT | RTC_ISR_RSF))
  691. #define RTC_FLAGS_MASK ((uint32_t)(RTC_FLAG_INITF | RTC_FLAG_INITS | \
  692. RTC_FLAG_ALRAF | RTC_FLAG_ALRAWF | \
  693. RTC_FLAG_ALRBF | RTC_FLAG_ALRBWF | \
  694. RTC_FLAG_WUTF | RTC_FLAG_WUTWF | \
  695. RTC_FLAG_RECALPF | RTC_FLAG_SHPF | \
  696. RTC_FLAG_TSF | RTC_FLAG_TSOVF | \
  697. RTC_FLAG_RSF | RTC_TAMPER_FLAGS_MASK))
  698. #define RTC_TIMEOUT_VALUE 1000U
  699. #define RTC_EXTI_LINE_ALARM_EVENT EXTI_IMR_IM17 /*!< External interrupt line 17 Connected to the RTC Alarm event */
  700. /**
  701. * @}
  702. */
  703. /* Private macros ------------------------------------------------------------*/
  704. /** @defgroup RTC_Private_Macros RTC Private Macros
  705. * @{
  706. */
  707. /** @defgroup RTC_IS_RTC_Definitions RTC Private macros to check input parameters
  708. * @{
  709. */
  710. #define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HOURFORMAT_12) || \
  711. ((FORMAT) == RTC_HOURFORMAT_24))
  712. #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
  713. ((OUTPUT) == RTC_OUTPUT_ALARMA) || \
  714. ((OUTPUT) == RTC_OUTPUT_ALARMB) || \
  715. ((OUTPUT) == RTC_OUTPUT_WAKEUP))
  716. #define IS_RTC_OUTPUT_REMAP(REMAP) (((REMAP) == RTC_OUTPUT_REMAP_NONE) || \
  717. ((REMAP) == RTC_OUTPUT_REMAP_POS1))
  718. #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \
  719. ((POL) == RTC_OUTPUT_POLARITY_LOW))
  720. #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \
  721. ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL))
  722. #define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7FU)
  723. #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7FFFU)
  724. #define IS_RTC_HOUR12(HOUR) (((HOUR) > 0U) && ((HOUR) <= 12U))
  725. #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23U)
  726. #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59U)
  727. #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59U)
  728. #define IS_RTC_HOURFORMAT12(PM) (((PM) == RTC_HOURFORMAT12_AM) || \
  729. ((PM) == RTC_HOURFORMAT12_PM))
  730. #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \
  731. ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \
  732. ((SAVE) == RTC_DAYLIGHTSAVING_NONE))
  733. #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \
  734. ((OPERATION) == RTC_STOREOPERATION_SET))
  735. #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || ((FORMAT) == RTC_FORMAT_BCD))
  736. #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99U)
  737. #define IS_RTC_MONTH(MONTH) (((MONTH) >= 1U) && ((MONTH) <= 12U))
  738. #define IS_RTC_DATE(DATE) (((DATE) >= 1U) && ((DATE) <= 31U))
  739. #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \
  740. ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \
  741. ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
  742. ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \
  743. ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \
  744. ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \
  745. ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
  746. #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0U) && ((DATE) <= 31U))
  747. #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \
  748. ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \
  749. ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
  750. ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \
  751. ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \
  752. ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \
  753. ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
  754. #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \
  755. ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY))
  756. #define IS_RTC_ALARM_MASK(MASK) (((MASK) & ((uint32_t)~RTC_ALARMMASK_ALL)) == 0U)
  757. #define IS_RTC_ALARM(ALARM) (((ALARM) == RTC_ALARM_A) || ((ALARM) == RTC_ALARM_B))
  758. #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= RTC_ALRMASSR_SS)
  759. #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == RTC_ALARMSUBSECONDMASK_ALL) || \
  760. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_1) || \
  761. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_2) || \
  762. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_3) || \
  763. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_4) || \
  764. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_5) || \
  765. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_6) || \
  766. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_7) || \
  767. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_8) || \
  768. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_9) || \
  769. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_10) || \
  770. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_11) || \
  771. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_12) || \
  772. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_13) || \
  773. ((MASK) == RTC_ALARMSUBSECONDMASK_SS14) || \
  774. ((MASK) == RTC_ALARMSUBSECONDMASK_NONE))
  775. /**
  776. * @}
  777. */
  778. /**
  779. * @}
  780. */
  781. /* Private functions ---------------------------------------------------------*/
  782. /** @defgroup RTC_Private_Functions RTC Private Functions
  783. * @{
  784. */
  785. HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef *hrtc);
  786. HAL_StatusTypeDef RTC_ExitInitMode(RTC_HandleTypeDef *hrtc);
  787. uint8_t RTC_ByteToBcd2(uint8_t number);
  788. uint8_t RTC_Bcd2ToByte(uint8_t number);
  789. /**
  790. * @}
  791. */
  792. /**
  793. * @}
  794. */
  795. /**
  796. * @}
  797. */
  798. #ifdef __cplusplus
  799. }
  800. #endif
  801. #endif /* STM32L0xx_HAL_RTC_H */