#include "def21369.h"
#include "Cdef21369.h"
#include "21369_SSL_Serial_FLASH.h"
#include "UART.h"
#include "Serial_FLASH.h"

int main()
{
	int i, temp, ii, jj;
	
	//System Initialization
	Init_PLL();
	Init_SRU();
	Init_SPI();
	Init_UART();
	asm("#include <def21369.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 PB2
	asm("if NOT FLAG0_IN jump (pc,0);");

	//Upgrade the firmware now			
	firmware_upgrade();

	//Load the upgraded firmware	
	asm("jump _load_application;");

	
	while(1)
	{
		ii=1;
	}
	

}
