新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > GPIO輸入----檢測按鍵(EasyARM2131)

GPIO輸入----檢測按鍵(EasyARM2131)

作者: 時間:2016-11-10 來源:網(wǎng)絡(luò) 收藏
/****************************************Copyright (c)*****************************

**--------------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"

本文引用地址:http://2s4d.com/article/201611/317407.htm

const uint32 BEEP = (1<<7);
const uint32 KEY1 = (1<<16);

/*************************************************************************
** 函數(shù)名稱:main()
** 函數(shù)功能:GPIO輸入測試
檢測按鍵KEY1:KEY1按下,蜂鳴器蜂鳴;松開后,停止蜂鳴
** 跳線說明:需將跳線JP8和KEY1短接,JP11連接蜂鳴器
*************************************************************************/
int main (void)
{

PINSEL0 = 0x00000000; //所有引腳都設(shè)置為GPIO
PINSEL1 = 0x00000000; //
IO0DIR = BEEP; //蜂鳴器控制口輸出,其余輸入

while(1)
{
if((IO0PIN & KEY1) == 0) //KEY1按下,蜂鳴器蜂鳴
IO0CLR = BEEP;
else //松開后,停止蜂鳴
IO0SET = BEEP;
}
return 0;
}
/**********************************************************************************
** End Of File
***********************************************************************************/



評論


技術(shù)專區(qū)

關(guān)閉