apm32f4xx_rtc.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. /*!
  2. * @file apm32f4xx_rtc.h
  3. *
  4. * @brief This file contains all the functions prototypes for the RTC firmware library.
  5. *
  6. * @version V1.0.2
  7. *
  8. * @date 2022-06-23
  9. *
  10. * @attention
  11. *
  12. * Copyright (C) 2021-2022 Geehy Semiconductor
  13. *
  14. * You may not use this file except in compliance with the
  15. * GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
  16. *
  17. * The program is only for reference, which is distributed in the hope
  18. * that it will be usefull and instructional for customers to develop
  19. * their software. Unless required by applicable law or agreed to in
  20. * writing, the program is distributed on an "AS IS" BASIS, WITHOUT
  21. * ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
  23. * and limitations under the License.
  24. */
  25. /* Define to prevent recursive inclusion */
  26. #ifndef __APM32F4XX_RTC_H
  27. #define __APM32F4XX_RTC_H
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /* Includes */
  32. #include "apm32f4xx.h"
  33. /** @addtogroup APM32F4xx_StdPeriphDriver
  34. @{
  35. */
  36. /** @addtogroup RTC_Driver
  37. @{
  38. */
  39. /** @defgroup RTC_Enumerations
  40. @{
  41. */
  42. /**
  43. * @brief RTC Hour Formats
  44. */
  45. typedef enum
  46. {
  47. RTC_HOURFORMAT_24, /*!< 24 hour/day format */
  48. RTC_HOURFORMAT_12 /*!< AM/PM hour format */
  49. } RTC_HOUR_FORMAT_T;
  50. /**
  51. * @brief RTC Input parameter format
  52. */
  53. typedef enum
  54. {
  55. RTC_FORMAT_BIN, /*!< Format in BIN */
  56. RTC_FORMAT_BCD /*!< Format in BCD */
  57. } RTC_FORMAT_T;
  58. /**
  59. * @brief RTC AM PM
  60. */
  61. typedef enum
  62. {
  63. RTC_H12_AM, /*!< Set RTC time to AM */
  64. RTC_H12_PM /*!< Set RTC time to PM */
  65. } RTC_H12_T;
  66. /**
  67. * @brief RTC MONTH
  68. */
  69. typedef enum
  70. {
  71. RTC_MONTH_JANUARY = 0x01, /*!< January */
  72. RTC_MONTH_FEBRUARY = 0x02, /*!< February */
  73. RTC_MONTH_MARCH = 0x03, /*!< March */
  74. RTC_MONTH_APRIL = 0x04, /*!< April */
  75. RTC_MONTH_MAY = 0x05, /*!< May */
  76. RTC_MONTH_JUNE = 0x06, /*!< June */
  77. RTC_MONTH_JULY = 0x07, /*!< July */
  78. RTC_MONTH_AUGUST = 0x08, /*!< August */
  79. RTC_MONTH_SEPTEMBER = 0x09, /*!< September */
  80. RTC_MONTH_OCTOBER = 0x10, /*!< October */
  81. RTC_MONTH_NOVEMBER = 0x11, /*!< November */
  82. RTC_MONTH_DECEMBER = 0x12 /*!< December */
  83. } RTC_MONTH_T;
  84. /**
  85. * @brief RTC WEEKDAY
  86. */
  87. typedef enum
  88. {
  89. RTC_WEEKDAY_MONDAY = 0x01, /*!< Set Monday as the weekend */
  90. RTC_WEEKDAY_TUESDAY = 0x02, /*!< Set Tuesday as the weekend */
  91. RTC_WEEKDAY_WEDNESDAY = 0x03, /*!< Set Wednesday as the weekend */
  92. RTC_WEEKDAY_THURSDAY = 0x04, /*!< Set Thursday as the weekend */
  93. RTC_WEEKDAY_FRIDAY = 0x05, /*!< Set Friday as the weekend */
  94. RTC_WEEKDAY_SATURDAY = 0x06, /*!< Set Saturday as the weekend */
  95. RTC_WEEKDAY_SUNDAY = 0x07 /*!< Set sunday as the weekend */
  96. } RTC_WEEKDAY_T;
  97. /**
  98. * @brief RTC AlarmDateWeekDay
  99. */
  100. typedef enum
  101. {
  102. RTC_WEEKDAY_SEL_DATE, /*!< Select DAYU to represent the date */
  103. RTC_WEEKDAY_SEL_WEEKDAY /*!< Select DAYU to represent the weekday */
  104. } RTC_WEEKDAY_SEL_T;
  105. /**
  106. * @brief RTC AlarmMask
  107. */
  108. typedef enum
  109. {
  110. RTC_MASK_NONE = (uint32_t)0x00000000, /*!< No mask */
  111. RTC_MASK_DATEWEEK = (int32_t)0x80000000, /*!< Dateweek mask */
  112. RTC_MASK_HOURS = (uint32_t)0x00800000, /*!< Hours mask */
  113. RTC_MASK_MINUTES = (uint32_t)0x00008000, /*!< Minutes mask */
  114. RTC_MASK_SECONDS = (uint32_t)0x00000080, /*!< Seconds mask */
  115. RTC_MASK_ALL = (int32_t)0x80808080 /*!< All mask */
  116. } RTC_MASK_T;
  117. /**
  118. * @brief RTC ALARMA ALARMB
  119. */
  120. typedef enum
  121. {
  122. RTC_ALARM_A = 0x0100, /*!< Select Alarm A */
  123. RTC_ALARM_B = 0x0200 /*!< Select Alarm B */
  124. } RTC_ALARM_T;
  125. /**
  126. * @brief RTC_ALARM_SS description
  127. */
  128. typedef enum
  129. {
  130. RTC_ALARM_SUBSEC_MASK_ALL , /*!< All Alarm SUBSEC fields are masked */
  131. RTC_ALARM_SUBSEC_MASK_14_1, /*!< Mask SUBSEC[14:1] and Alarm comparison is SUBSEC[0] */
  132. RTC_ALARM_SUBSEC_MASK_14_2, /*!< Mask SUBSEC[14:2] and Alarm comparison is SUBSEC[1:0] */
  133. RTC_ALARM_SUBSEC_MASK_14_3, /*!< Mask SUBSEC[14:3] and Alarm comparison is SUBSEC[2:0] */
  134. RTC_ALARM_SUBSEC_MASK_14_4, /*!< Mask SUBSEC[14:4] and Alarm comparison is SUBSEC[3:0] */
  135. RTC_ALARM_SUBSEC_MASK_14_5, /*!< Mask SUBSEC[14:5] and Alarm comparison is SUBSEC[4:0] */
  136. RTC_ALARM_SUBSEC_MASK_14_6, /*!< Mask SUBSEC[14:6] and Alarm comparison is SUBSEC[5:0] */
  137. RTC_ALARM_SUBSEC_MASK_14_7, /*!< Mask SUBSEC[14:7] and Alarm comparison is SUBSEC[6:0] */
  138. RTC_ALARM_SUBSEC_MASK_14_8, /*!< Mask SUBSEC[14:8] and Alarm comparison is SUBSEC[7:0] */
  139. RTC_ALARM_SUBSEC_MASK_14_9, /*!< Mask SUBSEC[14:9] and Alarm comparison is SUBSEC[8:0] */
  140. RTC_ALARM_SUBSEC_MASK_14_10, /*!< Mask SUBSEC[14:10] and Alarm comparison is SUBSEC[9:0] */
  141. RTC_ALARM_SUBSEC_MASK_14_11, /*!< Mask SUBSEC[14:11] and Alarm comparison is SUBSEC[10:0] */
  142. RTC_ALARM_SUBSEC_MASK_14_12, /*!< Mask SUBSEC[14:12] and Alarm comparison is SUBSEC[11:0] */
  143. RTC_ALARM_SUBSEC_MASK_14_13, /*!< Mask SUBSEC[14:13] and Alarm comparison is SUBSEC[12:0] */
  144. RTC_ALARM_SUBSEC_MASK_14, /*!< Mask SUBSEC[14] and Alarm comparison is SUBSEC[13:0] */
  145. RTC_ALARM_SUBSEC_MASK_NONE /*!< Alarm comparison is all the SUBSEC bit */
  146. } RTC_ALARM_SUBSEC_MASK_T;
  147. /**
  148. * @brief RTC Wakeup clock select
  149. */
  150. typedef enum
  151. {
  152. RTC_WAKEUP_CLOCK_RTC_DIV16 = 0x00, /*!< Wakeup Clock select to RTC/16 */
  153. RTC_WAKEUP_CLOCK_RTC_DIV8 = 0x01, /*!< Wakeup Clock select to RTC/8 */
  154. RTC_WAKEUP_CLOCK_RTC_DIV4 = 0x02, /*!< Wakeup Clock select to RTC/4 */
  155. RTC_WAKEUP_CLOCK_RTC_DIV2 = 0x03, /*!< Wakeup Clock select to RTC/2 */
  156. RTC_WAKEUP_CLOCK_CK_SPRE_16B = 0x04, /*!< Wakeup Clock select to clk_spre */
  157. RTC_WAKEUP_CLOCK_CK_SPRE_17B = 0x06 /*!< Wakeup Clock select to clk_spre */
  158. } RTC_WAKEUP_CLOCK_T;
  159. /**
  160. * @brief RTC Time Stamp Edges
  161. */
  162. typedef enum
  163. {
  164. RTC_TIMESTAMP_EDGE_RISING, /*!< Rising edge generates a timestamp event */
  165. RTC_TIMESTAMP_EDGE_FALLING /*!< Falling edge generates a timestamp event */
  166. } RTC_TIMESTAMP_EDGE_T;
  167. /**
  168. * @brief RTC Output selection
  169. */
  170. typedef enum
  171. {
  172. RTC_OUT_SEL_DISABLE, /*!< Disable RTC output */
  173. RTC_OUT_SEL_ALARM_A, /*!< Select alarm A as RTC output */
  174. RTC_OUT_SEL_ALARM_B, /*!< Select alarm B as RTC output */
  175. RTC_OUT_SEL_WAKEUP /*!< Select wake up as RTC output */
  176. } RTC_OUT_SEL_T;
  177. /**
  178. * @brief RTC Output Polarity
  179. */
  180. typedef enum
  181. {
  182. RTC_OUT_POLARITY_HIGH, /*!< The output polarity is high */
  183. RTC_OUT_POLARITY_LOW /*!< The output polarity is low */
  184. } RTC_OUT_POLARITY_T;
  185. /**
  186. * @brief RTC Digital Calibration sign
  187. */
  188. typedef enum
  189. {
  190. RTC_CALIB_SIGN_POSITIVE, /*!< The Calibration sign is positive */
  191. RTC_CALIB_SIGN_NEGATIVE /*!< The Calibration sign is negative */
  192. } RTC_CALIB_SIGN_T;
  193. /**
  194. * @brief RTC Calibration Output selection
  195. */
  196. typedef enum
  197. {
  198. RTC_CALIB_OUTPUT_512HZ, /*!< Calibration output is 512 Hz */
  199. RTC_CALIB_OUTPUT_1HZ /*!< Calibration output is 1 Hz */
  200. } RTC_CALIB_OUTPUT_T;
  201. /**
  202. * @brief RTC Smooth Calibration period
  203. */
  204. typedef enum
  205. {
  206. RTC_SCP_32SEC, /*!< if RTCCLK is 32768 Hz, Smooth calibration period will be 32s,
  207. else 2exp20 RTCCLK seconds */
  208. RTC_SCP_16SEC, /*!< if RTCCLK is 32768 Hz, Smooth calibration period will be 16s,
  209. else 2exp19 RTCCLK seconds */
  210. RTC_SCP_8SEC /*!< if RTCCLK is 32768 Hz, Smooth calibration period will be 8s,
  211. else 2exp18 RTCCLK seconds */
  212. } RTC_SCP_T;
  213. /**
  214. * @brief RTC Smooth Calibration Plus pulses
  215. */
  216. typedef enum
  217. {
  218. RTC_SCPP_RESET, /*!< Add one RTCCLK puls every 2**11 pulses */
  219. RTC_SCPP_SET /*!< No RTCCLK pulses are added */
  220. } RTC_SCPP_T;
  221. /**
  222. * @brief RTC DayLight Saving
  223. */
  224. typedef enum
  225. {
  226. RTC_DLS_SUB_1H, /*!< Winter time change */
  227. RTC_DLS_ADD_1H /*!< Summer time change */
  228. } RTC_DLS_T;
  229. /**
  230. * @brief RTC Store Operation to Backup bit
  231. */
  232. typedef enum
  233. {
  234. RTC_BACKUP_RESET, /*!< Reset backup value */
  235. RTC_BACKUP_SET /*!< Set backup value */
  236. } RTC_BACKUP_T;
  237. /**
  238. * @brief RTC Tamper Trigger
  239. */
  240. typedef enum
  241. {
  242. RTC_TAMPER_TRIGGER_EDGE_RISING = 0, /*!< Rising Edge of the tamper pin causes tamper event */
  243. RTC_TAMPER_TRIGGER_EDGE_FALLING = 1, /*!< Falling Edge of the tamper pin causes tamper event */
  244. RTC_TAMPER_TRIGGER_LEVEL_LOW = 0, /*!< Low Level of the tamper pin causes tamper event */
  245. RTC_TAMPER_TRIGGER_LEVEL_HIGH = 1 /*!< High Level of the tamper pin causes tamper event */
  246. } RTC_TAMPER_TRIGGER_T;
  247. /**
  248. * @brief Tampers Filter
  249. */
  250. typedef enum
  251. {
  252. RTC_TAMPER_FILTER_DISABLE, /*!< Tamper filter is disabled */
  253. RTC_TAMPER_FILTER_2SAMPLE, /*!< Tamper is activated after 2 consecutive samples at the active level */
  254. RTC_TAMPER_FILTER_4SAMPLE, /*!< Tamper is activated after 4 consecutive samples at the active level */
  255. RTC_TAMPER_FILTER_8SAMPLE /*!< Tamper is activated after 8 consecutive samples at the active level */
  256. } RTC_TAMPER_FILTER_T;
  257. /**
  258. * @brief Tampers Sampling Frequency
  259. */
  260. typedef enum
  261. {
  262. RTC_TSF_DIV_32768, /*!< Tampers Sampling Frequency = RTC_CLK / 32768 */
  263. RTC_TSF_DIV_16384, /*!< Tampers Sampling Frequency = RTC_CLK / 16384 */
  264. RTC_TSF_DIV_8192, /*!< Tampers Sampling Frequency = RTC_CLK / 8192 */
  265. RTC_TSF_DIV_4096, /*!< Tampers Sampling Frequency = RTC_CLK / 4096 */
  266. RTC_TSF_DIV_2048, /*!< Tampers Sampling Frequency = RTC_CLK / 2048 */
  267. RTC_TSF_DIV_1024, /*!< Tampers Sampling Frequency = RTC_CLK / 1024 */
  268. RTC_TSF_DIV_512, /*!< Tampers Sampling Frequency = RTC_CLK / 512 */
  269. RTC_TSF_DIV_256 /*!< Tampers Sampling Frequency = RTC_CLK / 256 */
  270. } RTC_TSF_DIV_T;
  271. /**
  272. * @brief Tamper Precharge Duration
  273. */
  274. typedef enum
  275. {
  276. RTC_TPD_RTCCLK_1, /*!< Duration is 1 RTCCLK cycle */
  277. RTC_TPD_RTCCLK_2, /*!< Duration is 2 RTCCLK cycle */
  278. RTC_TPD_RTCCLK_4, /*!< Duration is 4 RTCCLK cycle */
  279. RTC_TPD_RTCCLK_8 /*!< Duration is 8 RTCCLK cycle */
  280. } RTC_TPD_RTCCLK_T;
  281. /**
  282. * @brief RTC Tamper Pin Selection
  283. */
  284. typedef enum
  285. {
  286. RTC_TAMPER_PIN_AF1, /*!< RTC_TAMP1 is mapped to PC13 */
  287. RTC_TAMPER_PIN_AF2 /*!< RTC_TAMP1 is mapped to PI8 */
  288. } RTC_TAMPER_PIN_T;
  289. /**
  290. * @brief RTC TimeStamp Pin Selection
  291. */
  292. typedef enum
  293. {
  294. RTC_TIMESTAMP_PIN_AF1, /*!< TimeStamp Pin is mapped to PC13 */
  295. RTC_TIMESTAMP_PIN_AF2 /*!< TimeStamp Pin is mapped to PI8 */
  296. } RTC_TIMESTAMP_PIN_T;
  297. /**
  298. * @brief RTC Output Type ALARM OUT
  299. */
  300. typedef enum
  301. {
  302. RTC_OUTPUT_OD, /*!< RTC_ALARM output Open-drain */
  303. RTC_OUTPUT_PP /*!< RTC_ALARM output Push-pull */
  304. } RTC_OUTPUT_T;
  305. /**
  306. * @brief RTC Add 1 Second Parameter
  307. */
  308. typedef enum
  309. {
  310. RTC_SHIFT_ADD1S_RESET, /*!< No effect */
  311. RTC_SHIFT_ADD1S_SET /*!< Add one second to the clock calendar */
  312. } RTC_SHIFT_ADD1S_T;
  313. /**
  314. * @brief RTC_Backup register
  315. */
  316. typedef enum
  317. {
  318. RTC_BAKP_REG_0, /*!< Backup register 0 */
  319. RTC_BAKP_REG_1, /*!< Backup register 1 */
  320. RTC_BAKP_REG_2, /*!< Backup register 2 */
  321. RTC_BAKP_REG_3, /*!< Backup register 3 */
  322. RTC_BAKP_REG_4, /*!< Backup register 4 */
  323. RTC_BAKP_REG_5, /*!< Backup register 5 */
  324. RTC_BAKP_REG_6, /*!< Backup register 6 */
  325. RTC_BAKP_REG_7, /*!< Backup register 7 */
  326. RTC_BAKP_REG_8, /*!< Backup register 8 */
  327. RTC_BAKP_REG_9, /*!< Backup register 9 */
  328. RTC_BAKP_REG_10, /*!< Backup register 10 */
  329. RTC_BAKP_REG_11, /*!< Backup register 11 */
  330. RTC_BAKP_REG_12, /*!< Backup register 12 */
  331. RTC_BAKP_REG_13, /*!< Backup register 13 */
  332. RTC_BAKP_REG_14, /*!< Backup register 14 */
  333. RTC_BAKP_REG_15, /*!< Backup register 15 */
  334. RTC_BAKP_REG_16, /*!< Backup register 16 */
  335. RTC_BAKP_REG_17, /*!< Backup register 17 */
  336. RTC_BAKP_REG_18, /*!< Backup register 18 */
  337. RTC_BAKP_REG_19 /*!< Backup register 19 */
  338. } RTC_BAKP_REG_T;
  339. /**
  340. * @brief RTC flag
  341. */
  342. typedef enum
  343. {
  344. RTC_FLAG_AAWF = BIT0, /*!< Alarm A Write Flag */
  345. RTC_FLAG_ABWF = BIT1, /*!< Alarm B Write Flag */
  346. RTC_FLAG_WTWF = BIT2, /*!< Wakeup Timer Write Flag */
  347. RTC_FLAG_SOPF = BIT3, /*!< Shift Operation Pending Flag */
  348. RTC_FLAG_ISF = BIT4, /*!< Initialization State Flag */
  349. RTC_FLAG_RSF = BIT5, /*!< Registers Synchronization Flag */
  350. RTC_FLAG_INTF = BIT6, /*!< Register Initialization Flag */
  351. RTC_FLAG_ALRAF = BIT8, /*!< Alarm A Match Flag */
  352. RTC_FLAG_ALRBF = BIT9, /*!< Alarm B Match Flag */
  353. RTC_FLAG_WTF = BIT10, /*!< Wakeup Timer Flag */
  354. RTC_FLAG_TSF = BIT11, /*!< Time Stamp Flag */
  355. RTC_FLAG_TSOF = BIT12, /*!< Time Stamp Overflow Flag */
  356. RTC_FLAG_TP1F = BIT13, /*!< Tamper 1 event Detection Flag */
  357. RTC_FLAG_TP2F = BIT14, /*!< Tamper 2 event Detection Flag */
  358. RTC_FLAG_RPF = BIT16 /*!< Recalibration Pending Flag */
  359. } RTC_FLAG_T;
  360. /**
  361. * @brief RTC Interrupts Flag
  362. */
  363. typedef enum
  364. {
  365. RTC_INT_FLAG_ALRA = (uint32_t)0x00001000, /*!< Alarm A interrupt flag */
  366. RTC_INT_FLAG_ALRB = (uint32_t)0x00002000, /*!< Alarm B interrupt flag */
  367. RTC_INT_FLAG_WT = (uint32_t)0x00004000, /*!< Time Stamp interrupt flag */
  368. RTC_INT_FLAG_TS = (uint32_t)0x00008000, /*!< WakeUp Timer interrupt flag */
  369. RTC_INT_FLAG_TAMP1 = (uint32_t)0x00020001, /*!< Tamper1 event interrupt flag */
  370. RTC_INT_FLAG_TAMP2 = (uint32_t)0x00040001 /*!< Tamper2 event interrupt flag */
  371. } RTC_INT_FLAG_T;
  372. /**
  373. * @brief RTC Interrupts
  374. */
  375. typedef enum
  376. {
  377. RTC_INT_ALRA = BIT12, /*!< Alarm A interrupt */
  378. RTC_INT_ALRB = BIT13, /*!< Alarm B interrupt */
  379. RTC_INT_WT = BIT14, /*!< WakeUp Timer interrupt */
  380. RTC_INT_TS = BIT15, /*!< Time Stamp interrupt */
  381. RTC_INT_TAMP = BIT2 /*!< Tamper Interrupt in TACFG register */
  382. } RTC_INT_T;
  383. /**
  384. * @brief Selected RTC Tamper Pin
  385. */
  386. typedef enum
  387. {
  388. RTC_TAMPER_1, /*!< Select Tamper 1 */
  389. RTC_TAMPER_2 /*!< Select Tamper 2 */
  390. } RTC_TAMPER_T;
  391. /**@} end of group RTC_Enumerations*/
  392. /** @addtogroup RTC_Structure Data Structure
  393. @{
  394. */
  395. /**
  396. * @brief RTC Init structures definition
  397. */
  398. typedef struct
  399. {
  400. RTC_HOUR_FORMAT_T format; /*!< RTC hour formats selection */
  401. uint32_t asynchPrediv; /*!< Asynchronous prescaler coefficient setting */
  402. uint32_t synchPrediv; /*!< Synchronous prescaler coefficient setting */
  403. } RTC_Config_T;
  404. /**
  405. * @brief RTC Time structure definition
  406. */
  407. typedef struct
  408. {
  409. uint8_t hours; /*!< Set hours of RTC time */
  410. uint8_t minutes; /*!< Set minutes of RTC time */
  411. uint8_t seconds; /*!< Set seconds of RTC time */
  412. RTC_H12_T h12; /*!< Set RTC time to AM or PM */
  413. } RTC_TimeConfig_T;
  414. /**
  415. * @brief RTC Date structure definition
  416. */
  417. typedef struct
  418. {
  419. RTC_WEEKDAY_T weekday; /*!< Set weekday of RTC date */
  420. RTC_MONTH_T month; /*!< Set month of RTC date */
  421. uint8_t date; /*!< Set date of RTC date */
  422. uint8_t year; /*!< Set year of RTC date */
  423. } RTC_DateConfig_T;
  424. /**
  425. * @brief RTC ALRMA structure definition
  426. */
  427. typedef struct
  428. {
  429. RTC_TimeConfig_T time; /*!< Set RTC time */
  430. uint32_t alarmMask; /*!< Set alarm mask */
  431. RTC_WEEKDAY_SEL_T alarmDateWeekDaySel; /*!< Set weekday's DAYU of alarm date */
  432. uint8_t alarmDateWeekDay; /*!< Set weekday of alarm date */
  433. } RTC_AlarmConfig_T;
  434. /**@} end of group RTC_Structure*/
  435. /** @addtogroup RTC_Functions
  436. @{
  437. */
  438. /* RTC reset */
  439. uint8_t RTC_Reset(void);
  440. /* Initialization and Configuration */
  441. uint8_t RTC_Config(RTC_Config_T* rtcConfig);
  442. void RTC_ConfigStructInit(RTC_Config_T* rtcConfig);
  443. void RTC_EnableWriteProtection(void);
  444. void RTC_DisableWriteProtection(void);
  445. uint8_t RTC_EnableInit(void);
  446. void RTC_DisableInit(void);
  447. uint8_t RTC_WaitForSynchro(void);
  448. uint8_t RTC_EnableRefClock(void);
  449. uint8_t RTC_DisableRefClock(void);
  450. void RTC_EnableBypassShadow(void);
  451. void RTC_DisableBypassShadow(void);
  452. /* Time */
  453. uint8_t RTC_ConfigTime(RTC_FORMAT_T format, RTC_TimeConfig_T* timeConfig);
  454. void RTC_ConfigTimeStructInit(RTC_TimeConfig_T* timeConfig);
  455. void RTC_ReadTime(RTC_FORMAT_T format, RTC_TimeConfig_T* time);
  456. uint32_t RTC_ReadSubSecond(void);
  457. /* Date */
  458. uint8_t RTC_ConfigDate(RTC_FORMAT_T format, RTC_DateConfig_T* dateConfig);
  459. void RTC_ConfigDateStructInit(RTC_DateConfig_T* dateConfig);
  460. void RTC_ReadDate(RTC_FORMAT_T format, RTC_DateConfig_T* date);
  461. /* Alarms (Alarm A and Alarm B)*/
  462. void RTC_ConfigAlarm(RTC_FORMAT_T format, RTC_ALARM_T alarm, RTC_AlarmConfig_T* alarmConfig);
  463. void RTC_ConfigAlarmStructInit(RTC_AlarmConfig_T* alarmConfig);
  464. void RTC_ReadAlarm(RTC_FORMAT_T format, RTC_ALARM_T alarm, RTC_AlarmConfig_T* alarmConfig);
  465. void RTC_EnableAlarmA(void);
  466. uint8_t RTC_DisableAlarmA(void);
  467. void RTC_EnableAlarmB(void);
  468. uint8_t RTC_DisableAlarmB(void);
  469. void RTC_ConfigAlarmSubSecond(RTC_ALARM_T alarm, uint32_t val, RTC_ALARM_SUBSEC_MASK_T mask);
  470. uint16_t RTC_ReadAlarmSubSecond(RTC_ALARM_T alarm);
  471. /* WakeUp Timer */
  472. void RTC_ConfigWakeUpClock(RTC_WAKEUP_CLOCK_T wakeUpClock);
  473. void RTC_ConfigWakeUpValue(uint16_t wakeUpValue);
  474. uint16_t RTC_ReadWakeUpValue(void);
  475. void RTC_EnableWakeUp(void);
  476. uint8_t RTC_DisableWakeUp(void);
  477. /* Daylight Saving */
  478. void RTC_ConfigDayLightSaving(RTC_DLS_T saving, RTC_BACKUP_T bit);
  479. uint8_t RTC_ReadStoreOperation(void);
  480. /* Alarm Output */
  481. void RTC_ConfigOutput(RTC_OUT_SEL_T outputSel, RTC_OUT_POLARITY_T polarity);
  482. /* Coarse Digital Calibration */
  483. uint8_t RTC_ConfigCoarseCalib(RTC_CALIB_SIGN_T calibSign, uint32_t value);
  484. uint8_t RTC_EnableCoarseCalib(void);
  485. uint8_t RTC_DisableCoarseCalib(void);
  486. /* Calibration Output */
  487. void RTC_EnableCalibOutput(void);
  488. void RTC_DisableCalibOutput(void);
  489. void RTC_ConfigCalibOutput(RTC_CALIB_OUTPUT_T calib);
  490. /* Smooth Digital Calibration */
  491. uint8_t RTC_ConfigSmoothCalib(RTC_SCP_T period, RTC_SCPP_T calibPulse, uint16_t value);
  492. /* TimeStamp */
  493. void RTC_EnableTimeStamp(RTC_TIMESTAMP_EDGE_T edge);
  494. void RTC_DisableTimeStamp(void);
  495. void RTC_ReadTimeDate(RTC_FORMAT_T format, RTC_TimeConfig_T* time, RTC_DateConfig_T* date);
  496. uint16_t RTC_ReadTimeStampSubSecond(void);
  497. /* Tamper */
  498. void RTC_ConfigTamperTrigger(RTC_TAMPER_T tamper, RTC_TAMPER_TRIGGER_T trigger);
  499. void RTC_EnableTamper(RTC_TAMPER_T tamper);
  500. void RTC_DisableTamper(RTC_TAMPER_T tamper);
  501. void RTC_ConfigFilter(RTC_TAMPER_FILTER_T filter);
  502. void RTC_ConfigSamplingFreq(RTC_TSF_DIV_T freq);
  503. void RTC_PinsPrechargeDuration(RTC_TPD_RTCCLK_T duration);
  504. void RTC_EnableTDE(void);
  505. void RTC_DisableTDE(void);
  506. void RTC_EnablePullUp(void);
  507. void RTC_DisablePullUp(void);
  508. /* Backup Data Registers */
  509. void RTC_WriteBackup(RTC_BAKP_REG_T backupReg, uint32_t data);
  510. uint32_t RTC_ReadBackup(RTC_BAKP_REG_T backup);
  511. /* Tamper and TimeStamp Pins mapping */
  512. void RTC_ConfigTamperPin(RTC_TAMPER_PIN_T tamperPin);
  513. void RTC_ConfigTimeStampPin(RTC_TIMESTAMP_PIN_T timeStampPin);
  514. /* Output Type */
  515. void RTC_ConfigOutputType(RTC_OUTPUT_T outputType);
  516. /* Shift control synchonisation */
  517. uint8_t RTC_ConfigSynchroShift(RTC_SHIFT_ADD1S_T add1S, uint16_t subFS);
  518. /* Interrupts and flags */
  519. void RTC_EnableInterrupt(uint32_t interrupt);
  520. void RTC_DisableInterrupt(uint32_t interrupt);
  521. uint8_t RTC_ReadStatusFlag(RTC_FLAG_T flag);
  522. void RTC_ClearStatusFlag(uint32_t flag);
  523. uint8_t RTC_ReadIntFlag(RTC_INT_FLAG_T flag);
  524. void RTC_ClearIntFlag(uint32_t flag);
  525. #ifdef __cplusplus
  526. }
  527. #endif
  528. #endif /* __APM32F4XX_RTC_H */
  529. /**@} end of group RTC_Enumerations */
  530. /**@} end of group RTC_Driver */
  531. /**@} end of group APM32F4xx_StdPeriphDriver */