at32f421_scfg.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. /**
  2. **************************************************************************
  3. * @file at32f421_scfg.h
  4. * @brief at32f421 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 __AT32F421_SCFG_H
  26. #define __AT32F421_SCFG_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "at32f421.h"
  32. /** @addtogroup AT32F421_periph_driver
  33. * @{
  34. */
  35. /** @addtogroup SCFG
  36. * @{
  37. */
  38. #define SCFG_REG(value) PERIPH_REG(SCFG_CMP_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_TMR16 = 0x00, /* infrared signal source select tmr16 */
  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 pa11 pa12 pin remap type
  54. */
  55. typedef enum
  56. {
  57. SCFG_PA11PA12_NO_REMAP = 0x00, /* pa11 pa12 pin no remap */
  58. SCFG_PA11PA12_TO_PA9PA10 = 0x01, /* pa11 pa12 pin remap pa9 pa10*/
  59. } scfg_pa11pa12_remap_type;
  60. /**
  61. * @brief scfg adc dma channel remap type
  62. */
  63. typedef enum
  64. {
  65. SCFG_ADC_TO_DMA_CHANNEL_1 = 0x00, /* adc config to dma channel 1 */
  66. SCFG_ADC_TO_DMA_CHANNEL_2 = 0x01, /* adc config to dma channel 2*/
  67. } scfg_adc_dma_remap_type;
  68. /**
  69. * @brief scfg usart1 tx dma channel remap type
  70. */
  71. typedef enum
  72. {
  73. SCFG_USART1_TX_TO_DMA_CHANNEL_2 = 0x00, /* usart1 tx config to dma channel 2 */
  74. SCFG_USART1_TX_TO_DMA_CHANNEL_4 = 0x01, /* usart1 tx config to dma channel 4 */
  75. } scfg_usart1_tx_dma_remap_type;
  76. /**
  77. * @brief scfg usart1 rx dma channel remap type
  78. */
  79. typedef enum
  80. {
  81. SCFG_USART1_RX_TO_DMA_CHANNEL_3 = 0x00, /* usart1 rx config to dma channel 3 */
  82. SCFG_USART1_RX_TO_DMA_CHANNEL_5 = 0x01, /* usart1 rx config to dma channel 5 */
  83. } scfg_usart1_rx_dma_remap_type;
  84. /**
  85. * @brief scfg tmr16 dma channel remap type
  86. */
  87. typedef enum
  88. {
  89. SCFG_TMR16_TO_DMA_CHANNEL_3 = 0x00, /* tmr16 config to dma channel 3 */
  90. SCFG_TMR16_TO_DMA_CHANNEL_4 = 0x01, /* tmr16 config to dma channel 4 */
  91. } scfg_tmr16_dma_remap_type;
  92. /**
  93. * @brief scfg tmr17 dma channel remap type
  94. */
  95. typedef enum
  96. {
  97. SCFG_TMR17_TO_DMA_CHANNEL_1 = 0x00, /* tmr17 config to dma channel 1 */
  98. SCFG_TMR17_TO_DMA_CHANNEL_2 = 0x01, /* tmr17 config to dma channel 2 */
  99. } scfg_tmr17_dma_remap_type;
  100. /**
  101. * @brief scfg infrared output polarity selecting type
  102. */
  103. typedef enum
  104. {
  105. SCFG_IR_POLARITY_NO_AFFECTE = 0x00, /* infrared output polarity no affecte */
  106. SCFG_IR_POLARITY_REVERSE = 0x01 /* infrared output polarity reverse */
  107. } scfg_ir_polarity_type;
  108. /**
  109. * @brief scfg memory address mapping selecting type
  110. */
  111. typedef enum
  112. {
  113. SCFG_MEM_MAP_MAIN_MEMORY = 0x00, /* 0x00000000 address mapping from main memory */
  114. SCFG_MEM_MAP_BOOT_MEMORY = 0x01, /* 0x00000000 address mapping from boot memory */
  115. SCFG_MEM_MAP_INTERNAL_SRAM = 0x03, /* 0x00000000 address mapping from internal sram */
  116. } scfg_mem_map_type;
  117. /**
  118. * @brief scfg pin source type
  119. */
  120. typedef enum
  121. {
  122. SCFG_PINS_SOURCE0 = 0x00,
  123. SCFG_PINS_SOURCE1 = 0x01,
  124. SCFG_PINS_SOURCE2 = 0x02,
  125. SCFG_PINS_SOURCE3 = 0x03,
  126. SCFG_PINS_SOURCE4 = 0x04,
  127. SCFG_PINS_SOURCE5 = 0x05,
  128. SCFG_PINS_SOURCE6 = 0x06,
  129. SCFG_PINS_SOURCE7 = 0x07,
  130. SCFG_PINS_SOURCE8 = 0x08,
  131. SCFG_PINS_SOURCE9 = 0x09,
  132. SCFG_PINS_SOURCE10 = 0x0A,
  133. SCFG_PINS_SOURCE11 = 0x0B,
  134. SCFG_PINS_SOURCE12 = 0x0C,
  135. SCFG_PINS_SOURCE13 = 0x0D,
  136. SCFG_PINS_SOURCE14 = 0x0E,
  137. SCFG_PINS_SOURCE15 = 0x0F
  138. } scfg_pins_source_type;
  139. /**
  140. * @brief gpio port source type
  141. */
  142. typedef enum
  143. {
  144. SCFG_PORT_SOURCE_GPIOA = 0x00,
  145. SCFG_PORT_SOURCE_GPIOB = 0x01,
  146. SCFG_PORT_SOURCE_GPIOC = 0x02,
  147. SCFG_PORT_SOURCE_GPIOF = 0x05,
  148. } scfg_port_source_type;
  149. /**
  150. * @brief type define system config register all
  151. */
  152. typedef struct
  153. {
  154. /**
  155. * @brief scfg cfg1 register, offset:0x00
  156. */
  157. union
  158. {
  159. __IO uint32_t cfg1;
  160. struct
  161. {
  162. __IO uint32_t mem_map_sel : 2; /* [1:0] */
  163. __IO uint32_t reserved1 : 2; /* [3:2] */
  164. __IO uint32_t pa11_12_rmp : 1; /* [4] */
  165. __IO uint32_t ir_pol : 1; /* [5] */
  166. __IO uint32_t ir_src_sel : 2; /* [7:6] */
  167. __IO uint32_t adc_dma_rmp : 1; /* [8] */
  168. __IO uint32_t usart1_tx_dma_rmp : 1; /* [9] */
  169. __IO uint32_t usart1_rx_dma_rmp : 1; /* [10] */
  170. __IO uint32_t tmr16_dma_rmp : 1; /* [11] */
  171. __IO uint32_t tmr17_dma_rmp : 1; /* [12] */
  172. __IO uint32_t reserved2 : 19;/* [31:13] */
  173. } cfg1_bit;
  174. };
  175. /**
  176. * @brief scfg reserved1 register, offset:0x04
  177. */
  178. __IO uint32_t reserved1;
  179. /**
  180. * @brief scfg exintc1 register, offset:0x08
  181. */
  182. union
  183. {
  184. __IO uint32_t exintc1;
  185. struct
  186. {
  187. __IO uint32_t exint0 : 4; /* [3:0] */
  188. __IO uint32_t exint1 : 4; /* [7:4] */
  189. __IO uint32_t exint2 : 4; /* [11:8] */
  190. __IO uint32_t exint3 : 4; /* [15:12] */
  191. __IO uint32_t reserved1 : 16;/* [31:16] */
  192. } exintc1_bit;
  193. };
  194. /**
  195. * @brief scfg exintc2 register, offset:0x0C
  196. */
  197. union
  198. {
  199. __IO uint32_t exintc2;
  200. struct
  201. {
  202. __IO uint32_t exint4 : 4; /* [3:0] */
  203. __IO uint32_t exint5 : 4; /* [7:4] */
  204. __IO uint32_t exint6 : 4; /* [11:8] */
  205. __IO uint32_t exint7 : 4; /* [15:12] */
  206. __IO uint32_t reserved1 : 16;/* [31:16] */
  207. } exintc2_bit;
  208. };
  209. /**
  210. * @brief scfg exintc3 register, offset:0x10
  211. */
  212. union
  213. {
  214. __IO uint32_t exintc3;
  215. struct
  216. {
  217. __IO uint32_t exint8 : 4; /* [3:0] */
  218. __IO uint32_t exint9 : 4; /* [7:4] */
  219. __IO uint32_t exint10 : 4; /* [11:8] */
  220. __IO uint32_t exint11 : 4; /* [15:12] */
  221. __IO uint32_t reserved1 : 16;/* [31:16] */
  222. } exintc3_bit;
  223. };
  224. /**
  225. * @brief scfg exintc4 register, offset:0x14
  226. */
  227. union
  228. {
  229. __IO uint32_t exintc4;
  230. struct
  231. {
  232. __IO uint32_t exint12 : 4; /* [3:0] */
  233. __IO uint32_t exint13 : 4; /* [7:4] */
  234. __IO uint32_t exint14 : 4; /* [11:8] */
  235. __IO uint32_t exint15 : 4; /* [15:12] */
  236. __IO uint32_t reserved1 : 16;/* [31:16] */
  237. } exintc4_bit;
  238. };
  239. } scfg_type;
  240. /**
  241. * @}
  242. */
  243. #define SCFG ((scfg_type *) SCFG_CMP_BASE)
  244. /** @defgroup SCFG_exported_functions
  245. * @{
  246. */
  247. void scfg_reset(void);
  248. void scfg_infrared_config(scfg_ir_source_type source, scfg_ir_polarity_type polarity);
  249. uint8_t scfg_mem_map_get(void);
  250. void scfg_pa11pa12_pin_remap(scfg_pa11pa12_remap_type pin_remap);
  251. void scfg_adc_dma_channel_remap(scfg_adc_dma_remap_type dma_channel);
  252. void scfg_usart1_tx_dma_channel_remap(scfg_usart1_tx_dma_remap_type dma_channel);
  253. void scfg_usart1_rx_dma_channel_remap(scfg_usart1_rx_dma_remap_type dma_channel);
  254. void scfg_tmr16_dma_channel_remap(scfg_tmr16_dma_remap_type dma_channel);
  255. void scfg_tmr17_dma_channel_remap(scfg_tmr17_dma_remap_type dma_channel);
  256. void scfg_exint_line_config(scfg_port_source_type port_source, scfg_pins_source_type pin_source);
  257. /**
  258. * @}
  259. */
  260. /**
  261. * @}
  262. */
  263. /**
  264. * @}
  265. */
  266. #ifdef __cplusplus
  267. }
  268. #endif
  269. #endif