stm32f2xx_rtc.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. /**
  2. ******************************************************************************
  3. * @file stm32f2xx_rtc.h
  4. * @author MCD Application Team
  5. * @version V1.1.3
  6. * @date 31-December-2021
  7. * @brief This file contains all the functions prototypes for the RTC firmware
  8. * library.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * Copyright (c) 2012 STMicroelectronics.
  13. * All rights reserved.
  14. *
  15. * This software is licensed under terms that can be found in the LICENSE file
  16. * in the root directory of this software component.
  17. * If no LICENSE file comes with this software, it is provided AS-IS.
  18. *
  19. ******************************************************************************
  20. */
  21. /* Define to prevent recursive inclusion -------------------------------------*/
  22. #ifndef __STM32F2xx_RTC_H
  23. #define __STM32F2xx_RTC_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* Includes ------------------------------------------------------------------*/
  28. #include "stm32f2xx.h"
  29. /** @addtogroup STM32F2xx_StdPeriph_Driver
  30. * @{
  31. */
  32. /** @addtogroup RTC
  33. * @{
  34. */
  35. /* Exported types ------------------------------------------------------------*/
  36. /**
  37. * @brief RTC Init structures definition
  38. */
  39. typedef struct
  40. {
  41. uint32_t RTC_HourFormat; /*!< Specifies the RTC Hour Format.
  42. This parameter can be a value of @ref RTC_Hour_Formats */
  43. uint32_t RTC_AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value.
  44. This parameter must be set to a value lower than 0x7F */
  45. uint32_t RTC_SynchPrediv; /*!< Specifies the RTC Synchronous Predivider value.
  46. This parameter must be set to a value lower than 0x1FFF */
  47. }RTC_InitTypeDef;
  48. /**
  49. * @brief RTC Time structure definition
  50. */
  51. typedef struct
  52. {
  53. uint8_t RTC_Hours; /*!< Specifies the RTC Time Hour.
  54. This parameter must be set to a value in the 0-12 range
  55. if the RTC_HourFormat_12 is selected or 0-23 range if
  56. the RTC_HourFormat_24 is selected. */
  57. uint8_t RTC_Minutes; /*!< Specifies the RTC Time Minutes.
  58. This parameter must be set to a value in the 0-59 range. */
  59. uint8_t RTC_Seconds; /*!< Specifies the RTC Time Seconds.
  60. This parameter must be set to a value in the 0-59 range. */
  61. uint8_t RTC_H12; /*!< Specifies the RTC AM/PM Time.
  62. This parameter can be a value of @ref RTC_AM_PM_Definitions */
  63. }RTC_TimeTypeDef;
  64. /**
  65. * @brief RTC Date structure definition
  66. */
  67. typedef struct
  68. {
  69. uint8_t RTC_WeekDay; /*!< Specifies the RTC Date WeekDay.
  70. This parameter can be a value of @ref RTC_WeekDay_Definitions */
  71. uint8_t RTC_Month; /*!< Specifies the RTC Date Month (in BCD format).
  72. This parameter can be a value of @ref RTC_Month_Date_Definitions */
  73. uint8_t RTC_Date; /*!< Specifies the RTC Date.
  74. This parameter must be set to a value in the 1-31 range. */
  75. uint8_t RTC_Year; /*!< Specifies the RTC Date Year.
  76. This parameter must be set to a value in the 0-99 range. */
  77. }RTC_DateTypeDef;
  78. /**
  79. * @brief RTC Alarm structure definition
  80. */
  81. typedef struct
  82. {
  83. RTC_TimeTypeDef RTC_AlarmTime; /*!< Specifies the RTC Alarm Time members. */
  84. uint32_t RTC_AlarmMask; /*!< Specifies the RTC Alarm Masks.
  85. This parameter can be a value of @ref RTC_AlarmMask_Definitions */
  86. uint32_t RTC_AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay.
  87. This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */
  88. uint8_t RTC_AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay.
  89. If the Alarm Date is selected, this parameter
  90. must be set to a value in the 1-31 range.
  91. If the Alarm WeekDay is selected, this
  92. parameter can be a value of @ref RTC_WeekDay_Definitions */
  93. }RTC_AlarmTypeDef;
  94. /* Exported constants --------------------------------------------------------*/
  95. /** @defgroup RTC_Exported_Constants
  96. * @{
  97. */
  98. /** @defgroup RTC_Hour_Formats
  99. * @{
  100. */
  101. #define RTC_HourFormat_24 ((uint32_t)0x00000000)
  102. #define RTC_HourFormat_12 ((uint32_t)0x00000040)
  103. #define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HourFormat_12) || \
  104. ((FORMAT) == RTC_HourFormat_24))
  105. /**
  106. * @}
  107. */
  108. /** @defgroup RTC_Asynchronous_Predivider
  109. * @{
  110. */
  111. #define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7F)
  112. /**
  113. * @}
  114. */
  115. /** @defgroup RTC_Synchronous_Predivider
  116. * @{
  117. */
  118. #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x1FFF)
  119. /**
  120. * @}
  121. */
  122. /** @defgroup RTC_Time_Definitions
  123. * @{
  124. */
  125. #define IS_RTC_HOUR12(HOUR) (((HOUR) > 0) && ((HOUR) <= 12))
  126. #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23)
  127. #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59)
  128. #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59)
  129. /**
  130. * @}
  131. */
  132. /** @defgroup RTC_AM_PM_Definitions
  133. * @{
  134. */
  135. #define RTC_H12_AM ((uint8_t)0x00)
  136. #define RTC_H12_PM ((uint8_t)0x40)
  137. #define IS_RTC_H12(PM) (((PM) == RTC_H12_AM) || ((PM) == RTC_H12_PM))
  138. /**
  139. * @}
  140. */
  141. /** @defgroup RTC_Year_Date_Definitions
  142. * @{
  143. */
  144. #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99)
  145. /**
  146. * @}
  147. */
  148. /** @defgroup RTC_Month_Date_Definitions
  149. * @{
  150. */
  151. /* Coded in BCD format */
  152. #define RTC_Month_January ((uint8_t)0x01)
  153. #define RTC_Month_February ((uint8_t)0x02)
  154. #define RTC_Month_March ((uint8_t)0x03)
  155. #define RTC_Month_April ((uint8_t)0x04)
  156. #define RTC_Month_May ((uint8_t)0x05)
  157. #define RTC_Month_June ((uint8_t)0x06)
  158. #define RTC_Month_July ((uint8_t)0x07)
  159. #define RTC_Month_August ((uint8_t)0x08)
  160. #define RTC_Month_September ((uint8_t)0x09)
  161. #define RTC_Month_October ((uint8_t)0x10)
  162. #define RTC_Month_November ((uint8_t)0x11)
  163. #define RTC_Month_December ((uint8_t)0x12)
  164. #define IS_RTC_MONTH(MONTH) (((MONTH) >= 1) && ((MONTH) <= 12))
  165. #define IS_RTC_DATE(DATE) (((DATE) >= 1) && ((DATE) <= 31))
  166. /**
  167. * @}
  168. */
  169. /** @defgroup RTC_WeekDay_Definitions
  170. * @{
  171. */
  172. #define RTC_Weekday_Monday ((uint8_t)0x01)
  173. #define RTC_Weekday_Tuesday ((uint8_t)0x02)
  174. #define RTC_Weekday_Wednesday ((uint8_t)0x03)
  175. #define RTC_Weekday_Thursday ((uint8_t)0x04)
  176. #define RTC_Weekday_Friday ((uint8_t)0x05)
  177. #define RTC_Weekday_Saturday ((uint8_t)0x06)
  178. #define RTC_Weekday_Sunday ((uint8_t)0x07)
  179. #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_Weekday_Monday) || \
  180. ((WEEKDAY) == RTC_Weekday_Tuesday) || \
  181. ((WEEKDAY) == RTC_Weekday_Wednesday) || \
  182. ((WEEKDAY) == RTC_Weekday_Thursday) || \
  183. ((WEEKDAY) == RTC_Weekday_Friday) || \
  184. ((WEEKDAY) == RTC_Weekday_Saturday) || \
  185. ((WEEKDAY) == RTC_Weekday_Sunday))
  186. /**
  187. * @}
  188. */
  189. /** @defgroup RTC_Alarm_Definitions
  190. * @{
  191. */
  192. #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0) && ((DATE) <= 31))
  193. #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_Weekday_Monday) || \
  194. ((WEEKDAY) == RTC_Weekday_Tuesday) || \
  195. ((WEEKDAY) == RTC_Weekday_Wednesday) || \
  196. ((WEEKDAY) == RTC_Weekday_Thursday) || \
  197. ((WEEKDAY) == RTC_Weekday_Friday) || \
  198. ((WEEKDAY) == RTC_Weekday_Saturday) || \
  199. ((WEEKDAY) == RTC_Weekday_Sunday))
  200. /**
  201. * @}
  202. */
  203. /** @defgroup RTC_AlarmDateWeekDay_Definitions
  204. * @{
  205. */
  206. #define RTC_AlarmDateWeekDaySel_Date ((uint32_t)0x00000000)
  207. #define RTC_AlarmDateWeekDaySel_WeekDay ((uint32_t)0x40000000)
  208. #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_AlarmDateWeekDaySel_Date) || \
  209. ((SEL) == RTC_AlarmDateWeekDaySel_WeekDay))
  210. /**
  211. * @}
  212. */
  213. /** @defgroup RTC_AlarmMask_Definitions
  214. * @{
  215. */
  216. #define RTC_AlarmMask_None ((uint32_t)0x00000000)
  217. #define RTC_AlarmMask_DateWeekDay ((uint32_t)0x80000000)
  218. #define RTC_AlarmMask_Hours ((uint32_t)0x00800000)
  219. #define RTC_AlarmMask_Minutes ((uint32_t)0x00008000)
  220. #define RTC_AlarmMask_Seconds ((uint32_t)0x00000080)
  221. #define RTC_AlarmMask_All ((uint32_t)0x80808080)
  222. #define IS_ALARM_MASK(MASK) (((MASK) & 0x7F7F7F7F) == (uint32_t)RESET)
  223. /**
  224. * @}
  225. */
  226. /** @defgroup RTC_Alarms_Definitions
  227. * @{
  228. */
  229. #define RTC_Alarm_A ((uint32_t)0x00000100)
  230. #define RTC_Alarm_B ((uint32_t)0x00000200)
  231. #define IS_RTC_ALARM(ALARM) (((ALARM) == RTC_Alarm_A) || ((ALARM) == RTC_Alarm_B))
  232. #define IS_RTC_CMD_ALARM(ALARM) (((ALARM) & (RTC_Alarm_A | RTC_Alarm_B)) != (uint32_t)RESET)
  233. /**
  234. * @}
  235. */
  236. /** @defgroup RTC_Wakeup_Timer_Definitions
  237. * @{
  238. */
  239. #define RTC_WakeUpClock_RTCCLK_Div16 ((uint32_t)0x00000000)
  240. #define RTC_WakeUpClock_RTCCLK_Div8 ((uint32_t)0x00000001)
  241. #define RTC_WakeUpClock_RTCCLK_Div4 ((uint32_t)0x00000002)
  242. #define RTC_WakeUpClock_RTCCLK_Div2 ((uint32_t)0x00000003)
  243. #define RTC_WakeUpClock_CK_SPRE_16bits ((uint32_t)0x00000004)
  244. #define RTC_WakeUpClock_CK_SPRE_17bits ((uint32_t)0x00000006)
  245. #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WakeUpClock_RTCCLK_Div16) || \
  246. ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div8) || \
  247. ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div4) || \
  248. ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div2) || \
  249. ((CLOCK) == RTC_WakeUpClock_CK_SPRE_16bits) || \
  250. ((CLOCK) == RTC_WakeUpClock_CK_SPRE_17bits))
  251. #define IS_RTC_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= 0xFFFF)
  252. /**
  253. * @}
  254. */
  255. /** @defgroup RTC_Time_Stamp_Edges_definitions
  256. * @{
  257. */
  258. #define RTC_TimeStampEdge_Rising ((uint32_t)0x00000000)
  259. #define RTC_TimeStampEdge_Falling ((uint32_t)0x00000008)
  260. #define IS_RTC_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TimeStampEdge_Rising) || \
  261. ((EDGE) == RTC_TimeStampEdge_Falling))
  262. /**
  263. * @}
  264. */
  265. /** @defgroup RTC_Output_selection_Definitions
  266. * @{
  267. */
  268. #define RTC_Output_Disable ((uint32_t)0x00000000)
  269. #define RTC_Output_AlarmA ((uint32_t)0x00200000)
  270. #define RTC_Output_AlarmB ((uint32_t)0x00400000)
  271. #define RTC_Output_WakeUp ((uint32_t)0x00600000)
  272. #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_Output_Disable) || \
  273. ((OUTPUT) == RTC_Output_AlarmA) || \
  274. ((OUTPUT) == RTC_Output_AlarmB) || \
  275. ((OUTPUT) == RTC_Output_WakeUp))
  276. /**
  277. * @}
  278. */
  279. /** @defgroup RTC_Output_Polarity_Definitions
  280. * @{
  281. */
  282. #define RTC_OutputPolarity_High ((uint32_t)0x00000000)
  283. #define RTC_OutputPolarity_Low ((uint32_t)0x00100000)
  284. #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OutputPolarity_High) || \
  285. ((POL) == RTC_OutputPolarity_Low))
  286. /**
  287. * @}
  288. */
  289. /** @defgroup RTC_Digital_Calibration_Definitions
  290. * @{
  291. */
  292. #define RTC_CalibSign_Positive ((uint32_t)0x00000000)
  293. #define RTC_CalibSign_Negative ((uint32_t)0x00000080)
  294. #define IS_RTC_CALIB_SIGN(SIGN) (((SIGN) == RTC_CalibSign_Positive) || \
  295. ((SIGN) == RTC_CalibSign_Negative))
  296. #define IS_RTC_CALIB_VALUE(VALUE) ((VALUE) < 0x20)
  297. /**
  298. * @}
  299. */
  300. /** @defgroup RTC_DayLightSaving_Definitions
  301. * @{
  302. */
  303. #define RTC_DayLightSaving_SUB1H ((uint32_t)0x00020000)
  304. #define RTC_DayLightSaving_ADD1H ((uint32_t)0x00010000)
  305. #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DayLightSaving_SUB1H) || \
  306. ((SAVE) == RTC_DayLightSaving_ADD1H))
  307. #define RTC_StoreOperation_Reset ((uint32_t)0x00000000)
  308. #define RTC_StoreOperation_Set ((uint32_t)0x00040000)
  309. #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_StoreOperation_Reset) || \
  310. ((OPERATION) == RTC_StoreOperation_Set))
  311. /**
  312. * @}
  313. */
  314. /** @defgroup RTC_Tamper_Trigger_Definitions
  315. * @{
  316. */
  317. #define RTC_TamperTrigger_RisingEdge ((uint32_t)0x00000000)
  318. #define RTC_TamperTrigger_FallingEdge ((uint32_t)0x00000001)
  319. #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TamperTrigger_RisingEdge) || \
  320. ((TRIGGER) == RTC_TamperTrigger_FallingEdge))
  321. /**
  322. * @}
  323. */
  324. /** @defgroup RTC_Tamper_Pins_Definitions
  325. * @{
  326. */
  327. #define RTC_Tamper_1 RTC_TAFCR_TAMP1E
  328. #define IS_RTC_TAMPER(TAMPER) (((TAMPER) == RTC_Tamper_1))
  329. /**
  330. * @}
  331. */
  332. /** @defgroup RTC_Tamper_Pin_Selection
  333. * @{
  334. */
  335. #define RTC_TamperPin_PC13 ((uint32_t)0x00000000)
  336. #define RTC_TamperPin_PI8 ((uint32_t)0x00010000)
  337. #define IS_RTC_TAMPER_PIN(PIN) (((PIN) == RTC_TamperPin_PC13) || \
  338. ((PIN) == RTC_TamperPin_PI8))
  339. /**
  340. * @}
  341. */
  342. /** @defgroup RTC_TimeStamp_Pin_Selection
  343. * @{
  344. */
  345. #define RTC_TimeStampPin_PC13 ((uint32_t)0x00000000)
  346. #define RTC_TimeStampPin_PI8 ((uint32_t)0x00020000)
  347. #define IS_RTC_TIMESTAMP_PIN(PIN) (((PIN) == RTC_TimeStampPin_PC13) || \
  348. ((PIN) == RTC_TimeStampPin_PI8))
  349. /**
  350. * @}
  351. */
  352. /** @defgroup RTC_Output_Type_ALARM_OUT
  353. * @{
  354. */
  355. #define RTC_OutputType_OpenDrain ((uint32_t)0x00000000)
  356. #define RTC_OutputType_PushPull ((uint32_t)0x00040000)
  357. #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OutputType_OpenDrain) || \
  358. ((TYPE) == RTC_OutputType_PushPull))
  359. /**
  360. * @}
  361. */
  362. /** @defgroup RTC_Backup_Registers_Definitions
  363. * @{
  364. */
  365. #define RTC_BKP_DR0 ((uint32_t)0x00000000)
  366. #define RTC_BKP_DR1 ((uint32_t)0x00000001)
  367. #define RTC_BKP_DR2 ((uint32_t)0x00000002)
  368. #define RTC_BKP_DR3 ((uint32_t)0x00000003)
  369. #define RTC_BKP_DR4 ((uint32_t)0x00000004)
  370. #define RTC_BKP_DR5 ((uint32_t)0x00000005)
  371. #define RTC_BKP_DR6 ((uint32_t)0x00000006)
  372. #define RTC_BKP_DR7 ((uint32_t)0x00000007)
  373. #define RTC_BKP_DR8 ((uint32_t)0x00000008)
  374. #define RTC_BKP_DR9 ((uint32_t)0x00000009)
  375. #define RTC_BKP_DR10 ((uint32_t)0x0000000A)
  376. #define RTC_BKP_DR11 ((uint32_t)0x0000000B)
  377. #define RTC_BKP_DR12 ((uint32_t)0x0000000C)
  378. #define RTC_BKP_DR13 ((uint32_t)0x0000000D)
  379. #define RTC_BKP_DR14 ((uint32_t)0x0000000E)
  380. #define RTC_BKP_DR15 ((uint32_t)0x0000000F)
  381. #define RTC_BKP_DR16 ((uint32_t)0x00000010)
  382. #define RTC_BKP_DR17 ((uint32_t)0x00000011)
  383. #define RTC_BKP_DR18 ((uint32_t)0x00000012)
  384. #define RTC_BKP_DR19 ((uint32_t)0x00000013)
  385. #define IS_RTC_BKP(BKP) (((BKP) == RTC_BKP_DR0) || \
  386. ((BKP) == RTC_BKP_DR1) || \
  387. ((BKP) == RTC_BKP_DR2) || \
  388. ((BKP) == RTC_BKP_DR3) || \
  389. ((BKP) == RTC_BKP_DR4) || \
  390. ((BKP) == RTC_BKP_DR5) || \
  391. ((BKP) == RTC_BKP_DR6) || \
  392. ((BKP) == RTC_BKP_DR7) || \
  393. ((BKP) == RTC_BKP_DR8) || \
  394. ((BKP) == RTC_BKP_DR9) || \
  395. ((BKP) == RTC_BKP_DR10) || \
  396. ((BKP) == RTC_BKP_DR11) || \
  397. ((BKP) == RTC_BKP_DR12) || \
  398. ((BKP) == RTC_BKP_DR13) || \
  399. ((BKP) == RTC_BKP_DR14) || \
  400. ((BKP) == RTC_BKP_DR15) || \
  401. ((BKP) == RTC_BKP_DR16) || \
  402. ((BKP) == RTC_BKP_DR17) || \
  403. ((BKP) == RTC_BKP_DR18) || \
  404. ((BKP) == RTC_BKP_DR19))
  405. /**
  406. * @}
  407. */
  408. /** @defgroup RTC_Input_parameter_format_definitions
  409. * @{
  410. */
  411. #define RTC_Format_BIN ((uint32_t)0x000000000)
  412. #define RTC_Format_BCD ((uint32_t)0x000000001)
  413. #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_Format_BIN) || ((FORMAT) == RTC_Format_BCD))
  414. /**
  415. * @}
  416. */
  417. /** @defgroup RTC_Flags_Definitions
  418. * @{
  419. */
  420. #define RTC_FLAG_TAMP1F ((uint32_t)0x00002000)
  421. #define RTC_FLAG_TSOVF ((uint32_t)0x00001000)
  422. #define RTC_FLAG_TSF ((uint32_t)0x00000800)
  423. #define RTC_FLAG_WUTF ((uint32_t)0x00000400)
  424. #define RTC_FLAG_ALRBF ((uint32_t)0x00000200)
  425. #define RTC_FLAG_ALRAF ((uint32_t)0x00000100)
  426. #define RTC_FLAG_INITF ((uint32_t)0x00000040)
  427. #define RTC_FLAG_RSF ((uint32_t)0x00000020)
  428. #define RTC_FLAG_INITS ((uint32_t)0x00000010)
  429. #define RTC_FLAG_WUTWF ((uint32_t)0x00000004)
  430. #define RTC_FLAG_ALRBWF ((uint32_t)0x00000002)
  431. #define RTC_FLAG_ALRAWF ((uint32_t)0x00000001)
  432. #define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_TSOVF) || ((FLAG) == RTC_FLAG_TSF) || \
  433. ((FLAG) == RTC_FLAG_WUTF) || ((FLAG) == RTC_FLAG_ALRBF) || \
  434. ((FLAG) == RTC_FLAG_ALRAF) || ((FLAG) == RTC_FLAG_INITF) || \
  435. ((FLAG) == RTC_FLAG_RSF) || ((FLAG) == RTC_FLAG_WUTWF) || \
  436. ((FLAG) == RTC_FLAG_ALRBWF) || ((FLAG) == RTC_FLAG_ALRAWF) || \
  437. ((FLAG) == RTC_FLAG_TAMP1F))
  438. #define IS_RTC_CLEAR_FLAG(FLAG) (((FLAG) != (uint32_t)RESET) && (((FLAG) & 0xFFFFC0DF) == (uint32_t)RESET))
  439. /**
  440. * @}
  441. */
  442. /** @defgroup RTC_Interrupts_Definitions
  443. * @{
  444. */
  445. #define RTC_IT_TS ((uint32_t)0x00008000)
  446. #define RTC_IT_WUT ((uint32_t)0x00004000)
  447. #define RTC_IT_ALRB ((uint32_t)0x00002000)
  448. #define RTC_IT_ALRA ((uint32_t)0x00001000)
  449. #define RTC_IT_TAMP ((uint32_t)0x00000004) /* Used only to Enable the Tamper Interrupt */
  450. #define RTC_IT_TAMP1 ((uint32_t)0x00020000)
  451. #define IS_RTC_CONFIG_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFF0FFB) == (uint32_t)RESET))
  452. #define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_TS) || ((IT) == RTC_IT_WUT) || \
  453. ((IT) == RTC_IT_ALRB) || ((IT) == RTC_IT_ALRA) || \
  454. ((IT) == RTC_IT_TAMP1))
  455. #define IS_RTC_CLEAR_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFD0FFF) == (uint32_t)RESET))
  456. /**
  457. * @}
  458. */
  459. /** @defgroup RTC_Legacy
  460. * @{
  461. */
  462. #define RTC_DigitalCalibConfig RTC_CoarseCalibConfig
  463. #define RTC_DigitalCalibCmd RTC_CoarseCalibCmd
  464. /**
  465. * @}
  466. */
  467. /**
  468. * @}
  469. */
  470. /* Exported macro ------------------------------------------------------------*/
  471. /* Exported functions --------------------------------------------------------*/
  472. /* Function used to set the RTC configuration to the default reset state *****/
  473. ErrorStatus RTC_DeInit(void);
  474. /* Initialization and Configuration functions *********************************/
  475. ErrorStatus RTC_Init(RTC_InitTypeDef* RTC_InitStruct);
  476. void RTC_StructInit(RTC_InitTypeDef* RTC_InitStruct);
  477. void RTC_WriteProtectionCmd(FunctionalState NewState);
  478. ErrorStatus RTC_EnterInitMode(void);
  479. void RTC_ExitInitMode(void);
  480. ErrorStatus RTC_WaitForSynchro(void);
  481. ErrorStatus RTC_RefClockCmd(FunctionalState NewState);
  482. /* Time and Date configuration functions **************************************/
  483. ErrorStatus RTC_SetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct);
  484. void RTC_TimeStructInit(RTC_TimeTypeDef* RTC_TimeStruct);
  485. void RTC_GetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct);
  486. ErrorStatus RTC_SetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct);
  487. void RTC_DateStructInit(RTC_DateTypeDef* RTC_DateStruct);
  488. void RTC_GetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct);
  489. /* Alarms (Alarm A and Alarm B) configuration functions **********************/
  490. void RTC_SetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct);
  491. void RTC_AlarmStructInit(RTC_AlarmTypeDef* RTC_AlarmStruct);
  492. void RTC_GetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct);
  493. ErrorStatus RTC_AlarmCmd(uint32_t RTC_Alarm, FunctionalState NewState);
  494. /* WakeUp Timer configuration functions ***************************************/
  495. void RTC_WakeUpClockConfig(uint32_t RTC_WakeUpClock);
  496. void RTC_SetWakeUpCounter(uint32_t RTC_WakeUpCounter);
  497. uint32_t RTC_GetWakeUpCounter(void);
  498. ErrorStatus RTC_WakeUpCmd(FunctionalState NewState);
  499. /* Daylight Saving configuration functions ************************************/
  500. void RTC_DayLightSavingConfig(uint32_t RTC_DayLightSaving, uint32_t RTC_StoreOperation);
  501. uint32_t RTC_GetStoreOperation(void);
  502. /* Output pin Configuration function ******************************************/
  503. void RTC_OutputConfig(uint32_t RTC_Output, uint32_t RTC_OutputPolarity);
  504. /* Coarse Calibration configuration functions *********************************/
  505. ErrorStatus RTC_CoarseCalibConfig(uint32_t RTC_CalibSign, uint32_t Value);
  506. ErrorStatus RTC_CoarseCalibCmd(FunctionalState NewState);
  507. void RTC_CalibOutputCmd(FunctionalState NewState);
  508. /* TimeStamp configuration functions ******************************************/
  509. void RTC_TimeStampCmd(uint32_t RTC_TimeStampEdge, FunctionalState NewState);
  510. void RTC_GetTimeStamp(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_StampTimeStruct,
  511. RTC_DateTypeDef* RTC_StampDateStruct);
  512. /* Tampers configuration functions ********************************************/
  513. void RTC_TamperTriggerConfig(uint32_t RTC_Tamper, uint32_t RTC_TamperTrigger);
  514. void RTC_TamperCmd(uint32_t RTC_Tamper, FunctionalState NewState);
  515. /* Backup Data Registers configuration functions ******************************/
  516. void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data);
  517. uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR);
  518. /* RTC Tamper and TimeStamp Pins Selection and Output Type Config configuration
  519. functions ******************************************************************/
  520. void RTC_TamperPinSelection(uint32_t RTC_TamperPin);
  521. void RTC_TimeStampPinSelection(uint32_t RTC_TimeStampPin);
  522. void RTC_OutputTypeConfig(uint32_t RTC_OutputType);
  523. /* Interrupts and flags management functions **********************************/
  524. void RTC_ITConfig(uint32_t RTC_IT, FunctionalState NewState);
  525. FlagStatus RTC_GetFlagStatus(uint32_t RTC_FLAG);
  526. void RTC_ClearFlag(uint32_t RTC_FLAG);
  527. ITStatus RTC_GetITStatus(uint32_t RTC_IT);
  528. void RTC_ClearITPendingBit(uint32_t RTC_IT);
  529. #ifdef __cplusplus
  530. }
  531. #endif
  532. #endif /*__STM32F2xx_RTC_H */
  533. /**
  534. * @}
  535. */
  536. /**
  537. * @}
  538. */