#ifndef __IAP_H__
#define __IAP_H__

#include "main.h"
#include "string.h"
#include "stdio.h"
#include "usart.h"



#define Startup_Normal 					((uint32_t)0xBBBBBBBB)	
#define Startup_Update 					((uint32_t)0xAAAAAAAA)	
#define Startup_APP2  					((uint32_t)0x5555BBBB)	
#define Jump_app	  					((uint32_t)0x6666CCCC)	


#define Startup_Reset  					((uint32_t)0x5555AAAA)	
#define StartBytes_IAP  	 			((uint32_t)0xA55A55AA) 
#define EndBytes_IAP    	 			((uint32_t)0x5AA5AA55)

#define ADD_UPDATE_PROG                	((uint32_t)0x8020000)                          
#define Application_Buffer_Addr        	((uint32_t)0x8040000)        

#define StartMode_Addr                	((uint32_t)0x807F07A) 

#define BUFFER_SIZE_length 100           
    
#if 0
#define indexfl   4
#else
#define indexfl   5
#endif

extern int FileLength_IAP;
extern unsigned int all_len;
extern uint8_t buffer[BUFFER_SIZE_length];
extern uint8_t buffer_length[100];
extern uint16_t start_addr;
extern uint8_t YmodemID;
extern uint16_t version[4];
extern uint8_t startFrame[40];
extern uint8_t binName[32] ;
extern uint8_t binLength[10] ;
extern uint8_t binMd5[16] ;
extern uint32_t update_flag;
extern uint16_t packTotalNum;
extern uint16_t packIndex ;

extern int lenindex;
extern uint16_t iapbinMd5[8] ;
void Process_CMD_IAP_Update(void);
void Start_BootLoader(void);
extern uint16_t FileBuffArray[512];
void iap_load_app(uint32_t appxaddr);
extern uint16_t FileBuffArray1[512];
#endif

