?? 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 & 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)
{
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 + -