123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537 |
- #ifndef GD32F30X_GPIO_H
- #define GD32F30X_GPIO_H
- #include "gd32f30x.h"
- #define GPIOA (GPIO_BASE + 0x00000000U)
- #define GPIOB (GPIO_BASE + 0x00000400U)
- #define GPIOC (GPIO_BASE + 0x00000800U)
- #define GPIOD (GPIO_BASE + 0x00000C00U)
- #define GPIOE (GPIO_BASE + 0x00001000U)
- #define GPIOF (GPIO_BASE + 0x00001400U)
- #define GPIOG (GPIO_BASE + 0x00001800U)
- #define AFIO AFIO_BASE
- #define GPIO_CTL0(gpiox) REG32((gpiox) + 0x00U)
- #define GPIO_CTL1(gpiox) REG32((gpiox) + 0x04U)
- #define GPIO_ISTAT(gpiox) REG32((gpiox) + 0x08U)
- #define GPIO_OCTL(gpiox) REG32((gpiox) + 0x0CU)
- #define GPIO_BOP(gpiox) REG32((gpiox) + 0x10U)
- #define GPIO_BC(gpiox) REG32((gpiox) + 0x14U)
- #define GPIO_LOCK(gpiox) REG32((gpiox) + 0x18U)
- #define GPIOx_SPD(gpiox) REG32((gpiox) + 0x3CU)
- #define AFIO_EC REG32(AFIO + 0x00U)
- #define AFIO_PCF0 REG32(AFIO + 0x04U)
- #define AFIO_EXTISS0 REG32(AFIO + 0x08U)
- #define AFIO_EXTISS1 REG32(AFIO + 0x0CU)
- #define AFIO_EXTISS2 REG32(AFIO + 0x10U)
- #define AFIO_EXTISS3 REG32(AFIO + 0x14U)
- #define AFIO_PCF1 REG32(AFIO + 0x1CU)
- #define AFIO_CPSCTL REG32(AFIO + 0x20U)
- #define GPIO_CTL0_MD0 BITS(0,1)
- #define GPIO_CTL0_CTL0 BITS(2,3)
- #define GPIO_CTL0_MD1 BITS(4,5)
- #define GPIO_CTL0_CTL1 BITS(6,7)
- #define GPIO_CTL0_MD2 BITS(8,9)
- #define GPIO_CTL0_CTL2 BITS(10,11)
- #define GPIO_CTL0_MD3 BITS(12,13)
- #define GPIO_CTL0_CTL3 BITS(14,15)
- #define GPIO_CTL0_MD4 BITS(16,17)
- #define GPIO_CTL0_CTL4 BITS(18,19)
- #define GPIO_CTL0_MD5 BITS(20,21)
- #define GPIO_CTL0_CTL5 BITS(22,23)
- #define GPIO_CTL0_MD6 BITS(24,25)
- #define GPIO_CTL0_CTL6 BITS(26,27)
- #define GPIO_CTL0_MD7 BITS(28,29)
- #define GPIO_CTL0_CTL7 BITS(30,31)
- #define GPIO_CTL1_MD8 BITS(0,1)
- #define GPIO_CTL1_CTL8 BITS(2,3)
- #define GPIO_CTL1_MD9 BITS(4,5)
- #define GPIO_CTL1_CTL9 BITS(6,7)
- #define GPIO_CTL1_MD10 BITS(8,9)
- #define GPIO_CTL1_CTL10 BITS(10,11)
- #define GPIO_CTL1_MD11 BITS(12,13)
- #define GPIO_CTL1_CTL11 BITS(14,15)
- #define GPIO_CTL1_MD12 BITS(16,17)
- #define GPIO_CTL1_CTL12 BITS(18,19)
- #define GPIO_CTL1_MD13 BITS(20,21)
- #define GPIO_CTL1_CTL13 BITS(22,23)
- #define GPIO_CTL1_MD14 BITS(24,25)
- #define GPIO_CTL1_CTL14 BITS(26,27)
- #define GPIO_CTL1_MD15 BITS(28,29)
- #define GPIO_CTL1_CTL15 BITS(30,31)
- #define GPIO_ISTAT_ISTAT0 BIT(0)
- #define GPIO_ISTAT_ISTAT1 BIT(1)
- #define GPIO_ISTAT_ISTAT2 BIT(2)
- #define GPIO_ISTAT_ISTAT3 BIT(3)
- #define GPIO_ISTAT_ISTAT4 BIT(4)
- #define GPIO_ISTAT_ISTAT5 BIT(5)
- #define GPIO_ISTAT_ISTAT6 BIT(6)
- #define GPIO_ISTAT_ISTAT7 BIT(7)
- #define GPIO_ISTAT_ISTAT8 BIT(8)
- #define GPIO_ISTAT_ISTAT9 BIT(9)
- #define GPIO_ISTAT_ISTAT10 BIT(10)
- #define GPIO_ISTAT_ISTAT11 BIT(11)
- #define GPIO_ISTAT_ISTAT12 BIT(12)
- #define GPIO_ISTAT_ISTAT13 BIT(13)
- #define GPIO_ISTAT_ISTAT14 BIT(14)
- #define GPIO_ISTAT_ISTAT15 BIT(15)
- #define GPIO_OCTL_OCTL0 BIT(0)
- #define GPIO_OCTL_OCTL1 BIT(1)
- #define GPIO_OCTL_OCTL2 BIT(2)
- #define GPIO_OCTL_OCTL3 BIT(3)
- #define GPIO_OCTL_OCTL4 BIT(4)
- #define GPIO_OCTL_OCTL5 BIT(5)
- #define GPIO_OCTL_OCTL6 BIT(6)
- #define GPIO_OCTL_OCTL7 BIT(7)
- #define GPIO_OCTL_OCTL8 BIT(8)
- #define GPIO_OCTL_OCTL9 BIT(9)
- #define GPIO_OCTL_OCTL10 BIT(10)
- #define GPIO_OCTL_OCTL11 BIT(11)
- #define GPIO_OCTL_OCTL12 BIT(12)
- #define GPIO_OCTL_OCTL13 BIT(13)
- #define GPIO_OCTL_OCTL14 BIT(14)
- #define GPIO_OCTL_OCTL15 BIT(15)
- #define GPIO_BOP_BOP0 BIT(0)
- #define GPIO_BOP_BOP1 BIT(1)
- #define GPIO_BOP_BOP2 BIT(2)
- #define GPIO_BOP_BOP3 BIT(3)
- #define GPIO_BOP_BOP4 BIT(4)
- #define GPIO_BOP_BOP5 BIT(5)
- #define GPIO_BOP_BOP6 BIT(6)
- #define GPIO_BOP_BOP7 BIT(7)
- #define GPIO_BOP_BOP8 BIT(8)
- #define GPIO_BOP_BOP9 BIT(9)
- #define GPIO_BOP_BOP10 BIT(10)
- #define GPIO_BOP_BOP11 BIT(11)
- #define GPIO_BOP_BOP12 BIT(12)
- #define GPIO_BOP_BOP13 BIT(13)
- #define GPIO_BOP_BOP14 BIT(14)
- #define GPIO_BOP_BOP15 BIT(15)
- #define GPIO_BOP_CR0 BIT(16)
- #define GPIO_BOP_CR1 BIT(17)
- #define GPIO_BOP_CR2 BIT(18)
- #define GPIO_BOP_CR3 BIT(19)
- #define GPIO_BOP_CR4 BIT(20)
- #define GPIO_BOP_CR5 BIT(21)
- #define GPIO_BOP_CR6 BIT(22)
- #define GPIO_BOP_CR7 BIT(23)
- #define GPIO_BOP_CR8 BIT(24)
- #define GPIO_BOP_CR9 BIT(25)
- #define GPIO_BOP_CR10 BIT(26)
- #define GPIO_BOP_CR11 BIT(27)
- #define GPIO_BOP_CR12 BIT(28)
- #define GPIO_BOP_CR13 BIT(29)
- #define GPIO_BOP_CR14 BIT(30)
- #define GPIO_BOP_CR15 BIT(31)
- #define GPIO_BC_CR0 BIT(0)
- #define GPIO_BC_CR1 BIT(1)
- #define GPIO_BC_CR2 BIT(2)
- #define GPIO_BC_CR3 BIT(3)
- #define GPIO_BC_CR4 BIT(4)
- #define GPIO_BC_CR5 BIT(5)
- #define GPIO_BC_CR6 BIT(6)
- #define GPIO_BC_CR7 BIT(7)
- #define GPIO_BC_CR8 BIT(8)
- #define GPIO_BC_CR9 BIT(9)
- #define GPIO_BC_CR10 BIT(10)
- #define GPIO_BC_CR11 BIT(11)
- #define GPIO_BC_CR12 BIT(12)
- #define GPIO_BC_CR13 BIT(13)
- #define GPIO_BC_CR14 BIT(14)
- #define GPIO_BC_CR15 BIT(15)
- #define GPIO_LOCK_LK0 BIT(0)
- #define GPIO_LOCK_LK1 BIT(1)
- #define GPIO_LOCK_LK2 BIT(2)
- #define GPIO_LOCK_LK3 BIT(3)
- #define GPIO_LOCK_LK4 BIT(4)
- #define GPIO_LOCK_LK5 BIT(5)
- #define GPIO_LOCK_LK6 BIT(6)
- #define GPIO_LOCK_LK7 BIT(7)
- #define GPIO_LOCK_LK8 BIT(8)
- #define GPIO_LOCK_LK9 BIT(9)
- #define GPIO_LOCK_LK10 BIT(10)
- #define GPIO_LOCK_LK11 BIT(11)
- #define GPIO_LOCK_LK12 BIT(12)
- #define GPIO_LOCK_LK13 BIT(13)
- #define GPIO_LOCK_LK14 BIT(14)
- #define GPIO_LOCK_LK15 BIT(15)
- #define GPIO_LOCK_LKK BIT(16)
- #define GPIO_SPD_SPD0 BIT(0)
- #define GPIO_SPD_SPD1 BIT(1)
- #define GPIO_SPD_SPD2 BIT(2)
- #define GPIO_SPD_SPD3 BIT(3)
- #define GPIO_SPD_SPD4 BIT(4)
- #define GPIO_SPD_SPD5 BIT(5)
- #define GPIO_SPD_SPD6 BIT(6)
- #define GPIO_SPD_SPD7 BIT(7)
- #define GPIO_SPD_SPD8 BIT(8)
- #define GPIO_SPD_SPD9 BIT(9)
- #define GPIO_SPD_SPD10 BIT(10)
- #define GPIO_SPD_SPD11 BIT(11)
- #define GPIO_SPD_SPD12 BIT(12)
- #define GPIO_SPD_SPD13 BIT(13)
- #define GPIO_SPD_SPD14 BIT(14)
- #define GPIO_SPD_SPD15 BIT(15)
- #define AFIO_EC_PIN BITS(0,3)
- #define AFIO_EC_PORT BITS(4,6)
- #define AFIO_EC_EOE BIT(7)
- #ifdef GD32F30X_CL
- #define AFIO_PCF0_SPI0_REMAP BIT(0)
- #define AFIO_PCF0_I2C0_REMAP BIT(1)
- #define AFIO_PCF0_USART0_REMAP BIT(2)
- #define AFIO_PCF0_USART1_REMAP BIT(3)
- #define AFIO_PCF0_USART2_REMAP BITS(4,5)
- #define AFIO_PCF0_TIMER0_REMAP BITS(6,7)
- #define AFIO_PCF0_TIMER1_REMAP BITS(8,9)
- #define AFIO_PCF0_TIMER2_REMAP BITS(10,11)
- #define AFIO_PCF0_TIMER3_REMAP BIT(12)
- #define AFIO_PCF0_CAN0_REMAP BITS(13,14)
- #define AFIO_PCF0_PD01_REMAP BIT(15)
- #define AFIO_PCF0_TIMER4CH3_IREMAP BIT(16)
- #define AFIO_PCF0_ENET_REMAP BIT(21)
- #define AFIO_PCF0_CAN1_REMAP BIT(22)
- #define AFIO_PCF0_ENET_PHY_SEL BIT(23)
- #define AFIO_PCF0_SWJ_CFG BITS(24,26)
- #define AFIO_PCF0_SPI2_REMAP BIT(28)
- #define AFIO_PCF0_TIMER1ITR0_REMAP BIT(29)
- #define AFIO_PCF0_TIMER1ITI1_REMAP BIT(29)
- #define AFIO_PCF0_PTP_PPS_REMAP BIT(30)
- #else
- #define AFIO_PCF0_SPI0_REMAP BIT(0)
- #define AFIO_PCF0_I2C0_REMAP BIT(1)
- #define AFIO_PCF0_USART0_REMAP BIT(2)
- #define AFIO_PCF0_USART1_REMAP BIT(3)
- #define AFIO_PCF0_USART2_REMAP BITS(4,5)
- #define AFIO_PCF0_TIMER0_REMAP BITS(6,7)
- #define AFIO_PCF0_TIMER1_REMAP BITS(8,9)
- #define AFIO_PCF0_TIMER2_REMAP BITS(10,11)
- #define AFIO_PCF0_TIMER3_REMAP BIT(12)
- #define AFIO_PCF0_CAN_REMAP BITS(13,14)
- #define AFIO_PCF0_PD01_REMAP BIT(15)
- #define AFIO_PCF0_TIMER4CH3_IREMAP BIT(16)
- #define AFIO_PCF0_ADC0_ETRGINS_REMAP BIT(17)
- #define AFIO_PCF0_ADC0_ETRGREG_REMAP BIT(18)
- #define AFIO_PCF0_ADC1_ETRGINS_REMAP BIT(19)
- #define AFIO_PCF0_ADC1_ETRGREG_REMAP BIT(20)
- #define AFIO_PCF0_SWJ_CFG BITS(24,26)
- #define AFIO_PCF0_SPI2_REMAP BIT(28)
- #endif
- #define AFIO_EXTI0_SS BITS(0,3)
- #define AFIO_EXTI1_SS BITS(4,7)
- #define AFIO_EXTI2_SS BITS(8,11)
- #define AFIO_EXTI3_SS BITS(12,15)
- #define AFIO_EXTI4_SS BITS(0,3)
- #define AFIO_EXTI5_SS BITS(4,7)
- #define AFIO_EXTI6_SS BITS(8,11)
- #define AFIO_EXTI7_SS BITS(12,15)
- #define AFIO_EXTI8_SS BITS(0,3)
- #define AFIO_EXTI9_SS BITS(4,7)
- #define AFIO_EXTI10_SS BITS(8,11)
- #define AFIO_EXTI11_SS BITS(12,15)
- #define AFIO_EXTI12_SS BITS(0,3)
- #define AFIO_EXTI13_SS BITS(4,7)
- #define AFIO_EXTI14_SS BITS(8,11)
- #define AFIO_EXTI15_SS BITS(12,15)
- #define AFIO_PCF1_TIMER8_REMAP BIT(5)
- #define AFIO_PCF1_TIMER9_REMAP BIT(6)
- #define AFIO_PCF1_TIMER10_REMAP BIT(7)
- #define AFIO_PCF1_TIMER12_REMAP BIT(8)
- #define AFIO_PCF1_TIMER13_REMAP BIT(9)
- #define AFIO_PCF1_EXMC_NADV BIT(10)
- #define AFIO_PCF1_CTC_REMAP BITS(11,12)
- #define AFIO_CPSCTL_CPS_EN BIT(0)
- #define AFIO_CPSCTL_CPS_RDY BIT(8)
- typedef FlagStatus bit_status;
- #define GPIO_MODE_SET(n, mode) ((uint32_t)((uint32_t)(mode) << (4U * (n))))
- #define GPIO_MODE_MASK(n) (0xFU << (4U * (n)))
- #define GPIO_MODE_AIN ((uint8_t)0x00U)
- #define GPIO_MODE_IN_FLOATING ((uint8_t)0x04U)
- #define GPIO_MODE_IPD ((uint8_t)0x28U)
- #define GPIO_MODE_IPU ((uint8_t)0x48U)
- #define GPIO_MODE_OUT_OD ((uint8_t)0x14U)
- #define GPIO_MODE_OUT_PP ((uint8_t)0x10U)
- #define GPIO_MODE_AF_OD ((uint8_t)0x1CU)
- #define GPIO_MODE_AF_PP ((uint8_t)0x18U)
- #define GPIO_OSPEED_10MHZ ((uint8_t)0x01U)
- #define GPIO_OSPEED_2MHZ ((uint8_t)0x02U)
- #define GPIO_OSPEED_50MHZ ((uint8_t)0x03U)
- #define GPIO_OSPEED_MAX ((uint8_t)0x04U)
- #define GPIO_EVENT_PORT_GPIOA ((uint8_t)0x00U)
- #define GPIO_EVENT_PORT_GPIOB ((uint8_t)0x01U)
- #define GPIO_EVENT_PORT_GPIOC ((uint8_t)0x02U)
- #define GPIO_EVENT_PORT_GPIOD ((uint8_t)0x03U)
- #define GPIO_EVENT_PORT_GPIOE ((uint8_t)0x04U)
- #define GPIO_PORT_SOURCE_GPIOA ((uint8_t)0x00U)
- #define GPIO_PORT_SOURCE_GPIOB ((uint8_t)0x01U)
- #define GPIO_PORT_SOURCE_GPIOC ((uint8_t)0x02U)
- #define GPIO_PORT_SOURCE_GPIOD ((uint8_t)0x03U)
- #define GPIO_PORT_SOURCE_GPIOE ((uint8_t)0x04U)
- #define GPIO_PORT_SOURCE_GPIOF ((uint8_t)0x05U)
- #define GPIO_PORT_SOURCE_GPIOG ((uint8_t)0x06U)
- #define GPIO_EVENT_PIN_0 ((uint8_t)0x00U)
- #define GPIO_EVENT_PIN_1 ((uint8_t)0x01U)
- #define GPIO_EVENT_PIN_2 ((uint8_t)0x02U)
- #define GPIO_EVENT_PIN_3 ((uint8_t)0x03U)
- #define GPIO_EVENT_PIN_4 ((uint8_t)0x04U)
- #define GPIO_EVENT_PIN_5 ((uint8_t)0x05U)
- #define GPIO_EVENT_PIN_6 ((uint8_t)0x06U)
- #define GPIO_EVENT_PIN_7 ((uint8_t)0x07U)
- #define GPIO_EVENT_PIN_8 ((uint8_t)0x08U)
- #define GPIO_EVENT_PIN_9 ((uint8_t)0x09U)
- #define GPIO_EVENT_PIN_10 ((uint8_t)0x0AU)
- #define GPIO_EVENT_PIN_11 ((uint8_t)0x0BU)
- #define GPIO_EVENT_PIN_12 ((uint8_t)0x0CU)
- #define GPIO_EVENT_PIN_13 ((uint8_t)0x0DU)
- #define GPIO_EVENT_PIN_14 ((uint8_t)0x0EU)
- #define GPIO_EVENT_PIN_15 ((uint8_t)0x0FU)
- #define GPIO_PIN_SOURCE_0 ((uint8_t)0x00U)
- #define GPIO_PIN_SOURCE_1 ((uint8_t)0x01U)
- #define GPIO_PIN_SOURCE_2 ((uint8_t)0x02U)
- #define GPIO_PIN_SOURCE_3 ((uint8_t)0x03U)
- #define GPIO_PIN_SOURCE_4 ((uint8_t)0x04U)
- #define GPIO_PIN_SOURCE_5 ((uint8_t)0x05U)
- #define GPIO_PIN_SOURCE_6 ((uint8_t)0x06U)
- #define GPIO_PIN_SOURCE_7 ((uint8_t)0x07U)
- #define GPIO_PIN_SOURCE_8 ((uint8_t)0x08U)
- #define GPIO_PIN_SOURCE_9 ((uint8_t)0x09U)
- #define GPIO_PIN_SOURCE_10 ((uint8_t)0x0AU)
- #define GPIO_PIN_SOURCE_11 ((uint8_t)0x0BU)
- #define GPIO_PIN_SOURCE_12 ((uint8_t)0x0CU)
- #define GPIO_PIN_SOURCE_13 ((uint8_t)0x0DU)
- #define GPIO_PIN_SOURCE_14 ((uint8_t)0x0EU)
- #define GPIO_PIN_SOURCE_15 ((uint8_t)0x0FU)
- #define GPIO_PIN_0 BIT(0)
- #define GPIO_PIN_1 BIT(1)
- #define GPIO_PIN_2 BIT(2)
- #define GPIO_PIN_3 BIT(3)
- #define GPIO_PIN_4 BIT(4)
- #define GPIO_PIN_5 BIT(5)
- #define GPIO_PIN_6 BIT(6)
- #define GPIO_PIN_7 BIT(7)
- #define GPIO_PIN_8 BIT(8)
- #define GPIO_PIN_9 BIT(9)
- #define GPIO_PIN_10 BIT(10)
- #define GPIO_PIN_11 BIT(11)
- #define GPIO_PIN_12 BIT(12)
- #define GPIO_PIN_13 BIT(13)
- #define GPIO_PIN_14 BIT(14)
- #define GPIO_PIN_15 BIT(15)
- #define GPIO_PIN_ALL BITS(0,15)
- #define PCF0_USART2_REMAP(regval) (BITS(4,5) & ((uint32_t)(regval) << 4))
- #define PCF0_TIMER0_REMAP(regval) (BITS(6,7) & ((uint32_t)(regval) << 6))
- #define PCF0_TIMER1_REMAP(regval) (BITS(8,9) & ((uint32_t)(regval) << 8))
- #define PCF0_TIMER2_REMAP(regval) (BITS(10,11) & ((uint32_t)(regval) << 10))
- #define PCF0_CAN_REMAP(regval) (BITS(13,14) & ((uint32_t)(regval) << 13))
- #define PCF0_SWJ_CFG(regval) (BITS(24,26) & ((uint32_t)(regval) << 24))
- #define PCF1_CTC_REMAP(regval) (BITS(11,12) & ((uint32_t)(regval) << 11))
- #define GPIO_SPI0_REMAP AFIO_PCF0_SPI0_REMAP
- #define GPIO_I2C0_REMAP AFIO_PCF0_I2C0_REMAP
- #define GPIO_USART0_REMAP AFIO_PCF0_USART0_REMAP
- #define GPIO_USART1_REMAP AFIO_PCF0_USART1_REMAP
- #define GPIO_USART2_PARTIAL_REMAP ((uint32_t)0x00140000U | PCF0_USART2_REMAP(1))
- #define GPIO_USART2_FULL_REMAP ((uint32_t)0x00140000U | PCF0_USART2_REMAP(3))
- #define GPIO_TIMER0_PARTIAL_REMAP ((uint32_t)0x00160000U | PCF0_TIMER0_REMAP(1))
- #define GPIO_TIMER0_FULL_REMAP ((uint32_t)0x00160000U | PCF0_TIMER0_REMAP(3))
- #define GPIO_TIMER1_PARTIAL_REMAP0 ((uint32_t)0x00180000U | PCF0_TIMER1_REMAP(1))
- #define GPIO_TIMER1_PARTIAL_REMAP1 ((uint32_t)0x00180000U | PCF0_TIMER1_REMAP(2))
- #define GPIO_TIMER1_FULL_REMAP ((uint32_t)0x00180000U | PCF0_TIMER1_REMAP(3))
- #define GPIO_TIMER2_PARTIAL_REMAP ((uint32_t)0x001A0000U | PCF0_TIMER2_REMAP(2))
- #define GPIO_TIMER2_FULL_REMAP ((uint32_t)0x001A0000U | PCF0_TIMER2_REMAP(3))
- #define GPIO_TIMER3_REMAP AFIO_PCF0_TIMER3_REMAP
- #define GPIO_PD01_REMAP AFIO_PCF0_PD01_REMAP
- #define GPIO_TIMER4CH3_IREMAP ((uint32_t)0x00200000U | (AFIO_PCF0_TIMER4CH3_IREMAP >> 16))
- #if (defined(GD32F30X_HD) || defined(GD32F30X_XD))
- #define GPIO_CAN_PARTIAL_REMAP ((uint32_t)0x001D0000U | PCF0_CAN_REMAP(2))
- #define GPIO_CAN_FULL_REMAP ((uint32_t)0x001D0000U | PCF0_CAN_REMAP(3))
- #endif
- #if (defined(GD32F30X_HD) || defined(GD32F30X_XD))
- #define GPIO_ADC0_ETRGINS_REMAP ((uint32_t)0x00200000U | (AFIO_PCF0_ADC0_ETRGINS_REMAP >> 16))
- #define GPIO_ADC0_ETRGREG_REMAP ((uint32_t)0x00200000U | (AFIO_PCF0_ADC0_ETRGREG_REMAP >> 16))
- #define GPIO_ADC1_ETRGINS_REMAP ((uint32_t)0x00200000U | (AFIO_PCF0_ADC1_ETRGINS_REMAP >> 16))
- #define GPIO_ADC1_ETRGREG_REMAP ((uint32_t)0x00200000U | (AFIO_PCF0_ADC1_ETRGREG_REMAP >> 16))
- #endif
- #define GPIO_SWJ_NONJTRST_REMAP ((uint32_t)0x00300000U | (PCF0_SWJ_CFG(1) >> 16))
- #define GPIO_SWJ_SWDPENABLE_REMAP ((uint32_t)0x00300000U | (PCF0_SWJ_CFG(2) >> 16))
- #define GPIO_SWJ_DISABLE_REMAP ((uint32_t)0x00300000U | (PCF0_SWJ_CFG(4) >> 16))
- #define GPIO_SPI2_REMAP ((uint32_t)0x00200000U | (AFIO_PCF0_SPI2_REMAP >> 16))
- #ifdef GD32F30X_CL
- #define GPIO_CAN0_PARTIAL_REMAP ((uint32_t)0x001D0000U | PCF0_CAN_REMAP(2))
- #define GPIO_CAN0_FULL_REMAP ((uint32_t)0x001D0000U | PCF0_CAN_REMAP(3))
- #define GPIO_ENET_REMAP ((uint32_t)0x00200000U | (AFIO_PCF0_ENET_REMAP >> 16))
- #define GPIO_CAN1_REMAP ((uint32_t)0x00200000U | (AFIO_PCF0_CAN1_REMAP >> 16))
- #define GPIO_TIMER1ITR0_REMAP ((uint32_t)0x00200000U | (AFIO_PCF0_TIMER1ITR0_REMAP >> 16))
- #define GPIO_PTP_PPS_REMAP ((uint32_t)0x00200000U | (AFIO_PCF0_PTP_PPS_REMAP >> 16))
- #endif
- #define GPIO_TIMER8_REMAP ((uint32_t)0x80000000U | AFIO_PCF1_TIMER8_REMAP)
- #define GPIO_TIMER9_REMAP ((uint32_t)0x80000000U | AFIO_PCF1_TIMER9_REMAP)
- #define GPIO_TIMER10_REMAP ((uint32_t)0x80000000U | AFIO_PCF1_TIMER10_REMAP)
- #define GPIO_TIMER12_REMAP ((uint32_t)0x80000000U | AFIO_PCF1_TIMER12_REMAP)
- #define GPIO_TIMER13_REMAP ((uint32_t)0x80000000U | AFIO_PCF1_TIMER13_REMAP)
- #define GPIO_EXMC_NADV_REMAP ((uint32_t)0x80000000U | AFIO_PCF1_EXMC_NADV)
- #define GPIO_CTC_REMAP0 ((uint32_t)0x801B0000U | PCF1_CTC_REMAP(1))
- #define GPIO_CTC_REMAP1 ((uint32_t)0x801B0000U | PCF1_CTC_REMAP(2))
- #ifdef GD32F30X_CL
- #define GPIO_ENET_PHY_MII ((uint32_t)0x00000000U)
- #define GPIO_ENET_PHY_RMII AFIO_PCF0_ENET_PHY_SEL
- #endif
- #define GPIO_COMPENSATION_ENABLE AFIO_CPSCTL_CPS_EN
- #define GPIO_COMPENSATION_DISABLE ((uint32_t)0x00000000U)
- void gpio_deinit(uint32_t gpio_periph);
- void gpio_afio_deinit(void);
- void gpio_init(uint32_t gpio_periph, uint32_t mode, uint32_t speed, uint32_t pin);
- void gpio_bit_set(uint32_t gpio_periph, uint32_t pin);
- void gpio_bit_reset(uint32_t gpio_periph, uint32_t pin);
- void gpio_bit_write(uint32_t gpio_periph, uint32_t pin, bit_status bit_value);
- void gpio_port_write(uint32_t gpio_periph, uint16_t data);
- FlagStatus gpio_input_bit_get(uint32_t gpio_periph, uint32_t pin);
- uint16_t gpio_input_port_get(uint32_t gpio_periph);
- FlagStatus gpio_output_bit_get(uint32_t gpio_periph, uint32_t pin);
- uint16_t gpio_output_port_get(uint32_t gpio_periph);
- void gpio_pin_remap_config(uint32_t remap, ControlStatus newvalue);
- #ifdef GD32F30X_CL
- void gpio_ethernet_phy_select(uint32_t enet_sel);
- #endif
- void gpio_exti_source_select(uint8_t output_port, uint8_t output_pin);
- void gpio_event_output_config(uint8_t output_port, uint8_t output_pin);
- void gpio_event_output_enable(void);
- void gpio_event_output_disable(void);
- void gpio_pin_lock(uint32_t gpio_periph, uint32_t pin);
- void gpio_compensation_config(uint32_t compensation);
- FlagStatus gpio_compensation_flag_get(void);
- #endif
|