at32f421_ertc.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  1. /**
  2. **************************************************************************
  3. * @file at32f421_ertc.h
  4. * @brief at32f421 ertc header file
  5. **************************************************************************
  6. * Copyright notice & Disclaimer
  7. *
  8. * The software Board Support Package (BSP) that is made available to
  9. * download from Artery official website is the copyrighted work of Artery.
  10. * Artery authorizes customers to use, copy, and distribute the BSP
  11. * software and its related documentation for the purpose of design and
  12. * development in conjunction with Artery microcontrollers. Use of the
  13. * software is governed by this copyright notice and the following disclaimer.
  14. *
  15. * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  16. * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  17. * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  18. * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  19. * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  21. *
  22. **************************************************************************
  23. */
  24. /* Define to prevent recursive inclusion -------------------------------------*/
  25. #ifndef __AT32F421_ERTC_H
  26. #define __AT32F421_ERTC_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "at32f421.h"
  32. /** @addtogroup AT32F421_periph_driver
  33. * @{
  34. */
  35. /** @addtogroup ERTC
  36. * @{
  37. */
  38. /** @defgroup ERTC_interrupts_definition
  39. * @brief ertc interrupt
  40. * @{
  41. */
  42. #define ERTC_TP_INT ((uint32_t)0x00000004) /*!< ertc tamper interrupt */
  43. #define ERTC_ALA_INT ((uint32_t)0x00001000) /*!< ertc alarm a interrupt */
  44. #define ERTC_TS_INT ((uint32_t)0x00008000) /*!< ertc timestamp interrupt */
  45. /**
  46. * @}
  47. */
  48. /** @defgroup ERTC_flags_definition
  49. * @brief ertc flag
  50. * @{
  51. */
  52. #define ERTC_ALAWF_FLAG ((uint32_t)0x00000001) /*!< ertc alarm a register allows write flag */
  53. #define ERTC_TADJF_FLAG ((uint32_t)0x00000008) /*!< ertc time adjustment flag */
  54. #define ERTC_INITF_FLAG ((uint32_t)0x00000010) /*!< ertc calendar initialization flag */
  55. #define ERTC_UPDF_FLAG ((uint32_t)0x00000020) /*!< ertc calendar update flag */
  56. #define ERTC_IMF_FLAG ((uint32_t)0x00000040) /*!< ertc enter initialization mode flag */
  57. #define ERTC_ALAF_FLAG ((uint32_t)0x00000100) /*!< ertc alarm clock a flag */
  58. #define ERTC_TSF_FLAG ((uint32_t)0x00000800) /*!< ertc timestamp flag */
  59. #define ERTC_TSOF_FLAG ((uint32_t)0x00001000) /*!< ertc timestamp overflow flag */
  60. #define ERTC_TP1F_FLAG ((uint32_t)0x00002000) /*!< ertc tamper detection 1 flag */
  61. #define ERTC_CALUPDF_FLAG ((uint32_t)0x00010000) /*!< ertc calibration value update completed flag */
  62. /**
  63. * @brief ertc alarm mask
  64. */
  65. #define ERTC_ALARM_MASK_NONE ((uint32_t)0x00000000) /*!< ertc alarm match all */
  66. #define ERTC_ALARM_MASK_SEC ((uint32_t)0x00000080) /*!< ertc alarm don't match seconds */
  67. #define ERTC_ALARM_MASK_MIN ((uint32_t)0x00008000) /*!< ertc alarm don't match minute */
  68. #define ERTC_ALARM_MASK_HOUR ((uint32_t)0x00800000) /*!< ertc alarm don't match hour */
  69. #define ERTC_ALARM_MASK_DATE_WEEK ((uint32_t)0x80000000) /*!< ertc alarm don't match date or week */
  70. #define ERTC_ALARM_MASK_ALL ((uint32_t)0x80808080) /*!< ertc alarm don't match all */
  71. /**
  72. * @}
  73. */
  74. /** @defgroup ERTC_exported_types
  75. * @{
  76. */
  77. /**
  78. * @brief ertc hour mode
  79. */
  80. typedef enum
  81. {
  82. ERTC_HOUR_MODE_24 = 0x00, /*!< 24-hour format */
  83. ERTC_HOUR_MODE_12 = 0x01 /*!< 12-hour format */
  84. } ertc_hour_mode_set_type;
  85. /**
  86. * @brief ertc 12-hour format am/pm
  87. */
  88. typedef enum
  89. {
  90. ERTC_24H = 0x00, /*!< 24-hour format */
  91. ERTC_AM = 0x00, /*!< 12-hour format, ante meridiem */
  92. ERTC_PM = 0x01 /*!< 12-hour format, meridiem */
  93. } ertc_am_pm_type;
  94. /**
  95. * @brief ertc week or date select
  96. */
  97. typedef enum
  98. {
  99. ERTC_SLECT_DATE = 0x00, /*!< slect date mode */
  100. ERTC_SLECT_WEEK = 0x01 /*!< slect week mode */
  101. } ertc_week_date_select_type;
  102. /**
  103. * @brief ertc alarm x select
  104. */
  105. typedef enum
  106. {
  107. ERTC_ALA = 0x00, /*!< select alarm a */
  108. } ertc_alarm_type;
  109. /**
  110. * @brief ertc alarm sub second mask
  111. */
  112. typedef enum
  113. {
  114. ERTC_ALARM_SBS_MASK_ALL = 0x00, /*!< do not match the sub-second */
  115. ERTC_ALARM_SBS_MASK_14_1 = 0x01, /*!< only compare bit [0] */
  116. ERTC_ALARM_SBS_MASK_14_2 = 0x02, /*!< only compare bit [1:0] */
  117. ERTC_ALARM_SBS_MASK_14_3 = 0x03, /*!< only compare bit [2:0] */
  118. ERTC_ALARM_SBS_MASK_14_4 = 0x04, /*!< only compare bit [3:0] */
  119. ERTC_ALARM_SBS_MASK_14_5 = 0x05, /*!< only compare bit [4:0] */
  120. ERTC_ALARM_SBS_MASK_14_6 = 0x06, /*!< only compare bit [5:0] */
  121. ERTC_ALARM_SBS_MASK_14_7 = 0x07, /*!< only compare bit [6:0] */
  122. ERTC_ALARM_SBS_MASK_14_8 = 0x08, /*!< only compare bit [7:0] */
  123. ERTC_ALARM_SBS_MASK_14_9 = 0x09, /*!< only compare bit [8:0] */
  124. ERTC_ALARM_SBS_MASK_14_10 = 0x0A, /*!< only compare bit [9:0] */
  125. ERTC_ALARM_SBS_MASK_14_11 = 0x0B, /*!< only compare bit [10:0] */
  126. ERTC_ALARM_SBS_MASK_14_12 = 0x0C, /*!< only compare bit [11:0] */
  127. ERTC_ALARM_SBS_MASK_14_13 = 0x0D, /*!< only compare bit [12:0] */
  128. ERTC_ALARM_SBS_MASK_14 = 0x0E, /*!< only compare bit [13:0] */
  129. ERTC_ALARM_SBS_MASK_NONE = 0x0F /*!< compare bit [14:0] */
  130. } ertc_alarm_sbs_mask_type;
  131. /**
  132. * @brief ertc smooth calibration period
  133. */
  134. typedef enum
  135. {
  136. ERTC_SMOOTH_CAL_PERIOD_32 = 0x00, /*!< 32 second calibration period */
  137. ERTC_SMOOTH_CAL_PERIOD_16 = 0x01, /*!< 16 second calibration period */
  138. ERTC_SMOOTH_CAL_PERIOD_8 = 0x02 /*!< 8 second calibration period */
  139. } ertc_smooth_cal_period_type;
  140. /**
  141. * @brief ertc smooth calibration clock add mode
  142. */
  143. typedef enum
  144. {
  145. ERTC_SMOOTH_CAL_CLK_ADD_0 = 0x00, /*!< do not increase clock */
  146. ERTC_SMOOTH_CAL_CLK_ADD_512 = 0x01 /*!< add 512 clocks */
  147. } ertc_smooth_cal_clk_add_type;
  148. /**
  149. * @brief ertc calibration output mode
  150. */
  151. typedef enum
  152. {
  153. ERTC_CAL_OUTPUT_512HZ = 0x00, /*!< output 512 hz */
  154. ERTC_CAL_OUTPUT_1HZ = 0x01 /*!< output 1 hz */
  155. } ertc_cal_output_select_type;
  156. /**
  157. * @brief time adjust add mode
  158. */
  159. typedef enum
  160. {
  161. ERTC_TIME_ADD_NONE = 0x00, /*!< none operation */
  162. ERTC_TIME_ADD_1S = 0x01 /*!< add 1 second */
  163. } ertc_time_adjust_type;
  164. /**
  165. * @brief ertc daylight saving time hour adjustment mode
  166. */
  167. typedef enum
  168. {
  169. ERTC_DST_ADD_1H = 0x00, /*!< add 1 hour */
  170. ERTC_DST_DEC_1H = 0x01 /*!< dec 1 hour */
  171. } ertc_dst_operation_type;
  172. /**
  173. * @brief ertc daylight saving time store operation mode
  174. */
  175. typedef enum
  176. {
  177. ERTC_DST_SAVE_0 = 0x00, /*!< set the bpr register value to 0 */
  178. ERTC_DST_SAVE_1 = 0x01 /*!< set the bpr register value to 1 */
  179. } ertc_dst_save_type;
  180. /**
  181. * @brief output source
  182. */
  183. typedef enum
  184. {
  185. ERTC_OUTPUT_DISABLE = 0x00, /*!< diable output */
  186. ERTC_OUTPUT_ALARM_A = 0x01, /*!< output alarm a event */
  187. ERTC_OUTPUT_WAKEUP = 0x03 /*!< output wakeup event */
  188. } ertc_output_source_type;
  189. /**
  190. * @brief output polarity
  191. */
  192. typedef enum
  193. {
  194. ERTC_OUTPUT_POLARITY_HIGH = 0x00, /*!< when the event occurs, the output is high */
  195. ERTC_OUTPUT_POLARITY_LOW = 0x01 /*!< when the event occurs, the output is low */
  196. } ertc_output_polarity_type;
  197. /**
  198. * @brief output type
  199. */
  200. typedef enum
  201. {
  202. ERTC_OUTPUT_TYPE_OPEN_DRAIN = 0x00, /*!< open drain output */
  203. ERTC_OUTPUT_TYPE_PUSH_PULL = 0x01 /*!< push pull output */
  204. } ertc_output_type;
  205. /**
  206. * @brief ertc timestamp valid edge
  207. */
  208. typedef enum
  209. {
  210. ERTC_TIMESTAMP_EDGE_RISING = 0x00, /*!< rising edge trigger */
  211. ERTC_TIMESTAMP_EDGE_FALLING = 0x01 /*!< falling edge trigger */
  212. } ertc_timestamp_valid_edge_type;
  213. /**
  214. * @brief ertc tamper x select
  215. */
  216. typedef enum
  217. {
  218. ERTC_TAMPER_1 = 0x00, /*!< tamper 1 */
  219. } ertc_tamper_select_type;
  220. /**
  221. * @brief tamper detection pre-charge time
  222. */
  223. typedef enum
  224. {
  225. ERTC_TAMPER_PR_1_ERTCCLK = 0x00, /*!< pre-charge time is 1 ERTC_CLK */
  226. ERTC_TAMPER_PR_2_ERTCCLK = 0x01, /*!< pre-charge time is 2 ERTC_CLK */
  227. ERTC_TAMPER_PR_4_ERTCCLK = 0x02, /*!< pre-charge time is 4 ERTC_CLK */
  228. ERTC_TAMPER_PR_8_ERTCCLK = 0x03 /*!< pre-charge time is 8 ERTC_CLK */
  229. } ertc_tamper_precharge_type;
  230. /**
  231. * @brief ertc tamper filter
  232. */
  233. typedef enum
  234. {
  235. ERTC_TAMPER_FILTER_DISABLE = 0x00, /*!< disable filter function */
  236. ERTC_TAMPER_FILTER_2 = 0x01, /*!< 2 consecutive samples arw valid, effective tamper event */
  237. ERTC_TAMPER_FILTER_4 = 0x02, /*!< 4 consecutive samples arw valid, effective tamper event */
  238. ERTC_TAMPER_FILTER_8 = 0x03 /*!< 8 consecutive samples arw valid, effective tamper event */
  239. } ertc_tamper_filter_type;
  240. /**
  241. * @brief ertc tamper detection frequency
  242. */
  243. typedef enum
  244. {
  245. ERTC_TAMPER_FREQ_DIV_32768 = 0x00, /*!< ERTC_CLK / 32768 */
  246. ERTC_TAMPER_FREQ_DIV_16384 = 0x01, /*!< ERTC_CLK / 16384 */
  247. ERTC_TAMPER_FREQ_DIV_8192 = 0x02, /*!< ERTC_CLK / 8192 */
  248. ERTC_TAMPER_FREQ_DIV_4096 = 0x03, /*!< ERTC_CLK / 4096 */
  249. ERTC_TAMPER_FREQ_DIV_2048 = 0x04, /*!< ERTC_CLK / 2048 */
  250. ERTC_TAMPER_FREQ_DIV_1024 = 0x05, /*!< ERTC_CLK / 1024 */
  251. ERTC_TAMPER_FREQ_DIV_512 = 0x06, /*!< ERTC_CLK / 512 */
  252. ERTC_TAMPER_FREQ_DIV_256 = 0x07 /*!< ERTC_CLK / 256 */
  253. } ertc_tamper_detect_freq_type;
  254. /**
  255. * @brief ertc tamper valid edge
  256. */
  257. typedef enum
  258. {
  259. ERTC_TAMPER_EDGE_RISING = 0x00, /*!< rising gedge */
  260. ERTC_TAMPER_EDGE_FALLING = 0x01, /*!< falling gedge */
  261. ERTC_TAMPER_EDGE_LOW = 0x00, /*!< low level */
  262. ERTC_TAMPER_EDGE_HIGH = 0x01 /*!< high level */
  263. } ertc_tamper_valid_edge_type;
  264. /**
  265. * @brief ertc bpr register
  266. */
  267. typedef enum
  268. {
  269. ERTC_DT1 = 0, /*!< bpr data register 0 */
  270. ERTC_DT2 = 1, /*!< bpr data register 1 */
  271. ERTC_DT3 = 2, /*!< bpr data register 2 */
  272. ERTC_DT4 = 3, /*!< bpr data register 3 */
  273. ERTC_DT5 = 4, /*!< bpr data register 4 */
  274. } ertc_dt_type;
  275. /**
  276. * @brief ertc time
  277. */
  278. typedef struct
  279. {
  280. uint8_t year; /*!< year */
  281. uint8_t month; /*!< month */
  282. uint8_t day; /*!< date */
  283. uint8_t hour; /*!< hour */
  284. uint8_t min; /*!< minute */
  285. uint8_t sec; /*!< second */
  286. uint8_t week; /*!< week */
  287. ertc_am_pm_type ampm; /*!< ante meridiem / post meridiem */
  288. } ertc_time_type;
  289. /**
  290. * @brief ertc alarm
  291. */
  292. typedef struct
  293. {
  294. uint8_t day; /*!< date */
  295. uint8_t hour; /*!< hour */
  296. uint8_t min; /*!< minute */
  297. uint8_t sec; /*!< second */
  298. ertc_am_pm_type ampm; /*!< ante meridiem / post meridiem */
  299. uint32_t mask; /*!< alarm mask*/
  300. uint8_t week_date_sel; /*!< week or date mode */
  301. uint8_t week; /*!< week */
  302. } ertc_alarm_value_type;
  303. /**
  304. * @brief ertc time reg union
  305. */
  306. typedef union
  307. {
  308. __IO uint32_t time;
  309. struct
  310. {
  311. __IO uint32_t s : 7; /* [6:0] */
  312. __IO uint32_t reserved1 : 1; /* [7] */
  313. __IO uint32_t m : 7; /* [14:8] */
  314. __IO uint32_t reserved2 : 1; /* [15] */
  315. __IO uint32_t h : 6; /* [21:16] */
  316. __IO uint32_t ampm : 1; /* [22] */
  317. __IO uint32_t reserved3 : 9; /* [31:23] */
  318. } time_bit;
  319. } ertc_reg_time_type;
  320. /**
  321. * @brief ertc date reg union
  322. */
  323. typedef union
  324. {
  325. __IO uint32_t date;
  326. struct
  327. {
  328. __IO uint32_t d :6; /* [5:0] */
  329. __IO uint32_t reserved1 :2; /* [7:6] */
  330. __IO uint32_t m :5; /* [12:8] */
  331. __IO uint32_t wk :3; /* [15:13] */
  332. __IO uint32_t y :8; /* [23:16] */
  333. __IO uint32_t reserved2 :8; /* [31:24] */
  334. } date_bit;
  335. } ertc_reg_date_type;
  336. /**
  337. * @brief ertc alarm reg union
  338. */
  339. typedef union
  340. {
  341. __IO uint32_t ala;
  342. struct
  343. {
  344. __IO uint32_t s :7; /* [6:0] */
  345. __IO uint32_t mask1 :1; /* [7] */
  346. __IO uint32_t m :7; /* [14:8] */
  347. __IO uint32_t mask2 :1; /* [15] */
  348. __IO uint32_t h :6; /* [21:16] */
  349. __IO uint32_t ampm :1; /* [22] */
  350. __IO uint32_t mask3 :1; /* [23] */
  351. __IO uint32_t d :6; /* [29:24] */
  352. __IO uint32_t wksel :1; /* [30] */
  353. __IO uint32_t mask4 :1; /* [31] */
  354. } ala_bit;
  355. } ertc_reg_alarm_type;
  356. /**
  357. * @brief ertc scal reg union
  358. */
  359. typedef union
  360. {
  361. __IO uint32_t scal;
  362. struct
  363. {
  364. __IO uint32_t dec :9; /* [8:0] */
  365. __IO uint32_t reserved1 :4; /* [12:9] */
  366. __IO uint32_t cal16 :1; /* [13] */
  367. __IO uint32_t cal8 :1; /* [14] */
  368. __IO uint32_t add :1; /* [15] */
  369. __IO uint32_t reserved2 :16;/* [31:16] */
  370. } scal_bit;
  371. } ertc_reg_scal_type;
  372. /**
  373. * @brief ertc tadj reg union
  374. */
  375. typedef union
  376. {
  377. __IO uint32_t tadj;
  378. struct
  379. {
  380. __IO uint32_t decsbs :15;/* [14:0] */
  381. __IO uint32_t reserved1 :16;/* [30:15] */
  382. __IO uint32_t add1s :1; /* [31] */
  383. } tadj_bit;
  384. } ertc_reg_tadj_type;
  385. /**
  386. * @brief ertc tstm reg union
  387. */
  388. typedef union
  389. {
  390. __IO uint32_t tstm;
  391. struct
  392. {
  393. __IO uint32_t s :7; /* [6:0] */
  394. __IO uint32_t reserved1 :1; /* [7] */
  395. __IO uint32_t m :7; /* [14:8] */
  396. __IO uint32_t reserved2 :1; /* [15] */
  397. __IO uint32_t h :6; /* [21:16] */
  398. __IO uint32_t ampm :1; /* [22] */
  399. __IO uint32_t reserved3 :9; /* [31:23] */
  400. } tstm_bit;
  401. } ertc_reg_tstm_type;
  402. /**
  403. * @brief ertc tsdt register, offset:0x34
  404. */
  405. typedef union
  406. {
  407. __IO uint32_t tsdt;
  408. struct
  409. {
  410. __IO uint32_t d :6; /* [5:0] */
  411. __IO uint32_t reserved1 :2; /* [7:6] */
  412. __IO uint32_t m :5; /* [12:8] */
  413. __IO uint32_t wk :3; /* [15:13] */
  414. __IO uint32_t reserved2 :16;/* [31:16] */
  415. } tsdt_bit;
  416. } ertc_reg_tsdt_type;
  417. /**
  418. * @brief type define ertc register all
  419. */
  420. typedef struct
  421. {
  422. /**
  423. * @brief ertc time register, offset:0x00
  424. */
  425. union
  426. {
  427. __IO uint32_t time;
  428. struct
  429. {
  430. __IO uint32_t s : 7; /* [6:0] */
  431. __IO uint32_t reserved1 : 1; /* [7] */
  432. __IO uint32_t m : 7; /* [14:8] */
  433. __IO uint32_t reserved2 : 1; /* [15] */
  434. __IO uint32_t h : 6; /* [21:16] */
  435. __IO uint32_t ampm : 1; /* [22] */
  436. __IO uint32_t reserved3 : 9; /* [31:23] */
  437. } time_bit;
  438. };
  439. /**
  440. * @brief ertc date register, offset:0x04
  441. */
  442. union
  443. {
  444. __IO uint32_t date;
  445. struct
  446. {
  447. __IO uint32_t d :6; /* [5:0] */
  448. __IO uint32_t reserved1 :2; /* [7:6] */
  449. __IO uint32_t m :5; /* [12:8] */
  450. __IO uint32_t wk :3; /* [15:13] */
  451. __IO uint32_t y :8; /* [23:16] */
  452. __IO uint32_t reserved2 :8; /* [31:24] */
  453. } date_bit;
  454. };
  455. /**
  456. * @brief ertc ctrl register, offset:0x08
  457. */
  458. union
  459. {
  460. __IO uint32_t ctrl;
  461. struct
  462. {
  463. __IO uint32_t reserved1 :3; /* [2:0] */
  464. __IO uint32_t tsedg :1; /* [3] */
  465. __IO uint32_t rcden :1; /* [4] */
  466. __IO uint32_t dren :1; /* [5] */
  467. __IO uint32_t hm :1; /* [6] */
  468. __IO uint32_t reserved2 :1; /* [7] */
  469. __IO uint32_t alaen :1; /* [8] */
  470. __IO uint32_t reserved3 :1; /* [9] */
  471. __IO uint32_t reserved4 :1; /* [10] */
  472. __IO uint32_t tsen :1; /* [11] */
  473. __IO uint32_t alaien :1; /* [12] */
  474. __IO uint32_t reserved5 :1; /* [13] */
  475. __IO uint32_t reserved6 :1; /* [14] */
  476. __IO uint32_t tsien :1; /* [15] */
  477. __IO uint32_t add1h :1; /* [16] */
  478. __IO uint32_t dec1h :1; /* [17] */
  479. __IO uint32_t bpr :1; /* [18] */
  480. __IO uint32_t calosel :1; /* [19] */
  481. __IO uint32_t outp :1; /* [20] */
  482. __IO uint32_t outsel :2; /* [22:21] */
  483. __IO uint32_t caloen :1; /* [23] */
  484. __IO uint32_t reserved7 :8; /* [31:24] */
  485. } ctrl_bit;
  486. };
  487. /**
  488. * @brief ertc sts register, offset:0x0C
  489. */
  490. union
  491. {
  492. __IO uint32_t sts;
  493. struct
  494. {
  495. __IO uint32_t alawf :1; /* [0] */
  496. __IO uint32_t reserved1 :1; /* [1] */
  497. __IO uint32_t reserved2 :1; /* [2] */
  498. __IO uint32_t tadjf :1; /* [3] */
  499. __IO uint32_t initf :1; /* [4] */
  500. __IO uint32_t updf :1; /* [5] */
  501. __IO uint32_t imf :1; /* [6] */
  502. __IO uint32_t imen :1; /* [7] */
  503. __IO uint32_t alaf :1; /* [8] */
  504. __IO uint32_t reserved3 :1; /* [9] */
  505. __IO uint32_t reserved4 :1; /* [10] */
  506. __IO uint32_t tsf :1; /* [11] */
  507. __IO uint32_t tsof :1; /* [12] */
  508. __IO uint32_t tp1f :1; /* [13] */
  509. __IO uint32_t reserved5 :1; /* [14] */
  510. __IO uint32_t reserved6 :1; /* [15] */
  511. __IO uint32_t calupdf :1; /* [16] */
  512. __IO uint32_t reserved7 :15;/* [31:17] */
  513. } sts_bit;
  514. };
  515. /**
  516. * @brief ertc div register, offset:0x10
  517. */
  518. union
  519. {
  520. __IO uint32_t div;
  521. struct
  522. {
  523. __IO uint32_t divb :15;/* [14:0] */
  524. __IO uint32_t reserved1 :1; /* [15] */
  525. __IO uint32_t diva :7; /* [22:16] */
  526. __IO uint32_t reserved2 :9; /* [31:23] */
  527. } div_bit;
  528. };
  529. /**
  530. * @brief ertc reserved register, offset:0x14
  531. */
  532. __IO uint32_t reserved1;
  533. /**
  534. * @brief ertc reserved register, offset:0x18
  535. */
  536. __IO uint32_t reserved2;
  537. /**
  538. * @brief ertc ala register, offset:0x1C
  539. */
  540. union
  541. {
  542. __IO uint32_t ala;
  543. struct
  544. {
  545. __IO uint32_t s :7; /* [6:0] */
  546. __IO uint32_t mask1 :1; /* [7] */
  547. __IO uint32_t m :7; /* [14:8] */
  548. __IO uint32_t mask2 :1; /* [15] */
  549. __IO uint32_t h :6; /* [21:16] */
  550. __IO uint32_t ampm :1; /* [22] */
  551. __IO uint32_t mask3 :1; /* [23] */
  552. __IO uint32_t d :6; /* [29:24] */
  553. __IO uint32_t wksel :1; /* [30] */
  554. __IO uint32_t mask4 :1; /* [31] */
  555. } ala_bit;
  556. };
  557. /**
  558. * @brief ertc reserved register, offset:0x20
  559. */
  560. __IO uint32_t reserved3;
  561. /**
  562. * @brief ertc wp register, offset:0x24
  563. */
  564. union
  565. {
  566. __IO uint32_t wp;
  567. struct
  568. {
  569. __IO uint32_t cmd :8; /* [7:0] */
  570. __IO uint32_t reserved1 :24;/* [31:8] */
  571. } wp_bit;
  572. };
  573. /**
  574. * @brief ertc sbs register, offset:0x28
  575. */
  576. union
  577. {
  578. __IO uint32_t sbs;
  579. struct
  580. {
  581. __IO uint32_t sbs :16;/* [15:0] */
  582. __IO uint32_t reserved1 :16;/* [31:16] */
  583. } sbs_bit;
  584. };
  585. /**
  586. * @brief ertc tadj register, offset:0x2C
  587. */
  588. union
  589. {
  590. __IO uint32_t tadj;
  591. struct
  592. {
  593. __IO uint32_t decsbs :15;/* [14:0] */
  594. __IO uint32_t reserved1 :16;/* [30:15] */
  595. __IO uint32_t add1s :1; /* [31] */
  596. } tadj_bit;
  597. };
  598. /**
  599. * @brief ertc tstm register, offset:0x30
  600. */
  601. union
  602. {
  603. __IO uint32_t tstm;
  604. struct
  605. {
  606. __IO uint32_t s :7; /* [6:0] */
  607. __IO uint32_t reserved1 :1; /* [7] */
  608. __IO uint32_t m :7; /* [14:8] */
  609. __IO uint32_t reserved2 :1; /* [15] */
  610. __IO uint32_t h :6; /* [21:16] */
  611. __IO uint32_t ampm :1; /* [22] */
  612. __IO uint32_t reserved3 :9; /* [31:23] */
  613. } tstm_bit;
  614. };
  615. /**
  616. * @brief ertc tsdt register, offset:0x34
  617. */
  618. union
  619. {
  620. __IO uint32_t tsdt;
  621. struct
  622. {
  623. __IO uint32_t d :6; /* [5:0] */
  624. __IO uint32_t reserved1 :2; /* [7:6] */
  625. __IO uint32_t m :5; /* [12:8] */
  626. __IO uint32_t wk :3; /* [15:13] */
  627. __IO uint32_t reserved2 :16;/* [31:16] */
  628. } tsdt_bit;
  629. };
  630. /**
  631. * @brief ertc tssbs register, offset:0x38
  632. */
  633. union
  634. {
  635. __IO uint32_t tssbs;
  636. struct
  637. {
  638. __IO uint32_t sbs :16;/* [15:0] */
  639. __IO uint32_t reserved1 :16;/* [31:16] */
  640. } tssbs_bit;
  641. };
  642. /**
  643. * @brief ertc scal register, offset:0x3C
  644. */
  645. union
  646. {
  647. __IO uint32_t scal;
  648. struct
  649. {
  650. __IO uint32_t dec :9; /* [8:0] */
  651. __IO uint32_t reserved1 :4; /* [12:9] */
  652. __IO uint32_t cal16 :1; /* [13] */
  653. __IO uint32_t cal8 :1; /* [14] */
  654. __IO uint32_t add :1; /* [15] */
  655. __IO uint32_t reserved2 :16;/* [31:16] */
  656. } scal_bit;
  657. };
  658. /**
  659. * @brief ertc tamp register, offset:0x40
  660. */
  661. union
  662. {
  663. __IO uint32_t tamp;
  664. struct
  665. {
  666. __IO uint32_t tp1en :1; /* [0] */
  667. __IO uint32_t tp1edg :1; /* [1] */
  668. __IO uint32_t tpien :1; /* [2] */
  669. __IO uint32_t reserved1 :1; /* [3] */
  670. __IO uint32_t reserved2 :1; /* [4] */
  671. __IO uint32_t reserved3 :2; /* [6:5] */
  672. __IO uint32_t tptsen :1; /* [7] */
  673. __IO uint32_t tpfreq :3; /* [10:8] */
  674. __IO uint32_t tpflt :2; /* [12:11] */
  675. __IO uint32_t tppr :2; /* [14:13] */
  676. __IO uint32_t tppu :1; /* [15] */
  677. __IO uint32_t reserved4 :1; /* [16] */
  678. __IO uint32_t reserved5 :1; /* [17] */
  679. __IO uint32_t outtype :1; /* [18] */
  680. __IO uint32_t reserved6 :13;/* [31:19] */
  681. } tamp_bit;
  682. };
  683. /**
  684. * @brief ertc alasbs register, offset:0x44
  685. */
  686. union
  687. {
  688. __IO uint32_t alasbs;
  689. struct
  690. {
  691. __IO uint32_t sbs :15;/* [14:0] */
  692. __IO uint32_t reserved1 :9; /* [23:15] */
  693. __IO uint32_t sbsmsk :4; /* [27:24] */
  694. __IO uint32_t reserved2 :4; /* [31:28] */
  695. } alasbs_bit;
  696. };
  697. /**
  698. * @brief ertc reserved register, offset:0x48
  699. */
  700. __IO uint32_t reserved4;
  701. /**
  702. * @brief reserved register, offset:0x4c
  703. */
  704. __IO uint32_t reserved5;
  705. /**
  706. * @brief ertc dt1 register, offset:0x50
  707. */
  708. union
  709. {
  710. __IO uint32_t dt1;
  711. struct
  712. {
  713. __IO uint32_t dt :32;/* [31:0] */
  714. } dt1_bit;
  715. };
  716. /**
  717. * @brief ertc dt2 register, offset:0x54
  718. */
  719. union
  720. {
  721. __IO uint32_t dt2;
  722. struct
  723. {
  724. __IO uint32_t dt :32;/* [31:0] */
  725. } dt2_bit;
  726. };
  727. /**
  728. * @brief ertc dt3 register, offset:0x58
  729. */
  730. union
  731. {
  732. __IO uint32_t dt3;
  733. struct
  734. {
  735. __IO uint32_t dt :32;/* [31:0] */
  736. } dt3_bit;
  737. };
  738. /**
  739. * @brief ertc dt4 register, offset:0x5C
  740. */
  741. union
  742. {
  743. __IO uint32_t dt4;
  744. struct
  745. {
  746. __IO uint32_t dt :32;/* [31:0] */
  747. } dt4_bit;
  748. };
  749. /**
  750. * @brief ertc dt5 register, offset:0x60
  751. */
  752. union
  753. {
  754. __IO uint32_t dt5;
  755. struct
  756. {
  757. __IO uint32_t dt :32;/* [31:0] */
  758. } dt5_bit;
  759. };
  760. } ertc_type;
  761. /**
  762. * @}
  763. */
  764. #define ERTC ((ertc_type *) ERTC_BASE)
  765. /** @defgroup ERTC_exported_functions
  766. * @{
  767. */
  768. uint8_t ertc_num_to_bcd(uint8_t num);
  769. uint8_t ertc_bcd_to_num(uint8_t bcd);
  770. void ertc_write_protect_enable(void);
  771. void ertc_write_protect_disable(void);
  772. error_status ertc_wait_update(void);
  773. error_status ertc_wait_flag(uint32_t flag, flag_status status);
  774. error_status ertc_init_mode_enter(void);
  775. void ertc_init_mode_exit(void);
  776. error_status ertc_reset(void);
  777. error_status ertc_divider_set(uint16_t div_a, uint16_t div_b);
  778. error_status ertc_hour_mode_set(ertc_hour_mode_set_type mode);
  779. error_status ertc_date_set(uint8_t year, uint8_t month, uint8_t date, uint8_t week);
  780. error_status ertc_time_set(uint8_t hour, uint8_t min, uint8_t sec, ertc_am_pm_type ampm);
  781. void ertc_calendar_get(ertc_time_type* time);
  782. uint32_t ertc_sub_second_get(void);
  783. void ertc_alarm_mask_set(ertc_alarm_type alarm_x, uint32_t mask);
  784. void ertc_alarm_week_date_select(ertc_alarm_type alarm_x, ertc_week_date_select_type wk);
  785. void ertc_alarm_set(ertc_alarm_type alarm_x, uint8_t week_date, uint8_t hour, uint8_t min, uint8_t sec, ertc_am_pm_type ampm);
  786. void ertc_alarm_sub_second_set(ertc_alarm_type alarm_x, uint32_t value, ertc_alarm_sbs_mask_type mask);
  787. error_status ertc_alarm_enable(ertc_alarm_type alarm_x, confirm_state new_state);
  788. void ertc_alarm_get(ertc_alarm_type alarm_x, ertc_alarm_value_type* alarm);
  789. uint32_t ertc_alarm_sub_second_get(ertc_alarm_type alarm_x);
  790. error_status ertc_smooth_calibration_config(ertc_smooth_cal_period_type period, ertc_smooth_cal_clk_add_type clk_add, uint32_t clk_dec);
  791. void ertc_cal_output_select(ertc_cal_output_select_type output);
  792. void ertc_cal_output_enable(confirm_state new_state);
  793. error_status ertc_time_adjust(ertc_time_adjust_type add1s, uint32_t decsbs);
  794. void ertc_daylight_set(ertc_dst_operation_type operation, ertc_dst_save_type save);
  795. uint8_t ertc_daylight_bpr_get(void);
  796. error_status ertc_refer_clock_detect_enable(confirm_state new_state);
  797. void ertc_direct_read_enable(confirm_state new_state);
  798. void ertc_output_set(ertc_output_source_type source, ertc_output_polarity_type polarity, ertc_output_type type);
  799. void ertc_timestamp_valid_edge_set(ertc_timestamp_valid_edge_type edge);
  800. void ertc_timestamp_enable(confirm_state new_state);
  801. void ertc_timestamp_get(ertc_time_type* time);
  802. uint32_t ertc_timestamp_sub_second_get(void);
  803. void ertc_tamper_pull_up_enable(confirm_state new_state);
  804. void ertc_tamper_precharge_set(ertc_tamper_precharge_type precharge);
  805. void ertc_tamper_filter_set(ertc_tamper_filter_type filter);
  806. void ertc_tamper_detect_freq_set(ertc_tamper_detect_freq_type freq);
  807. void ertc_tamper_valid_edge_set(ertc_tamper_select_type tamper_x, ertc_tamper_valid_edge_type trigger);
  808. void ertc_tamper_timestamp_enable(confirm_state new_state);
  809. void ertc_tamper_enable(ertc_tamper_select_type tamper_x, confirm_state new_state);
  810. void ertc_interrupt_enable(uint32_t source, confirm_state new_state);
  811. flag_status ertc_interrupt_get(uint32_t source);
  812. flag_status ertc_flag_get(uint32_t flag);
  813. void ertc_flag_clear(uint32_t flag);
  814. void ertc_bpr_data_write(ertc_dt_type dt, uint32_t data);
  815. uint32_t ertc_bpr_data_read(ertc_dt_type dt);
  816. /**
  817. * @}
  818. */
  819. /**
  820. * @}
  821. */
  822. /**
  823. * @}
  824. */
  825. #ifdef __cplusplus
  826. }
  827. #endif
  828. #endif