📄 iic.h
字号:
#define IIC_READ 0XA1 //定义读指令
#define IIC_WRITE 0XA0 //定义写指令
#define NOP _nop_()
#define uchar unsigned char
#define uint unsigned int
#include "reg52.h"
#define IIC_READ 0XA1 //定义读指令
#define IIC_WRITE 0XA0 //定义写指令
#define NOP _nop_()
extern uchar readbyteseq(uint add,uchar *ptr,uint readlen);
extern uchar writebyteseq(uint add,uchar *ptr,uint writelen);
extern void delay10ms(void);
//#define SDA INT0
//#define SCL T0
//==============================
uchar xdata buff[2000]; //save the byte read out form iic device in test operation
uchar xdata readbuff[232];//测试数组,暂存写入读出数据
//uchar writebuff[32];
//===============================
sbit SDA=P3^5;//P2^7; //THE SDA BIT IS PORT 2 BIT 7
sbit SCL=P3^4;//P2^6; //THE SCL BIT IS PORT 2 BIT 6
sbit SEN=P3^3;//P2^6; //THE SCL BIT IS PORT 2 BIT 6
sbit STE=P3^2;//P2^6; //THE SCL BIT IS PORT 2 BIT 6
uchar bdata bbyte;//定义位操作用数组,采用此方法可提高位操作速度
sbit a0=bbyte^0;
sbit a1=bbyte^1;
sbit a2=bbyte^2;
sbit a3=bbyte^3;
sbit a4=bbyte^4;
sbit a5=bbyte^5;
sbit a6=bbyte^6;
sbit a7=bbyte^7;
//========================================
bit IFACK; //record the SDA state to confirn if ACK has happened
bit NO_ACK; //no ack flag
bit BUS_FAULT; //bus fault flag
//========================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -