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.
 
 
 

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