int main (void) { Init(); i2c_Open(0x7C, 0); I2CLcdInit(); while(1) { i2c_SendByte(0xC0); i2c_PutString("test", 4); i2c_SendByte(0xC0); } return 0; }
/** * Perform continuous reading accesses on I2C buses. * @param[in] threadData data needed for I2C processing. */ static void tatl06_03I2C_Process(void *threadData) { DTH_I2C_PROCESS_DATA *i2cData ; int vl_error = 0; int fd = 0; int count = 1; char buf[1024]; i2cData = (DTH_I2C_PROCESS_DATA *) threadData ; memset(buf, 0, 1024); if (strcmp(i2cData->deviceName, I2C3_DEVICE_NAME) == 0) { /* on 8520 no I2C3. Need to check board type */ fd = open("/sys/devices/platform/ab8505-i2c.0/ab8500-usb.0/boot_time_device",O_RDWR); if (fd<0){ /* board 8500 */ count = 6; } else { /* board 8520 : just need to return OK*/ close (fd); while (i2cData->order == START) { i2cData->state = ACTIVATED ; i2cData->error = NO_ERROR ; usleep(1000); } i2cData->state = DEACTIVATED ; pthread_exit(NULL); } } buf[0] = i2cData->registerAddress ; /* register address to be read. */ i2cData->state = ACTIVATED ; fd = i2c_Open(i2cData->deviceName, O_RDWR); if (fd < 0) { i2cData->error = I2cOpenError ; i2cData->state = DEACTIVATED ; pthread_exit(NULL); } if (i2cData->order == START) printf("dev=%s slave_addr=%x reg_addr=%x count=%d\n", i2cData->deviceName, i2cData->deviceAddress, i2cData->registerAddress, count); while (i2cData->order == START) { vl_error = i2c_Read(fd, i2cData->deviceAddress, buf, count); if (vl_error < 0) { i2c_Close(fd); i2cData->error = I2cReadError ; i2cData->state = DEACTIVATED ; pthread_exit(NULL); } i2cData->error = NO_ERROR ; usleep(1000); } i2c_Close(fd); i2cData->error = NO_ERROR ; i2cData->state = DEACTIVATED ; pthread_exit(NULL); }