[Voyage-linux] ALIX.2D2 and I2C EEPROM
John Coltrane
(spam-protected)
Wed May 2 17:15:38 HKT 2012
Hello Markus,
1. does /dev/i2c-0 exist ?
2. what are it's permissions ?
3. has the user you try to run your software permissions to write to
/dev/i2c-0 ?
cheers, John
On 05/01/2012 01:26 PM, Markus Cords wrote:
> Hello,
>
> I have a ALIX 2D2 Board with Voyage 0.8.
> My Problem is to access the I2C EEPROM (externel) with my programm.
>
> root at voyage:/tmp# i2cdetect -y 0
> 0 1 2 3 4 5 6 7 8 9 a b c d e f
> 00: -- -- -- -- -- -- -- -- -- -- -- -- --
> 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 40: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- --
> 50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 70: -- -- -- -- -- -- -- --
> root at voyage:/tmp#
>
>
> The Address of the eeprom is 0x50
>
>
> with my programm:
> root at voyage:/tmp# ./main
> Failed to write to the i2c bus.
>
>
> [code]
>
> #include <errno.h>
> #include <string.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <linux/i2c-dev.h>
> #include <sys/ioctl.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
>
> void main(void) {
> int file;
> char *filename = "/dev/i2c-0";
> if((file = open(filename, O_RDWR)) < 0)
> {
> perror("Failed to open the i2c bus");
> exit(1);
> }
>
> int addr = 0x50;
> if (ioctl(file, I2C_SLAVE, addr) < 0) {
> printf("Failed to acquire bus access and/or talk to slave.\n");
> exit(1);
> }
> char buf[10] = {0};
>
> buf[0] = 0x00;
> buf[1] = 0xAA;
> if(write(file, buf, 2) != 1)
> {
> printf("Failed to write to the i2c bus.\n");
> printf("\n\n");
> }
> }
> [/code]
>
> I hope anybody can help me.
>
> Thanks,
> Markus
>
> _______________________________________________
> Voyage-linux mailing list
> Voyage-linux at list.voyage.hk
> http://list.voyage.hk/mailman/listinfo/voyage-linux
More information about the Voyage-linux
mailing list