Seems there is an experimental kernel driver for this chip under misc
sensors in the kernel tree. might look there and use that.
Eric
Seems there is an experimental kernel driver for this chip under misc
sensors in the kernel tree. might look there and use that.
Eric
I believe that 8574-specific driver is deprecated, and the gpio-based replacement is bit-level only. Anyway, it isn't necessary. You can use the basic i2c drivers. I use something like this to communicate with 8574 devices:
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <glib.h>
#define I2C_BUS "/dev/i2c-3"
gboolean write_error_flagged;
gboolean read_error_flagged;
void I2C_Write(gulong address, guchar value)
{
struct i2c_smbus_ioctl_data argswrite;
argswrite.read_write = I2C_SMBUS_WRITE;
argswrite.size = I2C_SMBUS_BYTE;
argswrite.data = NULL;
argswrite.command = value;
int device = open(I2C_BUS, O_RDWR);
if ((device == -1) && !write_error_flagged) {
write_error_flagged = TRUE;
g_print_debug("ERROR: could not open I2C bus %s for writing\n", I2C_BUS);
return;
}
ioctl(device, I2C_SLAVE, address);
ioctl(device, I2C_SMBUS, &argswrite);
close(device);
}
guchar I2C_Read(gulong address)
{
union i2c_smbus_data data;
struct i2c_smbus_ioctl_data argsread;
argsread.read_write = I2C_SMBUS_READ;
argsread.size = I2C_SMBUS_BYTE;
argsread.data = &data;
argsread.command = 0;
int device = open(I2C_BUS, O_RDWR);
if ((device == -1) && !read_error_flagged) {
read_error_flagged = TRUE;
g_print_debug("ERROR: could not open I2C bus %s for reading\n", I2C_BUS);
return 0;
}
ioctl(device, I2C_SLAVE, address);
ioctl(device, I2C_SMBUS, &argsread);
close(device);
return data.byte;
}