Not able to initialize my ADXL355 custom driver

Hi, 

I have been trying to initialize my driver for the adxl355. I copied almost everything from the lesson 7 exercise 1 of the nrfConnect intermediate course. 
For some reason, when I compile I get:
 undefined reference to `__device_dts_ord_132'
Which when I entered the device tree, is my custom device. Also, when I open the .overlay file I get this errors:
  

So I guess I am not including correctly my overlay or the drivers for my device.
I will include the .zip file of my project in case it is needed.
SPITry5.zip
Thank you so much.
Adrian Lopez

  • Hi,

     

    Three things:

    1. rename #define DT_DRV_COMPAT adi_adxl355

    2. Move DT_DRV_COMPAT define to the top of the file

    3. your overlay file does not match any boards in zephyr. Rename to ../boards/nrf52840dk_nrf52840.overlay

     

    There's several warnings that you should address.

    Could you try this and see if it works?

     

    Kind regards,

    Håkon

  • Another thing:

    you might want to select both SPI and SENSOR subsys when enabling your custom driver:

    menuconfig CUSTOM_ADXL355_DRIVER
    	bool "Support for the demonstration out of tree custom ADXL355 driver using SPI"
    	depends on SPI
        # depends on SENSOR
        # or you can just select it
        # select SENSOR

     

    Kind regards,

    Håkon

  • Hi Håkon,

    Thank you so much for your answer, it was really helpful. Now it is building. Just to add, I also had to add in my prj.conf file CONFIG_SENSOR = y.

    Now I am getting this warnings, which I hope are nothing to be worried about.

    /custom_adxl355_driver/zephyr/custom_adxl355_driver_spi.c: In function 'adxl_read_values':
    ../custom_adxl355_driver/zephyr/custom_adxl355_driver_spi.c:30:30: warning: unsigned conversion from 'int' to 'unsigned char' changes value from '776' to '8' [-Woverflow]
       30 | #define ADXL355_XDATA        (ADXL355_ADDR(0x08) | SET_ADXL355_TRANSF_LEN(3))
          |                              ^
    ../custom_adxl355_driver/zephyr/custom_adxl355_driver_spi.c:221:27: note: in expansion of macro 'ADXL355_XDATA'
      221 |         uint8_t regs[] = {ADXL355_XDATA, ADXL355_YDATA, ADXL355_ZDATA,};        //0xFF is dummy reg
          |                           ^~~~~~~~~~~~~
    ../custom_adxl355_driver/zephyr/custom_adxl355_driver_spi.c:31:30: warning: unsigned conversion from 'int' to 'unsigned char' changes value from '779' to '11' [-Woverflow]
       31 | #define ADXL355_YDATA        (ADXL355_ADDR(0x0B) | SET_ADXL355_TRANSF_LEN(3))
          |                              ^
    ../custom_adxl355_driver/zephyr/custom_adxl355_driver_spi.c:221:42: note: in expansion of macro 'ADXL355_YDATA'
      221 |         uint8_t regs[] = {ADXL355_XDATA, ADXL355_YDATA, ADXL355_ZDATA,};        //0xFF is dummy reg
          |                                          ^~~~~~~~~~~~~
    ../custom_adxl355_driver/zephyr/custom_adxl355_driver_spi.c:32:30: warning: unsigned conversion from 'int' to 'unsigned char' changes value from '782' to '14' [-Woverflow]
       32 | #define ADXL355_ZDATA        (ADXL355_ADDR(0x0E) | SET_ADXL355_TRANSF_LEN(3))
          |                              ^
    ../custom_adxl355_driver/zephyr/custom_adxl355_driver_spi.c:221:57: note: in expansion of macro 'ADXL355_ZDATA'
      221 |         uint8_t regs[] = {ADXL355_XDATA, ADXL355_YDATA, ADXL355_ZDATA,};        //0xFF is dummy reg
          |                                                         ^~~~~~~~~~~~~
    ../custom_adxl355_driver/zephyr/custom_adxl355_driver_spi.c:218:41: warning: unused variable 'zAxis' [-Wunused-variable]
      218 |         float xAxis = 0.0, yAxis = 0.0, zAxis = 0.0;
          |                                         ^~~~~
    ../custom_adxl355_driver/zephyr/custom_adxl355_driver_spi.c:218:28: warning: unused variable 'yAxis' [-Wunused-variable]
      218 |         float xAxis = 0.0, yAxis = 0.0, zAxis = 0.0;
          |                            ^~~~~
    ../custom_adxl355_driver/zephyr/custom_adxl355_driver_spi.c:218:15: warning: unused variable 'xAxis' [-Wunused-variable]
      218 |         float xAxis = 0.0, yAxis = 0.0, zAxis = 0.0;
          |               ^~~~~
    ../custom_adxl355_driver/zephyr/custom_adxl355_driver_spi.c:240:25: warning: array subscript 3 is above array bounds of 'uint8_t[3]' {aka 'unsigned char[3]'} [-Warray-bounds]
      240 |         dataz = (readbuf[3] << 8);
          |                  ~~~~~~~^~~
    ../custom_adxl355_driver/zephyr/custom_adxl355_driver_spi.c:222:17: note: while referencing 'readbuf'
      222 |         uint8_t readbuf[sizeof(regs)];

    And also, when flashing it to the board, I am not able to connect to the COM ports: Opening COM5: Access denied.
    Is this because of the warnings I am getting?


    Thank you!
    Kind regards,
    Adrián Lopez.

  • Hi,

     

    Adrian1504 said:
    I am not able to connect to the COM ports: Opening COM5: Access denied.

    This is highly likely because another process has the COM port open, and is completely separate from the firmware running on the nRF.

    Opening/closing a COM port is on your computer side.

     

    Adrian1504 said:

    Now I am getting this warnings, which I hope are nothing to be worried about.

    The warnings emitted should not be ignored. They are crucial to handle in order to get the sensor up and running, as you're packing the data into too small buffers/data types.

     

    Kind regards,

    Håkon

Related