at32f403a_407_gpio.h 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939
  1. /**
  2. **************************************************************************
  3. * @file at32f403a_407_gpio.h
  4. * @brief at32f403a_407 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 __AT32F403A_407_GPIO_H
  26. #define __AT32F403A_407_GPIO_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* includes ------------------------------------------------------------------*/
  31. #include "at32f403a_407.h"
  32. /** @addtogroup AT32F403A_407_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. #define IOMUX_MAKE_VALUE(reg_offset, bit_addr ,bit_num, bit_val) \
  62. (uint32_t)(((reg_offset) << 24) | ((bit_addr) << 16) | ((bit_num) << 8) | (bit_val))
  63. /** @defgroup IOMUX_map_definition
  64. * @brief iomux map definitions
  65. * @{
  66. */
  67. #if defined (AT32F403Axx)
  68. #define SPI1_MUX_01 SPI1_GMUX_0001 /*!< spi1_cs/i2s1_ws(pa15), spi1_sck/i2s1_ck(pb3), spi1_miso(pb4), spi1_mosi/i2s1_sd(pb5), i2s1_mck(pb0) */
  69. #define SPI1_MUX_10 SPI1_GMUX_0010 /*!< spi1_cs/i2s1_ws(pa4), spi1_sck/i2s1_ck(pa5), spi1_miso(pa6), spi1_mosi/i2s1_sd(pa7), i2s1_mck(pb6) */
  70. #define SPI1_MUX_11 SPI1_GMUX_0011 /*!< spi1_cs/i2s1_ws(pa15), spi1_sck/i2s1_ck(pb3), spi1_miso(pb4), spi1_mosi/i2s1_sd(pb5), i2s1_mck(pb6) */
  71. #define I2C1_MUX I2C1_GMUX_0001 /*!< i2c1_scl(pb8), i2c1_sda(pb9) */
  72. #define USART1_MUX USART1_GMUX_0001 /*!< usart1_tx(pb6), usart1_rx(pb7) */
  73. #define USART2_MUX USART2_GMUX_0001 /*!< usart2_tx(pd5), usart2_rx(pd6), usart2_ck(pd7), usart2_cts(pd3), usart2_rts(pd4) */
  74. #define USART3_MUX_01 USART3_GMUX_0001 /*!< usart3_tx(pc10), usart3_rx(pc11), usart3_ck(pc12), usart3_cts(pb13), usart3_rts(pb14) */
  75. #define USART3_MUX_11 USART3_GMUX_0011 /*!< usart3_tx(pd8), usart3_rx(pd9), usart3_ck(pd10), usart3_cts(pd11), usart3_rts(pd12) */
  76. #define TMR1_MUX_01 TMR1_GMUX_0001 /*!< tmr1_ext(pa12), tmr1_ch1(pa8), tmr1_ch2(pa9), tmr1_ch3(pa10), tmr1_ch4(pa11), tmr1_brkin(pa6), tmr1_ch1c(pa7), tmr1_ch2c(pb0), tmr1_ch3c(pb1) */
  77. #define TMR1_MUX_11 TMR1_GMUX_0011 /*!< tmr1_ext(pe7), tmr1_ch1(pe9), tmr1_ch2(pe11), tmr1_ch3(pe13), tmr1_ch4(pe14), tmr1_brkin(pe15), tmr1_ch1c(pe8), tmr1_ch2c(pe10), tmr1_ch3c(pe12) */
  78. #define TMR2_MUX_01 TMR2_GMUX_01 /*!< tmr2_ch1_ext(pa15), tmr2_ch2(pb3), tmr2_ch3(pa2), tmr2_ch4(pa3) */
  79. #define TMR2_MUX_10 TMR2_GMUX_10 /*!< tmr2_ch1_ext(pa0), tmr2_ch2(pa1), tmr2_ch3(pb10), tmr2_ch4(pb11) */
  80. #define TMR2_MUX_11 TMR2_GMUX_11 /*!< tmr2_ch1_ext(pa15), tmr2_ch2(pb3), tmr2_ch3(pb10), tmr2_ch4(pb11) */
  81. #define TMR3_MUX_10 TMR3_GMUX_0010 /*!< tmr3_ch1(pb4), tmr3_ch2(pb5), tmr3_ch3(pb0), tmr3_ch4(pb1) */
  82. #define TMR3_MUX_11 TMR3_GMUX_0011 /*!< tmr3_ch1(pc6), tmr3_ch2(pc7), tmr3_ch3(pc8), tmr3_ch4(pc9) */
  83. #define TMR4_MUX TMR4_GMUX_0001 /*!< tmr4_ch1(pd12), tmr4_ch2(pd13), tmr4_ch3(pd14), tmr4_ch4(pd15) */
  84. #define CAN_MUX_10 CAN1_GMUX_0010 /*!< can_rx(pb8), can_tx(pb9) */
  85. #define CAN_MUX_11 CAN1_GMUX_0011 /*!< can_rx(pd0), can_tx(pd1) */
  86. #define PD01_MUX PD01_GMUX /*!< pd0/pd1 mapping on osc_in/osc_out */
  87. #define TMR5CH4_MUX TMR5CH4_GMUX /*!< lick connected to tmr5_ch4 input capture for calibration */
  88. #define ADC1_ETP_MUX ADC1_ETP_GMUX /*!< adc1 external trigger preempted conversion muxing */
  89. #define ADC1_ETO_MUX ADC1_ETO_GMUX /*!< adc1 external trigger ordinary conversion muxing */
  90. #define ADC2_ETP_MUX ADC2_ETP_GMUX /*!< adc2 external trigger preempted conversion muxing */
  91. #define ADC2_ETO_MUX ADC2_ETO_GMUX /*!< adc2 external trigger ordinary conversion muxing */
  92. #define SWJTAG_MUX_001 SWJTAG_GMUX_001 /*!< full swj enabled (jtag-dp + sw-dp) but without jtrst */
  93. #define SWJTAG_MUX_010 SWJTAG_GMUX_010 /*!< jtag-dp disabled and sw-dp enabled */
  94. #define SWJTAG_MUX_100 SWJTAG_GMUX_100 /*!< full swj disabled (jtag-dp + sw-dp) */
  95. #endif
  96. #if defined (AT32F407xx)
  97. #define SPI1_MUX_01 SPI1_GMUX_0001 /*!< spi1_cs/i2s1_ws(pa15), spi1_sck/i2s1_ck(pb3), spi1_miso(pb4), spi1_mosi/i2s1_sd(pb5), i2s1_mck(pb0) */
  98. #define SPI1_MUX_10 SPI1_GMUX_0010 /*!< spi1_cs/i2s1_ws(pa4), spi1_sck/i2s1_ck(pa5), spi1_miso(pa6), spi1_mosi/i2s1_sd(pa7), i2s1_mck(pb6) */
  99. #define SPI1_MUX_11 SPI1_GMUX_0011 /*!< spi1_cs/i2s1_ws(pa15), spi1_sck/i2s1_ck(pb3), spi1_miso(pb4), spi1_mosi/i2s1_sd(pb5), i2s1_mck(pb6) */
  100. #define I2C1_MUX I2C1_GMUX_0001 /*!< i2c1_scl(pb8), i2c1_sda(pb9) */
  101. #define USART1_MUX USART1_GMUX_0001 /*!< usart1_tx(pb6), usart1_rx(pb7) */
  102. #define USART2_MUX USART2_GMUX_0001 /*!< usart2_tx(pd5), usart2_rx(pd6), usart2_ck(pd7), usart2_cts(pd3), usart2_rts(pd4) */
  103. #define USART3_MUX_01 USART3_GMUX_0001 /*!< usart3_tx(pc10), usart3_rx(pc11), usart3_ck(pc12), usart3_cts(pb13), usart3_rts(pb14) */
  104. #define USART3_MUX_11 USART3_GMUX_0011 /*!< usart3_tx(pd8), usart3_rx(pd9), usart3_ck(pd10), usart3_cts(pd11), usart3_rts(pd12) */
  105. #define TMR1_MUX_01 TMR1_GMUX_0001 /*!< tmr1_ext(pa12), tmr1_ch1(pa8), tmr1_ch2(pa9), tmr1_ch3(pa10), tmr1_ch4(pa11), tmr1_brkin(pa6), tmr1_ch1c(pa7), tmr1_ch2c(pb0), tmr1_ch3c(pb1) */
  106. #define TMR1_MUX_11 TMR1_GMUX_0011 /*!< tmr1_ext(pe7), tmr1_ch1(pe9), tmr1_ch2(pe11), tmr1_ch3(pe13), tmr1_ch4(pe14), tmr1_brkin(pe15), tmr1_ch1c(pe8), tmr1_ch2c(pe10), tmr1_ch3c(pe12) */
  107. #define TMR2_MUX_01 TMR2_GMUX_01 /*!< tmr2_ch1_ext(pa15), tmr2_ch2(pb3), tmr2_ch3(pa2), tmr2_ch4(pa3) */
  108. #define TMR2_MUX_10 TMR2_GMUX_10 /*!< tmr2_ch1_ext(pa0), tmr2_ch2(pa1), tmr2_ch3(pb10), tmr2_ch4(pb11) */
  109. #define TMR2_MUX_11 TMR2_GMUX_11 /*!< tmr2_ch1_ext(pa15), tmr2_ch2(pb3), tmr2_ch3(pb10), tmr2_ch4(pb11) */
  110. #define TMR3_MUX_10 TMR3_GMUX_0010 /*!< tmr3_ch1(pb4), tmr3_ch2(pb5), tmr3_ch3(pb0), tmr3_ch4(pb1) */
  111. #define TMR3_MUX_11 TMR3_GMUX_0011 /*!< tmr3_ch1(pc6), tmr3_ch2(pc7), tmr3_ch3(pc8), tmr3_ch4(pc9) */
  112. #define TMR4_MUX TMR4_GMUX_0001 /*!< tmr4_ch1(pd12), tmr4_ch2(pd13), tmr4_ch3(pd14), tmr4_ch4(pd15) */
  113. #define CAN_MUX_00 CAN1_GMUX_0000 /*!< can_rx(pa11), can_tx(pa12) */
  114. #define CAN_MUX_10 CAN1_GMUX_0010 /*!< can_rx(pb8), can_tx(pb9) */
  115. #define CAN_MUX_11 CAN1_GMUX_0011 /*!< can_rx(pd0), can_tx(pd1) */
  116. #define PD01_MUX PD01_GMUX /*!< pd0/pd1 mapping on osc_in/osc_out */
  117. #define TMR5CH4_MUX TMR5CH4_GMUX /*!< lick connected to tmr5_ch4 input capture for calibration */
  118. #define ADC1_ETP_MUX ADC1_ETP_GMUX /*!< adc1 external trigger preempted conversion muxing */
  119. #define ADC1_ETO_MUX ADC1_ETO_GMUX /*!< adc1 external trigger ordinary conversion muxing */
  120. #define ADC2_ETP_MUX ADC2_ETP_GMUX /*!< adc2 external trigger preempted conversion muxing */
  121. #define ADC2_ETO_MUX ADC2_ETO_GMUX /*!< adc2 external trigger ordinary conversion muxing */
  122. #define EMAC_MUX EMAC_GMUX_01 /*!< rx_dv/crs_dv(pd8), rxd0(pd9), rxd1(pd10), rxd2(pd11), rxd3(pd12) */
  123. #define CAN2_MUX CAN2_GMUX_0001 /*!< can2_rx(pb5), can2_tx(pb6) */
  124. #define MII_RMII_SEL_MUX MII_RMII_SEL_GMUX /*!< mii or rmii selection */
  125. #define SWJTAG_MUX_001 SWJTAG_GMUX_001 /*!< full swj enabled (jtag-dp + sw-dp) but without jtrst */
  126. #define SWJTAG_MUX_010 SWJTAG_GMUX_010 /*!< jtag-dp disabled and sw-dp enabled */
  127. #define SWJTAG_MUX_100 SWJTAG_GMUX_100 /*!< full swj disabled (jtag-dp + sw-dp) */
  128. #define SPI3_MUX SPI3_GMUX_0001 /*!< spi3_cs/i2s3_ws(pa4), spi3_sck/i2s3_ck(pc10), spi3_miso(pc11), spi3_mosi/i2s3_sd(pc12), i2s3_mck(pc7) */
  129. #define TMR2ITR1_MUX TMR2ITR1_GMAP_10 /*!< tmr2 internal trigger 1 mux remapping */
  130. #define PTP_PPS_MUX PTP_PPS_GMUX /*!< ethernet ptp pps mux function remapping */
  131. #endif
  132. /**
  133. * @}
  134. */
  135. /** @defgroup IOMUX_map2_definition
  136. * @brief iomux map2 definitions
  137. * @{
  138. */
  139. #define TMR9_MUX TMR9_GMUX /*!< tmr9_ch1(pe5), tmr9_ch2(pe6) */
  140. #define XMC_NADV_MUX XMC_NADV_GMUX /*!< xmc_nadv not used */
  141. #define SPI4_MUX SPI4_GMUX_0001 /*!< spi4_cs/i2s4_ws(pe12), spi4_sck/i2s4_ck(pe11), spi4_miso(pe13), spi4_mosi/i2s4_sd(pe14), i2s4_mck(pc8) */
  142. #define I2C3_MUX I2C3_GMUX_0001 /*!< i2c3_scl(pa8), i2c3_sda(pb4) */
  143. #define SDIO2_MUX01 SDIO2_GMUX_0001 /*!< sdio2_ck(pc4), sdio2_cmd(pc5), sdio2_d0(pa4), sdio2_d1(pa5), sdio2_d2(pa6), sdio2_d3(pa7) */
  144. #define SDIO2_MUX10 SDIO2_GMUX_0010 /*!< sdio2_ck(pa2), sdio2_cmd(pa3), sdio2_d0(pc0), sdio2_d1(pc1), sdio2_d2(pc2), sdio2_d3(pc3), sdio2_d4(pa4), sdio2_d5(pa5), sdio2_d6(pa6), sdio2_d7(pa7) */
  145. #define SDIO2_MUX11 SDIO2_GMUX_0011 /*!< sdio2_ck(pa2), sdio2_cmd(pa3), sdio2_d0(pa4), sdio2_d1(pa5), sdio2_d2(pa6), sdio2_d3(pa7) */
  146. #define EXT_SPIM_EN_MUX EXT_SPIM_GMUX_1000 /*!< enable external spi-flash interface */
  147. /**
  148. * @}
  149. */
  150. /** @defgroup IOMUX_map3_definition
  151. * @brief iomux map3 definitions
  152. * @{
  153. */
  154. #define TMR9_GMUX IOMUX_MAKE_VALUE(0x20, 0, 4, 0x01) /*!< tmr9_ch1(pe5), tmr9_ch2(pe6) */
  155. /**
  156. * @}
  157. */
  158. /** @defgroup IOMUX_map4_definition
  159. * @brief iomux map4 definitions
  160. * @{
  161. */
  162. #define TMR1_GMUX_0001 IOMUX_MAKE_VALUE(0x24, 0, 4, 0x01) /*!< tmr1_ext(pa12), tmr1_ch1(pa8), tmr1_ch2(pa9), tmr1_ch3(pa10), tmr1_ch4(pa11), tmr1_brkin(pa6), tmr1_ch1c(pa7), tmr1_ch2c(pb0), tmr1_ch3c(pb1) */
  163. #define TMR1_GMUX_0011 IOMUX_MAKE_VALUE(0x24, 0, 4, 0x03) /*!< tmr1_ext(pe7), tmr1_ch1(pe9), tmr1_ch2(pe11), tmr1_ch3(pe13), tmr1_ch4(pe14), tmr1_brkin(pe15), tmr1_ch1c(pe8), tmr1_ch2c(pe10), tmr1_ch3c(pe12) */
  164. #define TMR2_GMUX_01 IOMUX_MAKE_VALUE(0x24, 4, 2, 0x01) /*!< tmr2_ch1_ext(pa15), tmr2_ch2(pb3), tmr2_ch3(pa2), tmr2_ch4(pa3) */
  165. #define TMR2_GMUX_10 IOMUX_MAKE_VALUE(0x24, 4, 2, 0x02) /*!< tmr2_ch1_ext(pa0), tmr2_ch2(pa1), tmr2_ch3(pb10), tmr2_ch4(pb11) */
  166. #define TMR2_GMUX_11 IOMUX_MAKE_VALUE(0x24, 4, 2, 0x03) /*!< tmr2_ch1_ext(pa15), tmr2_ch2(pb3), tmr2_ch3(pb10), tmr2_ch4(pb11) */
  167. #define TMR2ITR1_GMUX_10 IOMUX_MAKE_VALUE(0x24, 6, 2, 0x02) /*!< ethernet ptp as input to tmr2_int.1 */
  168. #define TMR2ITR1_GMUX_11 IOMUX_MAKE_VALUE(0x24, 6, 2, 0x03) /*!< usbdev sof as input to tmr2_int.1 */
  169. #define TMR3_GMUX_0010 IOMUX_MAKE_VALUE(0x24, 8, 4, 0x02) /*!< tmr3_ch1(pb4), tmr3_ch2(pb5), tmr3_ch3(pb0), tmr3_ch4(pb1) */
  170. #define TMR3_GMUX_0011 IOMUX_MAKE_VALUE(0x24, 8, 4, 0x03) /*!< tmr3_ch1(pc6), tmr3_ch2(pc7), tmr3_ch3(pc8), tmr3_ch4(pc9) */
  171. #define TMR4_GMUX_0001 IOMUX_MAKE_VALUE(0x24, 12, 4, 0x01) /*!< tmr4_ch1(pd12), tmr4_ch2(pd13), tmr4_ch3(pd14), tmr4_ch4(pd15) */
  172. #define TMR5CH4_GMUX IOMUX_MAKE_VALUE(0x24, 19, 1, 0x01) /*!< lick connected to tmr5_ch4 input capture for calibration */
  173. /**
  174. * @}
  175. */
  176. /** @defgroup IOMUX_map5_definition
  177. * @brief iomux map5 definitions
  178. * @{
  179. */
  180. #define UART5_GMUX_0001 IOMUX_MAKE_VALUE(0x28, 0, 4, 0x01) /*!< uart5_tx(pb9), uart5_rx(pb8) */
  181. #define I2C1_GMUX_0001 IOMUX_MAKE_VALUE(0x28, 4, 4, 0x01) /*!< i2c1_scl(pb8), i2c1_sda(pb9) */
  182. #define I2C3_GMUX_0001 IOMUX_MAKE_VALUE(0x28, 12, 4, 0x01) /*!< i2c3_scl(pa8), i2c3_sda(pb4) */
  183. #define SPI1_GMUX_0001 IOMUX_MAKE_VALUE(0x28, 16, 4, 0x01) /*!< spi1_cs/i2s1_ws(pa15), spi1_sck/i2s1_ck(pb3), spi1_miso(pb4), spi1_mosi/i2s1_sd(pb5), i2s1_mck(pb0) */
  184. #define SPI1_GMUX_0010 IOMUX_MAKE_VALUE(0x28, 16, 4, 0x02) /*!< spi1_cs/i2s1_ws(pa4), spi1_sck/i2s1_ck(pa5), spi1_miso(pa6), spi1_mosi/i2s1_sd(pa7), i2s1_mck(pb6) */
  185. #define SPI1_GMUX_0011 IOMUX_MAKE_VALUE(0x28, 16, 4, 0x03) /*!< spi1_cs/i2s1_ws(pa15), spi1_sck/i2s1_ck(pb3), spi1_miso(pb4), spi1_mosi/i2s1_sd(pb5), i2s1_mck(pb6) */
  186. #define SPI2_GMUX_0001 IOMUX_MAKE_VALUE(0x28, 20, 4, 0x01) /*!< i2s2_mck(pa3) */
  187. #define SPI2_GMUX_0010 IOMUX_MAKE_VALUE(0x28, 20, 4, 0x02) /*!< i2s2_mck(pa6) */
  188. #define SPI3_GMUX_0001 IOMUX_MAKE_VALUE(0x28, 24, 4, 0x01) /*!< spi3_cs/i2s3_ws(pa4), spi3_sck/i2s3_ck(pc10), spi3_miso(pc11), spi3_mosi/i2s3_sd(pc12), i2s3_mck(pc7) */
  189. #define SPI3_GMUX_0010 IOMUX_MAKE_VALUE(0x28, 24, 4, 0x02) /*!< spi3_cs/i2s3_ws(pa15), spi3_sck/i2s3_ck(pb3), spi3_miso(pb4), spi3_mosi/i2s3_sd(pb5), i2s3_mck(pb10) */
  190. #define SPI3_GMUX_0011 IOMUX_MAKE_VALUE(0x28, 24, 4, 0x03) /*!< spi3_cs/i2s3_ws(pa4), spi3_sck/i2s3_ck(pc10), spi3_miso(pc11), spi3_mosi/i2s3_sd(pc12), i2s3_mck(pb10) */
  191. #define SPI4_GMUX_0001 IOMUX_MAKE_VALUE(0x28, 28, 4, 0x01) /*!< spi4_cs/i2s4_ws(pe12), spi4_sck/i2s4_ck(pe11), spi4_miso(pe13), spi4_mosi/i2s4_sd(pe14), i2s4_mck(pc8) */
  192. #define SPI4_GMUX_0010 IOMUX_MAKE_VALUE(0x28, 28, 4, 0x02) /*!< spi4_cs/i2s4_ws(pb6), spi4_sck/i2s4_ck(pb7), spi4_miso(pb8), spi4_mosi/i2s4_sd(pb9), i2s4_mck(pc8) */
  193. #define SPI4_GMUX_0011 IOMUX_MAKE_VALUE(0x28, 28, 4, 0x03) /*!< spi4_cs/i2s4_ws(pb6), spi4_sck/i2s4_ck(pb7), spi4_miso(pb8), spi4_mosi/i2s4_sd(pb9), i2s4_mck(pa10) */
  194. /**
  195. * @}
  196. */
  197. /** @defgroup IOMUX_map6_definition
  198. * @brief iomux map6 definitions
  199. * @{
  200. */
  201. #define CAN1_GMUX_0010 IOMUX_MAKE_VALUE(0x2C, 0, 4, 0x02) /*!< can_rx(pb8), can_tx(pb9) */
  202. #define CAN1_GMUX_0011 IOMUX_MAKE_VALUE(0x2C, 0, 4, 0x03) /*!< can_rx(pd0), can_tx(pd1) */
  203. #define CAN2_GMUX_0001 IOMUX_MAKE_VALUE(0x2C, 4, 4, 0x01) /*!< can2_rx(pb5), can2_tx(pb6) */
  204. #define SDIO2_GMUX_0001 IOMUX_MAKE_VALUE(0x2C, 12, 4, 0x01) /*!< sdio2_ck(pc4), sdio2_cmd(pc5), sdio2_d0(pa4), sdio2_d1(pa5), sdio2_d2(pa6), sdio2_d3(pa7) */
  205. #define SDIO2_GMUX_0010 IOMUX_MAKE_VALUE(0x2C, 12, 4, 0x02) /*!< sdio2_ck(pa2), sdio2_cmd(pa3), sdio2_d0(pc0), sdio2_d1(pc1), sdio2_d2(pc2), sdio2_d3(pc3), sdio2_d4(pa4), sdio2_d5(pa5), sdio2_d6(pa6), sdio2_d7(pa7) */
  206. #define SDIO2_GMUX_0011 IOMUX_MAKE_VALUE(0x2C, 12, 4, 0x03) /*!< sdio2_ck(pa2), sdio2_cmd(pa3), sdio2_d0(pa4), sdio2_d1(pa5), sdio2_d2(pa6), sdio2_d3(pa7) */
  207. #define USART1_GMUX_0001 IOMUX_MAKE_VALUE(0x2C, 16, 4, 0x01) /*!< usart1_tx(pb6), usart1_rx(pb7) */
  208. #define USART2_GMUX_0001 IOMUX_MAKE_VALUE(0x2C, 20, 4, 0x01) /*!< usart2_tx(pd5), usart2_rx(pd6), usart2_ck(pd7), usart2_cts(pd3), usart2_rts(pd4) */
  209. #define USART3_GMUX_0001 IOMUX_MAKE_VALUE(0x2C, 24, 4, 0x01) /*!< usart3_tx(pc10), usart3_rx(pc11), usart3_ck(pc12), usart3_cts(pb13), usart3_rts(pb14) */
  210. #define USART3_GMUX_0011 IOMUX_MAKE_VALUE(0x2C, 24, 4, 0x03) /*!< usart3_tx(pd8), usart3_rx(pd9), usart3_ck(pd10), usart3_cts(pd11), usart3_rts(pd12) */
  211. #define UART4_GMUX_0010 IOMUX_MAKE_VALUE(0x2C, 28, 4, 0x02) /*!< uart4_tx(pa0), uart4_rx(pa1) */
  212. /**
  213. * @}
  214. */
  215. /** @defgroup IOMUX_map7_definition
  216. * @brief iomux map7 definitions
  217. * @{
  218. */
  219. #define EXT_SPIM_GMUX_1000 IOMUX_MAKE_VALUE(0x30, 0, 4, 0x08) /*!< spim_sck(pb1), spim_cs(pa8), spim_io0(pa11), spim_io1(pa12), spim_io2(pb7), spim_sio3(pb6) */
  220. #define EXT_SPIM_GMUX_1001 IOMUX_MAKE_VALUE(0x30, 0, 4, 0x09) /*!< spim_sck(pb1), spim_cs(pa8), spim_io0(pb10), spim_io1(pb11), spim_io2(pb7), spim_sio3(pb6) */
  221. #define ADC1_ETP_GMUX IOMUX_MAKE_VALUE(0x30, 4, 1, 0x01) /*!< adc1 external trigger preempted conversion muxing */
  222. #define ADC1_ETO_GMUX IOMUX_MAKE_VALUE(0x30, 5, 1, 0x01) /*!< adc1 external trigger ordinary conversion muxing */
  223. #define ADC2_ETP_GMUX IOMUX_MAKE_VALUE(0x30, 8, 1, 0x01) /*!< adc2 external trigger preempted conversion muxing */
  224. #define ADC2_ETO_GMUX IOMUX_MAKE_VALUE(0x30, 9, 1, 0x01) /*!< adc2 external trigger ordinary conversion muxing */
  225. #define SWJTAG_GMUX_001 IOMUX_MAKE_VALUE(0x30, 16, 3, 0x01) /*!< full swj enabled (jtag-dp + sw-dp) but without jtrst */
  226. #define SWJTAG_GMUX_010 IOMUX_MAKE_VALUE(0x30, 16, 3, 0x02) /*!< jtag-dp disabled and sw-dp enabled */
  227. #define SWJTAG_GMUX_100 IOMUX_MAKE_VALUE(0x30, 16, 3, 0x04) /*!< full swj disabled (jtag-dp + sw-dp) */
  228. #define PD01_GMUX IOMUX_MAKE_VALUE(0x30, 20, 1, 0x01) /*!< pd0/pd1 mapping on osc_in/osc_out */
  229. #define XMC_GMUX_001 IOMUX_MAKE_VALUE(0x30, 24, 3, 0x01) /*!< xmc_nwe(pd2), xmc_d0(pb14), xmc_d1(pc6), xmc_d2(pc11), xmc_d3(pc12), xmc_d4(pa2), xmc_d5(pa3), xmc_d6(pa4), xmc_d7(pa5), xmc_d13(pb12), xmc_noe(pc5) */
  230. #define XMC_GMUX_010 IOMUX_MAKE_VALUE(0x30, 24, 3, 0x02) /*!< xmc_nwe(pc2), xmc_d0(pb14), xmc_d1(pc6), xmc_d2(pc11), xmc_d3(pc12), xmc_d4(pa2), xmc_d5(pa3), xmc_d6(pa4), xmc_d7(pa5), xmc_d13(pb12), xmc_noe(pc5) */
  231. #define XMC_NADV_GMUX IOMUX_MAKE_VALUE(0x30, 27, 1, 0x01) /*!< xmc_nadv not used */
  232. /**
  233. * @}
  234. */
  235. /** @defgroup IOMUX_map8_definition
  236. * @brief iomux map8 definitions
  237. * @{
  238. */
  239. #if defined (AT32F407xx)
  240. #define EMAC_GMUX_01 IOMUX_MAKE_VALUE(0x34, 16, 2, 0x01) /*!< rx_dv/crs_dv(pd8), rxd0(pd9), rxd1(pd10), rxd2(pd11), rxd3(pd12) */
  241. #define MII_RMII_SEL_GMUX IOMUX_MAKE_VALUE(0x34, 18, 1, 0x01) /*!< mii or rmii selection */
  242. #define PTP_PPS_GMUX IOMUX_MAKE_VALUE(0x34, 19, 1, 0x01) /*!< ethernet ptp pps mux function remapping */
  243. #endif
  244. #define USART6_GMUX IOMUX_MAKE_VALUE(0x34, 20, 4, 0x01) /*!< usart6_tx(pa4), usart6_rx(pa5) */
  245. #define UART7_GMUX IOMUX_MAKE_VALUE(0x34, 24, 4, 0x01) /*!< uart7_tx(pb4), uart7_rx(pb3) */
  246. #define UART8_GMUX IOMUX_MAKE_VALUE(0x34, 28, 4, 0x01) /*!< uart8_tx(pc2), uart8_rx(pc3) */
  247. /**
  248. * @}
  249. */
  250. /** @defgroup GPIO_exported_types
  251. * @{
  252. */
  253. /**
  254. * @brief gpio mode select
  255. */
  256. typedef enum
  257. {
  258. GPIO_MODE_INPUT = 0x00, /*!< gpio input mode */
  259. GPIO_MODE_OUTPUT = 0x10, /*!< gpio output mode */
  260. GPIO_MODE_MUX = 0x08, /*!< gpio mux function mode */
  261. GPIO_MODE_ANALOG = 0x03 /*!< gpio analog in/out mode */
  262. } gpio_mode_type;
  263. /**
  264. * @brief gpio output drive strength select
  265. */
  266. typedef enum
  267. {
  268. GPIO_DRIVE_STRENGTH_STRONGER = 0x01, /*!< stronger sourcing/sinking strength */
  269. GPIO_DRIVE_STRENGTH_MODERATE = 0x02 /*!< moderate sourcing/sinking strength */
  270. } gpio_drive_type;
  271. /**
  272. * @brief gpio output type
  273. */
  274. typedef enum
  275. {
  276. GPIO_OUTPUT_PUSH_PULL = 0x00, /*!< output push-pull */
  277. GPIO_OUTPUT_OPEN_DRAIN = 0x04 /*!< output open-drain */
  278. } gpio_output_type;
  279. /**
  280. * @brief gpio pull type
  281. */
  282. typedef enum
  283. {
  284. GPIO_PULL_NONE = 0x0004, /*!< floating for input, no pull for output */
  285. GPIO_PULL_UP = 0x0018, /*!< pull-up */
  286. GPIO_PULL_DOWN = 0x0028 /*!< pull-down */
  287. } gpio_pull_type;
  288. /**
  289. * @brief gpio pins source type
  290. */
  291. typedef enum
  292. {
  293. GPIO_PINS_SOURCE0 = 0x00, /*!< gpio pins source number 0 */
  294. GPIO_PINS_SOURCE1 = 0x01, /*!< gpio pins source number 1 */
  295. GPIO_PINS_SOURCE2 = 0x02, /*!< gpio pins source number 2 */
  296. GPIO_PINS_SOURCE3 = 0x03, /*!< gpio pins source number 3 */
  297. GPIO_PINS_SOURCE4 = 0x04, /*!< gpio pins source number 4 */
  298. GPIO_PINS_SOURCE5 = 0x05, /*!< gpio pins source number 5 */
  299. GPIO_PINS_SOURCE6 = 0x06, /*!< gpio pins source number 6 */
  300. GPIO_PINS_SOURCE7 = 0x07, /*!< gpio pins source number 7 */
  301. GPIO_PINS_SOURCE8 = 0x08, /*!< gpio pins source number 8 */
  302. GPIO_PINS_SOURCE9 = 0x09, /*!< gpio pins source number 9 */
  303. GPIO_PINS_SOURCE10 = 0x0A, /*!< gpio pins source number 10 */
  304. GPIO_PINS_SOURCE11 = 0x0B, /*!< gpio pins source number 11 */
  305. GPIO_PINS_SOURCE12 = 0x0C, /*!< gpio pins source number 12 */
  306. GPIO_PINS_SOURCE13 = 0x0D, /*!< gpio pins source number 13 */
  307. GPIO_PINS_SOURCE14 = 0x0E, /*!< gpio pins source number 14 */
  308. GPIO_PINS_SOURCE15 = 0x0F /*!< gpio pins source number 15 */
  309. } gpio_pins_source_type;
  310. /**
  311. * @brief gpio port source type
  312. */
  313. typedef enum
  314. {
  315. GPIO_PORT_SOURCE_GPIOA = 0x00, /*!< gpio port source gpioa */
  316. GPIO_PORT_SOURCE_GPIOB = 0x01, /*!< gpio port source gpiob */
  317. GPIO_PORT_SOURCE_GPIOC = 0x02, /*!< gpio port source gpioc */
  318. GPIO_PORT_SOURCE_GPIOD = 0x03, /*!< gpio port source gpiod */
  319. GPIO_PORT_SOURCE_GPIOE = 0x04, /*!< gpio port source gpioe */
  320. } gpio_port_source_type;
  321. /**
  322. * @brief gpio init type
  323. */
  324. typedef struct
  325. {
  326. uint32_t gpio_pins; /*!< pins number selection */
  327. gpio_output_type gpio_out_type; /*!< output type selection */
  328. gpio_pull_type gpio_pull; /*!< pull type selection */
  329. gpio_mode_type gpio_mode; /*!< mode selection */
  330. gpio_drive_type gpio_drive_strength; /*!< drive strength selection */
  331. } gpio_init_type;
  332. /**
  333. * @brief type define gpio register all
  334. */
  335. typedef struct
  336. {
  337. /**
  338. * @brief gpio cfglr register, offset:0x00
  339. */
  340. union
  341. {
  342. __IO uint32_t cfglr;
  343. struct
  344. {
  345. __IO uint32_t iomc0 : 2; /* [1:0] */
  346. __IO uint32_t iofc0 : 2; /* [3:2] */
  347. __IO uint32_t iomc1 : 2; /* [5:4] */
  348. __IO uint32_t iofc1 : 2; /* [7:6] */
  349. __IO uint32_t iomc2 : 2; /* [9:8] */
  350. __IO uint32_t iofc2 : 2; /* [11:10] */
  351. __IO uint32_t iomc3 : 2; /* [13:12] */
  352. __IO uint32_t iofc3 : 2; /* [15:14] */
  353. __IO uint32_t iomc4 : 2; /* [17:16] */
  354. __IO uint32_t iofc4 : 2; /* [19:18] */
  355. __IO uint32_t iomc5 : 2; /* [21:20] */
  356. __IO uint32_t iofc5 : 2; /* [23:22] */
  357. __IO uint32_t iomc6 : 2; /* [25:24] */
  358. __IO uint32_t iofc6 : 2; /* [27:26] */
  359. __IO uint32_t iomc7 : 2; /* [29:28] */
  360. __IO uint32_t iofc7 : 2; /* [31:30] */
  361. } cfglr_bit;
  362. };
  363. /**
  364. * @brief gpio cfghr register, offset:0x04
  365. */
  366. union
  367. {
  368. __IO uint32_t cfghr;
  369. struct
  370. {
  371. __IO uint32_t iomc8 : 2; /* [1:0] */
  372. __IO uint32_t iofc8 : 2; /* [3:2] */
  373. __IO uint32_t iomc9 : 2; /* [5:4] */
  374. __IO uint32_t iofc9 : 2; /* [7:6] */
  375. __IO uint32_t iomc10 : 2; /* [9:8] */
  376. __IO uint32_t iofc10 : 2; /* [11:10] */
  377. __IO uint32_t iomc11 : 2; /* [13:12] */
  378. __IO uint32_t iofc11 : 2; /* [15:14] */
  379. __IO uint32_t iomc12 : 2; /* [17:16] */
  380. __IO uint32_t iofc12 : 2; /* [19:18] */
  381. __IO uint32_t iomc13 : 2; /* [21:20] */
  382. __IO uint32_t iofc13 : 2; /* [23:22] */
  383. __IO uint32_t iomc14 : 2; /* [25:24] */
  384. __IO uint32_t iofc14 : 2; /* [27:26] */
  385. __IO uint32_t iomc15 : 2; /* [29:28] */
  386. __IO uint32_t iofc15 : 2; /* [31:30] */
  387. } cfghr_bit;
  388. };
  389. /**
  390. * @brief gpio idt register, offset:0x08
  391. */
  392. union
  393. {
  394. __IO uint32_t idt;
  395. struct
  396. {
  397. __IO uint32_t idt0 : 1; /* [0] */
  398. __IO uint32_t idt1 : 1; /* [1] */
  399. __IO uint32_t idt2 : 1; /* [2] */
  400. __IO uint32_t idt3 : 1; /* [3] */
  401. __IO uint32_t idt4 : 1; /* [4] */
  402. __IO uint32_t idt5 : 1; /* [5] */
  403. __IO uint32_t idt6 : 1; /* [6] */
  404. __IO uint32_t idt7 : 1; /* [7] */
  405. __IO uint32_t idt8 : 1; /* [8] */
  406. __IO uint32_t idt9 : 1; /* [9] */
  407. __IO uint32_t idt10 : 1; /* [10] */
  408. __IO uint32_t idt11 : 1; /* [11] */
  409. __IO uint32_t idt12 : 1; /* [12] */
  410. __IO uint32_t idt13 : 1; /* [13] */
  411. __IO uint32_t idt14 : 1; /* [14] */
  412. __IO uint32_t idt15 : 1; /* [15] */
  413. __IO uint32_t reserved1 : 16;/* [31:16] */
  414. } idt_bit;
  415. };
  416. /**
  417. * @brief gpio odt register, offset:0x0C
  418. */
  419. union
  420. {
  421. __IO uint32_t odt;
  422. struct
  423. {
  424. __IO uint32_t odt0 : 1; /* [0] */
  425. __IO uint32_t odt1 : 1; /* [1] */
  426. __IO uint32_t odt2 : 1; /* [2] */
  427. __IO uint32_t odt3 : 1; /* [3] */
  428. __IO uint32_t odt4 : 1; /* [4] */
  429. __IO uint32_t odt5 : 1; /* [5] */
  430. __IO uint32_t odt6 : 1; /* [6] */
  431. __IO uint32_t odt7 : 1; /* [7] */
  432. __IO uint32_t odt8 : 1; /* [8] */
  433. __IO uint32_t odt9 : 1; /* [9] */
  434. __IO uint32_t odt10 : 1; /* [10] */
  435. __IO uint32_t odt11 : 1; /* [11] */
  436. __IO uint32_t odt12 : 1; /* [12] */
  437. __IO uint32_t odt13 : 1; /* [13] */
  438. __IO uint32_t odt14 : 1; /* [14] */
  439. __IO uint32_t odt15 : 1; /* [15] */
  440. __IO uint32_t reserved1 : 16;/* [31:16] */
  441. } odt_bit;
  442. };
  443. /**
  444. * @brief gpio scr register, offset:0x10
  445. */
  446. union
  447. {
  448. __IO uint32_t scr;
  449. struct
  450. {
  451. __IO uint32_t iosb0 : 1; /* [0] */
  452. __IO uint32_t iosb1 : 1; /* [1] */
  453. __IO uint32_t iosb2 : 1; /* [2] */
  454. __IO uint32_t iosb3 : 1; /* [3] */
  455. __IO uint32_t iosb4 : 1; /* [4] */
  456. __IO uint32_t iosb5 : 1; /* [5] */
  457. __IO uint32_t iosb6 : 1; /* [6] */
  458. __IO uint32_t iosb7 : 1; /* [7] */
  459. __IO uint32_t iosb8 : 1; /* [8] */
  460. __IO uint32_t iosb9 : 1; /* [9] */
  461. __IO uint32_t iosb10 : 1; /* [10] */
  462. __IO uint32_t iosb11 : 1; /* [11] */
  463. __IO uint32_t iosb12 : 1; /* [12] */
  464. __IO uint32_t iosb13 : 1; /* [13] */
  465. __IO uint32_t iosb14 : 1; /* [14] */
  466. __IO uint32_t iosb15 : 1; /* [15] */
  467. __IO uint32_t iocb0 : 1; /* [16] */
  468. __IO uint32_t iocb1 : 1; /* [17] */
  469. __IO uint32_t iocb2 : 1; /* [18] */
  470. __IO uint32_t iocb3 : 1; /* [19] */
  471. __IO uint32_t iocb4 : 1; /* [20] */
  472. __IO uint32_t iocb5 : 1; /* [21] */
  473. __IO uint32_t iocb6 : 1; /* [22] */
  474. __IO uint32_t iocb7 : 1; /* [23] */
  475. __IO uint32_t iocb8 : 1; /* [24] */
  476. __IO uint32_t iocb9 : 1; /* [25] */
  477. __IO uint32_t iocb10 : 1; /* [26] */
  478. __IO uint32_t iocb11 : 1; /* [27] */
  479. __IO uint32_t iocb12 : 1; /* [28] */
  480. __IO uint32_t iocb13 : 1; /* [29] */
  481. __IO uint32_t iocb14 : 1; /* [30] */
  482. __IO uint32_t iocb15 : 1; /* [31] */
  483. } scr_bit;
  484. };
  485. /**
  486. * @brief gpio clr register, offset:0x14
  487. */
  488. union
  489. {
  490. __IO uint32_t clr;
  491. struct
  492. {
  493. __IO uint32_t iocb0 : 1; /* [0] */
  494. __IO uint32_t iocb1 : 1; /* [1] */
  495. __IO uint32_t iocb2 : 1; /* [2] */
  496. __IO uint32_t iocb3 : 1; /* [3] */
  497. __IO uint32_t iocb4 : 1; /* [4] */
  498. __IO uint32_t iocb5 : 1; /* [5] */
  499. __IO uint32_t iocb6 : 1; /* [6] */
  500. __IO uint32_t iocb7 : 1; /* [7] */
  501. __IO uint32_t iocb8 : 1; /* [8] */
  502. __IO uint32_t iocb9 : 1; /* [9] */
  503. __IO uint32_t iocb10 : 1; /* [10] */
  504. __IO uint32_t iocb11 : 1; /* [11] */
  505. __IO uint32_t iocb12 : 1; /* [12] */
  506. __IO uint32_t iocb13 : 1; /* [13] */
  507. __IO uint32_t iocb14 : 1; /* [14] */
  508. __IO uint32_t iocb15 : 1; /* [15] */
  509. __IO uint32_t reserved1 : 16;/* [31:16] */
  510. } clr_bit;
  511. };
  512. /**
  513. * @brief gpio wpr register, offset:0x18
  514. */
  515. union
  516. {
  517. __IO uint32_t wpr;
  518. struct
  519. {
  520. __IO uint32_t wpen0 : 1; /* [0] */
  521. __IO uint32_t wpen1 : 1; /* [1] */
  522. __IO uint32_t wpen2 : 1; /* [2] */
  523. __IO uint32_t wpen3 : 1; /* [3] */
  524. __IO uint32_t wpen4 : 1; /* [4] */
  525. __IO uint32_t wpen5 : 1; /* [5] */
  526. __IO uint32_t wpen6 : 1; /* [6] */
  527. __IO uint32_t wpen7 : 1; /* [7] */
  528. __IO uint32_t wpen8 : 1; /* [8] */
  529. __IO uint32_t wpen9 : 1; /* [9] */
  530. __IO uint32_t wpen10 : 1; /* [10] */
  531. __IO uint32_t wpen11 : 1; /* [11] */
  532. __IO uint32_t wpen12 : 1; /* [12] */
  533. __IO uint32_t wpen13 : 1; /* [13] */
  534. __IO uint32_t wpen14 : 1; /* [14] */
  535. __IO uint32_t wpen15 : 1; /* [15] */
  536. __IO uint32_t wpseq : 1; /* [16] */
  537. __IO uint32_t reserved1 : 15;/* [31:17] */
  538. } wpr_bit;
  539. };
  540. /**
  541. * @brief gpio reserved1 register, offset:0x1C~0x38
  542. */
  543. __IO uint32_t reserved1[8];
  544. /**
  545. * @brief gpio hdrv register, offset:0x3C
  546. */
  547. union
  548. {
  549. __IO uint32_t hdrv;
  550. struct
  551. {
  552. __IO uint32_t hdrv0 : 1; /* [0] */
  553. __IO uint32_t hdrv1 : 1; /* [1] */
  554. __IO uint32_t hdrv2 : 1; /* [2] */
  555. __IO uint32_t hdrv3 : 1; /* [3] */
  556. __IO uint32_t hdrv4 : 1; /* [4] */
  557. __IO uint32_t hdrv5 : 1; /* [5] */
  558. __IO uint32_t hdrv6 : 1; /* [6] */
  559. __IO uint32_t hdrv7 : 1; /* [7] */
  560. __IO uint32_t hdrv8 : 1; /* [8] */
  561. __IO uint32_t hdrv9 : 1; /* [9] */
  562. __IO uint32_t hdrv10 : 1; /* [10] */
  563. __IO uint32_t hdrv11 : 1; /* [11] */
  564. __IO uint32_t hdrv12 : 1; /* [12] */
  565. __IO uint32_t hdrv13 : 1; /* [13] */
  566. __IO uint32_t hdrv14 : 1; /* [14] */
  567. __IO uint32_t hdrv15 : 1; /* [15] */
  568. __IO uint32_t reserved1 : 16;/* [31:16] */
  569. } hdrv_bit;
  570. };
  571. } gpio_type;
  572. /**
  573. * @brief type define iomux register all
  574. */
  575. typedef struct
  576. {
  577. /**
  578. * @brief mux event control register, offset:0x00
  579. */
  580. union
  581. {
  582. __IO uint32_t evtout;
  583. struct
  584. {
  585. __IO uint32_t selpin : 4; /* [3:0] */
  586. __IO uint32_t selport : 3; /* [6:4] */
  587. __IO uint32_t evoen : 1; /* [7] */
  588. __IO uint32_t reserved1 : 24;/* [31:8] */
  589. } evtout_bit;
  590. };
  591. /**
  592. * @brief iomux remap register, offset:0x04
  593. */
  594. union
  595. {
  596. __IO uint32_t remap;
  597. struct
  598. {
  599. __IO uint32_t spi1_mux_l : 1; /* [0] */
  600. __IO uint32_t i2c1_mux : 1; /* [1] */
  601. __IO uint32_t usart1_mux : 1; /* [2] */
  602. __IO uint32_t usart2_mux : 1; /* [3] */
  603. __IO uint32_t usart3_mux : 2; /* [5:4] */
  604. __IO uint32_t tmr1_mux : 2; /* [7:6] */
  605. __IO uint32_t tmr2_mux : 2; /* [9:8] */
  606. __IO uint32_t tmr3_mux : 2; /* [11:10] */
  607. __IO uint32_t tmr4_mux : 1; /* [12] */
  608. __IO uint32_t can_mux : 2; /* [14:13] */
  609. __IO uint32_t pd01_mux : 1; /* [15] */
  610. __IO uint32_t tmr5ch4_mux : 1; /* [16] */
  611. __IO uint32_t adc1_extrgpre_mux : 1; /* [17] */
  612. __IO uint32_t adc1_extrgord_mux : 1; /* [18] */
  613. __IO uint32_t adc2_extrgpre_mux : 1; /* [19] */
  614. __IO uint32_t adc2_extrgord_mux : 1; /* [20] */
  615. __IO uint32_t emac_mux : 1; /* [21] */
  616. __IO uint32_t can2_mux : 1; /* [22] */
  617. __IO uint32_t mii_rmii_sel_mux : 1; /* [23] */
  618. __IO uint32_t swjtag_mux : 3; /* [26:24] */
  619. __IO uint32_t reserved1 : 1; /* [27] */
  620. __IO uint32_t spi3_mux : 1; /* [28] */
  621. __IO uint32_t tim2itr1_mux : 1; /* [29] */
  622. __IO uint32_t ptp_pps_mux : 1; /* [30] */
  623. __IO uint32_t spi1_mux_h : 1; /* [31] */
  624. } remap_bit;
  625. };
  626. /**
  627. * @brief mux external interrupt configuration register 1, offset:0x08
  628. */
  629. union
  630. {
  631. __IO uint32_t exintc1;
  632. struct
  633. {
  634. __IO uint32_t exint0 : 4; /* [3:0] */
  635. __IO uint32_t exint1 : 4; /* [7:4] */
  636. __IO uint32_t exint2 : 4; /* [11:8] */
  637. __IO uint32_t exint3 : 4; /* [15:12] */
  638. __IO uint32_t reserved1 : 16;/* [31:16] */
  639. } exintc1_bit;
  640. };
  641. /**
  642. * @brief mux external interrupt configuration register 2, offset:0x0c
  643. */
  644. union
  645. {
  646. __IO uint32_t exintc2;
  647. struct
  648. {
  649. __IO uint32_t exint4 : 4; /* [3:0] */
  650. __IO uint32_t exint5 : 4; /* [7:4] */
  651. __IO uint32_t exint6 : 4; /* [11:8] */
  652. __IO uint32_t exint7 : 4; /* [15:12] */
  653. __IO uint32_t reserved1 : 16;/* [31:16] */
  654. } exintc2_bit;
  655. };
  656. /**
  657. * @brief mux external interrupt configuration register 3, offset:0x10
  658. */
  659. union
  660. {
  661. __IO uint32_t exintc3;
  662. struct
  663. {
  664. __IO uint32_t exint8 : 4; /* [3:0] */
  665. __IO uint32_t exint9 : 4; /* [7:4] */
  666. __IO uint32_t exint10 : 4; /* [11:8] */
  667. __IO uint32_t exint11 : 4; /* [15:12] */
  668. __IO uint32_t reserved1 : 16;/* [31:16] */
  669. } exintc3_bit;
  670. };
  671. /**
  672. * @brief mux external interrupt configuration register 4, offset:0x14
  673. */
  674. union
  675. {
  676. __IO uint32_t exintc4;
  677. struct
  678. {
  679. __IO uint32_t exint12 : 4; /* [3:0] */
  680. __IO uint32_t exint13 : 4; /* [7:4] */
  681. __IO uint32_t exint14 : 4; /* [11:8] */
  682. __IO uint32_t exint15 : 4; /* [15:12] */
  683. __IO uint32_t reserved1 : 16;/* [31:16] */
  684. } exintc4_bit;
  685. };
  686. /**
  687. * @brief iomux reserved1 register, offset:0x18
  688. */
  689. __IO uint32_t reserved1;
  690. /**
  691. * @brief iomux remap register 2, offset:0x1C
  692. */
  693. union
  694. {
  695. __IO uint32_t remap2;
  696. struct
  697. {
  698. __IO uint32_t tmr15_mux : 1; /* [0] */
  699. __IO uint32_t reserved1 : 4; /* [4:1] */
  700. __IO uint32_t tmr9_mux : 1; /* [5] */
  701. __IO uint32_t tmr10_mux : 1; /* [6] */
  702. __IO uint32_t tmr11_mux : 1; /* [7] */
  703. __IO uint32_t tmr13_mux : 1; /* [8] */
  704. __IO uint32_t tmr14_mux : 1; /* [9] */
  705. __IO uint32_t xmc_nadv_mux : 1; /* [10] */
  706. __IO uint32_t reserved2 : 6; /* [16:11] */
  707. __IO uint32_t spi4_mux : 1; /* [17] */
  708. __IO uint32_t i2c3_mux : 1; /* [18] */
  709. __IO uint32_t sdio2_mux : 2; /* [20:19] */
  710. __IO uint32_t ext_spim_en_mux : 1; /* [21] */
  711. __IO uint32_t reserved3 : 10;/* [31:22] */
  712. } remap2_bit;
  713. };
  714. /**
  715. * @brief iomux remap register 3, offset:0x20
  716. */
  717. union
  718. {
  719. __IO uint32_t remap3;
  720. struct
  721. {
  722. __IO uint32_t tmr9_gmux : 4; /* [3:0] */
  723. __IO uint32_t reserved1 : 28;/* [31:4] */
  724. } remap3_bit;
  725. };
  726. /**
  727. * @brief iomux remap register 4, offset:0x24
  728. */
  729. union
  730. {
  731. __IO uint32_t remap4;
  732. struct
  733. {
  734. __IO uint32_t tmr1_gmux : 4; /* [3:0] */
  735. __IO uint32_t tmr2_gmux : 2; /* [5:4] */
  736. __IO uint32_t tmr2itr1_gmux : 2; /* [7:6] */
  737. __IO uint32_t tmr3_gmux : 4; /* [11:8] */
  738. __IO uint32_t tmr4_gmux : 4; /* [15:12] */
  739. __IO uint32_t reserved1 : 3; /* [18:16] */
  740. __IO uint32_t tmr5ch4_gmux : 1; /* [19] */
  741. __IO uint32_t reserved2 : 12; /* [31:20] */
  742. } remap4_bit;
  743. };
  744. /**
  745. * @brief iomux remap register 5, offset:0x28
  746. */
  747. union
  748. {
  749. __IO uint32_t remap5;
  750. struct
  751. {
  752. __IO uint32_t usart5_gmux : 4; /* [3:0] */
  753. __IO uint32_t i2c1_gmux : 4; /* [7:4] */
  754. __IO uint32_t reserved1 : 4; /* [11:8] */
  755. __IO uint32_t i2c3_gmux : 4; /* [15:12] */
  756. __IO uint32_t spi1_gmux : 4; /* [19:16] */
  757. __IO uint32_t spi2_gmux : 4; /* [23:20] */
  758. __IO uint32_t spi3_gmux : 4; /* [27:24] */
  759. __IO uint32_t spi4_gmux : 4; /* [31:28] */
  760. } remap5_bit;
  761. };
  762. /**
  763. * @brief iomux remap register 6, offset:0x2C
  764. */
  765. union
  766. {
  767. __IO uint32_t remap6;
  768. struct
  769. {
  770. __IO uint32_t can1_gmux : 4; /* [3:0] */
  771. __IO uint32_t can2_gmux : 4; /* [7:4] */
  772. __IO uint32_t reserved1 : 4; /* [11:8] */
  773. __IO uint32_t sdio2_gmux : 4; /* [15:12] */
  774. __IO uint32_t usart1_gmux : 4; /* [19:16] */
  775. __IO uint32_t usart2_gmux : 4; /* [23:20] */
  776. __IO uint32_t usart3_gmux : 4; /* [27:24] */
  777. __IO uint32_t uart4_gmux : 4; /* [31:28] */
  778. } remap6_bit;
  779. };
  780. /**
  781. * @brief iomux remap register 7, offset:0x30
  782. */
  783. union
  784. {
  785. __IO uint32_t remap7;
  786. struct
  787. {
  788. __IO uint32_t ext_spim_gmux : 3; /* [2:0] */
  789. __IO uint32_t ext_spim_gen : 1; /* [3] */
  790. __IO uint32_t adc1_etp_gmux : 1; /* [4] */
  791. __IO uint32_t adc1_eto_gmux : 1; /* [5] */
  792. __IO uint32_t reserved1 : 2; /* [7:6] */
  793. __IO uint32_t adc2_etp_gmux : 1; /* [8] */
  794. __IO uint32_t adc2_eto_gmux : 1; /* [9] */
  795. __IO uint32_t reserved2 : 6; /* [15:10] */
  796. __IO uint32_t swjtag_gmux : 3; /* [18:16] */
  797. __IO uint32_t reserved3 : 1; /* [19] */
  798. __IO uint32_t pd01_gmux : 1; /* [20] */
  799. __IO uint32_t reserved4 : 3; /* [23:21] */
  800. __IO uint32_t xmc_gmux : 3; /* [26:24] */
  801. __IO uint32_t xmc_nadv_gmux : 1; /* [27] */
  802. __IO uint32_t reserved5 : 4; /* [31:28] */
  803. } remap7_bit;
  804. };
  805. /**
  806. * @brief iomux remap register 8, offset:0x34
  807. */
  808. union
  809. {
  810. __IO uint32_t remap8;
  811. struct
  812. {
  813. __IO uint32_t reserved1 : 16; /* [15:0] */
  814. __IO uint32_t emac_gmux : 2; /* [17:16] */
  815. __IO uint32_t mii_rmii_sel_gmux : 1; /* [18] */
  816. __IO uint32_t ptp_pps_gmux : 1; /* [19] */
  817. __IO uint32_t usart6_gmux : 4; /* [23:20] */
  818. __IO uint32_t uart7_gmux : 4; /* [27:24] */
  819. __IO uint32_t uart8_gmux : 4; /* [31:28] */
  820. } remap8_bit;
  821. };
  822. } iomux_type;
  823. /**
  824. * @}
  825. */
  826. #define GPIOA ((gpio_type *) GPIOA_BASE)
  827. #define GPIOB ((gpio_type *) GPIOB_BASE)
  828. #define GPIOC ((gpio_type *) GPIOC_BASE)
  829. #define GPIOD ((gpio_type *) GPIOD_BASE)
  830. #define GPIOE ((gpio_type *) GPIOE_BASE)
  831. #define IOMUX ((iomux_type *) IOMUX_BASE)
  832. /** @defgroup GPIO_exported_functions
  833. * @{
  834. */
  835. void gpio_reset(gpio_type *gpio_x);
  836. void gpio_iomux_reset(void);
  837. void gpio_init(gpio_type *gpio_x, gpio_init_type *gpio_init_struct);
  838. void gpio_default_para_init(gpio_init_type *gpio_init_struct);
  839. flag_status gpio_input_data_bit_read(gpio_type *gpio_x, uint16_t pins);
  840. uint16_t gpio_input_data_read(gpio_type *gpio_x);
  841. flag_status gpio_output_data_bit_read(gpio_type *gpio_x, uint16_t pins);
  842. uint16_t gpio_output_data_read(gpio_type *gpio_x);
  843. void gpio_bits_set(gpio_type *gpio_x, uint16_t pins);
  844. void gpio_bits_reset(gpio_type *gpio_x, uint16_t pins);
  845. void gpio_bits_write(gpio_type *gpio_x, uint16_t pins, confirm_state bit_state);
  846. void gpio_port_write(gpio_type *gpio_x, uint16_t port_value);
  847. void gpio_pin_wp_config(gpio_type *gpio_x, uint16_t pins);
  848. void gpio_pins_huge_driven_config(gpio_type *gpio_x, uint16_t pins, confirm_state new_state);
  849. void gpio_event_output_config(gpio_port_source_type gpio_port_source, gpio_pins_source_type gpio_pin_source);
  850. void gpio_event_output_enable(confirm_state new_state);
  851. void gpio_pin_remap_config(uint32_t gpio_remap, confirm_state new_state);
  852. void gpio_exint_line_config(gpio_port_source_type gpio_port_source, gpio_pins_source_type gpio_pin_source);
  853. /**
  854. * @}
  855. */
  856. /**
  857. * @}
  858. */
  859. /**
  860. * @}
  861. */
  862. #ifdef __cplusplus
  863. }
  864. #endif
  865. #endif