📄 led_test.c
字号:
/*********************************************************************************************
* File: led_test.c
* Author: embest
* Desc: Led_Test
* History:
*********************************************************************************************/
/*------------------------------------------------------------------------------------------*/
/* include files */
/*------------------------------------------------------------------------------------------*/
#include "2410lib.h"
/*------------------------------------------------------------------------------------------*/
/* constant define */
/*------------------------------------------------------------------------------------------*/
#define rCPLDLEDADDR (*(volatile unsigned char*)0x21180000) // LED Address
/*********************************************************************************************
* 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 = 0xFF;
rCPLDLEDADDR = nOut & 0xFE;
for(i = 0; i < 100000; i++);
rCPLDLEDADDR = nOut & 0xFC;
for(i = 0; i < 100000; i++);
rCPLDLEDADDR = nOut & 0xF8;
for(i = 0; i < 100000; i++);
rCPLDLEDADDR = nOut & 0xF0;
for(i = 0; i < 100000; i++);
}
/*********************************************************************************************
* 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 = 0xF0;
rCPLDLEDADDR = nOut | 0x01;
for(i = 0; i < 100000; i++);
rCPLDLEDADDR = nOut | 0x03;
for(i = 0; i < 100000; i++);
rCPLDLEDADDR = nOut | 0x07;
for(i = 0; i < 100000; i++);
rCPLDLEDADDR = nOut | 0x0F;
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;
rCPLDLEDADDR = 0xF0;
for(i = 0; i < 100000; i++);
rCPLDLEDADDR = 0xFF;
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)
{
uart_printf("\n Expand I/O (Diode Led) Test Example\n");
uart_printf(" Please Look At The LEDS \n");
led_on();
led_off();
led_on_off();
delay(2000);
uart_printf(" End.\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -