Quantcast
Channel: Intel Communities: Message List
Viewing all articles
Browse latest Browse all 17366

i2c directly under Yocto

$
0
0

Hi,

 

I'm trying to use an Adafruit Oled display directly under Yocto (1.0.0.7 compiled with dev tools).

 

I know that I plugged the screen correctly cause I was able to run the adafruit sketche sample (with some modifications) through the arduino IDE.

 

I guess I'm using the standard method under Yocto:

 

modprobe i2c-dev

chmod 666 /dev/i2c*

 

Then in my C file:

 

#define addr 0x3D

void send_command(int i2c, unsigned char command){
        unsigned char buf[10];        unsigned char control = 0x00;        buf[0] = control;        buf[1] = command;        buf[0] = control;        if (i2c_smbus_write_byte(i2c,control) == -1) {                printf("Failed to write to the i2c control.\n");        }        usleep(10000);        buf[0] = command;        if (i2c_smbus_write_byte(i2c,command) == -1) {                printf("Failed to write to the i2c command.\n");                perror("write data fail\n");        }        usleep(10000);
}

int main(int argc, char* argv[]){
        printf("Begin of program...\n");        int i2c, reset;        char *filename = "/dev/i2c-0";        if ((i2c = 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);        }        usleep(10000);        if (ioctl(i2c, I2C_SLAVE_FORCE, addr) < 0) {                printf("Failed to acquire bus access and/or talk to slave.\n");                exit(1);        }        usleep(10000);        send_command(i2c, 0xae);          return 0;
}

 

Now, when I run this code, I end up with:

Failed to write to the i2c control.

Failed to write to the i2c command.

write data fail

: Remote I/O error

I also downloaded i2c tools and I can't use i2cset or i2cget:

galileo# i2cget -y 0 0x3D
Error: Read failed

 

The address (0x3D) seems fine cause it's the same as the one used in the adafruit arduino scketche and the :

(ioctl(i2c, I2C_SLAVE_FORCE, addr) 

doesn't fail.

 

So have you ever seen this problem ? I hope it doesn't come from the i2c driver...

 

Thanks.

 

Cedric


Viewing all articles
Browse latest Browse all 17366

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>