at32f423_gpio.h 23 KB

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