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.
 
 
 

953 lines
38 KiB

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