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

📄 i2c.h

📁 T103的开发程序 能兼容很多屏 可根据需要修改定义
💻 H
字号:
#ifndef __TW_I2C_H__
#define __TW_I2C_H__

#define uCHAR unsigned char

#ifndef	TWO_TW_BUS
sbit	SDA = P1^6;  //P0^0;
sbit    SCL = P1^5; //P0^1;
sbit bSDA_MSB=ACC^7;
//sbit 	SDA = P0^6;
//sbit    SCL = P0^5;

#define Set_SDA2High  SDA = 1
#define Set_SDA2Low   SDA = 0
#define Set_SCL2High  SCL = 1
#define Set_SCL2Low   SCL = 0

#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 Set_SDA_High  SDA = 1
#define Set_SDA_Low   SDA = 0
#define Set_SCL_High  SCL = 1
#define Set_SCL_Low   SCL = 0
#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

#else	//define TWO_TW_BUS
static	bit gbTwBusSel = 1;
sbit    SDA1  = P1^6;
sbit    SCL1  = P1^5;
sbit    SDA2  = P1^4;	  // none conn 
sbit    SCL2  = P1^3;	  // none conn

#define Set_SDA_High  (gbTwBusSel) ? (SDA1 = 1) : (SDA2 = 1)
#define Set_SDA_Low   (gbTwBusSel) ? (SDA1 = 0) : (SDA2 = 0)
#define Set_SCL_High  (gbTwBusSel) ? (SCL1 = 1) : (SCL2 = 1)
#define Set_SCL_Low   (gbTwBusSel) ? (SCL1 = 0) : (SCL2 = 0)
#define SDA_High      (gbTwBusSel) ? (SDA1!=0 ) : (SDA2!=0 )
#define SDA_Low       (gbTwBusSel) ? (SDA1==0 ) : (SDA2==0 )
#define SCL_High      (gbTwBusSel) ? (SCL1!=0 ) : (SCL2!=0 )
#define SCL_Low       (gbTwBusSel) ? (SCL1==0 ) : (SCL2==0 )



#endif

#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)



void StartCondition(void);
void StopCondition(void);
uCHAR Send_Byte(uCHAR cData);
uCHAR Read_Byte(uCHAR cData);
//uCHAR twdWr_Burst_A(uCHAR cReg);
void twdWr_Burst_D(uCHAR cData);
//void twdWr_Burst_P(void);

#endif

⌨️ 快捷键说明

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