toofree 发表于 2018-3-17 22:11:16

先把前一个帖子的情况总结一下。

feixiang20 发表于 2018-3-17 22:18:15

是不是循环有问题啊,一般参数循环错误也会读不出

dsjsjf 发表于 2018-3-19 18:23:05

GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
{
GPIO_PinState bitstatus;

/* Check the parameters */
assert_param(IS_GPIO_PIN(GPIO_Pin));

if((GPIOx->IDR & GPIO_Pin) != (uint32_t)GPIO_PIN_RESET)
{
    bitstatus = GPIO_PIN_SET;
}
else
{
    bitstatus = GPIO_PIN_RESET;
}
return bitstatus;
}

这个函数的返回只有两个状态,要么0,要么1,所以你的swich里的值永远是0
页: 1 [2]
查看完整版本: 用STM32L053做矩阵键盘的代码,为什么IO口读不出数据啊