概述
本文分析总结STM32 GPIO特点、编程方法。
关于GPIO可以参考Reference manual中GPIO章节或者《AN4899 STM32 microcontroller GPIO configuration for hardware settings and low-power consumption》。
内存映射
GPIOx_REG,其中x = A to H, Piny= 0 … 15。
STM32:
typedef struct
{
__IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */
__IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */
__IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */
__IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */
__IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */
__IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */
__IO uint32_t BSRR; /*!< GPIO port bit set/reset register, Addres