Function | File |
---|---|
core driver | drivers/iio/accel/adxl367.c |
spi driver | drivers/iio/accel/adxl367_spi.c |
i2c driver | drivers/iio/accel/adxl367_i2c.c |
header | drivers/iio/accel/adxl367.h |
Documentation | adi,adxl367.yaml |
Example device tree
Function | File |
---|---|
dts | rpi-adxl367-overlay.dts |
Required devicetree properties:
Required properties for SPI bus usage:
Optional properties:
Example for a SPI device node:
#address-cells = <1>; #size-cells = <0>; status = "okay"; adxl367@0 { compatible = "adi,adxl367"; reg = <0>; spi-max-frequency = <1000000>; interrupt-parent = <&gpio>; interrupts = <25 IRQ_TYPE_EDGE_RISING>; };
Example for a I2C device node:
#address-cells = <1>; #size-cells = <0>; status = "okay"; adxl367@53 { compatible = "adi,adxl367"; reg = <53>; interrupt-parent = <&gpio>; interrupts = <25 IRQ_TYPE_EDGE_RISING>; };
This specifies any shell prompt running on the target
root:/> cd /sys/bus/iio/devices/ root:/sys/bus/iio/devices> ls iio:device0 root:/sys/bus/iio/devices> cd iio\:device0 root:/sys/bus/iio/devices/iio:device0> ls -l drwxr-xr-x 2 root root 0 May 3 16:17 buffer -r--r--r-- 1 root root 4096 May 3 16:17 dev drwxr-xr-x 2 root root 0 May 3 16:17 events -rw-r--r-- 1 root root 4096 May 3 16:17 in_accel_scale -r--r--r-- 1 root root 4096 May 3 16:17 in_accel_scale_available -rw-r--r-- 1 root root 4096 May 3 16:17 in_accel_x_raw -rw-r--r-- 1 root root 4096 May 3 16:17 in_accel_y_raw -rw-r--r-- 1 root root 4096 May 3 16:17 in_accel_z_raw -rw-r--r-- 1 root root 4096 May 3 16:17 in_temp_offset -rw-r--r-- 1 root root 4096 May 3 16:17 in_temp_raw -rw-r--r-- 1 root root 4096 May 3 16:17 in_temp_scale -rw-r--r-- 1 root root 4096 May 3 16:17 in_voltage_offset -rw-r--r-- 1 root root 4096 May 3 16:17 in_voltage_raw -rw-r--r-- 1 root root 4096 May 3 16:17 in_voltage_scale -r--r--r-- 1 root root 4096 May 3 16:17 name lrwxrwxrwx 1 root root 0 May 3 16:17 of_node -> ../../../../../../../../firmware/devicetree/base/soc/spi@7e204000/adxl367@0 drwxr-xr-x 2 root root 0 May 3 16:17 power -rw-r--r-- 1 root root 4096 May 3 16:17 sampling_frequency -r--r--r-- 1 root root 4096 May 3 16:17 sampling_frequency_available drwxr-xr-x 2 root root 0 May 3 16:17 scan_elements lrwxrwxrwx 1 root root 0 May 3 16:17 subsystem -> ../../../../../../../../bus/iio -rw-r--r-- 1 root root 4096 May 3 16:17 uevent
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device0> cat name adxl367
Description:
scale to be applied to in_accel_*_raw in order to obtain the acceleration.
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device0> cat in_accel_scale 0.002394347
Description:
Raw unscaled acceleration measurement on x axis
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device0> cat in_accel_x_raw -5
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device0> cat sampling_frequency_available 12.500000 25.000000 50.000000 100.000000 200.000000 400.000000 root:/sys/bus/iio/devices/iio:device0> cat sampling_frequency 12.500000 root:/sys/bus/iio/devices/iio:device0> echo 400.000000 > sampling_frequency root:/sys/bus/iio/devices/iio:device0> cat sampling_frequency 400.000000
Description:
The ADXL367 includes a deep, 512 sample FIFO buffer. The 512 FIFO samples can be allotted in several ways, such as the following:
Description:
The scan_elements directory contains interfaces for elements that will be captured for a single triggered sample set in the buffer
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device0> cd scan_elements/ root:/sys/bus/iio/devices/iio:device0/scan_elements> ls -l -rw-r--r-- 1 root root 4096 May 3 16:17 in_accel_x_en -r--r--r-- 1 root root 4096 May 3 16:17 in_accel_x_index -r--r--r-- 1 root root 4096 May 3 16:17 in_accel_x_type -rw-r--r-- 1 root root 4096 May 3 16:17 in_accel_y_en -r--r--r-- 1 root root 4096 May 3 16:17 in_accel_y_index -r--r--r-- 1 root root 4096 May 3 16:17 in_accel_y_type -rw-r--r-- 1 root root 4096 May 3 16:17 in_accel_z_en -r--r--r-- 1 root root 4096 May 3 16:17 in_accel_z_index -r--r--r-- 1 root root 4096 May 3 16:17 in_accel_z_type -rw-r--r-- 1 root root 4096 May 3 16:17 in_temp_en -r--r--r-- 1 root root 4096 May 3 16:17 in_temp_index -r--r--r-- 1 root root 4096 May 3 16:17 in_temp_type -rw-r--r-- 1 root root 4096 May 3 16:17 in_voltage_en -r--r--r-- 1 root root 4096 May 3 16:17 in_voltage_index -r--r--r-- 1 root root 4096 May 3 16:17 in_voltage_type
Before enabling the buffer, a few steps need to be completed.
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device0/scan_elements> echo 1 > in_accel_x_en root:/sys/bus/iio/devices/iio:device0/scan_elements> echo 1 > in_accel_y_en root:/sys/bus/iio/devices/iio:device0/scan_elements> echo 1 > in_accel_z_en
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device0/scan_elements> cd ../buffer/ root:/sys/bus/iio/devices/iio:device0/buffer> ls -l -r--r--r-- 1 root root 4096 May 3 16:17 data_available -rw-r--r-- 1 root root 4096 May 3 16:17 enable -r--r--r-- 1 root root 4096 May 3 16:17 hwfifo_enabled -r--r--r-- 1 root root 4096 May 3 16:17 hwfifo_watermark -r--r--r-- 1 root root 4096 May 3 16:17 hwfifo_watermark_max -r--r--r-- 1 root root 4096 May 3 16:17 hwfifo_watermark_min -rw-r--r-- 1 root root 4096 May 3 16:17 length -rw-r--r-- 1 root root 4096 May 3 16:17 watermark
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device0/buffer> echo 1024 > length
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device0/buffer> echo 512 > watermark
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device0/buffer> echo 1 > enable
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device0/buffer> cat /dev/iio:device0
Some IIO drivers feature an optional debug facility, allowing users to read or write registers directly. Special care needs to be taken when using this feature, since you can modify registers on the back of the driver. Accessing debugfs requires root privileges.
This specifies any shell prompt running on the target
root:/> /sys/kernel/debug/iio/iio:device0/ root:/sys/kernel/debug/iio/iio:device0> ls direct_reg_access direct_reg_access
Reading
This specifies any shell prompt running on the target
root:/sys/kernel/debug/iio/iio:device0> echo 0x0 > direct_reg_access root:/sys/kernel/debug/iio/iio:device0> cat direct_reg_access 0xAD
Writing
Write ADDRESS VALUE
This specifies any shell prompt running on the target
root@analog:/sys/kernel/debug/iio/iio:device0> echo 0x3D 0x80 > direct_reg_access root@analog:/sys/kernel/debug/iio/iio:device0> cat direct_reg_access 0x80