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 Thingy91 and the Asset Tracker application. There is also an LIS2DW12 present on SPI. In prj.conf, I added these lines:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
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 file thingy91_nrf9160_common.dts:
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
&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:
Fullscreen
1
2
#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:
Fullscreen
1
2
3
4
5
#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? Any ideas?