2010-01-28 03:11:06     Writing I2C in userspace

Document created by Aaronwu Employee on Aug 20, 2013
Version 1Show Document
  • View in full screen mode

2010-01-28 03:11:06     Writing I2C in userspace

Patrick Hotz (GERMANY)

Message: 85217   




i want to write a programm in eclipse which is using i2c-0 char-device....


This is a code-snippet:


/* Open I2C Device */

    file = open_i2c_dev(1, "/dev/i2c-", 0);

    if (file < 0 || set_slave_addr(file, 0x48, 0))





My problem is that i can´t compile my programm in eclipse brcause the function "open_i2c_dev", "i2c_smbus_write_byte" and the other i2c-functions aren´t known.....



If i compile the programm as a part of the userspace programms, there is no problem.....




Is there a howto or a example how can i use eclipse to develop the programm?




Best regards,





2010-01-28 03:33:04     Re: Writing I2C in userspace

Mike Frysinger (UNITED STATES)

Message: 85253   


the uclinux-dist build process shows you the exact compile commands it runs.  figure out what -I paths are being used there and add them to your eclipse setup.


you can run specific subdirs by doing:

make user/foo_clean

make user/foo_only




2010-01-29 06:50:08     Re: Writing I2C in userspace

Rob Maris (GERMANY)

Message: 85322   


I got it compiled outside of the linux build environment without errors via this include:


#include "linux/i2c-dev.h"


while having copied the .h file from the distribution to the project local directory.