示例#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
void configIIC(void){
  IIC_Start();
  IIC_write_byte(0x3C);
  IIC_write_byte(0x02);
  IIC_write_byte(0x00);
  IIC_Stop(TRUE);
  
}
示例#3
0
void 
iic2402_write(uint8 address, uint8 byte)
{
   IIC_start();
   IIC_write_byte(0xa0);
   IIC_tack();
   IIC_write_byte(address);
   IIC_tack();
   IIC_write_byte(byte);
   IIC_tack();
   IIC_stop();
   delay();
}
示例#4
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;
}