at32f421_gpio.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. /**
  2. **************************************************************************
  3. * @file at32f421_gpio.h
  4. * @brief at32f421 gpio 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. /**
  25. porta iomux table
  26. --------------------------------------------------------------------------------------------------------------------------------
  27. pin name | mux0 | mux1 | mux2 | mux3 | mux4 | mux5 | mux6 | mux7 |
  28. --------------------------------------------------------------------------------------------------------------------------------
  29. pa0 | | usart2_cts | | | i2c2_scl | tmr1_etr | | comp_out |
  30. --------------------------------------------------------------------------------------------------------------------------------
  31. pa1 | eventout | usart2_rts | | | i2c2_sda | tmr15_ch1c | | |
  32. --------------------------------------------------------------------------------------------------------------------------------
  33. pa2 | tmr15_ch1 | usart2_tx | | | | | | |
  34. --------------------------------------------------------------------------------------------------------------------------------
  35. pa3 | tmr15_ch2 | usart2_rx | | | | i2s2_mck | | |
  36. --------------------------------------------------------------------------------------------------------------------------------
  37. pa4 | spi1_nss | usart2_ck | | | tmr14_ch1 | | | |
  38. | i2s1_ws | | | | | | | |
  39. --------------------------------------------------------------------------------------------------------------------------------
  40. pa5 | spi1_sck | | | | | | | |
  41. | i2s1_ck | | | | | | | |
  42. --------------------------------------------------------------------------------------------------------------------------------
  43. pa6 | spi1_miso | tmr3_ch1 | tmr1_bkin | i2s2_mck | | tmr16_ch1 | eventout | comp_out |
  44. | i2s1_mck | | | | | | | |
  45. --------------------------------------------------------------------------------------------------------------------------------
  46. pa7 | spi1_mosi | tmr3_ch2 | tmr1_ch1c | | tmr14_ch1 | tmr17_ch1 | eventout | |
  47. | i2s1_sd | | | | | | | |
  48. --------------------------------------------------------------------------------------------------------------------------------
  49. pa8 | clkout | usart1_ck | tmr1_ch1 | eventout | usart2_tx | | | i2c2_scl |
  50. --------------------------------------------------------------------------------------------------------------------------------
  51. pa9 | tmr15_bkin | usart1_tx | tmr1_ch2 | | i2c1_scl | clkout | | i2c2_smba |
  52. --------------------------------------------------------------------------------------------------------------------------------
  53. pa10 | tmr17_bkin | usart1_rx | tmr1_ch3 | | i2c1_sda | | | |
  54. --------------------------------------------------------------------------------------------------------------------------------
  55. pa11 | eventout | usart1_cts | tmr1_ch4 | | i2c1_smba | i2c2_scl | | comp_out |
  56. ----------------------------- --------------------------------------------------------------------------------------------------
  57. pa12 | eventout | usart1_rts | tmr1_etr | | | i2c2_sda | | |
  58. --------------------------------------------------------------------------------------------------------------------------------
  59. pa13 | swdio | ir_out | | | | | spi2_miso | |
  60. | | | | | | | i2s2_mck | |
  61. --------------------------------------------------------------------------------------------------------------------------------
  62. pa14 | swclk | usart2_tx | | | | | spi2_mosi | |
  63. | | | | | | | i2s2_sd | |
  64. --------------------------------------------------------------------------------------------------------------------------------
  65. pa15 | spi1_nss | usart2_rx | | | | | spi2_nss | |
  66. | i2s1_ws | | | eventout | | | i2s2_ws | |
  67. --------------------------------------------------------------------------------------------------------------------------------
  68. */
  69. /**
  70. portb iomux table
  71. --------------------------------------------------------------------------------------------------------------------------------
  72. pin name | mux0 | mux1 | mux2 | mux3 | mux4 | mux5 | mux6 | mux7 |
  73. --------------------------------------------------------------------------------------------------------------------------------
  74. pb0 | eventout | tmr3_ch3 | tmr1_ch2c | usart2_rx | | | i2s1_mck | |
  75. --------------------------------------------------------------------------------------------------------------------------------
  76. pb1 | tmr14_ch1 | tmr3_ch4 | tmr1_ch3c | | | | spi2_sck | |
  77. | | | | | | | i2s2_ck | |
  78. --------------------------------------------------------------------------------------------------------------------------------
  79. pb2 | | | tmr3_etr | | | | | |
  80. --------------------------------------------------------------------------------------------------------------------------------
  81. pb3 | spi1_sck | eventout | | | | | spi2_sck | |
  82. | i2s1_ck | | | | | | i2s2_ck | |
  83. --------------------------------------------------------------------------------------------------------------------------------
  84. pb4 | spi1_miso | tmr3_ch1 | eventout | | | tmr17_bkin | spi2_miso | i2c2_sda |
  85. | i2s1_mck | | | | | | spi2_mck | |
  86. --------------------------------------------------------------------------------------------------------------------------------
  87. pb5 | spi1_mosi | tmr3_ch2 | tmr16_bkin | i2c1_smba | | | spi2_mosi | |
  88. | i2s1_sd | | | | | | i2s2_sd | |
  89. --------------------------------------------------------------------------------------------------------------------------------
  90. pb6 | usart1_tx | i2c1_scl | tmr16_ch1c | | | | i2s1_mck | |
  91. --------------------------------------------------------------------------------------------------------------------------------
  92. pb7 | usart1_rx | i2c1_sda | tmr17_ch1c | | | | | |
  93. --------------------------------------------------------------------------------------------------------------------------------
  94. pb8 | | i2c1_scl | tmr16_ch1 | | | | | |
  95. --------------------------------------------------------------------------------------------------------------------------------
  96. pb9 | ir_out | i2c1_sda | tmr17_ch1 | eventout | | | i2s1_mck | spi2_nss |
  97. | | | | | | | | i2s2_ws |
  98. --------------------------------------------------------------------------------------------------------------------------------
  99. pb10 | | i2c2_scl | | | | | | spi2_sck |
  100. | | | | | | | | i2s2_ck |
  101. --------------------------------------------------------------------------------------------------------------------------------
  102. pb11 | eventout | i2c2_sda | | | | | | |
  103. --------------------------------------------------------------------------------------------------------------------------------
  104. pb12 | spi2_nss | eventout | tmr1_bkin | | | tmr15_bkin | | i2c2_smba |
  105. | i2s2_ws | | | | | | | |
  106. --------------------------------------------------------------------------------------------------------------------------------
  107. pb13 | spi2_sck | | tmr1_ch1c | | | i2c2_scl | | |
  108. | i2s2_ck | | | | | | | |
  109. --------------------------------------------------------------------------------------------------------------------------------
  110. pb14 | spi2_miso | tmr15_ch1 | tmr1_ch2c | | | i2c2_sda | | |
  111. | i2s2_mck | | | | | | | |
  112. --------------------------------------------------------------------------------------------------------------------------------
  113. pb15 | spi2_mosi | tmr15_ch2 | tmr1_ch3c | tmr15_ch1c | | | | |
  114. | i2s2_sd | | | | | | | |
  115. --------------------------------------------------------------------------------------------------------------------------------
  116. */
  117. /**
  118. portf iomux table
  119. --------------------------------------------------------------------------------------------------------------------------------
  120. pin name | mux0 | mux1 | mux2 | mux3 | mux4 | mux5 | mux6 | mux7 |
  121. --------------------------------------------------------------------------------------------------------------------------------
  122. pf0 | | i2c1_sda | | | | | | |
  123. --------------------------------------------------------------------------------------------------------------------------------
  124. pf0 | | i2c1_scl | | | | | | |
  125. --------------------------------------------------------------------------------------------------------------------------------
  126. pf6 | i2c2_scl | | | | | | | |
  127. --------------------------------------------------------------------------------------------------------------------------------
  128. pf7 | i2c2_sda | | | | | | | |
  129. --------------------------------------------------------------------------------------------------------------------------------
  130. */
  131. /* define to prevent recursive inclusion -------------------------------------*/
  132. #ifndef __AT32F421_GPIO_H
  133. #define __AT32F421_GPIO_H
  134. #ifdef __cplusplus
  135. extern "C" {
  136. #endif
  137. /* includes ------------------------------------------------------------------*/
  138. #include "at32f421.h"
  139. /** @addtogroup AT32F421_periph_driver
  140. * @{
  141. */
  142. /** @addtogroup GPIO
  143. * @{
  144. */
  145. /** @defgroup GPIO_pins_number_definition
  146. * @{
  147. */
  148. #define GPIO_PINS_0 0x0001 /*!< gpio pins number 0 */
  149. #define GPIO_PINS_1 0x0002 /*!< gpio pins number 1 */
  150. #define GPIO_PINS_2 0x0004 /*!< gpio pins number 2 */
  151. #define GPIO_PINS_3 0x0008 /*!< gpio pins number 3 */
  152. #define GPIO_PINS_4 0x0010 /*!< gpio pins number 4 */
  153. #define GPIO_PINS_5 0x0020 /*!< gpio pins number 5 */
  154. #define GPIO_PINS_6 0x0040 /*!< gpio pins number 6 */
  155. #define GPIO_PINS_7 0x0080 /*!< gpio pins number 7 */
  156. #define GPIO_PINS_8 0x0100 /*!< gpio pins number 8 */
  157. #define GPIO_PINS_9 0x0200 /*!< gpio pins number 9 */
  158. #define GPIO_PINS_10 0x0400 /*!< gpio pins number 10 */
  159. #define GPIO_PINS_11 0x0800 /*!< gpio pins number 11 */
  160. #define GPIO_PINS_12 0x1000 /*!< gpio pins number 12 */
  161. #define GPIO_PINS_13 0x2000 /*!< gpio pins number 13 */
  162. #define GPIO_PINS_14 0x4000 /*!< gpio pins number 14 */
  163. #define GPIO_PINS_15 0x8000 /*!< gpio pins number 15 */
  164. #define GPIO_PINS_ALL 0xFFFF /*!< gpio all pins */
  165. /**
  166. * @}
  167. */
  168. /** @defgroup GPIO_exported_types
  169. * @{
  170. */
  171. /**
  172. * @brief gpio mode select
  173. */
  174. typedef enum
  175. {
  176. GPIO_MODE_INPUT = 0x00, /*!< gpio input mode */
  177. GPIO_MODE_OUTPUT = 0x01, /*!< gpio output mode */
  178. GPIO_MODE_MUX = 0x02, /*!< gpio mux function mode */
  179. GPIO_MODE_ANALOG = 0x03 /*!< gpio analog in/out mode */
  180. } gpio_mode_type;
  181. /**
  182. * @brief gpio output drive strength select
  183. */
  184. typedef enum
  185. {
  186. GPIO_DRIVE_STRENGTH_STRONGER = 0x01, /*!< stronger sourcing/sinking strength */
  187. GPIO_DRIVE_STRENGTH_MODERATE = 0x02 /*!< moderate sourcing/sinking strength */
  188. } gpio_drive_type;
  189. /**
  190. * @brief gpio output type
  191. */
  192. typedef enum
  193. {
  194. GPIO_OUTPUT_PUSH_PULL = 0x00, /*!< output push-pull */
  195. GPIO_OUTPUT_OPEN_DRAIN = 0x01 /*!< output open-drain */
  196. } gpio_output_type;
  197. /**
  198. * @brief gpio pull type
  199. */
  200. typedef enum
  201. {
  202. GPIO_PULL_NONE = 0x00, /*!< floating for input, no pull for output */
  203. GPIO_PULL_UP = 0x01, /*!< pull-up */
  204. GPIO_PULL_DOWN = 0x02 /*!< pull-down */
  205. } gpio_pull_type;
  206. /**
  207. * @brief gpio init type
  208. */
  209. typedef struct
  210. {
  211. uint32_t gpio_pins; /*!< pins number selection */
  212. gpio_output_type gpio_out_type; /*!< output type selection */
  213. gpio_pull_type gpio_pull; /*!< pull type selection */
  214. gpio_mode_type gpio_mode; /*!< mode selection */
  215. gpio_drive_type gpio_drive_strength; /*!< drive strength selection */
  216. } gpio_init_type;
  217. /**
  218. * @brief gpio pins source type
  219. */
  220. typedef enum
  221. {
  222. GPIO_PINS_SOURCE0 = 0x00, /*!< gpio pins source number 0 */
  223. GPIO_PINS_SOURCE1 = 0x01, /*!< gpio pins source number 1 */
  224. GPIO_PINS_SOURCE2 = 0x02, /*!< gpio pins source number 2 */
  225. GPIO_PINS_SOURCE3 = 0x03, /*!< gpio pins source number 3 */
  226. GPIO_PINS_SOURCE4 = 0x04, /*!< gpio pins source number 4 */
  227. GPIO_PINS_SOURCE5 = 0x05, /*!< gpio pins source number 5 */
  228. GPIO_PINS_SOURCE6 = 0x06, /*!< gpio pins source number 6 */
  229. GPIO_PINS_SOURCE7 = 0x07, /*!< gpio pins source number 7 */
  230. GPIO_PINS_SOURCE8 = 0x08, /*!< gpio pins source number 8 */
  231. GPIO_PINS_SOURCE9 = 0x09, /*!< gpio pins source number 9 */
  232. GPIO_PINS_SOURCE10 = 0x0A, /*!< gpio pins source number 10 */
  233. GPIO_PINS_SOURCE11 = 0x0B, /*!< gpio pins source number 11 */
  234. GPIO_PINS_SOURCE12 = 0x0C, /*!< gpio pins source number 12 */
  235. GPIO_PINS_SOURCE13 = 0x0D, /*!< gpio pins source number 13 */
  236. GPIO_PINS_SOURCE14 = 0x0E, /*!< gpio pins source number 14 */
  237. GPIO_PINS_SOURCE15 = 0x0F /*!< gpio pins source number 15 */
  238. } gpio_pins_source_type;
  239. /**
  240. * @brief gpio muxing function selection type
  241. */
  242. typedef enum
  243. {
  244. GPIO_MUX_0 = 0x00, /*!< gpio muxing function selection 0 */
  245. GPIO_MUX_1 = 0x01, /*!< gpio muxing function selection 1 */
  246. GPIO_MUX_2 = 0x02, /*!< gpio muxing function selection 2 */
  247. GPIO_MUX_3 = 0x03, /*!< gpio muxing function selection 3 */
  248. GPIO_MUX_4 = 0x04, /*!< gpio muxing function selection 4 */
  249. GPIO_MUX_5 = 0x05, /*!< gpio muxing function selection 5 */
  250. GPIO_MUX_6 = 0x06, /*!< gpio muxing function selection 6 */
  251. GPIO_MUX_7 = 0x07, /*!< gpio muxing function selection 7 */
  252. } gpio_mux_sel_type;
  253. /**
  254. * @brief type define gpio register all
  255. */
  256. typedef struct
  257. {
  258. /**
  259. * @brief gpio mode register, offset:0x00
  260. */
  261. union
  262. {
  263. __IO uint32_t cfgr;
  264. struct
  265. {
  266. __IO uint32_t iomc0 : 2; /* [1:0] */
  267. __IO uint32_t iomc1 : 2; /* [3:2] */
  268. __IO uint32_t iomc2 : 2; /* [5:4] */
  269. __IO uint32_t iomc3 : 2; /* [7:6] */
  270. __IO uint32_t iomc4 : 2; /* [9:8] */
  271. __IO uint32_t iomc5 : 2; /* [11:10] */
  272. __IO uint32_t iomc6 : 2; /* [13:12] */
  273. __IO uint32_t iomc7 : 2; /* [15:14] */
  274. __IO uint32_t iomc8 : 2; /* [17:16] */
  275. __IO uint32_t iomc9 : 2; /* [19:18] */
  276. __IO uint32_t iomc10 : 2; /* [21:20] */
  277. __IO uint32_t iomc11 : 2; /* [23:22] */
  278. __IO uint32_t iomc12 : 2; /* [25:24] */
  279. __IO uint32_t iomc13 : 2; /* [27:26] */
  280. __IO uint32_t iomc14 : 2; /* [29:28] */
  281. __IO uint32_t iomc15 : 2; /* [31:30] */
  282. } cfgr_bit;
  283. };
  284. /**
  285. * @brief gpio output type register, offset:0x04
  286. */
  287. union
  288. {
  289. __IO uint32_t omode;
  290. struct
  291. {
  292. __IO uint32_t om0 : 1; /* [0] */
  293. __IO uint32_t om1 : 1; /* [1] */
  294. __IO uint32_t om2 : 1; /* [2] */
  295. __IO uint32_t om3 : 1; /* [3] */
  296. __IO uint32_t om4 : 1; /* [4] */
  297. __IO uint32_t om5 : 1; /* [5] */
  298. __IO uint32_t om6 : 1; /* [6] */
  299. __IO uint32_t om7 : 1; /* [7] */
  300. __IO uint32_t om8 : 1; /* [8] */
  301. __IO uint32_t om9 : 1; /* [9] */
  302. __IO uint32_t om10 : 1; /* [10] */
  303. __IO uint32_t om11 : 1; /* [11] */
  304. __IO uint32_t om12 : 1; /* [12] */
  305. __IO uint32_t om13 : 1; /* [13] */
  306. __IO uint32_t om14 : 1; /* [14] */
  307. __IO uint32_t om15 : 1; /* [15] */
  308. __IO uint32_t reserved1 : 16;/* [31:16] */
  309. } omode_bit;
  310. };
  311. /**
  312. * @brief gpio output driver register, offset:0x08
  313. */
  314. union
  315. {
  316. __IO uint32_t odrvr;
  317. struct
  318. {
  319. __IO uint32_t odrv0 : 2; /* [1:0] */
  320. __IO uint32_t odrv1 : 2; /* [3:2] */
  321. __IO uint32_t odrv2 : 2; /* [5:4] */
  322. __IO uint32_t odrv3 : 2; /* [7:6] */
  323. __IO uint32_t odrv4 : 2; /* [9:8] */
  324. __IO uint32_t odrv5 : 2; /* [11:10] */
  325. __IO uint32_t odrv6 : 2; /* [13:12] */
  326. __IO uint32_t odrv7 : 2; /* [15:14] */
  327. __IO uint32_t odrv8 : 2; /* [17:16] */
  328. __IO uint32_t odrv9 : 2; /* [19:18] */
  329. __IO uint32_t odrv10 : 2; /* [21:20] */
  330. __IO uint32_t odrv11 : 2; /* [23:22] */
  331. __IO uint32_t odrv12 : 2; /* [25:24] */
  332. __IO uint32_t odrv13 : 2; /* [27:26] */
  333. __IO uint32_t odrv14 : 2; /* [29:28] */
  334. __IO uint32_t odrv15 : 2; /* [31:30] */
  335. } odrvr_bit;
  336. };
  337. /**
  338. * @brief gpio pull up/down register, offset:0x0C
  339. */
  340. union
  341. {
  342. __IO uint32_t pull;
  343. struct
  344. {
  345. __IO uint32_t pull0 : 2; /* [1:0] */
  346. __IO uint32_t pull1 : 2; /* [3:2] */
  347. __IO uint32_t pull2 : 2; /* [5:4] */
  348. __IO uint32_t pull3 : 2; /* [7:6] */
  349. __IO uint32_t pull4 : 2; /* [9:8] */
  350. __IO uint32_t pull5 : 2; /* [11:10] */
  351. __IO uint32_t pull6 : 2; /* [13:12] */
  352. __IO uint32_t pull7 : 2; /* [15:14] */
  353. __IO uint32_t pull8 : 2; /* [17:16] */
  354. __IO uint32_t pull9 : 2; /* [19:18] */
  355. __IO uint32_t pull10 : 2; /* [21:20] */
  356. __IO uint32_t pull11 : 2; /* [23:22] */
  357. __IO uint32_t pull12 : 2; /* [25:24] */
  358. __IO uint32_t pull13 : 2; /* [27:26] */
  359. __IO uint32_t pull14 : 2; /* [29:28] */
  360. __IO uint32_t pull15 : 2; /* [31:30] */
  361. } pull_bit;
  362. };
  363. /**
  364. * @brief gpio input data register, offset:0x10
  365. */
  366. union
  367. {
  368. __IO uint32_t idt;
  369. struct
  370. {
  371. __IO uint32_t idt0 : 1; /* [0] */
  372. __IO uint32_t idt1 : 1; /* [1] */
  373. __IO uint32_t idt2 : 1; /* [2] */
  374. __IO uint32_t idt3 : 1; /* [3] */
  375. __IO uint32_t idt4 : 1; /* [4] */
  376. __IO uint32_t idt5 : 1; /* [5] */
  377. __IO uint32_t idt6 : 1; /* [6] */
  378. __IO uint32_t idt7 : 1; /* [7] */
  379. __IO uint32_t idt8 : 1; /* [8] */
  380. __IO uint32_t idt9 : 1; /* [9] */
  381. __IO uint32_t idt10 : 1; /* [10] */
  382. __IO uint32_t idt11 : 1; /* [11] */
  383. __IO uint32_t idt12 : 1; /* [12] */
  384. __IO uint32_t idt13 : 1; /* [13] */
  385. __IO uint32_t idt14 : 1; /* [14] */
  386. __IO uint32_t idt15 : 1; /* [15] */
  387. __IO uint32_t reserved1 : 16;/* [31:16] */
  388. } idt_bit;
  389. };
  390. /**
  391. * @brief gpio output data register, offset:0x14
  392. */
  393. union
  394. {
  395. __IO uint32_t odt;
  396. struct
  397. {
  398. __IO uint32_t odt0 : 1; /* [0] */
  399. __IO uint32_t odt1 : 1; /* [1] */
  400. __IO uint32_t odt2 : 1; /* [2] */
  401. __IO uint32_t odt3 : 1; /* [3] */
  402. __IO uint32_t odt4 : 1; /* [4] */
  403. __IO uint32_t odt5 : 1; /* [5] */
  404. __IO uint32_t odt6 : 1; /* [6] */
  405. __IO uint32_t odt7 : 1; /* [7] */
  406. __IO uint32_t odt8 : 1; /* [8] */
  407. __IO uint32_t odt9 : 1; /* [9] */
  408. __IO uint32_t odt10 : 1; /* [10] */
  409. __IO uint32_t odt11 : 1; /* [11] */
  410. __IO uint32_t odt12 : 1; /* [12] */
  411. __IO uint32_t odt13 : 1; /* [13] */
  412. __IO uint32_t odt14 : 1; /* [14] */
  413. __IO uint32_t odt15 : 1; /* [15] */
  414. __IO uint32_t reserved1 : 16;/* [31:16] */
  415. } odt_bit;
  416. };
  417. /**
  418. * @brief gpio scr register, offset:0x18
  419. */
  420. union
  421. {
  422. __IO uint32_t scr;
  423. struct
  424. {
  425. __IO uint32_t iosb0 : 1; /* [0] */
  426. __IO uint32_t iosb1 : 1; /* [1] */
  427. __IO uint32_t iosb2 : 1; /* [2] */
  428. __IO uint32_t iosb3 : 1; /* [3] */
  429. __IO uint32_t iosb4 : 1; /* [4] */
  430. __IO uint32_t iosb5 : 1; /* [5] */
  431. __IO uint32_t iosb6 : 1; /* [6] */
  432. __IO uint32_t iosb7 : 1; /* [7] */
  433. __IO uint32_t iosb8 : 1; /* [8] */
  434. __IO uint32_t iosb9 : 1; /* [9] */
  435. __IO uint32_t iosb10 : 1; /* [10] */
  436. __IO uint32_t iosb11 : 1; /* [11] */
  437. __IO uint32_t iosb12 : 1; /* [12] */
  438. __IO uint32_t iosb13 : 1; /* [13] */
  439. __IO uint32_t iosb14 : 1; /* [14] */
  440. __IO uint32_t iosb15 : 1; /* [15] */
  441. __IO uint32_t iocb0 : 1; /* [16] */
  442. __IO uint32_t iocb1 : 1; /* [17] */
  443. __IO uint32_t iocb2 : 1; /* [18] */
  444. __IO uint32_t iocb3 : 1; /* [19] */
  445. __IO uint32_t iocb4 : 1; /* [20] */
  446. __IO uint32_t iocb5 : 1; /* [21] */
  447. __IO uint32_t iocb6 : 1; /* [22] */
  448. __IO uint32_t iocb7 : 1; /* [23] */
  449. __IO uint32_t iocb8 : 1; /* [24] */
  450. __IO uint32_t iocb9 : 1; /* [25] */
  451. __IO uint32_t iocb10 : 1; /* [26] */
  452. __IO uint32_t iocb11 : 1; /* [27] */
  453. __IO uint32_t iocb12 : 1; /* [28] */
  454. __IO uint32_t iocb13 : 1; /* [29] */
  455. __IO uint32_t iocb14 : 1; /* [30] */
  456. __IO uint32_t iocb15 : 1; /* [31] */
  457. } scr_bit;
  458. };
  459. /**
  460. * @brief gpio wpr register, offset:0x1C
  461. */
  462. union
  463. {
  464. __IO uint32_t wpr;
  465. struct
  466. {
  467. __IO uint32_t wpen0 : 1; /* [0] */
  468. __IO uint32_t wpen1 : 1; /* [1] */
  469. __IO uint32_t wpen2 : 1; /* [2] */
  470. __IO uint32_t wpen3 : 1; /* [3] */
  471. __IO uint32_t wpen4 : 1; /* [4] */
  472. __IO uint32_t wpen5 : 1; /* [5] */
  473. __IO uint32_t wpen6 : 1; /* [6] */
  474. __IO uint32_t wpen7 : 1; /* [7] */
  475. __IO uint32_t wpen8 : 1; /* [8] */
  476. __IO uint32_t wpen9 : 1; /* [9] */
  477. __IO uint32_t wpen10 : 1; /* [10] */
  478. __IO uint32_t wpen11 : 1; /* [11] */
  479. __IO uint32_t wpen12 : 1; /* [12] */
  480. __IO uint32_t wpen13 : 1; /* [13] */
  481. __IO uint32_t wpen14 : 1; /* [14] */
  482. __IO uint32_t wpen15 : 1; /* [15] */
  483. __IO uint32_t wpseq : 1; /* [16] */
  484. __IO uint32_t reserved1 : 15;/* [31:17] */
  485. } wpr_bit;
  486. };
  487. /**
  488. * @brief gpio muxl register, offset:0x20
  489. */
  490. union
  491. {
  492. __IO uint32_t muxl;
  493. struct
  494. {
  495. __IO uint32_t muxl0 : 4; /* [3:0] */
  496. __IO uint32_t muxl1 : 4; /* [7:4] */
  497. __IO uint32_t muxl2 : 4; /* [11:8] */
  498. __IO uint32_t muxl3 : 4; /* [15:12] */
  499. __IO uint32_t muxl4 : 4; /* [19:16] */
  500. __IO uint32_t muxl5 : 4; /* [23:20] */
  501. __IO uint32_t muxl6 : 4; /* [27:24] */
  502. __IO uint32_t muxl7 : 4; /* [31:28] */
  503. } muxl_bit;
  504. };
  505. /**
  506. * @brief gpio muxh register, offset:0x24
  507. */
  508. union
  509. {
  510. __IO uint32_t muxh;
  511. struct
  512. {
  513. __IO uint32_t muxh8 : 4; /* [3:0] */
  514. __IO uint32_t muxh9 : 4; /* [7:4] */
  515. __IO uint32_t muxh10 : 4; /* [11:8] */
  516. __IO uint32_t muxh11 : 4; /* [15:12] */
  517. __IO uint32_t muxh12 : 4; /* [19:16] */
  518. __IO uint32_t muxh13 : 4; /* [23:20] */
  519. __IO uint32_t muxh14 : 4; /* [27:24] */
  520. __IO uint32_t muxh15 : 4; /* [31:28] */
  521. } muxh_bit;
  522. };
  523. /**
  524. * @brief gpio clr register, offset:0x28
  525. */
  526. union
  527. {
  528. __IO uint32_t clr;
  529. struct
  530. {
  531. __IO uint32_t iocb0 : 1; /* [0] */
  532. __IO uint32_t iocb1 : 1; /* [1] */
  533. __IO uint32_t iocb2 : 1; /* [2] */
  534. __IO uint32_t iocb3 : 1; /* [3] */
  535. __IO uint32_t iocb4 : 1; /* [4] */
  536. __IO uint32_t iocb5 : 1; /* [5] */
  537. __IO uint32_t iocb6 : 1; /* [6] */
  538. __IO uint32_t iocb7 : 1; /* [7] */
  539. __IO uint32_t iocb8 : 1; /* [8] */
  540. __IO uint32_t iocb9 : 1; /* [9] */
  541. __IO uint32_t iocb10 : 1; /* [10] */
  542. __IO uint32_t iocb11 : 1; /* [11] */
  543. __IO uint32_t iocb12 : 1; /* [12] */
  544. __IO uint32_t iocb13 : 1; /* [13] */
  545. __IO uint32_t iocb14 : 1; /* [14] */
  546. __IO uint32_t iocb15 : 1; /* [15] */
  547. __IO uint32_t reserved1 : 16;/* [31:16] */
  548. } clr_bit;
  549. };
  550. /**
  551. * @brief gpio reserved1 register, offset:0x2C~0x38
  552. */
  553. __IO uint32_t reserved1[4];
  554. /**
  555. * @brief gpio hdrv register, offset:0x3C
  556. */
  557. union
  558. {
  559. __IO uint32_t hdrv;
  560. struct
  561. {
  562. __IO uint32_t hdrv0 : 1; /* [0] */
  563. __IO uint32_t hdrv1 : 1; /* [1] */
  564. __IO uint32_t hdrv2 : 1; /* [2] */
  565. __IO uint32_t hdrv3 : 1; /* [3] */
  566. __IO uint32_t hdrv4 : 1; /* [4] */
  567. __IO uint32_t hdrv5 : 1; /* [5] */
  568. __IO uint32_t hdrv6 : 1; /* [6] */
  569. __IO uint32_t hdrv7 : 1; /* [7] */
  570. __IO uint32_t hdrv8 : 1; /* [8] */
  571. __IO uint32_t hdrv9 : 1; /* [9] */
  572. __IO uint32_t hdrv10 : 1; /* [10] */
  573. __IO uint32_t hdrv11 : 1; /* [11] */
  574. __IO uint32_t hdrv12 : 1; /* [12] */
  575. __IO uint32_t hdrv13 : 1; /* [13] */
  576. __IO uint32_t hdrv14 : 1; /* [14] */
  577. __IO uint32_t hdrv15 : 1; /* [15] */
  578. __IO uint32_t reserved1 : 16;/* [31:16] */
  579. } hdrv_bit;
  580. };
  581. } gpio_type;
  582. /**
  583. * @}
  584. */
  585. #define GPIOA ((gpio_type *) GPIOA_BASE)
  586. #define GPIOB ((gpio_type *) GPIOB_BASE)
  587. #define GPIOC ((gpio_type *) GPIOC_BASE)
  588. #define GPIOF ((gpio_type *) GPIOF_BASE)
  589. /** @defgroup GPIO_exported_functions
  590. * @{
  591. */
  592. void gpio_reset(gpio_type *gpio_x);
  593. void gpio_init(gpio_type *gpio_x, gpio_init_type *gpio_init_struct);
  594. void gpio_default_para_init(gpio_init_type *gpio_init_struct);
  595. flag_status gpio_input_data_bit_read(gpio_type *gpio_x, uint16_t pins);
  596. uint16_t gpio_input_data_read(gpio_type *gpio_x);
  597. flag_status gpio_output_data_bit_read(gpio_type *gpio_x, uint16_t pins);
  598. uint16_t gpio_output_data_read(gpio_type *gpio_x);
  599. void gpio_bits_set(gpio_type *gpio_x, uint16_t pins);
  600. void gpio_bits_reset(gpio_type *gpio_x, uint16_t pins);
  601. void gpio_bits_write(gpio_type *gpio_x, uint16_t pins, confirm_state bit_state);
  602. void gpio_port_write(gpio_type *gpio_x, uint16_t port_value);
  603. void gpio_pin_wp_config(gpio_type *gpio_x, uint16_t pins);
  604. void gpio_pins_huge_driven_config(gpio_type *gpio_x, uint16_t pins, confirm_state new_state);
  605. void gpio_pin_mux_config(gpio_type *gpio_x, gpio_pins_source_type gpio_pin_source, gpio_mux_sel_type gpio_mux);
  606. /**
  607. * @}
  608. */
  609. /**
  610. * @}
  611. */
  612. /**
  613. * @}
  614. */
  615. #ifdef __cplusplus
  616. }
  617. #endif
  618. #endif