想要在stm32f103中配置一个引脚同时具备输入和输出功能,这种功能能否实现?输出时配置为输出,
用作输入时再配置回输入,这样循环往复。
有没有可以参考的例程?
以下是我自己写的,
用作输出时这样配置
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_25MHz; GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4; GPIO_Init(GPIOE, &GPIO_InitStruct); 用作输入时这样配置 GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN; // so change the strut to from Alt funct to GPIO (in) GPIO_InitStruct.GPIO_Speed = GPIO_Speed_25MHz; GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4; GPIO_Init(GPIOE, &GPIO_InitStruct);
|