新闻中心

EEPW首页>嵌入式系统>设计应用> GPIO输出---单个LED闪烁(EasyARM3131)

GPIO输出---单个LED闪烁(EasyARM3131)

作者: 时间:2016-11-10 来源:网络 收藏

/****************************************Copyright (c)***************************

本文引用地址://m.amcfsurvey.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 uint32LED1 = (1<<18);

/*************************************************************************
** 函数名称:DelayNS()
** 函数功能:长软件延时
** 入口参数:dly延时控制值,值越大,延时越长
** 出口参数:无
*************************************************************************/

void DelayNS(uint32 dly)
{
uint32 i;
for(;dly>0;dly--)
for(i=0;i<50000;i++);
}

/*************************************************************************
** 函数名称:main()
** 函数功能:用P1.18控制LED1,让LED1闪烁
** 调试说明:需将跳线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); //延时
IO1CLR = LED1; //LED点亮
DelayNS(200); //延时

}
return 0;
}
/********************************************************************************
** End Of File
*********************************************************************************/



评论


技术专区

关闭