![ARTERY AT32F421 GPIO User Manual Download Page 13](http://html1.mh-extra.com/html/artery/at32f421-gpio/at32f421-gpio_user-manual_2977597013.webp)
AT32F421 GPIO user guide
2020.07.30
13
Rev.1.0.0
GPIO firmware driver API
Artery
’s firmware driver contains a series of firmware functions to manage the following GPIO
functions:
Initialization configuration
Read input ports or certain input pin
Read output ports or certain output pin
Set or clear the output on a certain pin
lock pins
Pin alternate function configuration
For AT32F421xx series, the driver used by GPIO is at32f4xx_gpio_ex.c/.h, located in the following
directory:
AT32F4xx_StdPeriph_Lib_Vx.x.x\Libraries\AT32F4xx_StdPeriph_Driver
Note: The AT32F421 series GPIOs use different driver at32f4xx_gpio.c/.h from that of other series. The user
should be noted about this when using.
Output mode
GPIO provides two different types of output modes: push-pull and open-drain. Refer to the following
configuration example of output mode.
GPIO_InitStructure.GPIO_Pins = GPIO_Pins_x;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OutType = GPIO_OutType_PP; /* push-pull or open-drain */
GPIO_InitStructure.GPIO_Pull = GPIO_Pull_NOPULL; /* None, pull-down or pull-up*/
GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;/* 10,2 or 50MHz */
GPIO_Init(GPIOy, &GPIO_InitStructure);
Input mode
GPIO provides three different types of input modes: input floating, input pull-down and input pull-
down. Refer to the following configuration example of input mode.
GPIO_InitStructure.GPIO_Pins = GPIO_Pins_x;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_Pull = GPIO_Pull_NOPULL; /* None, pull-up or pull-down*/
GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;/* 10, 2 or 50MHz */
GPIO_Init(GPIOy, &GPIO_InitStructure);