ADXL362 registers writing

Hi 

I am using ADXL362 moving sensor in my nrf5340 custom board. In a previous ticket I could achieve to read its registers by modifying the overlay file 

according to my hardware design. Now  I want to know how can I write to its registers by SPI commands. For example I want to increase its g measurement

range from 1g to 8g. For your information I am using nRF connect for Desktop software for writing and programing my custom board.

Thank you in advance for your support.

Best Regards

Saeed Mahvis

  • Hi Naeem

    I sent you a zip sample of my project.

    the problematic command is:

    //adxl362_set_range(dev,8); 

    which has been commented on.

    the error is:

    undefined reference to `adxl362_set_range'

    ld returned 1 exit status

  • Hello Saeed,

    I have received your project in zip file.

    I will let you know when I go through it and have more information.

    Regards,

  • Hello Saeed,

    I have looked into your code, and I can see that you are trying to use driver specific function (adxl362_set_range).

    However, as we can see the function is not defined and the build system cannot locate it.

    You can have two solutions:

    1) You get the driver header and source files and include in your project explicitly. You might need to change / update header files or the function prototypes.

    2) You can use Zepher sensor Api to access the driver functions.

    As in the second case, 

          you already have included the sensor.h

          you have already defined your sensor node in the overlay file

          you already have the obtained the DTS node using zephyr devicetree api

          also, you are already using sensor api, for example sensor_trigger_set and sensor_sample_fetch, and sensor_channel_get etc.

    As you can see you are already using sensor api to access the functionality of the underlying driver. 

    Similarly, you can use "sensor_attr_set()" function to access those driver functions that you have mentioned.

    Hope it helps,

    Regards

  • Hi Naeem

    As you mentioned I have already used sensor api  to fetch and get sensor data. So I used

     sensor_attr_set(dev,SENSOR_CHAN_ACCEL_XYZ,SENSOR_ATTR_FULL_SCALE,8);

    command in my code to change the full sacle default of the sensor from 2g to 8g.The program

    was compiled and built with no errors but nothing changes and the limiting value of accelerations

    are still 2g. there is only a warning issued:

    passing argument 4 of 'sensor_attr_set' makes pointer from integer without a cast [-Wint-conversion]

    expected 'const struct sensor_value *' but argument is of type 'int'

    Would you please guide me how to use  sensor_attr_set() function to make effects.

  • Sorry for delays here. Naeem is away for few days and will be back on Monday to look into this. Thanks for your patience so far.

Related