STMicroelectronics / st-mems-android-linux-drivers-iio

stm mems iio drivers for Android and Linux platforms.
GNU General Public License v2.0
23 stars 1 forks source link

How to Stabilize Sensor Output and Achieve Target Frequency for asm330lhhxg1 and lsm6dsox? #17

Open AlysonQ opened 5 months ago

AlysonQ commented 5 months ago

Hi ,

I am currently working on porting two sensors, the asm330lhhxg1 and lsm6dsox, to my platform. However, I have no idea how to stabilize the sensor data and achieve the frequency in Hz as specified in the hardware specifications. Despite searching and trying various tutorials, using the iio_generic_buffer tools yields no results.

# Enable Y-axis acceleration
echo 1 > /sys/bus/iio/devices/iio:device2/scan_elements/in_accel_y_en

# Enable X-axis acceleration
echo 1 > /sys/bus/iio/devices/iio:device2/scan_elements/in_accel_x_en

# Enable timestamp
echo 1 > /sys/bus/iio/devices/iio:device2/scan_elements/in_timestamp_en

# Enable Z-axis acceleration
echo 1 > /sys/bus/iio/devices/iio:device2/scan_elements/in_accel_z_en

# Attempt to enable buffer
echo 1 > /sys/bus/iio/devices/iio:device2/buffer/enable

# Run generic buffer utility
./iio_generic_buffer -a -g -n asm330lhhxg1_accel
# Output from incomplete command
  iio device number being used is 2
  trigger-less mode selected
  Auto-channels selected but some channels are already activated in sysfs
  Proceeding without activating any channels
##stuck here

#Here is my device tree configuration under `i2c0`:

&i2c0 {
   asm330lhhx-imu@0x6b {
        compatible = "st,asm330lhhxg1";
        reg = <0x6b>;
        interrupt-parent = <&gpio0>;
        interrupts = <0 IRQ_TYPE_LEVEL_HIGH>;
        /*vddio-supply = <&sensors_vddio>;*/
        /*vdd-supply = <&sensors_vdd>;*/
        drive-open-drain;
        st,int-pin = <1>;
        st,mlc-int-pin = <2>;
        mount-matrix = "1", "0", "0",
                   "0", "1", "0",
                   "0", "0", "1";
        };
    }
#  ./iio_generic_buffer -a -n asm330lhhxg1_gyro -e -g
iio device number being used is 1
trigger-less mode selected
No channels are enabled, enabling all channels
Enabling: in_anglvel_z_en
Enabling: in_timestamp_en
Enabling: in_raw_en
Enabling: in_anglvel_y_en
Enabling: in_anglvel_x_en
nothing available
nothing available
Disabling: in_anglvel_z_en
Disabling: in_timestamp_en
Disabling: in_raw_en
Disabling: in_anglvel_y_en

Could you please provide any suggestions?

Thanks, AlysonQ

mariotesi commented 4 months ago

Hi,

all the work of enabling the axes and the buffer is already done by the iio_generic_buffer tool so you can directly run the command (for 100 samples):

$ iio_generic_buffer -n asm330lhhxg1_accel -ga -c 100

If this is not working you can check if interrupt are properly configured in /proc/interrupts:

$ cat /proc/interrupts | grep asm330

If the irq line is correctly configured you should see something different from zero