#ifndef __BOOTLOADER_H
#define __BOOTLOADER_H 


// zacatek uzivatelske aplikace ve FLASH - kontrola jestli je neco nahrane
#define USER_APPL_ADDRESS 	0x8000L		


// prikazy
#define COM_ERASE 			0x01
#define COM_FLASH 			0x02
#define COM_SN	 			0x04

unsigned int RestartToBootloader(void);
unsigned int CheckBootMode(void);
unsigned int SetBootMode(tUInt state);

void ProcessBoot(void);

tUInt BootInitFrame(tUInt adrs, tUInt no);
void BootCopyFrame( tUInt bytes);
tUInt BootWriteFrame(void);


//void wait_tick_10ms( tUInt delay);

	
void Parse_BootData(void);
void Clear_RxBuffer(void);


void BootParseSciRxData(void);
void Boot_Init_HW(void);

tUInt ParseSrecord(tsSrec *S19);
tUInt CheckPage(tUInt address);


enum
{
  ACSLINE_INSTRUCTION_NONE = (0),
  ACSLINE_INSTRUCTION_CAL,
  ACSLINE_INSTRUCTION_SET,
  ACSLINE_INSTRUCTION_CFG,
  ACSLINE_INSTRUCTION_INF,
  ACSLINE_INSTRUCTION_DLL,
  ACSLINE_INSTRUCTION_RDI,
  ACSLINE_INSTRUCTION_BUF,
  ACSLINE_INSTRUCTION_CMD,
};




enum
{ 
  ACSLINE_COMM_STATE_IDLE = (0),
  ACSLINE_COMM_STATE_BUSY,
  ACSLINE_COMM_STATE_GET_MODULE_NUM,
  ACSLINE_COMM_STATE_ESTABLISHED,
  ACSLINE_COMM_STATE_GET_INSTR,
  ACSLINE_COMM_STATE_GET_SUBINSTR,
  ACSLINE_COMM_STATE_GET_DATA,
  ACSLINE_COMM_STATE_GET_INF,
  ACSLINE_COMM_STATE_GET_DLL,
  ACSLINE_COMM_STATE_GET_RDI,
  ACSLINE_COMM_STATE_GET_CRC,
};


#define ACS_CMD_CRC_NUM_SIZE      	1
#define ACS_CMD_START_SIZE        	4
#define ACS_CMD_END_SIZE          	6


#endif


