STMicroelectronics / STMems_Linux_IIO_drivers

DISCONTINUED (October 2022): the maintenance for this repository has been discontinued. Please refer to https://github.com/STMicroelectronics/st-mems-android-linux-drivers-iio for the up-to-date drivers repository. This repository contains Linux Kernel (v3.10, v3.14, v3.18, v4.9, v4.14, v4.19) including STMicroelectronics MEMS IIO sensor support
Other
75 stars 42 forks source link

How to use the st_imu68 IIO driver with a hrtimer? #1

Closed deblauwetom closed 5 years ago

deblauwetom commented 5 years ago

I compiled the st_imu68_i2c driver for use with a 4.14 linux kernel with the industrial IO subsystem successfully. And I could read values from the device using the files that provide the "raw" values. However, it is very slow when I just cat the raw values very fast. Normally, in IIO you can define a hrtimer with scan_elements, but the iio device you get from the linux driver does not contain such a 'scan_elements' subdir so it seems I can't attach a hrtimer trigger to it. However, there is a sample_frequency file, but not clear to me what this then does or how it is supposed to work. Is there maybe a high level overview documentation somewhere of how you can get the values faster?

mariotesi commented 5 years ago

Hi deblauwetom,

Yes I confirm the raw value can be read using the

/sys/bus/iio/devices/iio:devicex/in_xxx_x_raw /sys/bus/iio/devices/iio:devicex/in_xxx_y_raw /sys/bus/iio/devices/iio:devicex/in_xxx_z_raw

but is very slow because is only for spare access

To read data in a standard way (using FIFO and iio channels) there is the generic_buffer iio utility in linux kernel documentation, otherwise you can use the Linux/Android HAL in this repository: https://github.com/STMicroelectronics/STMems_Android_Sensor_HAL_IIO

Generic Buffer utility need the scan_elements directory but in st_imu68 there should be this entry path (please see in CONFIG_IIO_BUFFER is enabled in your .config)