Hi all,
I have a beagleboard-xM Rev.C on to which dvsdk-4.01 is ported. im interfacing a ADV7403 ic with DM3730 processor via I2C-2 which is on DM3730. in order to test the i2c communication of adv7403 and beagleboard i wrote a simple program which reads the value stored in reg.address 0x11 and the address of device is 0x42.
i have pasted the code for i2c communication and makefile below.
code for i2c:-
#include <stdio.h>
#include <linux/i2c-dev.h>
#include <linux/i2c.h>
#include <linux/glib.h>
#include <linux/gprintf.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define REG_IDENT 0x11
main(void)
{
int file, val,i;
char *filename = "/dev/i2c-2";
char addr= 0x42;
while(1)
{
sprintf(filename,"/dev/i2c-2");
if ((file = open(filename, O_RDWR)) < 0) {
/* ERROR HANDLING: you can check errno to see what went wrong */
perror("Failed to open the i2c bus");
exit(1);
}
if (ioctl(file, I2C_SLAVE, addr) < 0) {
printf("Failed to acquire bus access and/or talk to slave.\n");
/* ERROR HANDLING; you can check errno to see what went wrong */
exit(1);
}
val = i2c_smbus_read_byte_data(file, REG_IDENT);
printf("device_id = %d\n",val);
for(i=0;i<1000;i++);
}
}
Makefile:-
include $ /home/edcn400/ti-dvsdk_dm3730-evm_4_01_00_09/Rules.make
adv_i2c:
$(CSTOOL_PREFIX)gcc adv_i2c.c -o adv_i2c
when i compile it in the terminal i get the following error
Error:-
root@edcn400-desktop:/home/edcn400/Desktop/i2c# make
/home/edcn400/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-gcc adv_i2c.c -o adv_i2c
adv_i2c.c:4:24: error: linux/glib.h: No such file or directory
adv_i2c.c:5:27: error: linux/gprintf.h: No such file or directory
make: *** [adv_i2c] Error 1
root@edcn400-desktop:/home/edcn400/Desktop/i2c#
how do i solve this problem.?
thanking you,
Shravan Kulkarni