GD32W51x User Manual
230
8. General-purpose and alternate-function I/Os (GPIO and
AFIO)
8.1.
Overview
There are up to 43 general purpose I/O pins (GPIO), named PA0 ~ PA15, PB0 ~ PB15, PC0
~ PC8, and PC14 ~ PC15 for the device to implement logic input/output functions. Each GPIO
port has related control and configuration registers to satisfy the requirements of specific
applications. The external interrupts on the GPIO pins of the device have related control and
configuration registers in the Interrupt/Event Controller Unit (EXTI).
The GPIO ports are pin-shared with other alternative functions (AFs) to obtain maximum
flexibility on the package pins. The GPIO pins can be used as alternative functional pins by
configuring the corresponding registers regardless of the AF input or output pins.
Each of the GPIO pins can be configured by software as output (push-pull or open-drain),
input, peripheral alternate function or analog mode. Each GPIO pin can be configured as pull-
up, pull-down or no pull-up/pull-down. All GPIOs are high-current capable except for analog
mode.
8.2.
Characteristics
Input/output direction control
Schmitt trigger input function enable control
Each pin weak pull-up/pull-down function
Output push-pull/open drain enable control
Output set/reset control
External interrupt with programmable trigger edge
– using EXTI configuration registers
Analog input/output configuration
Alternate function input/output configuration
Port configuration lock
Single cycle toggle output capability
8.3.
Function overview
Each of the general-purpose I/O ports can be configured as GPIO inputs, GPIO outputs, AF
function or analog mode by GPIO 32-bit configuration registers (GPIOx_CTL). When select
AF function, the pad input or output is decided by selected AF function output enable. When
the port is output (GPIO output or AFIO output), it can be configured as push-pull or open
drain mode by GPIO output mode registers (GPIOx_OMODE). And the port max speed can
be configured by GPIO output speed registers (GPIOx_OSPD). Each port can be configured