历史上的今天
今天是:2024年09月06日(星期五)
2019年09月06日 | STM32实战1:按键点亮LED小灯 hh
2019-09-06 来源:eefocus
#include "sys.h"
#include "key.h"
void KEY_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);//初始化时钟
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOB, &GPIO_InitStructure);
} //key.c
#include "sys.h"
#include "led.h"
void LED_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);//初始化时钟
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
}
#include "sys.h"
#include "led.h"
#include "key.h"
int main()
{
LED_Init();
KEY_Init();
while(1)
{
LED = 1;
if(KEY == 0)
{
LED = 0;
}
}
}
上一篇:stm32实现LED灯亮灭
下一篇:基于STM32实现MQTT
史海拾趣
|
如题,因为项目需要,急需这方面的例子(一定要例子,资料我已经有了很多,但是例子没有一个能调通的),望各位高人出手相助,在此谢过了QQ792549792… 查看全部问答> |
|
我公司用cyprss的68013开发的USB驱动在USB1.1下正常使用,但是在USB2.0下就收不到数据,请教各位有开发经验的朋友,问题大概出在哪里?本人刚接触驱动,领导要我近期内解决这个问题,急啊!… 查看全部问答> |
|
用的是ateml的9263的版子,现在想改成三菱公司的AA065VB01型号的640*480的显示器,弄了一个星期了,还没有调好,感觉都快崩溃了 [img=http://hi.eeworld.net/attachment/201003/8/2080554_1268028378R0cE.jpg.thumb.jpg[/img] … 查看全部问答> |
|
请参阅文件,在IAR环境下编译的。Error[e46]: Undefined external "__program_start" referred in ?ABS_ENTRY_MOD ( ) 这是什么意思?找不到错误源...ST(万利)如果能把实验资料做得 ...… 查看全部问答> |




