#include #define uchar unsigned char #define slave 0x02 #define BN 16 uchar idata rbuf[16]; uchar idata tbuf[16]={"master transmit"}; void err(void) {SBUF=0xff; while(TI==0);TI=0; } uchar master(uchar addr,uchar command) {uchar aa,i,pf; while(TI==0);TI=0; while(RI==0);RI=0; if(SBUF!=addr)err(); else{TB8=0; SBUF=command; while(TI==0);TI=0; while(RI==0);RI=0; aa=SBUF; if((aa&0x08)==0x08){TB8=1;err();} else{ if(command==0x01) {if((aa&0x01)==0x01) { do { pf=0; for(i=0;i