GPIO輸出---單個(gè)LED閃爍(EasyARM3131)

/****************************************Copyright (c)***************************
本文引用地址:http://dyxdggzs.com/article/201611/317405.htm**--------------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 LED1 = (1<<18);
/*************************************************************************
** 函數名稱(chēng):DelayNS()
** 函數功能:長(cháng)軟件延時(shí)
** 入口參數:dly延時(shí)控制值,值越大,延時(shí)越長(cháng)
** 出口參數:無(wú)
*************************************************************************/
void DelayNS(uint32 dly)
{
uint32 i;
for(;dly>0;dly--)
for(i=0;i<50000;i++);
}
/*************************************************************************
** 函數名稱(chēng):main()
** 函數功能:用P1.18控制LED1,讓LED1閃爍
** 調試說(shuō)明:需將跳線(xiàn)JP12和LED1短接
*************************************************************************/
int main (void)
{
PINSEL2 = PINSEL2 &(~0x80); //P1[25:16]為GPIO功能,PINSEL2的第三位設置為0
IO1DIR = LED1; //設置P1.18為輸出
while(1)
{
IO1SET = LED1; //LED熄滅
DelayNS(50); //延時(shí)
IO1CLR = LED1; //LED點(diǎn)亮
DelayNS(200); //延時(shí)
}
return 0;
}
/********************************************************************************
** End Of File
*********************************************************************************/
評論