GPIO輸入----檢測(cè)按鍵(EasyARM2131)
**--------------File Info----------------------------------------------------------
** File name:main.c
** Last modified Date: 2011-04-09
** Last Version:1.0
** Descriptions:The main() function example template
**
**---------------------------------------------------------------------------------
** Created by:lxliu
** Created date:2011-04-09
** Version:1.0
** Descriptions:The original version
************************************************************************************/
#include "config.h"
const uint32 BEEP = (1<<7);
const uint32 KEY1 = (1<<16);
/*************************************************************************
** 函數(shù)名稱:main()
** 函數(shù)功能:GPIO輸入測(cè)試
檢測(cè)按鍵KEY1:KEY1按下,蜂鳴器蜂鳴;松開(kāi)后,停止蜂鳴
** 跳線說(shuō)明:需將跳線JP8和KEY1短接,JP11連接蜂鳴器
*************************************************************************/
int main (void)
{
PINSEL0 = 0x00000000; //所有引腳都設(shè)置為GPIO
PINSEL1 = 0x00000000; //
IO0DIR = BEEP; //蜂鳴器控制口輸出,其余輸入
while(1)
{
if((IO0PIN & KEY1) == 0) //KEY1按下,蜂鳴器蜂鳴
IO0CLR = BEEP;
else //松開(kāi)后,停止蜂鳴
IO0SET = BEEP;
}
return 0;
}
/**********************************************************************************
** End Of File
***********************************************************************************/
評(píng)論