You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

982 lines
42 KiB

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