stm32f0xx_hal_rtc.h 39 KB

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