#ifndef	__MEMORY_H
#define	__MEMORY_H

#define STACK_ADDR	0xA0

//*****************************DATA MEMORY START***************************//
extern U8 idata STACK[];		//堆栈

//*****************************BIT MEMORY START***************************//
extern U16  bdata uiPackConfig;				
extern BOOL bCellNum1;
extern BOOL bCellNum2;
extern BOOL bCellNum3;
extern BOOL bLEDNum0;
extern BOOL bLEDNum1;
extern BOOL bTempNum;
extern BOOL bLoadLock;
extern BOOL bChgerLock;
extern BOOL bOV_EN;
extern BOOL bSC_EN;
extern BOOL bOCRC_EN;
extern BOOL bBAL_EN;
extern BOOL bCTO_EN;
extern BOOL bEnEEPRomBK;

extern U16  bdata uiPackStatus;				
extern BOOL bCHGMOS;					   //chgmos flag
extern BOOL bDSGMOS;					   //dsgmos flag
extern BOOL bCHGING;				       //charge status flag means connect to charger
extern BOOL bDSGING;				       //discharge status flag means disconnect to charger 
extern BOOL bSlowDischarge;			   	   //charge PWM ratio is max
extern BOOL bMidDischarge;			  	   //charge PWM ratio is max
extern BOOL bFastDischarge;			  	   //charge PWM ratio is min

extern U16  bdata uiBatStatus;
extern BOOL bOV;
extern BOOL bUV;
extern BOOL bFC;
extern BOOL bFD;
extern BOOL bVDQ;

extern BOOL bOCC;
extern BOOL bOCD1;
extern BOOL bOCD2;
extern BOOL bOTC;
extern BOOL bOTD;
extern BOOL bUTC;
extern BOOL bUTD;

//ALARM
extern BOOL	bAFE_SC;
extern BOOL	bAFE_OV;
extern BOOL	bAFE_WDT;
extern BOOL	bAFE_TWI;
extern BOOL	bAFE_POR;
extern BOOL	bAFE_ODD_ERR;
extern BOOL	bAFE_RST;
extern BOOL	bAFE_VADC;
extern BOOL	bCTO;

extern U8 bdata ucAFEStatus;
extern BOOL	bAfeChger;
extern BOOL	bAfeLoad;
extern BOOL	bAfeChging;
extern BOOL	bAfeDsging;
extern BOOL	bAfeCHG;
extern BOOL	bAfeDSG;

/**************************************************************************************/
//DataFlash中区块地址定义
/**************************************************************************************/
//系统信息区开始 SubClassID=0x00		langth=48
extern U16 xdata 	E2uiPackConfigMap;
extern U16 xdata	E2uiVOC[10];
extern U32 xdata	E2ulDesignCapacity;
extern U16 xdata	E2Reserve;
extern S16 xdata	E2siDfilterCur;
extern U8  xdata	E2ucLowPowerDeley;
extern U8  xdata	E2ucChgBKDelay;
extern S16 xdata	E2siChgBKCur;
extern U8  xdata	E2ucRTCBKDelay;
extern U8  xdata	E2ucRamCheckFlg0;

//用户自定义参数区开始 SubClassID=0x01	langth=50
extern U16 xdata	E2uiSWVersion;
extern U16 xdata	E2uiHWVersion;
extern U8  xdata	E2ucID;
extern U8  xdata	E2ucMNFName[12];
extern U32 xdata	E2ulMNFDate;
extern U16 xdata	E2uiSerialNum;
extern U8  xdata	E2ucDeviceName[12];
extern U8  xdata	E2ucDeviceChem[12];
extern U16 xdata	E2uiChemID;
extern U8  xdata	E2ucRamCheckFlg1;

//充电参数区开始 SubClassID=0x02		langth=18		
extern U16 xdata  	E2uiOVvol;
extern U16 xdata  	E2uiOVRvol;
extern U8  xdata  	E2ucOVDelay;
extern U8  xdata  	E2ucOVRDelay;
extern U16 xdata  	E2uiChgEndVol0;
extern S16 xdata	E2siChgEndCurr0;
extern U8  xdata	E2ucChgEndDelay0;
extern S32 xdata	E2slOCCCurrent;
extern U8  xdata   	E2ucOCCDelay;
extern U8  xdata  	E2ucOCCRDelay;
extern U8  xdata	E2ucRamCheckFlg2;

//放电参数区开始 SubClassID=0x03		langth=21
extern U16 xdata  	E2uiUVvol;
extern U16 xdata  	E2uiUVRvol;
extern U8  xdata  	E2ucUVDelay;
extern U8  xdata  	E2ucUVRDelay;
extern U8  xdata  	E2ucDsgEndDelay0;
extern U16 xdata  	E2uiDsgEndVol0;
extern S32 xdata	E2slOCD1Current;
extern U8  xdata	E2ucOCD1Delay;
extern S32 xdata	E2slOCD2Current;
extern U8  xdata	E2ucOCD2Delay;
extern U8  xdata	E2ucLoadRDelay;
extern U8  xdata	E2ucRamCheckFlg3;

//预留参数区开始 SubClassID=0x04
//Reserved

//放电PWM参数区开始 SubClassID=0x05		langth=5
extern U16 xdata 	E2uiDSG1PWMFreq;
extern U8  xdata  	E2ucDSG1PWMRatioL;
extern U8  xdata  	E2ucDSG1PWMRatioH;
extern U8  xdata	E2ucRamCheckFlg5;

//充电温度保护参数开始 SubClassID=0x06	langth=11
extern U16 xdata  	E2uiTempOTC;
extern U16 xdata  	E2uiTempOTCR;
extern U16 xdata  	E2uiTempOTD;
extern U16 xdata  	E2uiTempOTDR;
extern U8  xdata  	E2ucTempDelay;
extern U8  xdata  	E2ucTempRDelay;
extern U8  xdata	E2ucRamCheckFlg6;

//放电温度保护参数开始 SubClassID=0x07	langth=9
extern U16 xdata  	E2uiTempUTC;
extern U16 xdata  	E2uiTempUTCR;
extern U16 xdata  	E2uiTempUTD;
extern U16 xdata  	E2uiTempUTDR;
extern U8  xdata	E2ucRamCheckFlg7;

//平衡参数区开始 SubClassID=0x08		langth=8
extern U16 xdata	E2uiBalanceVol;
extern U16 xdata	E2uiBalanceVolDiff;
extern S16 xdata	E2siBalCurrent;
extern U8  xdata	E2ucBalanceDelay;
extern U8  xdata	E2ucRamCheckFlg8;

//容量统计参数开始 SubClassID=0x09				length=17
extern U16	xdata	E2uiLearnLowTempe;
extern U8	xdata	E2ucSOC;
extern U32	xdata	E2ulFCC;
extern U32	xdata	E2ulDfRC;
extern U32	xdata	E2ulCycleThreshold;
extern U32	xdata	E2ulCycleThresholdCount;
extern U16	xdata	E2uiCycleCount;
extern S32	xdata	E2slDsgEndCurr;
extern U16      xdata	E2uiLastCCount;
extern U8	xdata	E2ucDsgEndFlg;
extern U8	xdata	E2ucRamCheckFlg9;

//AFE参数区开始 SubClassID=0x0A			langth=4
extern U8  xdata	E2ucAFEProtectConfig;
extern U16 xdata	E2uiAFEOVvol;
extern U8  xdata	E2ucRamCheckFlgA;

//校准参数区开始 SubClassID=0x0B		langth=12
extern U16 xdata 	E2uiVPackGain;
extern S16 xdata 	E2siCadcGain;
extern S16 xdata 	E2siCadcOffset;
extern S16 xdata 	E2siTS0Offset;
extern S16 xdata 	E2siTS1Offset;
extern U8  xdata	E2ucCalibrated;
extern U8  xdata	E2ucRamCheckFlgB;

//DataflashCheck
extern U16 xdata	E2uiCheckFlag;	 		



#endif