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.
 
 
 

814 lines
34 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f7xx_hal_rtc.h
  4. * @author MCD Application Team
  5. * @version V1.2.2
  6. * @date 14-April-2017
  7. * @brief Header file of RTC HAL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32F7xx_HAL_RTC_H
  39. #define __STM32F7xx_HAL_RTC_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32f7xx_hal_def.h"
  45. /** @addtogroup STM32F7xx_HAL_Driver
  46. * @{
  47. */
  48. /** @addtogroup RTC
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /** @defgroup RTC_Exported_Types RTC Exported Types
  53. * @{
  54. */
  55. /**
  56. * @brief HAL State structures definition
  57. */
  58. typedef enum
  59. {
  60. HAL_RTC_STATE_RESET = 0x00U, /*!< RTC not yet initialized or disabled */
  61. HAL_RTC_STATE_READY = 0x01U, /*!< RTC initialized and ready for use */
  62. HAL_RTC_STATE_BUSY = 0x02U, /*!< RTC process is ongoing */
  63. HAL_RTC_STATE_TIMEOUT = 0x03U, /*!< RTC timeout state */
  64. HAL_RTC_STATE_ERROR = 0x04U /*!< RTC error state */
  65. }HAL_RTCStateTypeDef;
  66. /**
  67. * @brief RTC Configuration Structure definition
  68. */
  69. typedef struct
  70. {
  71. uint32_t HourFormat; /*!< Specifies the RTC Hour Format.
  72. This parameter can be a value of @ref RTC_Hour_Formats */
  73. uint32_t AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value.
  74. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */
  75. uint32_t SynchPrediv; /*!< Specifies the RTC Synchronous Predivider value.
  76. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF */
  77. uint32_t OutPut; /*!< Specifies which signal will be routed to the RTC output.
  78. This parameter can be a value of @ref RTCEx_Output_selection_Definitions */
  79. uint32_t OutPutPolarity; /*!< Specifies the polarity of the output signal.
  80. This parameter can be a value of @ref RTC_Output_Polarity_Definitions */
  81. uint32_t OutPutType; /*!< Specifies the RTC Output Pin mode.
  82. This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */
  83. }RTC_InitTypeDef;
  84. /**
  85. * @brief RTC Time structure definition
  86. */
  87. typedef struct
  88. {
  89. uint8_t Hours; /*!< Specifies the RTC Time Hour.
  90. This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected.
  91. This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */
  92. uint8_t Minutes; /*!< Specifies the RTC Time Minutes.
  93. This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
  94. uint8_t Seconds; /*!< Specifies the RTC Time Seconds.
  95. This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
  96. uint32_t SubSeconds; /*!< Specifies the RTC_SSR RTC Sub Second register content.
  97. This parameter corresponds to a time unit range between [0-1] Second
  98. with [1 Sec / SecondFraction +1] granularity */
  99. uint32_t SecondFraction; /*!< Specifies the range or granularity of Sub Second register content
  100. corresponding to Synchronous pre-scaler factor value (PREDIV_S)
  101. This parameter corresponds to a time unit range between [0-1] Second
  102. with [1 Sec / SecondFraction +1] granularity.
  103. This field will be used only by HAL_RTC_GetTime function */
  104. uint8_t TimeFormat; /*!< Specifies the RTC AM/PM Time.
  105. This parameter can be a value of @ref RTC_AM_PM_Definitions */
  106. uint32_t DayLightSaving; /*!< Specifies RTC_DayLightSaveOperation: the value of hour adjustment.
  107. This parameter can be a value of @ref RTC_DayLightSaving_Definitions */
  108. uint32_t StoreOperation; /*!< Specifies RTC_StoreOperation value to be written in the BCK bit
  109. in CR register to store the operation.
  110. This parameter can be a value of @ref RTC_StoreOperation_Definitions */
  111. }RTC_TimeTypeDef;
  112. /**
  113. * @brief RTC Date structure definition
  114. */
  115. typedef struct
  116. {
  117. uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay.
  118. This parameter can be a value of @ref RTC_WeekDay_Definitions */
  119. uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format).
  120. This parameter can be a value of @ref RTC_Month_Date_Definitions */
  121. uint8_t Date; /*!< Specifies the RTC Date.
  122. This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
  123. uint8_t Year; /*!< Specifies the RTC Date Year.
  124. This parameter must be a number between Min_Data = 0 and Max_Data = 99 */
  125. }RTC_DateTypeDef;
  126. /**
  127. * @brief RTC Alarm structure definition
  128. */
  129. typedef struct
  130. {
  131. RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */
  132. uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks.
  133. This parameter can be a value of @ref RTC_AlarmMask_Definitions */
  134. uint32_t AlarmSubSecondMask; /*!< Specifies the RTC Alarm SubSeconds Masks.
  135. This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */
  136. uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay.
  137. This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */
  138. uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay.
  139. If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range.
  140. If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */
  141. uint32_t Alarm; /*!< Specifies the alarm .
  142. This parameter can be a value of @ref RTC_Alarms_Definitions */
  143. }RTC_AlarmTypeDef;
  144. /**
  145. * @brief RTC Handle Structure definition
  146. */
  147. typedef struct
  148. {
  149. RTC_TypeDef *Instance; /*!< Register base address */
  150. RTC_InitTypeDef Init; /*!< RTC required parameters */
  151. HAL_LockTypeDef Lock; /*!< RTC locking object */
  152. __IO HAL_RTCStateTypeDef State; /*!< Time communication state */
  153. }RTC_HandleTypeDef;
  154. /**
  155. * @}
  156. */
  157. /* Exported constants --------------------------------------------------------*/
  158. /** @defgroup RTC_Exported_Constants RTC Exported Constants
  159. * @{
  160. */
  161. /** @defgroup RTC_Hour_Formats RTC Hour Formats
  162. * @{
  163. */
  164. #define RTC_HOURFORMAT_24 0x00000000U
  165. #define RTC_HOURFORMAT_12 0x00000040U
  166. /**
  167. * @}
  168. */
  169. /** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions
  170. * @{
  171. */
  172. #define RTC_OUTPUT_POLARITY_HIGH 0x00000000U
  173. #define RTC_OUTPUT_POLARITY_LOW 0x00100000U
  174. /**
  175. * @}
  176. */
  177. /** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT
  178. * @{
  179. */
  180. #define RTC_OUTPUT_TYPE_OPENDRAIN 0x00000000U
  181. #define RTC_OUTPUT_TYPE_PUSHPULL RTC_OR_ALARMTYPE /* 0x00000008 */
  182. /**
  183. * @}
  184. */
  185. /** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions
  186. * @{
  187. */
  188. #define RTC_HOURFORMAT12_AM ((uint8_t)0x00U)
  189. #define RTC_HOURFORMAT12_PM ((uint8_t)0x40U)
  190. /**
  191. * @}
  192. */
  193. /** @defgroup RTC_DayLightSaving_Definitions RTC DayLight Saving Definitions
  194. * @{
  195. */
  196. #define RTC_DAYLIGHTSAVING_SUB1H 0x00020000U
  197. #define RTC_DAYLIGHTSAVING_ADD1H 0x00010000U
  198. #define RTC_DAYLIGHTSAVING_NONE 0x00000000U
  199. /**
  200. * @}
  201. */
  202. /** @defgroup RTC_StoreOperation_Definitions RTC Store Operation Definitions
  203. * @{
  204. */
  205. #define RTC_STOREOPERATION_RESET 0x00000000U
  206. #define RTC_STOREOPERATION_SET 0x00040000U
  207. /**
  208. * @}
  209. */
  210. /** @defgroup RTC_Input_parameter_format_definitions RTC Input Parameter Format Definitions
  211. * @{
  212. */
  213. #define RTC_FORMAT_BIN 0x00000000U
  214. #define RTC_FORMAT_BCD 0x00000001U
  215. /**
  216. * @}
  217. */
  218. /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions
  219. * @{
  220. */
  221. /* Coded in BCD format */
  222. #define RTC_MONTH_JANUARY ((uint8_t)0x01U)
  223. #define RTC_MONTH_FEBRUARY ((uint8_t)0x02U)
  224. #define RTC_MONTH_MARCH ((uint8_t)0x03U)
  225. #define RTC_MONTH_APRIL ((uint8_t)0x04U)
  226. #define RTC_MONTH_MAY ((uint8_t)0x05U)
  227. #define RTC_MONTH_JUNE ((uint8_t)0x06U)
  228. #define RTC_MONTH_JULY ((uint8_t)0x07U)
  229. #define RTC_MONTH_AUGUST ((uint8_t)0x08U)
  230. #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09U)
  231. #define RTC_MONTH_OCTOBER ((uint8_t)0x10U)
  232. #define RTC_MONTH_NOVEMBER ((uint8_t)0x11U)
  233. #define RTC_MONTH_DECEMBER ((uint8_t)0x12U)
  234. /**
  235. * @}
  236. */
  237. /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions
  238. * @{
  239. */
  240. #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01U)
  241. #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02U)
  242. #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03U)
  243. #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04U)
  244. #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05U)
  245. #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06U)
  246. #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07U)
  247. /**
  248. * @}
  249. */
  250. /** @defgroup RTC_AlarmDateWeekDay_Definitions RTC Alarm Date WeekDay Definitions
  251. * @{
  252. */
  253. #define RTC_ALARMDATEWEEKDAYSEL_DATE 0x00000000U
  254. #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY 0x40000000U
  255. /**
  256. * @}
  257. */
  258. /** @defgroup RTC_AlarmMask_Definitions RTC Alarm Mask Definitions
  259. * @{
  260. */
  261. #define RTC_ALARMMASK_NONE 0x00000000U
  262. #define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4
  263. #define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3
  264. #define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2
  265. #define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1
  266. #define RTC_ALARMMASK_ALL 0x80808080U
  267. /**
  268. * @}
  269. */
  270. /** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions
  271. * @{
  272. */
  273. #define RTC_ALARM_A RTC_CR_ALRAE
  274. #define RTC_ALARM_B RTC_CR_ALRBE
  275. /**
  276. * @}
  277. */
  278. /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions RTC Alarm Sub Seconds Masks Definitions
  279. * @{
  280. */
  281. #define RTC_ALARMSUBSECONDMASK_ALL 0x00000000U /*!< All Alarm SS fields are masked.
  282. There is no comparison on sub seconds
  283. for Alarm */
  284. #define RTC_ALARMSUBSECONDMASK_SS14_1 0x01000000U /*!< SS[14:1] are don't care in Alarm
  285. comparison. Only SS[0] is compared. */
  286. #define RTC_ALARMSUBSECONDMASK_SS14_2 0x02000000U /*!< SS[14:2] are don't care in Alarm
  287. comparison. Only SS[1:0] are compared */
  288. #define RTC_ALARMSUBSECONDMASK_SS14_3 0x03000000U /*!< SS[14:3] are don't care in Alarm
  289. comparison. Only SS[2:0] are compared */
  290. #define RTC_ALARMSUBSECONDMASK_SS14_4 0x04000000U /*!< SS[14:4] are don't care in Alarm
  291. comparison. Only SS[3:0] are compared */
  292. #define RTC_ALARMSUBSECONDMASK_SS14_5 0x05000000U /*!< SS[14:5] are don't care in Alarm
  293. comparison. Only SS[4:0] are compared */
  294. #define RTC_ALARMSUBSECONDMASK_SS14_6 0x06000000U /*!< SS[14:6] are don't care in Alarm
  295. comparison. Only SS[5:0] are compared */
  296. #define RTC_ALARMSUBSECONDMASK_SS14_7 0x07000000U /*!< SS[14:7] are don't care in Alarm
  297. comparison. Only SS[6:0] are compared */
  298. #define RTC_ALARMSUBSECONDMASK_SS14_8 0x08000000U /*!< SS[14:8] are don't care in Alarm
  299. comparison. Only SS[7:0] are compared */
  300. #define RTC_ALARMSUBSECONDMASK_SS14_9 0x09000000U /*!< SS[14:9] are don't care in Alarm
  301. comparison. Only SS[8:0] are compared */
  302. #define RTC_ALARMSUBSECONDMASK_SS14_10 0x0A000000U /*!< SS[14:10] are don't care in Alarm
  303. comparison. Only SS[9:0] are compared */
  304. #define RTC_ALARMSUBSECONDMASK_SS14_11 0x0B000000U /*!< SS[14:11] are don't care in Alarm
  305. comparison. Only SS[10:0] are compared */
  306. #define RTC_ALARMSUBSECONDMASK_SS14_12 0x0C000000U /*!< SS[14:12] are don't care in Alarm
  307. comparison.Only SS[11:0] are compared */
  308. #define RTC_ALARMSUBSECONDMASK_SS14_13 0x0D000000U /*!< SS[14:13] are don't care in Alarm
  309. comparison. Only SS[12:0] are compared */
  310. #define RTC_ALARMSUBSECONDMASK_SS14 0x0E000000U /*!< SS[14] is don't care in Alarm
  311. comparison.Only SS[13:0] are compared */
  312. #define RTC_ALARMSUBSECONDMASK_NONE 0x0F000000U /*!< SS[14:0] are compared and must match
  313. to activate alarm. */
  314. /**
  315. * @}
  316. */
  317. /** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions
  318. * @{
  319. */
  320. #define RTC_IT_TS RTC_CR_TSIE
  321. #define RTC_IT_WUT RTC_CR_WUTIE
  322. #define RTC_IT_ALRA RTC_CR_ALRAIE
  323. #define RTC_IT_ALRB RTC_CR_ALRBIE
  324. #define RTC_IT_TAMP RTC_TAMPCR_TAMPIE /* Used only to Enable the Tamper Interrupt */
  325. #define RTC_IT_TAMP1 RTC_TAMPCR_TAMP1IE
  326. #define RTC_IT_TAMP2 RTC_TAMPCR_TAMP2IE
  327. #define RTC_IT_TAMP3 RTC_TAMPCR_TAMP3IE
  328. /**
  329. * @}
  330. */
  331. /** @defgroup RTC_Flags_Definitions RTC Flags Definitions
  332. * @{
  333. */
  334. #define RTC_FLAG_RECALPF RTC_ISR_RECALPF
  335. #define RTC_FLAG_TAMP3F RTC_ISR_TAMP3F
  336. #define RTC_FLAG_TAMP2F RTC_ISR_TAMP2F
  337. #define RTC_FLAG_TAMP1F RTC_ISR_TAMP1F
  338. #define RTC_FLAG_TSOVF RTC_ISR_TSOVF
  339. #define RTC_FLAG_TSF RTC_ISR_TSF
  340. #define RTC_FLAG_ITSF RTC_ISR_ITSF
  341. #define RTC_FLAG_WUTF RTC_ISR_WUTF
  342. #define RTC_FLAG_ALRBF RTC_ISR_ALRBF
  343. #define RTC_FLAG_ALRAF RTC_ISR_ALRAF
  344. #define RTC_FLAG_INITF RTC_ISR_INITF
  345. #define RTC_FLAG_RSF RTC_ISR_RSF
  346. #define RTC_FLAG_INITS RTC_ISR_INITS
  347. #define RTC_FLAG_SHPF RTC_ISR_SHPF
  348. #define RTC_FLAG_WUTWF RTC_ISR_WUTWF
  349. #define RTC_FLAG_ALRBWF RTC_ISR_ALRBWF
  350. #define RTC_FLAG_ALRAWF RTC_ISR_ALRAWF
  351. /**
  352. * @}
  353. */
  354. /**
  355. * @}
  356. */
  357. /* Exported macro ------------------------------------------------------------*/
  358. /** @defgroup RTC_Exported_Macros RTC Exported Macros
  359. * @{
  360. */
  361. /** @brief Reset RTC handle state
  362. * @param __HANDLE__: specifies the RTC handle.
  363. * @retval None
  364. */
  365. #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
  366. /**
  367. * @brief Disable the write protection for RTC registers.
  368. * @param __HANDLE__: specifies the RTC handle.
  369. * @retval None
  370. */
  371. #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) \
  372. do{ \
  373. (__HANDLE__)->Instance->WPR = 0xCAU; \
  374. (__HANDLE__)->Instance->WPR = 0x53U; \
  375. } while(0U)
  376. /**
  377. * @brief Enable the write protection for RTC registers.
  378. * @param __HANDLE__: specifies the RTC handle.
  379. * @retval None
  380. */
  381. #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) \
  382. do{ \
  383. (__HANDLE__)->Instance->WPR = 0xFFU; \
  384. } while(0U)
  385. /**
  386. * @brief Enable the RTC ALARMA peripheral.
  387. * @param __HANDLE__: specifies the RTC handle.
  388. * @retval None
  389. */
  390. #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE))
  391. /**
  392. * @brief Disable the RTC ALARMA peripheral.
  393. * @param __HANDLE__: specifies the RTC handle.
  394. * @retval None
  395. */
  396. #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE))
  397. /**
  398. * @brief Enable the RTC ALARMB peripheral.
  399. * @param __HANDLE__: specifies the RTC handle.
  400. * @retval None
  401. */
  402. #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE))
  403. /**
  404. * @brief Disable the RTC ALARMB peripheral.
  405. * @param __HANDLE__: specifies the RTC handle.
  406. * @retval None
  407. */
  408. #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE))
  409. /**
  410. * @brief Enable the RTC Alarm interrupt.
  411. * @param __HANDLE__: specifies the RTC handle.
  412. * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled.
  413. * This parameter can be any combination of the following values:
  414. * @arg RTC_IT_ALRA: Alarm A interrupt
  415. * @arg RTC_IT_ALRB: Alarm B interrupt
  416. * @retval None
  417. */
  418. #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  419. /**
  420. * @brief Disable the RTC Alarm interrupt.
  421. * @param __HANDLE__: specifies the RTC handle.
  422. * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled.
  423. * This parameter can be any combination of the following values:
  424. * @arg RTC_IT_ALRA: Alarm A interrupt
  425. * @arg RTC_IT_ALRB: Alarm B interrupt
  426. * @retval None
  427. */
  428. #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  429. /**
  430. * @brief Check whether the specified RTC Alarm interrupt has occurred or not.
  431. * @param __HANDLE__: specifies the RTC handle.
  432. * @param __INTERRUPT__: specifies the RTC Alarm interrupt to check.
  433. * This parameter can be:
  434. * @arg RTC_IT_ALRA: Alarm A interrupt
  435. * @arg RTC_IT_ALRB: Alarm B interrupt
  436. * @retval None
  437. */
  438. #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) ((((((__HANDLE__)->Instance->ISR)& ((__INTERRUPT__)>> 4U)) & 0x0000FFFFU) != RESET)? SET : RESET)
  439. /**
  440. * @brief Get the selected RTC Alarm's flag status.
  441. * @param __HANDLE__: specifies the RTC handle.
  442. * @param __FLAG__: specifies the RTC Alarm Flag to check.
  443. * This parameter can be:
  444. * @arg RTC_FLAG_ALRAF
  445. * @arg RTC_FLAG_ALRBF
  446. * @arg RTC_FLAG_ALRAWF
  447. * @arg RTC_FLAG_ALRBWF
  448. * @retval None
  449. */
  450. #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
  451. /**
  452. * @brief Clear the RTC Alarm's pending flags.
  453. * @param __HANDLE__: specifies the RTC handle.
  454. * @param __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled.
  455. * This parameter can be:
  456. * @arg RTC_FLAG_ALRAF
  457. * @arg RTC_FLAG_ALRBF
  458. * @retval None
  459. */
  460. #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& 0x0000FFFFU)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
  461. /**
  462. * @brief Check whether the specified RTC Alarm interrupt has been enabled or not.
  463. * @param __HANDLE__: specifies the RTC handle.
  464. * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to check.
  465. * This parameter can be:
  466. * @arg RTC_IT_ALRA: Alarm A interrupt
  467. * @arg RTC_IT_ALRB: Alarm B interrupt
  468. * @retval None
  469. */
  470. #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != RESET) ? SET : RESET)
  471. /**
  472. * @brief Enable interrupt on the RTC Alarm associated Exti line.
  473. * @retval None
  474. */
  475. #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_ALARM_EVENT)
  476. /**
  477. * @brief Disable interrupt on the RTC Alarm associated Exti line.
  478. * @retval None
  479. */
  480. #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI->IMR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
  481. /**
  482. * @brief Enable event on the RTC Alarm associated Exti line.
  483. * @retval None.
  484. */
  485. #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_ALARM_EVENT)
  486. /**
  487. * @brief Disable event on the RTC Alarm associated Exti line.
  488. * @retval None.
  489. */
  490. #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
  491. /**
  492. * @brief Enable falling edge trigger on the RTC Alarm associated Exti line.
  493. * @retval None.
  494. */
  495. #define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_ALARM_EVENT)
  496. /**
  497. * @brief Disable falling edge trigger on the RTC Alarm associated Exti line.
  498. * @retval None.
  499. */
  500. #define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
  501. /**
  502. * @brief Enable rising edge trigger on the RTC Alarm associated Exti line.
  503. * @retval None.
  504. */
  505. #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_ALARM_EVENT)
  506. /**
  507. * @brief Disable rising edge trigger on the RTC Alarm associated Exti line.
  508. * @retval None.
  509. */
  510. #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
  511. /**
  512. * @brief Enable rising & falling edge trigger on the RTC Alarm associated Exti line.
  513. * @retval None.
  514. */
  515. #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE();__HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE();
  516. /**
  517. * @brief Disable rising & falling edge trigger on the RTC Alarm associated Exti line.
  518. * @retval None.
  519. */
  520. #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE();__HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE();
  521. /**
  522. * @brief Check whether the RTC Alarm associated Exti line interrupt flag is set or not.
  523. * @retval Line Status.
  524. */
  525. #define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_ALARM_EVENT)
  526. /**
  527. * @brief Clear the RTC Alarm associated Exti line flag.
  528. * @retval None.
  529. */
  530. #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_ALARM_EVENT)
  531. /**
  532. * @brief Generate a Software interrupt on RTC Alarm associated Exti line.
  533. * @retval None.
  534. */
  535. #define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_ALARM_EVENT)
  536. /**
  537. * @}
  538. */
  539. /* Include RTC HAL Extension module */
  540. #include "stm32f7xx_hal_rtc_ex.h"
  541. /* Exported functions --------------------------------------------------------*/
  542. /** @addtogroup RTC_Exported_Functions
  543. * @{
  544. */
  545. /** @addtogroup RTC_Exported_Functions_Group1
  546. * @{
  547. */
  548. /* Initialization and de-initialization functions ****************************/
  549. HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc);
  550. HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc);
  551. void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc);
  552. void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc);
  553. /**
  554. * @}
  555. */
  556. /** @addtogroup RTC_Exported_Functions_Group2
  557. * @{
  558. */
  559. /* RTC Time and Date functions ************************************************/
  560. HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
  561. HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
  562. HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
  563. HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
  564. /**
  565. * @}
  566. */
  567. /** @addtogroup RTC_Exported_Functions_Group3
  568. * @{
  569. */
  570. /* RTC Alarm functions ********************************************************/
  571. HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
  572. HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
  573. HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm);
  574. HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format);
  575. void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc);
  576. HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
  577. void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc);
  578. /**
  579. * @}
  580. */
  581. /** @addtogroup RTC_Exported_Functions_Group4
  582. * @{
  583. */
  584. /* Peripheral Control functions ***********************************************/
  585. HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef* hrtc);
  586. /**
  587. * @}
  588. */
  589. /** @addtogroup RTC_Exported_Functions_Group5
  590. * @{
  591. */
  592. /* Peripheral State functions *************************************************/
  593. HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc);
  594. /**
  595. * @}
  596. */
  597. /**
  598. * @}
  599. */
  600. /* Private types -------------------------------------------------------------*/
  601. /* Private variables ---------------------------------------------------------*/
  602. /* Private constants ---------------------------------------------------------*/
  603. /** @defgroup RTC_Private_Constants RTC Private Constants
  604. * @{
  605. */
  606. /* Masks Definition */
  607. #define RTC_TR_RESERVED_MASK 0x007F7F7FU
  608. #define RTC_DR_RESERVED_MASK 0x00FFFF3FU
  609. #define RTC_INIT_MASK 0xFFFFFFFFU
  610. #define RTC_RSF_MASK 0xFFFFFF5FU
  611. #define RTC_TIMEOUT_VALUE 1000U
  612. #define RTC_EXTI_LINE_ALARM_EVENT EXTI_IMR_IM17 /*!< External interrupt line 17 Connected to the RTC Alarm event */
  613. /**
  614. * @}
  615. */
  616. /* Private macros ------------------------------------------------------------*/
  617. /** @defgroup RTC_Private_Macros RTC Private Macros
  618. * @{
  619. */
  620. /** @defgroup RTC_IS_RTC_Definitions RTC Private macros to check input parameters
  621. * @{
  622. */
  623. #define IS_RTC_HOUR_FORMAT(__FORMAT__) (((__FORMAT__) == RTC_HOURFORMAT_12) || \
  624. ((__FORMAT__) == RTC_HOURFORMAT_24))
  625. #define IS_RTC_OUTPUT_POL(__POL__) (((__POL__) == RTC_OUTPUT_POLARITY_HIGH) || \
  626. ((__POL__) == RTC_OUTPUT_POLARITY_LOW))
  627. #define IS_RTC_OUTPUT_TYPE(__TYPE__) (((__TYPE__) == RTC_OUTPUT_TYPE_OPENDRAIN) || \
  628. ((__TYPE__) == RTC_OUTPUT_TYPE_PUSHPULL))
  629. #define IS_RTC_ASYNCH_PREDIV(__PREDIV__) ((__PREDIV__) <= 0x7FU)
  630. #define IS_RTC_SYNCH_PREDIV(__PREDIV__) ((__PREDIV__) <= 0x7FFFU)
  631. #define IS_RTC_HOUR12(__HOUR__) (((__HOUR__) > 0U) && ((__HOUR__) <= 12U))
  632. #define IS_RTC_HOUR24(__HOUR__) ((__HOUR__) <= 23U)
  633. #define IS_RTC_MINUTES(__MINUTES__) ((__MINUTES__) <= 59U)
  634. #define IS_RTC_SECONDS(__SECONDS__) ((__SECONDS__) <= 59U)
  635. #define IS_RTC_HOURFORMAT12(__PM__) (((__PM__) == RTC_HOURFORMAT12_AM) || ((__PM__) == RTC_HOURFORMAT12_PM))
  636. #define IS_RTC_DAYLIGHT_SAVING(__SAVE__) (((__SAVE__) == RTC_DAYLIGHTSAVING_SUB1H) || \
  637. ((__SAVE__) == RTC_DAYLIGHTSAVING_ADD1H) || \
  638. ((__SAVE__) == RTC_DAYLIGHTSAVING_NONE))
  639. #define IS_RTC_STORE_OPERATION(__OPERATION__) (((__OPERATION__) == RTC_STOREOPERATION_RESET) || \
  640. ((__OPERATION__) == RTC_STOREOPERATION_SET))
  641. #define IS_RTC_FORMAT(__FORMAT__) (((__FORMAT__) == RTC_FORMAT_BIN) || ((__FORMAT__) == RTC_FORMAT_BCD))
  642. #define IS_RTC_YEAR(__YEAR__) ((__YEAR__) <= 99U)
  643. #define IS_RTC_MONTH(__MONTH__) (((__MONTH__) >= 1U) && ((__MONTH__) <= 12U))
  644. #define IS_RTC_DATE(__DATE__) (((__DATE__) >= 1U) && ((__DATE__) <= 31U))
  645. #define IS_RTC_WEEKDAY(__WEEKDAY__) (((__WEEKDAY__) == RTC_WEEKDAY_MONDAY) || \
  646. ((__WEEKDAY__) == RTC_WEEKDAY_TUESDAY) || \
  647. ((__WEEKDAY__) == RTC_WEEKDAY_WEDNESDAY) || \
  648. ((__WEEKDAY__) == RTC_WEEKDAY_THURSDAY) || \
  649. ((__WEEKDAY__) == RTC_WEEKDAY_FRIDAY) || \
  650. ((__WEEKDAY__) == RTC_WEEKDAY_SATURDAY) || \
  651. ((__WEEKDAY__) == RTC_WEEKDAY_SUNDAY))
  652. #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(__DATE__) (((__DATE__) >0U) && ((__DATE__) <= 31U))
  653. #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(__WEEKDAY__) (((__WEEKDAY__) == RTC_WEEKDAY_MONDAY) || \
  654. ((__WEEKDAY__) == RTC_WEEKDAY_TUESDAY) || \
  655. ((__WEEKDAY__) == RTC_WEEKDAY_WEDNESDAY) || \
  656. ((__WEEKDAY__) == RTC_WEEKDAY_THURSDAY) || \
  657. ((__WEEKDAY__) == RTC_WEEKDAY_FRIDAY) || \
  658. ((__WEEKDAY__) == RTC_WEEKDAY_SATURDAY) || \
  659. ((__WEEKDAY__) == RTC_WEEKDAY_SUNDAY))
  660. #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(__SEL__) (((__SEL__) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \
  661. ((__SEL__) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY))
  662. #define IS_RTC_ALARM_MASK(__MASK__) (((__MASK__) & 0x7F7F7F7FU) == (uint32_t)RESET)
  663. #define IS_RTC_ALARM(__ALARM__) (((__ALARM__) == RTC_ALARM_A) || ((__ALARM__) == RTC_ALARM_B))
  664. #define IS_RTC_ALARM_SUB_SECOND_VALUE(__VALUE__) ((__VALUE__) <= 0x00007FFFU)
  665. #define IS_RTC_ALARM_SUB_SECOND_MASK(__MASK__) (((__MASK__) == RTC_ALARMSUBSECONDMASK_ALL) || \
  666. ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_1) || \
  667. ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_2) || \
  668. ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_3) || \
  669. ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_4) || \
  670. ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_5) || \
  671. ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_6) || \
  672. ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_7) || \
  673. ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_8) || \
  674. ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_9) || \
  675. ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_10) || \
  676. ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_11) || \
  677. ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_12) || \
  678. ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_13) || \
  679. ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14) || \
  680. ((__MASK__) == RTC_ALARMSUBSECONDMASK_NONE))
  681. /**
  682. * @}
  683. */
  684. /**
  685. * @}
  686. */
  687. /* Private functions ---------------------------------------------------------*/
  688. /** @defgroup RTC_Private_Functions RTC Private Functions
  689. * @{
  690. */
  691. HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef* hrtc);
  692. uint8_t RTC_ByteToBcd2(uint8_t Value);
  693. uint8_t RTC_Bcd2ToByte(uint8_t Value);
  694. /**
  695. * @}
  696. */
  697. /**
  698. * @}
  699. */
  700. /**
  701. * @}
  702. */
  703. #ifdef __cplusplus
  704. }
  705. #endif
  706. #endif /* __STM32F7xx_HAL_RTC_H */
  707. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/