From: silex <mer...@gm...> - 2011-12-03 18:22:45
|
Hello, I have Gumstix Overo, with 2.6.35 kernel on it.. I need to achieve communication with Sparkfun IMU3000 Accelerometer&Gyro. I had spent so much hours on it, but i could not succeed on using "ioctl" function, i need your help. I can open i2c-3 port without any problem. But, after running (ioctl(fh, I2C_SLAVE,GYRO_W) function ,as i used at the below, i get this error: "ioctl: Invalid Argument" I have realized that, if i write 7 bits of data to the address of slave device, i dont get any errors. But all of my r/w slave address bits are 8 bit, so how can i use ioctl without problem?? Here is the code; #include <stdint.h> #include <stdio.h> #include <fcntl.h> #include <linux/i2c-dev.h> #include <linux/i2c.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <errno.h> //addresses of imu #define GYRO_W 0xD0 #define GYRO_R 0XD1 #define ACC_W 0xA6 #define ACC_R 0xA7 int main(void) { int fh; char buff[16]; fh=open("/dev/i2c-3",O_RDWR); if (fh < 0) { perror("open"); return 1; } if (ioctl(fh, I2C_SLAVE,GYRO_W) < 0) { perror("ioctl"); return 1; } //rest of code.. not important for now.. return 0; } -- View this message in context: http://gumstix.8.n6.nabble.com/I2C-Problem-For-a-Newbie-tp891074p891074.html Sent from the Gumstix mailing list archive at Nabble.com. |