i2c.h

来自「USB固件驱动,ISP1581评估板的MPEG方案源码」· C头文件 代码 · 共 99 行

H
99
字号
/*
   //*************************************************************************
   //
   //                  P H I L I P S   P R O P R I E T A R Y
   //
   //           COPYRIGHT (c)   1999 BY PHILIPS SINGAPORE.
   //                     --  ALL RIGHTS RESERVED  --
   //
   // File Name:	    Hal4I2C.H
   // Author:           Xia Huiyuan
   // Created:			25 Jan.2002
   // Modified:
   // Revision:		    0.0
   //
   //*************************************************************************
   //
   //*************************************************************************
   */
#define	SAA6752_ADDR	0x40 //0x40, Write; read adderss(0x41),
#define SAA7114_ADDR    0x42 //0x42, Write; read adderss(0x43). 
#define EEPROM_ADDR		0xA8 

//#undef WORK_AT_FS_MODE
//#define  WORK_AT_ST_MODE

#define WORK_AT_FS_MODE
#undef  WORK_AT_ST_MODE

#define I2C_ERROR   1
#define I2C_OK      0


typedef union I2C_FLAG
{
	struct I2C_FLAG_BITS
	{


	UC	WRITESTARTING		:	1,
		WRITEENDING			:	1,
		DATAPHASE			:	1,
		READSTARTING		:	1,
		READENDING			:	1,
		ACKASSERT			:	1,
		RESERVED1			:	1,
		RESERVED2			:	1;

	}BITS;

	UC	VALUE;

}I2C_FLAG;





/* ------------------------------------------------------------------------- */
/* Function  : Hal4I2C_MasterWrite						     */
/* Depiction :								     */
/*   Host sends datas to I2C device					     */
/* Input     :								     */
/*   bSlaveAddress : I2C device slave address including W bit		     */
/*   bLength : the length of data will be transmitted to I2C device	     */
/*   pDataBuffer : pointer to data buffer which will be transmitted to I2C   */
/*		   device						     */
/* Output    :								     */
/*   0	   : Transmitted OK						     */
/*   Not 0 : Transmitted Error						     */
/* ------------------------------------------------------------------------- */
bit Hal4I2C_Write(UC);
/* ------------------------------------------------------------------------- */
/* Function  : Hal4I2C_MasterRead						     */
/* Depiction :								     */
/*   Host receives datas from I2C device				     */
/* Input     :								     */
/*   bSlaveAddress : I2C device slave address including R bit		     */
/*   bLength : the length of data will be received from I2C device	     */
/*   pDataBuffer : pointer to data buffer which will be received from  I2C   */
/*		   device						     */
/* Output	 :							     */
/*   0	       : Received OK						     */
/*   Not 0 : Received Error						     */
/* ------------------------------------------------------------------------- */
bit Hal4I2C_Read(UC);
/* ------------------------------------------------------------------------- */
/* Supporting functions */
/* ------------------------------------------------------------------------- */
bit Hal4I2Csup_SCLHigh(void);
void Hal4I2Csup_StartCond(void);
void Hal4I2Csup_StopCond(void);
bit Hal4I2Csup_Send(UC);
bit Hal4I2Csup_Receive(UC,UC);
void Hal4Sys_Wait4US(void);
void Hal4Sys_Wait1US(void);
bit Hal4I2C_ContinualWrite(UC);
bit Hal4I2C_ContinualRead(UC);

⌨️ 快捷键说明

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