📄 fiotest.c
字号:
/*****************************************************************************
* fiotest.c: GPIO test main C entry file for NXP LPC23xx/24xx Family
* Microprocessors
*
* Copyright(C) 2006, NXP Semiconductor
* All rights reserved.
*
* History
* 2006.07.14 ver 1.00 Prelimnary version, first Release
*
******************************************************************************/
#include "LPC230x.h" /* LPC2xxx definitions */
#include "type.h"
#include "irq.h"
#include "target.h"
#include "timer.h"
#include "fio.h"
extern DWORD timer_counter;
void Delay(DWORD ms)
{
/*
* setup timer #1 for delay
*/
T1TCR = 0x02; /* reset timer */
T1PR = 0x00; /* set prescaler to zero */
T1MR0 = ms * (Fpclk / 1000);
T1IR = 0xff; /* reset all interrrupts */
T1MCR = 0x04; /* stop timer on match */
T1TCR = 0x01; /* start timer */
/* wait until delay time has elapsed */
while (T1TCR & 0x01);
}
/*****************************************************************************
** Main Function main()
******************************************************************************/
int main (void)
{
DWORD counter;
/********* The main Function is an endless loop ***********/
// init_timer( TIME_INTERVAL );
/* GPIOInit() need to be carefully called if you want to run some
other peripherals, it will set the PINSEL to default value and change
the direction of IOs. */
/* Initialize port for LED display, the LEDs on Keil MCB2300 is Port 2.0~2.7 */
// GPIOInit( 2, FAST_PORT, DIR_OUT );
GPIOInit( 3, FAST_PORT, DIR_OUT );
/* Initialize timer for GPIO toggling timing */
// enable_timer( 0 );
// counter = 0;
// FIO2SET = 1 << counter;
FIO3DIR = 0xFF0000;
FIO3CLR = 0xFF0000;
while(1)
{
Delay(100);
D6_ON();
Delay(100);
D6_OFF();
D5_ON();
Delay(100);
D5_OFF();
D4_ON();
Delay(100);
D4_OFF();
D7_ON();
Delay(100);
D7_OFF();
D8_ON();
Delay(100);
D8_OFF();
D3_ON();
Delay(100);
D3_OFF();
D2_ON();
Delay(100);
D2_OFF();
D9_ON();
Delay(100);
D9_OFF();
}
/*
while ( 1 )
{
if ( timer_counter >= (0x20 * counter) )
{
FIO2SET = 1 << counter;
counter++;
if ( counter > 8 )
{
counter = 0;
timer_counter = 0;
FIO2CLR = 0x000000FF;
}
}
}
return 0;
*/
}
/*****************************************************************************
** End Of File
*****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -