/* This code commuicates with the firmmware upgrade GUI on PC  via RS-232 to upgrade and load the firmware on 
parallel FLASH*/

#include "UART.h"
#include "Parallel_FLASH.h"
#include "21469_SSL_Parallel_FLASH.h"

int main()
{
	
	int ii=0;
	int jj=0;
	
	int dll, dlh;
	
	//System Initialization
	Init_PLL();
	Init_SRU();
	Init_UART();
	Setup_for_flash();
	asm("#include <def21469.h>;");
	asm("bit set FLAGS FLG9O;");
	
	//Toggle LED1 10 times
	for(ii=0;ii<10;ii++)
	{
		for(jj=0;jj<5000000;jj++);
		
		asm("bit tgl FLAGS FLG9;");
	}
	
	//Wait for the user to press SW8 
	asm("if NOT FLAG1_IN jump (pc,0);");
	
	//Upgrade the firmware now
	firmware_upgrade();
	
	//Load the upgraded firmware
	asm("jump _load_application;");
	
	while(1)
	{
		ii=1;
	}
		

}


