예제 #1
0
void main(void) {
  int i=0;
  EnableInterrupts; /* enable interrupts */
  /* include your code here */
  InitClock();
  IIC1_Init();
  configIIC();
  /*
  IIC_Start();
  IIC_write_byte(0x3D);
  IIC_write_byte(0x03);
  IIC_Stop();    */
  //iic1=IIC_read_byte();
  
  for(;;) {
    IIC_Start();
    IIC_write_byte(0x3C);
    IIC_write_byte(0x03);
    IIC_Stop(FALSE);
    IIC_write_byte(0x3D);
    while(i<6){
      
      iic1=IIC_read_byte();
      i++;
    }
    i=0;
    IIC_Stop(FALSE);
    //__RESET_WATCHDOG(); /* feeds the dog */
  } /* loop forever */
  /* please make sure that you never leave main */
}
예제 #2
0
uint8 
iic2402_read(uint8 address)
{
    uint8 tmp;
    IIC_start();
    IIC_write_byte(0xa0);
    IIC_tack();
    IIC_write_byte(address);
    IIC_tack();
    
    IIC_start();
    IIC_write_byte(0xa1);
    IIC_tack();
    tmp = IIC_read_byte();
    SCL_LOW;
    IIC_notack();
    IIC_stop();
    return tmp;
}