led_test.c

来自「ARM2410 要更多的远吗」· C语言 代码 · 共 104 行

C
104
字号
/*********************************************************************************************
* File:	led_test.c
* Author:	embest
* Desc:	IO port test file
* History:	
*			H.T.Zhang, Programming modify, September 14, 2005
*********************************************************************************************/

/*------------------------------------------------------------------------------------------*/
/*                                     include files	                                    */
/*------------------------------------------------------------------------------------------*/
#include "2410lib.h"
#include "demo.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 & 0x70;
	for(i=0;i<100000;i++);	
	rGPFDAT=nOut & 0x30;
	for(i=0;i<100000;i++);	
	rGPFDAT=nOut & 0x10;
	for(i=0;i<100000;i++);
	rGPFDAT=nOut & 0x00;
	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=0;
	rGPFDAT = 0;
	for(i=0;i<100000;i++);	
	rGPFDAT = nOut | 0x80;
	for(i=0;i<100000;i++);	
	rGPFDAT |= nOut | 0x40;
	for(i=0;i<100000;i++);	
	rGPFDAT |= nOut | 0x20;
	for(i=0;i<100000;i++);	
	rGPFDAT |= nOut | 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)
{
	lcd_disp_ascii8x16(f_nInfoCol,f_nInfoRow,RED,"I/O test start...");
	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");
	lcd_disp_ascii8x16(f_nInfoCol,f_nInfoRow+f_nPadRow,RED,"end");
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?