#ifndef	__EXT_E2PROM_H
#define	__EXT_E2PROM_H

#define E2PROM_ID				    0xA0

#define E2PROM_SIZE				    0x10000
#define E2PROM_BOOT_ADDR		    0x10000-0x20
#define E2PROM_RTC_ADDR			    0x10000-0x10

#define E2PROM_BKTYPE_CHG_START	    0x10	
#define E2PROM_BKTYPE_CHG_END	    0x01
#define E2PROM_BKTYPE_DSG_END	    0x02

extern BOOL	bE2PProcessFlg;                             //EEPROM处理标志
extern BOOL	bE2PBKDsgEnd;                               //放电结束标志，需要备份信息到外挂EEPROM
extern BOOL	bE2PBKDsgEndValid;
extern BOOL	bE2PBKChgStop;                              //充电结束标志，需要备份信息到外挂EEPROM
extern BOOL	bE2PBKChgStart;                             //充电开始标志，需要备份信息到外挂EEPROM
extern BOOL	bE2PBKRtc;                                  //RTC定时备份标志，需要备份信息到外挂EEPROM
extern BOOL	bE2PErase;                                  //擦除外挂EEPROM标志
extern U8 xdata	bUart0E2PRdData;                                 //读取外挂EEPROM标志
extern U8 xdata	bUart1E2PRdData;                                 //读取外挂EEPROM标志
extern U8 xdata	bUart2E2PRdData;                                 //读取外挂EEPROM标志
extern BOOL	bE2PRErr;                                   //EEPROM访问错误，当读写错误持续5S后置位该标志
extern BOOL	bE2PTwiRWErrFlg;                            //EEPROM读写单次错误
extern U8 xdata bUart0RTCRdTime;                                                //读取RTC时间标志
extern U8 xdata bUart1RTCRdTime;                                                //读取RTC时间标志
extern U8 xdata bUart2RTCRdTime;                                                //读取RTC时间标志
extern BOOL	bDsgToChgFlg;                               //放电转换为充电，需要备份数据
extern BOOL	bChgToDsgFlg;                               //充电转换为放电，需要备份数据
extern U16	xdata	uiE2PDataAddr;
extern U8	xdata	ucE2PTwiRWErrDelayCnt;
extern U8	xdata	ucRTCBKTime1;
extern U16	xdata	uiRTCBKTime2;
extern U8	idata	ucUpDataLimitTime;
extern U16	xdata	uiCHGValidTime;
extern U8	xdata	ucRTCBuf[7];


extern BOOL E2PRomRead(U16 RdAddr, U8 Length, U8 xdata *RdBuf);
extern BOOL E2PRomInit(void);
extern void E2PRomBKProcess(void);
extern void E2PRomBKCheck(void);
extern void E2PRomTwiCheck(void);

#endif