Guest User

Untitled

a guest
Dec 25th, 2012
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. bit IIC_writeByte(unsigned char uchData)
  2. {
  3.     unsigned char x = 0;
  4.     bit bAck = 0;
  5.  
  6.     while(x < 8)
  7.     {
  8.     SCL=0;
  9.         wait5us();
  10.         SDA=(uchData & AND_MASK)>>7;
  11.         uchData=uchData<<1;
  12.         SCL=1
  13.         wait5us();
  14.         x++;
  15.   }
  16.     bAck=SDA;
  17.    
  18.     return(bAck);
  19. }
  20.  
  21.  
  22. -----
  23.  
  24. unsigned int IIC_read_byte(bit bAck)
  25. {
  26.     unsigned char x = 0;
  27.     unsigned char uchData = 0;
  28.    
  29.     while(x < 8)
  30.     {
  31.     uchData = (uchData<<1) | (unsigned char)SDA;
  32.        
  33.   }
  34.     SDA=bAck;
  35.    
  36.     return(uchData);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment