#include <stm32f10x_lib.h>
/******************************
**LED端口定义
******************************/
#define LED0 PAout(8)// PA8
#define LED1 PDout(2)// PD2
/***********************************
**按键IO口定义
***********************************/
#define KEY0 PAin(13) //PA13
#define KEY1 PAin(15) //PA15
void delayms(unsigned int xms) //非精确延时函数,8MHZ下大约延时1ms
{
unsigned int i,j;
for(i=xms;i>0;i--)
for(j=860;j>0;j--);
}
/*****************************************************************
** 函 数 名:void LED_Init(void)
** 功 能:LED模块初始化
** 参 数:无
** 描 述:PA8与PD2两个IO端口
** 使用说明LEDx为0时点亮,默认灭
******************************************************************/
void LED_Init(void)
{
RCC->APB2ENR|=1<<2; //使能PORTA时钟 当外设时钟没有启用时,软件不能读出外设寄存器的数值
RCC->APB2ENR|=1<<5; //使能PORTD时钟
GPIOA-&
STM32 按键检测
最新推荐文章于 2024-03-10 15:35:24 发布