Пример #1
0
int ad_i2c_init(int op_delay)
{
    int ret;

    if (op_delay >= 0 && op_delay <= AD_I2C_OP_MAX_DELAY) {
        RERRO("ERROR: %s i2c operation delay [%d]", __func__, op_delay);
        ad_i2c_op_delay = op_delay;
    } else
        ad_i2c_op_delay = AD_I2C_OP_DEFAULT_DELAY;

    ad_i2c_fd = open(ad_path, O_RDWR);
    if (ad_i2c_fd < 0) {
        RERRO("ERROR: %s open error (%s)", __func__, strerror(errno));
        return -1;
    }

    ret = ioctl(ad_i2c_fd, AD_ENABLE_CLOCK);
    if(ret) {
        RERRO("ERROR: %s ioctl  ENABLE_CLOCK error (%s)", __func__, strerror(errno));
        return -1;
    }
    close(ad_i2c_fd);
    usleep(ad_i2c_op_delay);

    ad_i2c_sync();

    return ad_i2c_fd;
}
Пример #2
0
int ad_i2c_init(void)
{
    int ret;

    ad_i2c_fd = open(ad_path, O_RDWR);
    if (ad_i2c_fd < 0) {
        ALOGE("%s open error (%s)", __func__, strerror(errno));
        return -1;
    }

    ret = ioctl(ad_i2c_fd, AD_ENABLE_CLOCK);
    if(ret) {
        ALOGE("%s ioctl  ENABLE_CLOCK error (%s)", __func__, strerror(errno));
        return -1;
    }
    close(ad_i2c_fd);

    return ad_i2c_sync();
}