How to connect the LSM6DS0 sensor when using a custom board? #sensor #dts #defconfig


Stefan Jaritz
 

Hej

I am failing to get my LSM6DS3(almost LSM6DS0) sensor rightfully setup. Maybe someone can give me a hint.

My system:

LSM6DS3 <--> I2C1 @ stm32F412 <--> Zephyr OS

I created an own board for that. It is configured via myboard_defconfig. I added into that file:

# movement sensor
CONFIG_SENSOR=y
CONFIG_LSM6DS0=y
CONFIG_LSM6DS0_I2C_MASTER_DEV_NAME="LSM6DS3"
CONFIG_LSM6DS0_I2C_ADDR=0x6A

In myboard.dts I added:

&i2c1 {
    status = "ok";
    clock-frequency = <I2C_BITRATE_FAST>;

    lsm6ds0@106 {
        compatible = "st,lsm6ds0";
        reg = <0x6A>;
        label = "LSM6DS3";
    };
};

I am getting following error:

~/zephyr/drivers/sensor/lsm6ds0/lsm6ds0.c:499:25: error: ‘CONFIG_LSM6DS0_I2C_MASTER_DEV_NAME’ undeclared here (not in a function)
  .i2c_master_dev_name = CONFIG_LSM6DS0_I2C_MASTER_DEV_NAME,
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~/zephyr/drivers/sensor/lsm6ds0/lsm6ds0.c:500:20: error: ‘CONFIG_LSM6DS0_I2C_ADDR’ undeclared here (not in a function)
  .i2c_slave_addr = CONFIG_LSM6DS0_I2C_ADDR,
                    ^~~~~~~~~~~~~~~~~~~~~~~
In file included from ~/zephyr/include/sensor.h:27:0,
                 from ~/zephyr/drivers/sensor/lsm6ds0/lsm6ds0.c:11:
~/zephyr/drivers/sensor/lsm6ds0/lsm6ds0.c:505:30: error: ‘CONFIG_LSM6DS0_DEV_NAME’ undeclared here (not in a function)
 DEVICE_AND_API_INIT(lsm6ds0, CONFIG_LSM6DS0_DEV_NAME, lsm6ds0_init,
                              ^
~/zephyr/include/device.h:106:11: note: in definition of macro ‘DEVICE_AND_API_INIT’
   .name = drv_name, .init = (init_fn),     \
           ^~~~~~~~


I took the hexiwear_k64 board as template.

Any ideas how to get these problem solved?

Stefan


Maureen Helm
 

Hi Stefan,
If your board selects HAS_DTS_I2C_DEVICE, then you should define CONFIG_LSM6DS0_I2C_MASTER_DEV_NAME and CONFIG_LSM6DS0_I2C_ADDR in your board dts.fixup file rather than myboard_defconfig. See boards/arm/hexiwear_k64/dts.fixup for an example.

Maureen

-----Original Message-----
From: users@... [mailto:users@...] On Behalf Of Stefan Jaritz
Sent: Friday, August 10, 2018 1:15 PM
To: zephyr-users@...
Subject: [Zephyr-users] How to connect the LSM6DS0 sensor when using a custom board? #sensor #dts #defconfig

Hej

I am failing to get my LSM6DS3(almost LSM6DS0) sensor rightfully setup.
Maybe someone can give me a hint.

My system:

LSM6DS3 <--> I2C1 @ stm32F412 <--> Zephyr OS

I created an own board for that. It is configured via myboard_defconfig.
I added into that file:

# movement sensor
CONFIG_SENSOR=y
CONFIG_LSM6DS0=y
CONFIG_LSM6DS0_I2C_MASTER_DEV_NAME="LSM6DS3"
CONFIG_LSM6DS0_I2C_ADDR=0x6A

In myboard.dts I added:

&i2c1 {
    status = "ok";
    clock-frequency = <I2C_BITRATE_FAST>;

    lsm6ds0@106 {
        compatible = "st,lsm6ds0";
        reg = <0x6A>;
        label = "LSM6DS3";
    };
};

I am getting following error:

~/zephyr/drivers/sensor/lsm6ds0/lsm6ds0.c:499:25: error:
‘CONFIG_LSM6DS0_I2C_MASTER_DEV_NAME’ undeclared here (not in a function)
  .i2c_master_dev_name = CONFIG_LSM6DS0_I2C_MASTER_DEV_NAME,
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~/zephyr/drivers/sensor/lsm6ds0/lsm6ds0.c:500:20: error:
‘CONFIG_LSM6DS0_I2C_ADDR’ undeclared here (not in a function)
  .i2c_slave_addr = CONFIG_LSM6DS0_I2C_ADDR,
                    ^~~~~~~~~~~~~~~~~~~~~~~ In file included from ~/zephyr/include/sensor.h:27:0,
                 from ~/zephyr/drivers/sensor/lsm6ds0/lsm6ds0.c:11:
~/zephyr/drivers/sensor/lsm6ds0/lsm6ds0.c:505:30: error:
‘CONFIG_LSM6DS0_DEV_NAME’ undeclared here (not in a function)
 DEVICE_AND_API_INIT(lsm6ds0, CONFIG_LSM6DS0_DEV_NAME, lsm6ds0_init,
                              ^
~/zephyr/include/device.h:106:11: note: in definition of macro ‘DEVICE_AND_API_INIT’
   .name = drv_name, .init = (init_fn),     \
           ^~~~~~~~


I took the hexiwear_k64 board as template.

Any ideas how to get these problem solved?

Stefan