1. The basic structure of GPIO
2. GPIO working mode
Input mode
Input float
Input pull-up
Input drop down
Analog input
Output mode
Open drain output
Open drain multiplexing function
Push-pull output
Push-pull multiplexing function
3. The corresponding code in the library function
1 typedef enum
2 {
3 GPIO_Mode_AIN = 0x0 , / * Analog input * /
4 GPIO_Mode_IN_FLOATING = 0x04 , / * Floating input, state after reset * /
5 GPIO_Mode_IPD = 0x28 , / * Pull-down input, where pull-down refers to the internal of the microcontroller Resistance * /
6 GPIO_Mode_IPU = 0x48 , / * Pull-up input, where pull-up refers to the internal resistance of the microcontroller * /
7 GPIO_Mode_Out_OD = 0x14 , / * Open-drain output * /
8 GPIO_Mode_Out_PP = 0x10 ,/ * Push-pull output * /
9 GPIO_Mode_AF_OD = 0x1C , / * multiplexed open-drain output * /
10 GPIO_Mode_AF_PP = 0x18 / * multiplexed push-pull output * /
11 } GPIOMode_TypeDef;
There are so many working modes of GPIO, so how does each mode work? The following is explained in the form of pictures
So let ’s first explain the four working modes in input mode (input floating, input pull-up, input pull-down, analog input)
(1) Input floating mode