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

📄 i2c_bus.h

📁 T112 MCU源程码,用于T112外接MCU篇程,用来驱动模拟屏
💻 H
字号:
#ifndef  __I2C_BUS_H__
#define  __I2C_BUS_H__

#define COPY
#define TW_SLOW_SPEED

#define   	uchar  				unsigned char 
#define   	uCHAR  				unsigned char     	
//#define   	uint   				unsigned int 
//#define		uWORD				unsigned short

#ifdef	COPY
	sbit	SDA = P1^7; 
	sbit    SCL = P1^6; 
	
	#define Set_SDA_High  SDA = 1,SDA = 1
	#define Set_SDA_Low   SDA = 0,SDA = 0
	#define Set_SCL_High  SCL = 1,SCL = 1
	#define Set_SCL_Low   SCL = 0,SCL = 0
	
	#define SDA_High      SDA!=0
	#define SDA_Low       SDA==0
	#define SCL_High      SCL!=0
	#define SCL_Low       SCL==0
	
	#define	TWD_SPEED       0x01		//value: 1 (Fastest), 2 (slower), ... N (much slower)
	#define	TWD_LONG_TIME	(TWD_SPEED*8)
	#define	TWD_SHORT_TIME	(TWD_SPEED*1)

	#ifdef	TW_SLOW_SPEED	
		uCHAR Send_Byte1(uCHAR cData);
		uCHAR Read_Byte(uCHAR cNum);
	#else
		uCHAR Read_Byte(void);
	#endif
	void StartCondition(void);
	void StopCondition(void);
	uCHAR Send_Byte(uCHAR cData);
	uCHAR I2CReadByte(uCHAR cDevAddr, uCHAR cReg);
	uCHAR I2CWriteByte(uCHAR cDevAddr, uCHAR cReg, uCHAR cData);
	uCHAR I2CWriteByte1(uCHAR cDevAddr, uCHAR cReg, uCHAR cData);
#else
	sbit	P_SCK=P1^6;
	sbit	P_SDA=P1^7;

	void	Start_I2C(void);
	void	Stop_I2C(void);
	void	WByte_I2C(uchar value);
	uCHAR I2C_RByte(void);
	uCHAR I2CReadByte(uCHAR cDevAddr, uCHAR cReg);
	void I2CWriteByte(uCHAR cDevAddr, uCHAR cReg, uCHAR cData);
#endif

#endif

⌨️ 快捷键说明

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