LIS2DW12 over SPI on nRF9160 #sensor #spi #driver #lis2dw12 #nrf9160


p.swenson@...
 
Edited

Using: Windows 10, nRF Connect v3.5.0, SES v4.52, ncs v1.3.0, zephyr v2.3.0

I have a custom board based on the Nordic Thingy91 and the Asset Tracker application. There is also an LIS2DW12 present on SPI.  In "prj.conf", I added these lines:

 
CONFIG_SENSOR=y
CONFIG_TEMP_USE_EXTERNAL=y
CONFIG_TEMP_USE_SIM=n
CONFIG_SENSOR_SIM=n
CONFIG_SPI=y
CONFIG_SPI_NRFX=y
CONFIG_SPI_3=y
CONFIG_ACCEL_USE_EXTERNAL=y
CONFIG_LIS2DW12=y
CONFIG_ACCEL_DEV_NAME="LIS2DW12"
CONFIG_LIS2DW12_ODR_1_6=y
CONFIG_LIS2DW12_ACCEL_RANGE_2G=y

I modified the Thingy91 board devicetree file "thingy91_nrf9160_common.dts":

&spi3 {
compatible = "nordic,nrf-spim";
status = "okay";
sck-pin = <16>;
mosi-pin = <13>;
miso-pin = <14>;
cs-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
 
lis2dw12 {
compatible = "stm,lis2dw12";
label = "LIS2DW12";
spi-max-frequency = <10000000>;
int1-gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>;
};
};
 
In "lis2dw12.c", I added these lines to the top:

#define DT_DRV_COMPAT stm_lis2dw12
#define LIS2DW12 DT_INST(0, stm_lis2dw12)

In SES, it builds quite far, but I get an error:

C:/engr/ncs/v1.3.0/zephyr/drivers/sensor/lis2dw12/lis2dw12.c:227: undefined reference to `lis2dw12_spi_init'

In "lis2dw12.c", this section is grayed out:

#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
#include <drivers/spi.h>
#elif DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
#include <drivers/i2c.h>
#endif
 

Which means it never includes the spi.h file.  What am I missing?  I can force the issue, but it just shifts the problem and doesn't solve it.

Join users@lists.zephyrproject.org to automatically receive all group messages.