stm32f3xx_hal_rtc.h 39 KB

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