Hello. I am working with the Thingy 91. On the nRF52840 I have the connectivity bridge application running so I can see print messages from the nRF9160.
On the nRF9160 side, my goal is to simply collect accelerometer sensor data. I have looked at the thingy91_nrf9160_common.dts I see the following declared:
&spi3 { compatible = "nordic,nrf-spim"; status = "okay"; cs-gpios = <&gpio0 8 GPIO_ACTIVE_LOW>, <&gpio0 7 GPIO_ACTIVE_LOW>; pinctrl-0 = <&spi3_default>; pinctrl-1 = <&spi3_sleep>; pinctrl-names = "default", "sleep"; adxl362: adxl362@0 { compatible = "adi,adxl362"; spi-max-frequency = <8000000>; reg = <0>; int1-gpios = <&gpio0 9 0>; }; adxl372: adxl372@1 { compatible = "adi,adxl372"; spi-max-frequency = <8000000>; reg = <1>; int1-gpios = <&gpio0 6 0>; }; };
And in my code, I have the following:
#include <stdio.h> #include <stdlib.h> #include <zephyr/kernel.h> #include <zephyr/drivers/spi.h> #include <zephyr/drivers/sensor.h> #include <zephyr/device.h> #define DEFAULT_ACCL_NODE DT_ALIAS(adxl372) BUILD_ASSERT(DT_NODE_HAS_STATUS(DEFAULT_ACCL_NODE, okay), "ADXL372 not specified in DT"); #define DEFAULT_ACCL_NODE DT_ALIAS(adxl362) BUILD_ASSERT(DT_NODE_HAS_STATUS(DEFAULT_ACCL_NODE, okay), "ADXL362 not specified in DT"); int main(void) { while(1){ printk("Hello World\n"); k_msleep(1000); } }
As you can see from above, I just want to perform static assertion to check if adxl372 and adxl362 is declared in device tree.
When I try to build my project, I am getting the following error:
C:\Users\petrikas.lu\Desktop\WORK\NRF\Thingy_91\external\zephyr\include\zephyr\toolchain\gcc.h:81:36: error: static assertion failed: "ADXL372 not specified in DT" 81 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert(EXPR, "" MSG) | ^~~~~~~~~~~~~~ c:\Users\petrikas.lu\Desktop\WORK\NRF\Thingy_91\app_nrf9160\src\main.c:19:1: note: in expansion of macro 'BUILD_ASSERT' 19 | BUILD_ASSERT(DT_NODE_HAS_STATUS(DEFAULT_ACCL_NODE, okay), | ^~~~~~~~~~~~ c:\Users\petrikas.lu\Desktop\WORK\NRF\Thingy_91\app_nrf9160\src\main.c:22: warning: "DEFAULT_ACCL_NODE" redefined 22 | #define DEFAULT_ACCL_NODE DT_ALIAS(adxl362) | c:\Users\petrikas.lu\Desktop\WORK\NRF\Thingy_91\app_nrf9160\src\main.c:18: note: this is the location of the previous definition 18 | #define DEFAULT_ACCL_NODE DT_ALIAS(adxl372) | C:\Users\petrikas.lu\Desktop\WORK\NRF\Thingy_91\external\zephyr\include\zephyr\toolchain\gcc.h:81:36: error: static assertion failed: "ADXL362 not specified in DT" 81 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert(EXPR, "" MSG) | ^~~~~~~~~~~~~~ c:\Users\petrikas.lu\Desktop\WORK\NRF\Thingy_91\app_nrf9160\src\main.c:23:1: note: in expansion of macro 'BUILD_ASSERT' 23 | BUILD_ASSERT(DT_NODE_HAS_STATUS(DEFAULT_ACCL_NODE, okay), | ^~~~~~~~~~~~
I cannot wrap my head around this issue. I am sure it is something very simple I just cant seem to notice it! Why would it not pass the static assertion if it is declared in the device tree?