1
votes

I am trying to talk to a Bosch Sensortec BNO055 sensor. I am using the shuttleboard. VDD and VDDIO are connected to 3.3V, on pin 17 and 18 Are SDA and SCL. These connected to a embedded linux board. An other sensor is on the same bus, I can see its values on the scope. I have the following code:

BNO055_RETURN_FUNCTION_TYPE Bno055I2cBusWrite(u8 dev_addr, u8 reg_addr, u8* reg_data, u8 wr_len){
//According to https://www.kernel.org/doc/Documentation/i2c/dev-interface

    int file = 0;
    char filename[20];
    snprintf(filename, 19, "/dev/i2c-%d", ADAPTER_NR);

    if(open(filename, O_RDWR) < 0){ /*error*/   }
    if(ioctl(file, I2C_SLAVE, dev_addr) < 0){ /*error*/ }

    char buf[1 + wr_len];
    buf[0] = reg_addr;
    memcpy(&buf[1], reg_data, wr_len);

    int written_bytes = 0;
    if(write(file, buf, wr_len) != wr_len){
        printf("Error BusWrite-write: %s.\n", strerror(errno));
        exit(-1);
    }
}

The first two if-statements are passed fine. The write-operation fails. On the oscilloscope I see the correct device-address (which is then not acknowledged). What I've done:

My sensor just does not acknowledges when its device address appears on the line.

  • What is exactly done by ioctl(file, I2C_SLAVE, dev_addr)? Does that send out the device-address on the I2C-bus?
  • Does the linuxkernel send the device-address by itself? I expect so.

Resuming:

  • Can someone point me in the right direction to let the sensor react?
1
Hint: What is file in your program, and where is it assigned?glglgl

1 Answers

1
votes

Well... it just seemed that a wire to the scope interfered too much. And the device-address is sent by the driver when writing or reading, to answer my own question.