文档简介
标签:
的程
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 ……
评论
加载更多
推荐下载
查看更多
精选文集
推荐帖子