at32f423_scfg.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. /**
  2. **************************************************************************
  3. * @file at32f423_scfg.h
  4. * @brief at32f423 system config 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 __AT32F423_SCFG_H
  26. #define __AT32F423_SCFG_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "at32f423.h"
  32. /** @addtogroup AT32F423_periph_driver
  33. * @{
  34. */
  35. /** @addtogroup SCFG
  36. * @{
  37. */
  38. #define SCFG_REG(value) PERIPH_REG(SCFG_BASE, value)
  39. #define SCFG_REG_BIT(value) PERIPH_REG_BIT(value)
  40. /** @defgroup SCFG_exported_types
  41. * @{
  42. */
  43. /**
  44. * @brief scfg infrared modulation signal source selecting type
  45. */
  46. typedef enum
  47. {
  48. SCFG_IR_SOURCE_TMR10 = 0x00, /* infrared signal source select tmr10 */
  49. SCFG_IR_SOURCE_USART1 = 0x01, /* infrared signal source select usart1 */
  50. SCFG_IR_SOURCE_USART2 = 0x02 /* infrared signal source select usart2 */
  51. } scfg_ir_source_type;
  52. /**
  53. * @brief scfg infrared output polarity selecting type
  54. */
  55. typedef enum
  56. {
  57. SCFG_IR_POLARITY_NO_AFFECTE = 0x00, /* infrared output polarity no affecte */
  58. SCFG_IR_POLARITY_REVERSE = 0x01 /* infrared output polarity reverse */
  59. } scfg_ir_polarity_type;
  60. /**
  61. * @brief scfg memory address mapping selecting type
  62. */
  63. typedef enum
  64. {
  65. SCFG_MEM_MAP_MAIN_MEMORY = 0x00, /* 0x00000000 address mapping from main memory */
  66. SCFG_MEM_MAP_BOOT_MEMORY = 0x01, /* 0x00000000 address mapping from boot memory */
  67. SCFG_MEM_MAP_INTERNAL_SRAM = 0x03, /* 0x00000000 address mapping from internal sram */
  68. } scfg_mem_map_type;
  69. /**
  70. * @brief scfg pin source type
  71. */
  72. typedef enum
  73. {
  74. SCFG_PINS_SOURCE0 = 0x00,
  75. SCFG_PINS_SOURCE1 = 0x01,
  76. SCFG_PINS_SOURCE2 = 0x02,
  77. SCFG_PINS_SOURCE3 = 0x03,
  78. SCFG_PINS_SOURCE4 = 0x04,
  79. SCFG_PINS_SOURCE5 = 0x05,
  80. SCFG_PINS_SOURCE6 = 0x06,
  81. SCFG_PINS_SOURCE7 = 0x07,
  82. SCFG_PINS_SOURCE8 = 0x08,
  83. SCFG_PINS_SOURCE9 = 0x09,
  84. SCFG_PINS_SOURCE10 = 0x0A,
  85. SCFG_PINS_SOURCE11 = 0x0B,
  86. SCFG_PINS_SOURCE12 = 0x0C,
  87. SCFG_PINS_SOURCE13 = 0x0D,
  88. SCFG_PINS_SOURCE14 = 0x0E,
  89. SCFG_PINS_SOURCE15 = 0x0F
  90. } scfg_pins_source_type;
  91. /**
  92. * @brief gpio port source type
  93. */
  94. typedef enum
  95. {
  96. SCFG_PORT_SOURCE_GPIOA = 0x00,
  97. SCFG_PORT_SOURCE_GPIOB = 0x01,
  98. SCFG_PORT_SOURCE_GPIOC = 0x02,
  99. SCFG_PORT_SOURCE_GPIOD = 0x03,
  100. SCFG_PORT_SOURCE_GPIOE = 0x04,
  101. SCFG_PORT_SOURCE_GPIOF = 0x05,
  102. SCFG_PORT_SOURCE_GPIOG = 0x06,
  103. SCFG_PORT_SOURCE_GPIOH = 0x07
  104. } scfg_port_source_type;
  105. /**
  106. * @brief scfg i2s full duplex type
  107. */
  108. typedef enum
  109. {
  110. SCFG_FULL_DUPLEX_I2S_NONE = 0x00, /* no i2s full duplex */
  111. SCFG_FULL_DUPLEX_I2S1_I2S3 = 0x01, /* i2s full duplex with i2s1 and i2s3 */
  112. SCFG_FULL_DUPLEX_I2S2_I2S3 = 0x02, /* i2s full duplex with i2s2 and i2s3 */
  113. SCFG_FULL_DUPLEX_I2S1_I2S2 = 0x03, /* i2s full duplex with i2s1 and i2s2 */
  114. } scfg_i2s_type;
  115. /**
  116. * @brief scfg ultra high sourcing/sinking strength pins type
  117. */
  118. typedef enum
  119. {
  120. SCFG_ULTRA_DRIVEN_PB9 = MAKE_VALUE(0x2C, 1),
  121. SCFG_ULTRA_DRIVEN_PB8 = MAKE_VALUE(0x2C, 3),
  122. SCFG_ULTRA_DRIVEN_PD12 = MAKE_VALUE(0x2C, 5),
  123. SCFG_ULTRA_DRIVEN_PD13 = MAKE_VALUE(0x2C, 6)
  124. } scfg_ultra_driven_pins_type;
  125. /**
  126. * @brief type define system config register all
  127. */
  128. typedef struct
  129. {
  130. /**
  131. * @brief scfg cfg1 register, offset:0x00
  132. */
  133. union
  134. {
  135. __IO uint32_t cfg1;
  136. struct
  137. {
  138. __IO uint32_t mem_map_sel : 2; /* [1:0] */
  139. __IO uint32_t reserved1 : 3; /* [4:2] */
  140. __IO uint32_t ir_pol : 1; /* [5] */
  141. __IO uint32_t ir_src_sel : 2; /* [7:6] */
  142. __IO uint32_t reserved2 : 24;/* [31:8] */
  143. } cfg1_bit;
  144. };
  145. /**
  146. * @brief scfg cfg2 register, offset:0x04
  147. */
  148. union
  149. {
  150. __IO uint32_t cfg2;
  151. struct
  152. {
  153. __IO uint32_t lockup_lk : 1; /* [0] */
  154. __IO uint32_t reserved1 : 1; /* [1] */
  155. __IO uint32_t pvm_lk : 1; /* [2] */
  156. __IO uint32_t reserved2 : 27;/* [29:3] */
  157. __IO uint32_t i2s_fd : 2; /* [31:30] */
  158. } cfg2_bit;
  159. };
  160. /**
  161. * @brief scfg exintc1 register, offset:0x08
  162. */
  163. union
  164. {
  165. __IO uint32_t exintc1;
  166. struct
  167. {
  168. __IO uint32_t exint0 : 4; /* [3:0] */
  169. __IO uint32_t exint1 : 4; /* [7:4] */
  170. __IO uint32_t exint2 : 4; /* [11:8] */
  171. __IO uint32_t exint3 : 4; /* [15:12] */
  172. __IO uint32_t reserved1 : 16;/* [31:16] */
  173. } exintc1_bit;
  174. };
  175. /**
  176. * @brief scfg exintc2 register, offset:0x0C
  177. */
  178. union
  179. {
  180. __IO uint32_t exintc2;
  181. struct
  182. {
  183. __IO uint32_t exint4 : 4; /* [3:0] */
  184. __IO uint32_t exint5 : 4; /* [7:4] */
  185. __IO uint32_t exint6 : 4; /* [11:8] */
  186. __IO uint32_t exint7 : 4; /* [15:12] */
  187. __IO uint32_t reserved1 : 16;/* [31:16] */
  188. } exintc2_bit;
  189. };
  190. /**
  191. * @brief scfg exintc3 register, offset:0x10
  192. */
  193. union
  194. {
  195. __IO uint32_t exintc3;
  196. struct
  197. {
  198. __IO uint32_t exint8 : 4; /* [3:0] */
  199. __IO uint32_t exint9 : 4; /* [7:4] */
  200. __IO uint32_t exint10 : 4; /* [11:8] */
  201. __IO uint32_t exint11 : 4; /* [15:12] */
  202. __IO uint32_t reserved1 : 16;/* [31:16] */
  203. } exintc3_bit;
  204. };
  205. /**
  206. * @brief scfg exintc4 register, offset:0x14
  207. */
  208. union
  209. {
  210. __IO uint32_t exintc4;
  211. struct
  212. {
  213. __IO uint32_t exint12 : 4; /* [3:0] */
  214. __IO uint32_t exint13 : 4; /* [7:4] */
  215. __IO uint32_t exint14 : 4; /* [11:8] */
  216. __IO uint32_t exint15 : 4; /* [15:12] */
  217. __IO uint32_t reserved1 : 16;/* [31:16] */
  218. } exintc4_bit;
  219. };
  220. /**
  221. * @brief crm reserved1 register, offset:0x18~0x28
  222. */
  223. __IO uint32_t reserved1[5];
  224. /**
  225. * @brief scfg uhdrv register, offset:0x2C
  226. */
  227. union
  228. {
  229. __IO uint32_t uhdrv;
  230. struct
  231. {
  232. __IO uint32_t reserved1 : 1; /* [0] */
  233. __IO uint32_t pb9_uh : 1; /* [1] */
  234. __IO uint32_t reserved2 : 1; /* [2] */
  235. __IO uint32_t pb8_uh : 1; /* [3] */
  236. __IO uint32_t reserved3 : 1; /* [4] */
  237. __IO uint32_t pd12_uh : 1; /* [5] */
  238. __IO uint32_t pd13_uh : 1; /* [6] */
  239. __IO uint32_t reserved4 : 25;/* [31:7] */
  240. } uhdrv_bit;
  241. };
  242. } scfg_type;
  243. /**
  244. * @}
  245. */
  246. #define SCFG ((scfg_type *) SCFG_BASE)
  247. /** @defgroup SCFG_exported_functions
  248. * @{
  249. */
  250. void scfg_reset(void);
  251. void scfg_infrared_config(scfg_ir_source_type source, scfg_ir_polarity_type polarity);
  252. uint8_t scfg_mem_map_get(void);
  253. void scfg_i2s_full_duplex_config(scfg_i2s_type i2s_full_duplex);
  254. void scfg_pvm_lock_enable(confirm_state new_state);
  255. void scfg_lockup_enable(confirm_state new_state);
  256. void scfg_exint_line_config(scfg_port_source_type port_source, scfg_pins_source_type pin_source);
  257. void scfg_pins_ultra_driven_enable(scfg_ultra_driven_pins_type value, confirm_state new_state);
  258. /**
  259. * @}
  260. */
  261. /**
  262. * @}
  263. */
  264. /**
  265. * @}
  266. */
  267. #ifdef __cplusplus
  268. }
  269. #endif
  270. #endif