/****************************************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”
/*LED8~LED1 这8个LED分别由P1.25~P1.18操控*/
const uint32 LEDS8 = (0xFF<<18);
/*************************************************************************
** 函数称号:DelayNS()
** 函数功用:长软件延时
** 进口参数:dly延时操控值,值越大,延时越长
** 出口参数:无
*************************************************************************/
void DelayNS(uint32 dly)
{
uint32 i;
for(;dly>0;dly–)
for(i=0;i<50000;i++);
}
/*************************************************************************
** 函数称号:main()
** 函数功用:流水灯显现程序
** 调试阐明:需将跳线JP12衔接至LED8~LED1
*************************************************************************/
/*流水灯把戏,低电平点亮,调用时使用了取反操作*/
const uint32 LED_TBL[] =
{
0x00,0xFF, //悉数平息后再次点亮
0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80, //顺次逐一点亮
0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF, //顺次逐一叠加
0xFF,0x7f,0x3F,0x1F,0x0F,0x07,0x03,0x01, //顺次逐一递减
0x81,0x42,0x24,0x18,0x18,0x24,0x42,0x81, //两个挨近后分隔
0x81,0xC3,0xE7,0xFF,0xFF,0xE7,0xC3,0x81 //从两头叠加后递减
};
int main (void)
{
uint8 i;
PINSEL2 = PINSEL2 & (~0x08); //P1[25:16]为GPIO功用,PINSEL2的第三位设置为0
IO0DIR = LEDS8; //设置P1.25~P1.18为输出
while(1)
{
for (i=0;i<42;i++)
{
IO1SET = ~((LED_TBL[i])<<18);
DelayNS(50);
IO1CLR = ~((LED_TBL[i])<<18);
DelayNS(50);
}
}
return 0;
}
/*****************************************************************************
** End Of File
*****************************************************************************/