[Voyage-linux] ALIX.2D2 and I2C EEPROM
Markus Cords
(spam-protected)
Tue May 1 19:26:00 HKT 2012
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
More information about the Voyage-linux
mailing list