

#ifndef BOOTLOADER_STATE_MACHINE_H
#define BOOTLOADER_STATE_MACHINE_H

#define SM_NULL_DATA 0
#define PSEUDO_TIMER_VALUE	1500000
#define BOOTLOADER_UNLOCK_CODE 0xA5


enum eBootloaderSMStates
{
//	SM_UPDATE_WAIT_STATE,
//	SM_IDLE_STATE,
//	SM_WAIT_FOR_UNLOCK_STATE,
//	SM_WAIT_FOR_NEXT_RECORD
    
    SM_STANDBY_STATE,
    SM_CHECK_BOOTLOADER_FLAGS,
    SM_CHECK_FIRMWARE_VALIDITY,
    SM_ERASE_INTERNAL_FLASH,
    SM_WRITE_DATA_TO_PROGRAM_FLASH,
    SM_CHECK_PROGRAM_FLASH_VALIDITY,
    SM_ERROR_STATE
    
};

enum eBootloaderEvents
{
	SM_TICK_EVENT,
	SM_RX_CMD_EVENT,
	SM_ABORT_UPDATE
    
};


void BootloaderSMInit(void);
void BootloaderSM( unsigned int event, unsigned int Data );
void JumpToApp(void);
void DownloadFlash(unsigned int StartAddress, unsigned int EndAddress);
void BootloaderSMSetSPIFlashDetected(int Detected);
void BootloaderSMReadBootloaderFlags();

#endif

//===========================================================================
// End of file.
//===========================================================================
