Accessing I2C/SPI under uCLinux

Hi,

I’m new to developing under Linux. I have an I2C chip that I would like to interface with, how do I send data to the chip with uCLinux? I’m trying to access it the same way I access the UARTs, through opening “/dev/I2C-0”, but it gives an error on opening. How exactly do I do this under uCLinux?

I read about writing a chip driver for I2C devices, but wouldn’t that involve recompiling the linux image? If thats the case then I would like to avoid that if possible.

The MCU I’m using is the LPC2468.

Thanks,

Dave

Whats the error? I am not familiar with this platform, but usually in order to use I2C under Linux on other platforms you usually have to make sure the device driver for the I2C controller is loaded, and if you want to use the I2C dev entries you need to make sure the i2c-dev driver is loaded.

Mike

mpanetta:
Whats the error? I am not familiar with this platform, but usually in order to use I2C under Linux on other platforms you usually have to make sure the device driver for the I2C controller is loaded, and if you want to use the I2C dev entries you need to make sure the i2c-dev driver is loaded.

Mike

That’s probably it. How exactly do I load the i2c-dev driver? And how difficult is it to write a device driver? I can’t seem to find a good tutorial for the I2C device drivers from start to finish.

DZZ0615:
That’s probably it. How exactly do I load the i2c-dev driver? And how difficult is it to write a device driver? I can’t seem to find a good tutorial for the I2C device drivers from start to finish.

Usually just do a modprobe i2c-dev I believe. Depends on how your kernel is set up.

As for writing the drivers, I usually just look at the other pre-existing drivers for examples. I2C drivers are fairly simple to write, and there are quite a few examples to work from.

Mike

mpanetta:
As for writing the drivers, I usually just look at the other pre-existing drivers for examples. I2C drivers are fairly simple to write, and there are quite a few examples to work from.

Mike

Thanks for your help, I'll look into the I2C drivers.

One problem that I’ve been having is if I include i2c.h or i2c-dev.h in my program, it would give a lot of errors when compiling. Are there special arguments when compiling a device driver?