#include "SPORT_AS_UART.h"
#include "Parallel_FLASH.h"
#include "21262_SSL_Parallel_FLASH.h"
#include "def21262.h"
#include "Cdef21262.h"

int main()
{
	
	int ii=0;
	int jj=0;
	
	int dll, dlh;
	
	//System Initialization
	Init_PLL();
	Init_SRU();
	Init_UART();
	Setup_for_flash();
	*pSYSCTL|=PPFLGS;//|FLG2EN;
	asm("#include <def21262.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;");
	}
	
	*pSYSCTL^=PPFLGS;//|FLG2EN;
	
	for(jj=0;jj<50;jj++);
	
	//Wait for the user to press SW1
	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;
	}
		

}
