1Userspace access to IIO 2 3Example, ST Microelectronics LIS3L02DQ accelerometer. 4 5Typical sysfs entries (pruned for clarity) 6 7/sys/class/iio 8 device0 - iio_dev related elements 9 name - driver specific identifier (here lis3l02dq) 10 accel_x - polled (or from ring) raw readout of acceleration 11 accel_x_gain - hardware gain (calibration) 12 accel_x_offset - hardware offset (calibration) 13 available_sampling_frequency 14 15 available_sampling_frequency - what options are there 16 sampling_frequency - control of internal sampling frequency 17 scan_elements - controls which channels will be stored in the ring buffer 18 scan_en_accel_x 19 scan_en_accel_y 20 scan_en_timestamp 21 device - link to underlying hardware device 22 uevent - udev related element 23 24 thresh - unified threshold used for detection on all axis 25 event_line0_sources - which events are enabled 26 accel_x_high - enable x axis high threshold event 27 accel_x_low - enable x axis low threshold event 28 29 event_line0 - event interface 30 dev - major:minor for the chrdev (note major allocation dynamic) 31 trigger - consumer attachement 32 current_trigger - name based association with a trigger 33 ring_buffer0 - ring buffer interface 34 bps - byptes per sample (read only), dependant on scan element selection 35 length - (rw) specificy length fo software ring buffer (typically ro in hw case) 36 ring_enable - turn the ring on. If its the first to be enabled attached to this 37 trigger will also enable the trigger. 38 ring_access0 39 dev - major:minor for ring buffer access chrdev 40 ring_event_line0 41 dev - major:minor for ring buffer event chrdev 42 43 trigger0 - data ready trigger elements 44 name - unqiue name of trigger 45 46Udev will create the following entries under /dev by default: 47 48ring_access0 - ring access chrdev 49ring_event0 - ring event chrdev 50event_line0 - general event chrdev. 51 52For the example code we assume the following rules have been used to ensure 53unique and consistent naming of these for the lis3l02dq in question: 54 55KERNEL="ring_event_line*", ID="spi1.0", DRIVER="lis3l02dq", NAME="iio/lis3l02dq_ring_event" 56KERNEL="event_line*", ID="spi1.0", DRIVER="lis3l02dq", NAME="iio/lis3l02dq_event" 57KERNEL="ring_access*", ID="spi1.0", DRIVER="lis3l02dq", NAME="iio/lis3l02dq_ring_access" 58 59The files, lis3l02dqbuffersimple.c and iio_utils.h in this directory provide an example 60of how to use the ring buffer and event interfaces. 61