Personal tools

Log in

Changes

From IGEP - ISEE Wiki

Jump to: navigation, search

How to use I2C

876 bytes added, 18:53, 16 January 2012
no edit summary
Download '''(upload source code)''' and extract it.
There are a some interesting things that it is interesting knowlearn, open source before compiling the program. Open '''(main program)''' and seek next lines: <br>
<pre>//1==enabled 0==disable
#define FORCE 1
//Address DVI Standard: 0x50
#define ADDRESS 0x50</pre>
Constant FORCE is defined to allow this program acces to I2c, although other program use this one. It can be dangerous in writing operations but in this cause don't have sense no use it.<br>
 
Constant ADDRESS is defined to acces in specific I2C address, in DVI devices 0x50 is default address, that means that same bus can be connected with more peripherals.
 
See the code below:<br>
<pre>for (i=0;i&lt;=255;i++)
{
edidint[i]=i2c_smbus_read_byte_data(fd,i);
if (edidint[i]&lt;0)
{
printf("Error:read failed\n");
return -1;
}
} </pre>
The program uses i2c_smbus_read_byte_data to get information from display, "i" variable is the EEPROM address, EEPROM (Slave) reads address and after EEPROM send value to Omap (Master).
 
More information about [[Peripherals_Summary|I2C]].
 
<br> <br>
 
Compile program using your Cross Compiler, i used arm-linux-gnueabi-:
<pre>arm-linux-gnueabi-gcc parse-edid-beta2.c -o parse-edid-beta2</pre>
4,199
edits