adxl380.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ===============
  3. ADXL380 driver
  4. ===============
  5. This driver supports Analog Device's ADXL380/382 on SPI/I2C bus.
  6. 1. Supported devices
  7. ====================
  8. * `ADXL380 <https://www.analog.com/ADXL380>`_
  9. * `ADXL382 <https://www.analog.com/ADXL382>`_
  10. The ADXL380/ADXL382 is a low noise density, low power, 3-axis accelerometer with
  11. selectable measurement ranges. The ADXL380 supports the ±4 g, ±8 g, and ±16 g
  12. ranges, and the ADXL382 supports ±15 g, ±30 g, and ±60 g ranges.
  13. 2. Device attributes
  14. ====================
  15. Accelerometer measurements are always provided.
  16. Temperature data are also provided. This data can be used to monitor the
  17. internal system temperature or to improve the temperature stability of the
  18. device via calibration.
  19. Each IIO device, has a device folder under ``/sys/bus/iio/devices/iio:deviceX``,
  20. where X is the IIO index of the device. Under these folders reside a set of
  21. device files, depending on the characteristics and features of the hardware
  22. device in questions. These files are consistently generalized and documented in
  23. the IIO ABI documentation.
  24. The following tables show the adxl380 related device files, found in the
  25. specific device folder path ``/sys/bus/iio/devices/iio:deviceX``.
  26. +---------------------------------------------------+----------------------------------------------------------+
  27. | 3-Axis Accelerometer related device files | Description |
  28. +---------------------------------------------------+----------------------------------------------------------+
  29. | in_accel_scale | Scale for the accelerometer channels. |
  30. +---------------------------------------------------+----------------------------------------------------------+
  31. | in_accel_filter_high_pass_3db_frequency | Low pass filter bandwidth. |
  32. +---------------------------------------------------+----------------------------------------------------------+
  33. | in_accel_filter_high_pass_3db_frequency_available | Available low pass filter bandwidth configurations. |
  34. +---------------------------------------------------+----------------------------------------------------------+
  35. | in_accel_filter_low_pass_3db_frequency | High pass filter bandwidth. |
  36. +---------------------------------------------------+----------------------------------------------------------+
  37. | in_accel_filter_low_pass_3db_frequency_available | Available high pass filter bandwidth configurations. |
  38. +---------------------------------------------------+----------------------------------------------------------+
  39. | in_accel_x_calibbias | Calibration offset for the X-axis accelerometer channel. |
  40. +---------------------------------------------------+----------------------------------------------------------+
  41. | in_accel_x_raw | Raw X-axis accelerometer channel value. |
  42. +---------------------------------------------------+----------------------------------------------------------+
  43. | in_accel_y_calibbias | y-axis acceleration offset correction |
  44. +---------------------------------------------------+----------------------------------------------------------+
  45. | in_accel_y_raw | Raw Y-axis accelerometer channel value. |
  46. +---------------------------------------------------+----------------------------------------------------------+
  47. | in_accel_z_calibbias | Calibration offset for the Z-axis accelerometer channel. |
  48. +---------------------------------------------------+----------------------------------------------------------+
  49. | in_accel_z_raw | Raw Z-axis accelerometer channel value. |
  50. +---------------------------------------------------+----------------------------------------------------------+
  51. +----------------------------------+--------------------------------------------+
  52. | Temperature sensor related files | Description |
  53. +----------------------------------+--------------------------------------------+
  54. | in_temp_raw | Raw temperature channel value. |
  55. +----------------------------------+--------------------------------------------+
  56. | in_temp_offset | Offset for the temperature sensor channel. |
  57. +----------------------------------+--------------------------------------------+
  58. | in_temp_scale | Scale for the temperature sensor channel. |
  59. +----------------------------------+--------------------------------------------+
  60. +------------------------------+----------------------------------------------+
  61. | Miscellaneous device files | Description |
  62. +------------------------------+----------------------------------------------+
  63. | name | Name of the IIO device. |
  64. +------------------------------+----------------------------------------------+
  65. | sampling_frequency | Currently selected sample rate. |
  66. +------------------------------+----------------------------------------------+
  67. | sampling_frequency_available | Available sampling frequency configurations. |
  68. +------------------------------+----------------------------------------------+
  69. Channels processed values
  70. -------------------------
  71. A channel value can be read from its _raw attribute. The value returned is the
  72. raw value as reported by the devices. To get the processed value of the channel,
  73. apply the following formula:
  74. .. code-block:: bash
  75. processed value = (_raw + _offset) * _scale
  76. Where _offset and _scale are device attributes. If no _offset attribute is
  77. present, simply assume its value is 0.
  78. The adis16475 driver offers data for 2 types of channels, the table below shows
  79. the measurement units for the processed value, which are defined by the IIO
  80. framework:
  81. +-------------------------------------+---------------------------+
  82. | Channel type | Measurement unit |
  83. +-------------------------------------+---------------------------+
  84. | Acceleration on X, Y, and Z axis | Meters per Second squared |
  85. +-------------------------------------+---------------------------+
  86. | Temperature | Millidegrees Celsius |
  87. +-------------------------------------+---------------------------+
  88. Usage examples
  89. --------------
  90. Show device name:
  91. .. code-block:: bash
  92. root:/sys/bus/iio/devices/iio:device0> cat name
  93. adxl382
  94. Show accelerometer channels value:
  95. .. code-block:: bash
  96. root:/sys/bus/iio/devices/iio:device0> cat in_accel_x_raw
  97. -1771
  98. root:/sys/bus/iio/devices/iio:device0> cat in_accel_y_raw
  99. 282
  100. root:/sys/bus/iio/devices/iio:device0> cat in_accel_z_raw
  101. -1523
  102. root:/sys/bus/iio/devices/iio:device0> cat in_accel_scale
  103. 0.004903325
  104. - X-axis acceleration = in_accel_x_raw * in_accel_scale = −8.683788575 m/s^2
  105. - Y-axis acceleration = in_accel_y_raw * in_accel_scale = 1.38273765 m/s^2
  106. - Z-axis acceleration = in_accel_z_raw * in_accel_scale = -7.467763975 m/s^2
  107. Set calibration offset for accelerometer channels:
  108. .. code-block:: bash
  109. root:/sys/bus/iio/devices/iio:device0> cat in_accel_x_calibbias
  110. 0
  111. root:/sys/bus/iio/devices/iio:device0> echo 50 > in_accel_x_calibbias
  112. root:/sys/bus/iio/devices/iio:device0> cat in_accel_x_calibbias
  113. 50
  114. Set sampling frequency:
  115. .. code-block:: bash
  116. root:/sys/bus/iio/devices/iio:device0> cat sampling_frequency
  117. 16000
  118. root:/sys/bus/iio/devices/iio:device0> cat sampling_frequency_available
  119. 16000 32000 64000
  120. root:/sys/bus/iio/devices/iio:device0> echo 32000 > sampling_frequency
  121. root:/sys/bus/iio/devices/iio:device0> cat sampling_frequency
  122. 32000
  123. Set low pass filter bandwidth for accelerometer channels:
  124. .. code-block:: bash
  125. root:/sys/bus/iio/devices/iio:device0> cat in_accel_filter_low_pass_3db_frequency
  126. 32000
  127. root:/sys/bus/iio/devices/iio:device0> cat in_accel_filter_low_pass_3db_frequency_available
  128. 32000 8000 4000 2000
  129. root:/sys/bus/iio/devices/iio:device0> echo 2000 > in_accel_filter_low_pass_3db_frequency
  130. root:/sys/bus/iio/devices/iio:device0> cat in_accel_filter_low_pass_3db_frequency
  131. 2000
  132. 3. Device buffers
  133. =================
  134. This driver supports IIO buffers.
  135. All devices support retrieving the raw acceleration and temperature measurements
  136. using buffers.
  137. Usage examples
  138. --------------
  139. Select channels for buffer read:
  140. .. code-block:: bash
  141. root:/sys/bus/iio/devices/iio:device0> echo 1 > scan_elements/in_accel_x_en
  142. root:/sys/bus/iio/devices/iio:device0> echo 1 > scan_elements/in_accel_y_en
  143. root:/sys/bus/iio/devices/iio:device0> echo 1 > scan_elements/in_accel_z_en
  144. root:/sys/bus/iio/devices/iio:device0> echo 1 > scan_elements/in_temp_en
  145. Set the number of samples to be stored in the buffer:
  146. .. code-block:: bash
  147. root:/sys/bus/iio/devices/iio:device0> echo 10 > buffer/length
  148. Enable buffer readings:
  149. .. code-block:: bash
  150. root:/sys/bus/iio/devices/iio:device0> echo 1 > buffer/enable
  151. Obtain buffered data:
  152. .. code-block:: bash
  153. root:/sys/bus/iio/devices/iio:device0> hexdump -C /dev/iio\:device0
  154. ...
  155. 002bc300 f7 e7 00 a8 fb c5 24 80 f7 e7 01 04 fb d6 24 80 |......$.......$.|
  156. 002bc310 f7 f9 00 ab fb dc 24 80 f7 c3 00 b8 fb e2 24 80 |......$.......$.|
  157. 002bc320 f7 fb 00 bb fb d1 24 80 f7 b1 00 5f fb d1 24 80 |......$...._..$.|
  158. 002bc330 f7 c4 00 c6 fb a6 24 80 f7 a6 00 68 fb f1 24 80 |......$....h..$.|
  159. 002bc340 f7 b8 00 a3 fb e7 24 80 f7 9a 00 b1 fb af 24 80 |......$.......$.|
  160. 002bc350 f7 b1 00 67 fb ee 24 80 f7 96 00 be fb 92 24 80 |...g..$.......$.|
  161. 002bc360 f7 ab 00 7a fc 1b 24 80 f7 b6 00 ae fb 76 24 80 |...z..$......v$.|
  162. 002bc370 f7 ce 00 a3 fc 02 24 80 f7 c0 00 be fb 8b 24 80 |......$.......$.|
  163. 002bc380 f7 c3 00 93 fb d0 24 80 f7 ce 00 d8 fb c8 24 80 |......$.......$.|
  164. 002bc390 f7 bd 00 c0 fb 82 24 80 f8 00 00 e8 fb db 24 80 |......$.......$.|
  165. 002bc3a0 f7 d8 00 d3 fb b4 24 80 f8 0b 00 e5 fb c3 24 80 |......$.......$.|
  166. 002bc3b0 f7 eb 00 c8 fb 92 24 80 f7 e7 00 ea fb cb 24 80 |......$.......$.|
  167. 002bc3c0 f7 fd 00 cb fb 94 24 80 f7 e3 00 f2 fb b8 24 80 |......$.......$.|
  168. ...
  169. See ``Documentation/iio/iio_devbuf.rst`` for more information about how buffered
  170. data is structured.
  171. 4. IIO Interfacing Tools
  172. ========================
  173. See ``Documentation/iio/iio_tools.rst`` for the description of the available IIO
  174. interfacing tools.