野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 17384|回复: 3

火哥的视频作业:用GPIO初始化结构题和初始化函数点亮PB1和

[复制链接]
发表于 2020-8-17 14:47:56 | 显示全部楼层 |阅读模式
想要点亮PB1是不是直接将59行的代码改成 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
之后将64 65行函数参数也改成GPIO_Pin_1就可以了
求大神告知
野火论坛202008171445417133..png
回复

使用道具 举报

发表于 2020-8-19 09:03:19 | 显示全部楼层
也是可以的
回复 支持 反对

使用道具 举报

发表于 2020-9-26 10:05:14 | 显示全部楼层
点亮pb1(蓝色的灯)与pb5(红色的灯)确实只是把GPIO_Pin_0改成GPIO_Pin_1    或者 GPIO_Pin_5 就行,
想我这图里代码的话对应的GPIO_Pin的取值会被下一行取代,这是错误示范,比如
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;这就会导致GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;失去作用
野火论坛202009261001076711..png
回复 支持 反对

使用道具 举报

发表于 2020-9-26 17:32:02 | 显示全部楼层
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1|GPIO_Pin_5;
GPIO_Init(GPIOB, &GPIO_InitStructure);

或者
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_Init(GPIOB, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_Init(GPIOB, &GPIO_InitStructure);
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-6-27 21:55 , Processed in 0.033142 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表