#ifndef	__TWI_MODULE_H
#define	__TWI_MODULE_H

#define TWI_Hardware_Module	
#ifdef TWI_Hardware_Module
#define TWI_FREQ_KHz    100 //(KHz)  //ÇëÊäÈë10-400KHzÍ¨Ñ¶ÆµÂÊ

#define TWIBR1  (24000/TWI_FREQ_KHz -16)/2
#define TWIBR2  (24000/TWI_FREQ_KHz -16)/8
#define TWIBR3  (24000/TWI_FREQ_KHz -16)/32
#define TWIBR4  (24000/TWI_FREQ_KHz -16)/128

#define TWI_ADDR_1B		0
#define TWI_ADDR_2B		1

#define TWI_CRC_NO		0
#define TWI_CRC_YES		1

//#define AFE_CHIP_ID		(0x1B<<1)		//AFE_ID
#define HTimeoutChk()	TWITOUT |= 0xc0; TWISTA |=0x01; TWICON |=0X01;
extern U8 CRC8cal(U8 *p, U8 counter);
extern BOOL TwiWrite(U8 SlaveID, U16 WrAddr, U8 AddrType, U8 Length, U8 CrcFlg, U8 xdata *WrBuf);
extern BOOL TwiRead(U8 SlaveID, U16 RdAddr, U8 AddrType, U8 Length, U8 CrcFlg, U8 xdata *RdBuf);
extern void TwiInit(void);

#endif
#endif
