Hi,
I am currently working on a custom project that requires the integration of the ADXL-362 accelerometer. The project involves a system with a radar sensor connected to custom pins configured for SPI2 communication.
Initially, I attempted to connect the ADXL-362 directly to SPI2, but this caused conflicts with the radar sensor, resulting in errors. Subsequently, I assigned the ADXL-362 to custom pins. This adjustment allowed the system to build and flash successfully. However, during integrated system testing, i encountered an issue: the system fails to read data from the ADXL-362 sensor.
The sensor has been defined in the code as follows:
#define ACCELEROMETER_SPI_NODE DT_ALIAS(adxl362) /**< SPI sensor node */
Calling it like this:
static const struct device *accelerometer_spi_device = DEVICE_DT_GET(ACCELEROMETER_SPI_NODE); /**< SPI device for communication */
And this gives me the undefined Reference.
When i use:
static const struct device *accelerometer_spi_device = DEVICE_DT_GET_ANY(ACCELEROMETER_SPI_NODE); /**< SPI device for communication */
The system cant find the sensor and gives me a NULL pointer back.
Here is my prj.conf:
CONFIG_MAIN_STACK_SIZE=6144 CONFIG_HEAP_MEM_POOL_SIZE=8192 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 # General config CONFIG_NCS_SAMPLES_DEFAULTS=y CONFIG_REBOOT=y # NEWLIB C CONFIG_NEWLIB_LIBC=y CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y CONFIG_NEWLIB_LIBC_MIN_REQUIRED_HEAP_SIZE=2048 # Network CONFIG_NETWORKING=y CONFIG_NET_NATIVE=n CONFIG_LTE_NETWORK_USE_FALLBACK=y # LTE link control CONFIG_LTE_LINK_CONTROL=y # CONFIG_LTE_NETWORK_MODE_LTE_M=y CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y CONFIG_LTE_AUTO_INIT_AND_CONNECT=n CONFIG_LTE_NETWORK_TIMEOUT=20 CONFIG_LTE_PSM_REQ_RAT="00000010" CONFIG_LTE_PSM_REQ_RPTAU="00110000" # Modem library CONFIG_NRF_MODEM_LIB=y # AT Host CONFIG_UART_INTERRUPT_DRIVEN=y CONFIG_AT_HOST_LIBRARY=y # AWS IoT library CONFIG_AWS_IOT=y #IMPORTANT: If building for firmware update, this must be set to y CONFIG_AWS_IOT_CLIENT_ID_APP=y CONFIG_AWS_IOT_CLIENT_ID_MAX_LEN=15 #If building for firmware update, this is ignored CONFIG_AWS_IOT_CLIENT_ID_STATIC="" CONFIG_AWS_IOT_BROKER_HOST_NAME="HOSTNAME" CONFIG_AWS_IOT_SEC_TAG=1 CONFIG_AWS_IOT_APP_SUBSCRIPTION_LIST_COUNT=1 CONFIG_AWS_IOT_TOPIC_UPDATE_DELTA_SUBSCRIBE=n CONFIG_AWS_IOT_LAST_WILL=n CONFIG_AWS_IOT_TOPIC_GET_ACCEPTED_SUBSCRIBE=y CONFIG_AWS_IOT_TOPIC_GET_REJECTED_SUBSCRIBE=y CONFIG_AWS_FOTA_PAYLOAD_SIZE=1350 CONFIG_AWS_FOTA_HOSTNAME_MAX_LEN=255 CONFIG_AWS_FOTA_FILE_PATH_MAX_LEN=255 CONFIG_AWS_IOT_LOG_LEVEL_DBG=n CONFIG_MQTT_CLEAN_SESSION=y # NRF Cloud CONFIG_NRF_CLOUD_AGPS=y CONFIG_NRF_CLOUD_LOG_LEVEL_DBG=n #AWS shadow CONFIG_AWS_IOT_AUTO_DEVICE_SHADOW_REQUEST=n # MCUBOOT CONFIG_BOOTLOADER_MCUBOOT=y CONFIG_MCUBOOT_IMG_MANAGER=y # Image manager CONFIG_IMG_MANAGER=y CONFIG_FLASH=y CONFIG_IMG_ERASE_PROGRESSIVELY=y # AWS FOTA CONFIG_FOTA_DOWNLOAD=y CONFIG_AWS_FOTA=y CONFIG_DFU_TARGET=y # Download client (needed by AWS FOTA) CONFIG_DOWNLOAD_CLIENT=y CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096 # MQTT - Maximum MQTT keepalive timeout specified by AWS IoT Core = 1200 CONFIG_MQTT_KEEPALIVE=1200 # Date Time library CONFIG_DATE_TIME=y # Modem information CONFIG_MODEM_INFO=y # CJSON CONFIG_CJSON_LIB=y # Peripherals CONFIG_I2C=y CONFIG_SPI=y CONFIG_FPU=n CONFIG_NRFX_SPIM2=y CONFIG_NRFX_TWIM3=y # Power management CONFIG_PM=y CONFIG_PM_DEVICE=y CONFIG_PM_DEVICE_RUNTIME=y # Logging CONFIG_LOG=y CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_DBG=n # Fault handling CONFIG_RESET_ON_FATAL_ERROR=y # Heap CONFIG_SYS_HEAP_RUNTIME_STATS=n # ADC CONFIG_ADC=y # Watchdog CONFIG_WATCHDOG=y # Enable Sensor CONFIG_SENSOR=y # Enable ADXL362 Accelerometer Sensor CONFIG_ADXL362=y
Vs-Code tells me the following:
CONFIG_ADXL362 was assigned the value y, but got the value n. Missing dependencies:
DT_HAS_ADI_ADXL362_ENABLED
How to add the missing dependencies?
Here is my sensor_ovelay for reference:
#include "sensor1_ns.dtsi" / { zephyr,user { io-channels = <&adc 0>; }; vbatt { io-channels = <&adc 1>; }; custom_pins { adxl362: adxl362 { gpios = <&gpio0 15 0>; label = "ADXL362_spi_ss"; }; }; aliases { eeprom-i2c = &i2c3; temperature-i2c = &i2c3; rtc-i2c = &i2c3; adxl362 = &adxl362; }; }; &spi2 { compatible = "nordic,nrf-spim"; status = "okay"; pinctrl-0 = <&spi2_default>; pinctrl-1 = <&spi2_sleep>; pinctrl-names = "default", "sleep"; clock-frequency = <1000000>; label = "SPI_2_1"; }; &spi2_default { group1 { psels = <NRF_PSEL(SPIM_SCK, 0, 23)>, <NRF_PSEL(SPIM_MOSI, 0, 20)>, <NRF_PSEL(SPIM_MISO, 0, 22)>; }; }; &spi2_sleep { group1 { psels = <NRF_PSEL(SPIM_SCK, 0, 23)>, <NRF_PSEL(SPIM_MOSI, 0, 20)>, <NRF_PSEL(SPIM_MISO, 0, 22)>; }; }; &i2c3 { compatible = "nordic,nrf-twim"; status = "okay"; pinctrl-0 = <&i2c3_default>; pinctrl-1 = <&i2c3_sleep>; pinctrl-names = "default", "sleep"; clock-frequency = <I2C_BITRATE_FAST>; label = "I2C_3_1"; }; &gpio0 { status = "okay"; label = "GPIO_0"; }; &adc { #address-cells = <1>; #size-cells = <0>; channel@0 { reg = <0>; zephyr,gain = "ADC_GAIN_1_6"; zephyr,reference = "ADC_REF_INTERNAL"; zephyr,acquisition-time = <ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 40)>; zephyr,input-positive = <NRF_SAADC_AIN1>; zephyr,resolution = <10>; zephyr,oversampling = <16>; }; };