Typedef enumeration
{
GPIO_Mode_IN? = 0x00,/*! & ltGPIO input mode? */
GPIO_Mode_OUT? = 0x0 1,/*! & ltGPIO output mode */
GPIO_Mode_AF? = 0x02,/*! & ltGPIO standby function mode */
GPIO_Mode_AN? = 0x03? /*! < gpio analog input/output mode? */
} GPIOMode _ TypeDef
This structure defines the mode of the port. They are: input, output, multiplexing and analog input. The default is ordinary IO port, that is, input or output. At this time, the port of single chip microcomputer can only input or output high and low levels, and cannot be used for other peripherals (such as PWM, UART, SPI, etc. ).
So if this port is used as the output port of the peripheral, how to set it? Yes, it is GPIO_Mode_AF, which means port reuse.
To sum up, if the port is only used as an input/output port signal, the setting mode is normal IO; If peripherals are used, the microcontroller must be set to multiplex mode, i.e. GPIO_Mode_AF.
By the way, STM32F 1 serial ports are a little more complicated. There are seven modes, which are divided into primary multiplexing and secondary multiplexing, but the principle is the same.