I saw that you wrote LM75. Do you have a driver for the LM75?


2006/10/15, John <[EMAIL PROTECTED]>:

  Hi Geert,

here is how it works :

2,6 is default

i2c.c is just a test app look inside it to find out more

also check out http://acmesystems.it/?id=162

- linux-tag--devboard -R2_01 -> 2.4
- linux-2.6-tag--devboard-R2_01 -> 2.6.13 not used
- linux-2.6-tag--devboard-R2_01-1 -> 2.6.15 i added this to the sdk

2.6.13 is installed by axis sdk
the patch add 2.6.16 and sim links it as the default 2.6 kernel

/os/linux-2.6-tag--devboard-R2_01/arch/cris/arch-v10/drivers/i2c is the
2.6 i2c driver for foxboard
/os/linux-tag--devboard-R2_01/arch/cris/drivers/i2c is the i2c driver
for 2.4

here is an example of how to use the driver

#include "stdio.h"
#include "stdlib.h"
#include "unistd.h"
#include "sys/ioctl.h"
#include "fcntl.h"
#include "time.h"
#include "string.h"
#include <asm/etraxi2c.h>

// Global variables
int fd_i2c;

int I2C_Open(void) {
fd_i2c = open("/dev/i2c", O_RDWR);
if (fd_i2c <= 0) {
printf("I2C: open error on /dev/i2c\n");
return(-1);
}

return(0);
}

void I2C_Close(void) {
close(fd_i2c);
}

int main(int argc, char **argv) {
int retcode;

retcode = I2C_Open();
if (retcode != 0) {
exit(1);
}

// write/read 2 bytes to/from i2c slave id 66, that supports no
registers (pcf8575)
I2C_DATA i2cdata;
i2cdata.length = 2;
i2cdata.slave = 66;

i2cdata.data[0] = 0xbe;
i2cdata.data[1] = 0xef;

ioctl(fd_i2c, _IO(ETRAXI2C_IOCTYPE, I2C_WRITEDATA), &i2cdata);
ioctl(fd_i2c, _IO(ETRAXI2C_IOCTYPE, I2C_READDATA), &i2cdata);


// now use a register write 1 byte to register 1 and read it back (lm75)
i2cdata.reg = 1;
i2cdata.length = 1;
i2cdata.slave = 22;
i2cdata.data[0] = 0xdd;
ioctl(fd_i2c, _IO(ETRAXI2C_IOCTYPE, I2C_WRITEREG_N), &i2cdata);
ioctl(fd_i2c, _IO(ETRAXI2C_IOCTYPE, I2C_READREG_N), &i2cdata);

I2C_Close();

return(0);
}

hope it helps :)

any questions ? let me know

bye,
John



--
MfG
Ernst Mayerhofer

Reply via email to