GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)读的是GPIOx_IDR,读的是当IO口设置为输入状态时候的IO口值
GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)读的是GPIOx_ODR,读的是当IO口设置为输出状态时候的IO口值
#define KEY0 GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_4) //PE4
#define KEY1 GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_3) //PE3
#define KEY2 GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_2) //PE2
#define WK_UP GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0) //PA0
本文详细解析了STM32中GPIO_ReadInputDataBit与GPIO_ReadOutputDataBit函数的使用方法,介绍了如何通过这两个函数读取GPIOx_IDR和GPIOx_ODR寄存器的值,以获取输入和输出状态。并提供了具体的代码示例,如KEY0、KEY1、KEY2和WK_UP等按键状态读取的实现。

1037


被折叠的 条评论
为什么被折叠?



