/*
***********************************************************************************************************************
*                    Simple LED blinking program for LPC2103 by using GNU toolchain under uVision3 IDE
*
* Programmer 	: 	John Leung, TechToys. Hong Kong
* Web presence  : 	www.TechToys.com.hk
* Toolchain		: 	RealView MDK-ARM Ver 3.22a
* Hardware		: 	LPC2103-Eval-1A
* Date			: 	9th Sept 2008
* File			: 	Blinky_main.c
* Note			: 	This example uses GNU toolchain in Keil uVision3 IDE.
*					The same set of source code for RealdView compiler has been used but this time, the GNU
*					complier has been used.
*					Further details about this example can be found under Doc 09 at
*					http://www.techtoys.com.hk/ARM_boards/LPC2103_Eval_1A/LPC2103_Eval_1A.htm
***********************************************************************************************************************
*/            

#include <LPC2103.H>
#include "..\SYSTEM\system.h"

#define LED				(1<<8)		 		//LED connected to P0.8

#define LED_OFF			(IOSET=IOSET|LED)
#define LED_ON			(IOCLR=IOCLR|LED)

										 
/* simple software delay function */
void Delay (unsigned int i)
{                        
	unsigned int n;

	while(i>1)
	{
		for(n=65535;n>1;n--);
		i--;
	}
}

/* main function */
int main (void)
{
		sysInit();							//Set CCLK and PCLK to 60MHz 
		LED_OFF;							//set LED off to start with
		IODIR = IODIR|LED;					//Set LED pin as output
			
		for(;;){
			LED_ON;
			Delay(20);						//simple software delay
			LED_OFF;
			Delay(20);
		}

		return (0);
}
