/****************************************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"
const uint32 LED1 = (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
*********************************************************************************/
『本文转载自网络,版权归原作者所有,如有侵权请联系删除』