//#include "SPORT_AS_UART.h"
#include "Serial_FLASH.h"
//#include "21364_SSL_Serial_FLASH.h"
#include "def21364.h"
#include "Cdef21364.h"

int main()
{
	
	int ii=0;
	int jj=0;
	
	int x=0;
	
	int dll, dlh;
	
	//System Initialization
	Init_PLL();
	Init_SRU();
	Init_UART();
	Init_SPI();
	*pSYSCTL|=PPFLGS|FLG2EN;
	asm("#include <def21364.h>;");
	asm("bit set FLAGS FLG9O;");
	
	//Toggle LED2 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 SW1
	asm("if NOT FLAG1_IN jump (pc,0);");
	
	*pSYSCTL^=PPFLGS|FLG2EN;
	
	//Upgrade the firmware now
	firmware_upgrade();
	
	//Load the upgraded firmware
	asm("jump _load_application;");
	
	while(1)
	{
		ii=1;
	}
		

}

