⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t2i2c.h

📁 M3355的源代码
💻 H
字号:
/********************************************************************
// file TI2Cio.h													//
//	 TI2C IO read/write routine										//
// author:lby														//
//																	//
// date:2001-11-22													//
// 																	//
// 2001-11-24: the read/write cycle and data style is error,fix it	//
//	modify by Victor .	data 2001/12/11.															//
*********************************************************************/

#ifndef TI2CIO_H
#define TI2CIO_H
/*
typedef unsigned char	UINT8;
typedef short			INT16;
typedef unsigned short	UINT16;
typedef int				INT32;
typedef unsigned int	UINT32;
*/
typedef	INT32			STATUS;

#define SUCESS			0

#define IOBASE 0xb8000000

/* M6303 I2C register */
#define TI2C_HCR		0x1800
#define TI2C_HSR		0x1801
#define	TI2C_IER		0x1802
#define TI2C_ISR		0x1803
#define TI2C_SAR		0x1804
#define	TI2C_SSAR		0x1805
#define	TI2C_HPCC		0x1806
#define	TI2C_LPCC		0x1807
#define	TI2C_PSUR		0x1808
#define	TI2C_PHDR		0x1809
#define	TI2C_RSUR		0x180a
#define	TI2C_SHDR		0x180b
#define TI2C_FCR		0x180c
#define	TI2C_FDR		0x1810

#define	HCR_HCE			0x80	// Host Control Enable
#define HCR_HCD			0x00	//	Host Control disable
#define	HCR_CP			0x0E	// Command Protocol
#define	HCR_ST			0x01	// Start Transaction

#define	HCR_CP_WRITE	0x00	// write
#define	HCR_CP_READ		0x04	// current address read
#define	HCR_CP_SEQREAD	0x08	// sequential read
#define	HCR_CP_SR		0x0c	// stand read


// For TI2C_HSR
#define	HSR_FE		0x01	// FIFO Empty
#define	HSR_FF		0x02	// FIFO Full
#define	HSR_FU		0x04	// FIFO Underrun
#define	HSR_FO		0x08	// FIFO Overrun
#define	HSR_FER		0x10	// FIFO Error
#define	HSR_HB		0x20	// Host Busy
#define	HSR_DNE		0x40	// Device Not Exist
#define	HSR_DB		0x80	// Device Busy

// For TI2C_IER
#define	IER_IE		0x01	// Interrupt Enable

// For TI2C_ISR
#define	ISR_TDI		0x01	// Transaction Done Interrupt

// For TI2C_FCR
#define	FCR_FLUSH	0x80	// FIFO Flush
#define	FCR_BC		0x2F	// Byte Count



UINT8 T2I2CRegRead(UINT32 offset);
void T2I2CRegWrite(UINT32 offset,UINT8 value);
void T2I2CRegWriteD(UINT32 offset,UINT32 value);
UINT32 T2I2CRegReadD(UINT32 offset);
void ReadAllReg();

void	InitTI2C(void);

STATUS	T2I2CDevBusy(void);
STATUS	T2I2CDevNotExist(void);
STATUS	T2I2CHostBusy(void);

STATUS	T2I2CTransDone(void);
STATUS	WaitT2I2CIdle(void);
STATUS	WaiteT2I2CTransDone(void);

STATUS	T2I2CCurReadFIFO(UINT8 *TargetDataPtr);
STATUS	T2I2CReadFIFO(UINT16 trposition,UINT8 trlen,UINT8 *TargetDataPtr);
STATUS	T2I2CWriteFIFO(UINT16 twposition,UINT8 twlen,UINT8 *tSourceDataPtr);

#endif /* #ifudef TI2CIO_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -