I2C的程序I2C的程序/*VIICC.H*/#pragma db cd small#include #include #define NOP nop ( ); nop ( ); nop ( ); nop ( )#define SDA P1^7#define SCL P1^6void sta( );void cack( );void stop( );void mnack( );void mack( );void wrbyt(uchar shu);void wrnbyta(uchar slaw,uchar gg[],uchar n);void wrnbyt(uchar slaw,uchar ff[],uchar number);uchar rdbyt( );void rdnbyt(uchar slar,uchar qq[],uchar number);源程序由9个函数组成,程序清单如下:voidsta( )/*启动I2C总线*/{SDA=1;SCL=1;NOP;SDA=0;NOP;SCL=0;}void stop( )/*停止I2C总线*/{SDA=0;SCL=1;NOP;SDA=1;NOP;SCL=0;}void mack( )/*发送应答位*/{SDA=0;SCL=1;NOP;SCL=0;SDA=1;}void mnack( )/*发送非应答位*/{SDA=1;SCL=1;NOP;SCL=0;SDA=0;}void cack( )/*应答位检查*/{SDA=1;SCL=1;F0=0;if(SDA==1)F0=1;SCL=0;nop( );}/*向虚拟I2C总线上发送1个数据字节*/void wrbyt(uchar ……
猜您喜欢
推荐内容
开源项目推荐 更多
热门活动
热门器件
用户搜过
随便看看
热门下载
热门文章
热门标签
评论