📄 led_test.c
字号:
/*********************************************************************************************
* File: led_test.c
* Author: embest
* Desc: IO port test file
* History:
*********************************************************************************************/
/*------------------------------------------------------------------------------------------*/
/* include files */
/*------------------------------------------------------------------------------------------*/
#include "2410lib.h"
/*********************************************************************************************
* name: led_on
* func: turn on the leds one by one
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void led_on(void)
{
int i,nOut;
nOut = 0xF0;
//rGPFDAT=nOut & 0x10;
rGPFDAT=nOut & 0xd0;
for(i=0;i<100000;i++);
rGPFDAT = nOut & 0x50; //0x70
for(i=0;i<100000;i++);
rGPFDAT=nOut & 0x40; //0x00
for(i=0;i<100000;i++);
rGPFDAT=nOut & 0x00; //0x30
for(i=0;i<100000;i++);
rGPFDAT=nOut ;
}
/*********************************************************************************************
* name: led_off
* func: turn off the leds one by one
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void led_off(void)
{
int i,nOut;
nOut=0;
rGPFDAT = 0;
for(i=0;i<100000;i++);
rGPFDAT = nOut | 0x20;//0x80;
for(i=0;i<100000;i++);
rGPFDAT |= nOut | 0xa0;//0x40;
for(i=0;i<100000;i++);
rGPFDAT |= nOut | 0xb0;//0x20;
for(i=0;i<100000;i++);
rGPFDAT |= nOut | 0xf0;//0x10;
for(i=0;i<100000;i++);
}
/*********************************************************************************************
* name: led_on_off
* func: turn on the 4 leds and then turn off the 4 leds
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void led_on_off(void)
{
int i;
rGPFDAT=0;
for(i=0;i<100000;i++);
rGPFDAT=0xF0;
for(i=0;i<100000;i++);
}
/*********************************************************************************************
* name: led_test
* func: i/o control test(led)
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void led_test(void)
{
rGPFCON=0x5500; // PORTF7/6/5/4 OUTPUT
rGPFUP=0; // PULL-UP ENABLE
rGPBCON = rGPBCON & 0xFFFFFC|1; // beep configuration
uart_printf("\n I/O (Diode Led) Test Example\n");
rGPBDAT &= 0xFFFFFE;
led_on();
led_off();
led_on_off();
rGPBDAT |= 1;
delay(1000);
rGPFCON = 0x55aa; // GPF1,GPF0=10 :EINT1,EINT0,(2410lib.c)
uart_printf(" end.\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -