#include "config.h"
#include "delay.h"
#define LED1 1<<16
#define LED2 1<<17
#define LED3 1<<18
#define LED4 1<<19
#define BEEP 1<<5
#define KEY1 1<<3
#define KEY2 1<<6
#define KEY3 1<<7
#define KEY4 1<<15
#define KEY5 1<<30
void initSystem(void)
{
IO1SET = LED1 | LED2 | LED3 | LED4;
IO1DIR = LED1 | LED2 | LED3 | LED4;
IO0CLR = BEEP;
IO0DIR = BEEP;
}
void LED_On(uint32 num)
{
IO1CLR = num;
}
void LED_Off(uint32 num)
{
IO1SET = num;
}
void BEEP_On(uint32 num)
{
IO0SET = num;
}
void BEEP_Off(uint32 num)
{
IO0CLR = num;
}
int main(void)
{
initSystem();
while(1)
{
if( (KEY1 & IO0PIN) == 0)//防抖程序
{
delay(10);
if( (KEY1 & IO0PIN) == 0)
{
while((IO0PIN & KEY1) == 0);//按钮提起
if( (IO0PIN & BEEP) == 0)
{
BEEP_On(BEEP);//BEEP高电平有效
}
else
{
BEEP_Off(BEEP);
}
}
}
}
}
求解释
if( (IO0PIN & BEEP) == 0)
{
BEEP_On(BEEP);//BEEP高电平有效
}
else
{
BEEP_Off(BEEP);
}
}
}
}
}
为什么这样写 BEEP为高点有效 在P0.5脚 key1在PO.3脚
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>