← Documents Documentation/iio/adxl313.rst GitHub 원문 ↗

Linux 6.18.37 · IIO

ADXL313 driver

ADXL313 가속도계의 측정 범위, 보정, 샘플링, 버퍼와 activity 이벤트를 설명합니다.

Source pathDocumentation/iio/adxl313.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

adxl313.rst:1-293

ADXL313 드라이버는 SPI·I²C 3축 가속도계의 네 측정 범위, 축별 보정, 10단계 샘플 속도, IIO 버퍼와 DC·AC activity/inactivity 이벤트를 제공합니다. 이벤트 방식 교체와 auto-sleep 연동 규칙이 핵심입니다.

문서 개요
항목
SourceDocumentation/iio/adxl313.rst
분량293 source lines
버스SPI, I²C
측정 범위±0.5 g, ±1 g, ±2 g, ±4 g
이벤트Activity, inactivity, AC adaptive, auto-sleep

지원 범위와 주요 기능을 요약합니다.

통합 가속도 흐름
측정 범위와 sampling frequency 선택3축 raw와 calibbias·scale 처리필요한 scan element로 버퍼 수집DC 또는 AC activity·inactivity 설정`iio_event_monitor`로 움직임 상태 감시

센서 측정부터 버퍼·이벤트 감시까지의 전체 경로입니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 ===============
4 ADXL313 driver
5 ===============
6
7 This driver supports Analog Device's ADXL313 on SPI/I2C bus.
8
9 1. Supported devices
10 ====================
11
12 * `ADXL313 <https://www.analog.com/ADXL313>`_
13
14 The ADXL313is a low noise density, low power, 3-axis accelerometer with
15 selectable measurement ranges. The ADXL313 supports the ±0.5 g, ±1 g, ±2 g and
16 ±4 g ranges.
17
18 2. Device attributes
19 ====================
20
21 Accelerometer measurements are always provided.
22
23 Each IIO device, has a device folder under ``/sys/bus/iio/devices/iio:deviceX``,
24 where X is the IIO index of the device. Under these folders reside a set of
25 device files, depending on the characteristics and features of the hardware
26 device in questions. These files are consistently generalized and documented in
27 the IIO ABI documentation.
28
29 The following tables show the adxl313 related device files, found in the
30 specific device folder path ``/sys/bus/iio/devices/iio:deviceX``.
31
32 +---------------------------------------------------+----------------------------------------------------------+
33 | 3-Axis Accelerometer related device files | Description |
34 +---------------------------------------------------+----------------------------------------------------------+
35 | in_accel_scale | Scale for the accelerometer channels. |
36 +---------------------------------------------------+----------------------------------------------------------+
37 | in_accel_x_calibbias | Calibration offset for the X-axis accelerometer channel. |
38 +---------------------------------------------------+----------------------------------------------------------+
39 | in_accel_x_raw | Raw X-axis accelerometer channel value. |
40 +---------------------------------------------------+----------------------------------------------------------+
41 | in_accel_y_calibbias | y-axis acceleration offset correction |
42 +---------------------------------------------------+----------------------------------------------------------+
43 | in_accel_y_raw | Raw Y-axis accelerometer channel value. |
44 +---------------------------------------------------+----------------------------------------------------------+
45 | in_accel_z_calibbias | Calibration offset for the Z-axis accelerometer channel. |
46 +---------------------------------------------------+----------------------------------------------------------+
47 | in_accel_z_raw | Raw Z-axis accelerometer channel value. |
48 +---------------------------------------------------+----------------------------------------------------------+
49
50 +---------------------------------------+----------------------------------------------+
51 | Miscellaneous device files | Description |
52 +---------------------------------------+----------------------------------------------+
53 | name | Name of the IIO device. |
54 +---------------------------------------+----------------------------------------------+
55 | in_accel_sampling_frequency | Currently selected sample rate. |
56 +---------------------------------------+----------------------------------------------+
57 | in_accel_sampling_frequency_available | Available sampling frequency configurations. |
58 +---------------------------------------+----------------------------------------------+
59
60 The iio event related settings, found in ``/sys/bus/iio/devices/iio:deviceX/events``.
61
62 +---------------------------------------------------+----------------------------------------------------------+
63 | in_accel_mag_adaptive_falling_period | AC coupled inactivity time. |
64 +---------------------------------------------------+----------------------------------------------------------+
65 | in_accel_mag_adaptive_falling_value | AC coupled inactivity threshold. |
66 +---------------------------------------------------+----------------------------------------------------------+
67 | in_accel_mag_adaptive_rising_value | AC coupled activity threshold. |
68 +---------------------------------------------------+----------------------------------------------------------+
69 | in_accel_mag_falling_period | Inactivity time. |
70 +---------------------------------------------------+----------------------------------------------------------+
71 | in_accel_mag_falling_value | Inactivity threshold. |
72 +---------------------------------------------------+----------------------------------------------------------+
73 | in_accel_mag_rising_value | Activity threshold. |
74 +---------------------------------------------------+----------------------------------------------------------+
75 | in_accel_x\&y\&z_mag_adaptive_falling_en | Enable or disable AC coupled inactivity events. |
76 +---------------------------------------------------+----------------------------------------------------------+
77 | in_accel_x\|y\|z_mag_adaptive_rising_en | Enable or disable AC coupled activity events. |
78 +---------------------------------------------------+----------------------------------------------------------+
79 | in_accel_x\&y\&z_mag_falling_en | Enable or disable inactivity events. |
80 +---------------------------------------------------+----------------------------------------------------------+
81 | in_accel_x\|y\|z_mag_rising_en | Enable or disable activity events. |
82 +---------------------------------------------------+----------------------------------------------------------+
83
84 The default coupling is DC coupled events. In this case the threshold will
85 be in place as such, where for the AC coupled case an adaptive threshold
86 (described in the datasheet) will be applied by the sensor. In general activity,
87 i.e. ``ACTIVITY`` or ``ACTIVITY_AC`` and inactivity i.e. ``INACTIVITY`` or
88 ``INACTIVITY_AC``, will be linked with auto-sleep enabled when both are enabled.
89 This means in particular ``ACTIVITY`` can also be linked to ``INACTIVITY_AC``
90 and vice versa, without problem.
91
92 Note here, that ``ACTIVITY`` and ``ACTIVITY_AC`` are mutually exclusive. This
93 means, that the most recent configuration will be set. For instance, if
94 ``ACTIVITY`` is enabled, and ``ACTIVITY_AC`` will be enabled, the sensor driver
95 will have ``ACTIVITY`` disabled, but ``ACTIVITY_AC`` enabled. The same is valid
96 for inactivity. In case of turning off an event, it has to match to what is
97 actually enabled, i.e. enabling ``ACTIVITY_AC`` and then disabling ``ACTIVITY``
98 is simply ignored as it is already disabled. Or, as if it was any other not
99 enabled event, too.
100
101 Channels processed values
102 -------------------------
103
104 A channel value can be read from its _raw attribute. The value returned is the
105 raw value as reported by the devices. To get the processed value of the channel,
106 apply the following formula:
107
108 .. code-block::
109
110 processed value = (_raw + _offset) * _scale
111
112 Where _offset and _scale are device attributes. If no _offset attribute is
113 present, simply assume its value is 0.
114
115 The ADXL313 driver offers data for a single types of channels, the table below
116 shows the measurement units for the processed value, which are defined by the
117 IIO framework:
118
119 +-------------------------------------+---------------------------+
120 | Channel type | Measurement unit |
121 +-------------------------------------+---------------------------+
122 | Acceleration on X, Y, and Z axis | Meters per Second squared |
123 +-------------------------------------+---------------------------+
124
125 Usage examples
126 --------------
127
128 Show device name:
129
130 .. code-block:: bash
131
132 root:/sys/bus/iio/devices/iio:device0> cat name
133 adxl313
134
135 Show accelerometer channels value:
136
137 .. code-block:: bash
138
139 root:/sys/bus/iio/devices/iio:device0> cat in_accel_x_raw
140 2
141 root:/sys/bus/iio/devices/iio:device0> cat in_accel_y_raw
142 -57
143 root:/sys/bus/iio/devices/iio:device0> cat in_accel_z_raw
144 2
145 root:/sys/bus/iio/devices/iio:device0> cat in_accel_scale
146 0.009576806
147
148 The accelerometer values will be:
149
150 - X-axis acceleration = in_accel_x_raw * in_accel_scale = 0.0191536 m/s^2
151 - Y-axis acceleration = in_accel_y_raw * in_accel_scale = -0.5458779 m/s^2
152 - Z-axis acceleration = in_accel_z_raw * in_accel_scale = 0.0191536 m/s^2
153
154 Set calibration offset for accelerometer channels. Note, that the calibration
155 will be rounded according to the graduation of LSB units:
156
157 .. code-block:: bash
158
159 root:/sys/bus/iio/devices/iio:device0> cat in_accel_x_calibbias
160 0
161
162 root:/sys/bus/iio/devices/iio:device0> echo 50 > in_accel_x_calibbias
163 root:/sys/bus/iio/devices/iio:device0> cat in_accel_x_calibbias
164 48
165
166 Set sampling frequency:
167
168 .. code-block:: bash
169
170 root:/sys/bus/iio/devices/iio:device0> cat in_accel_sampling_frequency
171 100.000000
172 root:/sys/bus/iio/devices/iio:device0> cat in_accel_sampling_frequency_available
173 6.250000 12.500000 25.000000 50.000000 100.000000 200.000000 400.000000 800.000000 1600.000000 3200.000000
174
175 root:/sys/bus/iio/devices/iio:device0> echo 400 > in_accel_sampling_frequency
176 root:/sys/bus/iio/devices/iio:device0> cat in_accel_sampling_frequency
177 400.000000
178
179 3. Device buffers and triggers
180 ==============================
181
182 This driver supports IIO buffers.
183
184 All devices support retrieving the raw acceleration measurements using buffers.
185
186 Usage examples
187 --------------
188
189 Select channels for buffer read:
190
191 .. code-block:: bash
192
193 root:/sys/bus/iio/devices/iio:device0> echo 1 > scan_elements/in_accel_x_en
194 root:/sys/bus/iio/devices/iio:device0> echo 1 > scan_elements/in_accel_y_en
195 root:/sys/bus/iio/devices/iio:device0> echo 1 > scan_elements/in_accel_z_en
196
197 Set the number of samples to be stored in the buffer:
198
199 .. code-block:: bash
200
201 root:/sys/bus/iio/devices/iio:device0> echo 10 > buffer/length
202
203 Enable buffer readings:
204
205 .. code-block:: bash
206
207 root:/sys/bus/iio/devices/iio:device0> echo 1 > buffer/enable
208
209 Obtain buffered data:
210
211 .. code-block:: bash
212
213 root:/sys/bus/iio/devices/iio:device0> hexdump -C /dev/iio\:device0
214 ...
215 000000d0 01 fc 31 00 c7 ff 03 fc 31 00 c7 ff 04 fc 33 00 |..1.....1.....3.|
216 000000e0 c8 ff 03 fc 32 00 c5 ff ff fc 32 00 c7 ff 0a fc |....2.....2.....|
217 000000f0 30 00 c8 ff 06 fc 33 00 c7 ff 01 fc 2f 00 c8 ff |0.....3...../...|
218 00000100 02 fc 32 00 c6 ff 04 fc 33 00 c8 ff 05 fc 33 00 |..2.....3.....3.|
219 00000110 ca ff 02 fc 31 00 c7 ff 02 fc 30 00 c9 ff 09 fc |....1.....0.....|
220 00000120 35 00 c9 ff 08 fc 35 00 c8 ff 02 fc 31 00 c5 ff |5.....5.....1...|
221 00000130 03 fc 32 00 c7 ff 04 fc 32 00 c7 ff 02 fc 31 00 |..2.....2.....1.|
222 00000140 c7 ff 08 fc 30 00 c7 ff 02 fc 32 00 c5 ff ff fc |....0.....2.....|
223 00000150 31 00 c5 ff 04 fc 31 00 c8 ff 03 fc 32 00 c8 ff |1.....1.....2...|
224 00000160 01 fc 31 00 c7 ff 05 fc 31 00 c3 ff 04 fc 31 00 |..1.....1.....1.|
225 00000170 c5 ff 04 fc 30 00 c7 ff 03 fc 31 00 c9 ff 03 fc |....0.....1.....|
226 ...
227
228 Enabling activity detection:
229
230 .. code-block:: bash
231
232 root:/sys/bus/iio/devices/iio:device0> echo 1.28125 > ./events/in_accel_mag_rising_value
233 root:/sys/bus/iio/devices/iio:device0> echo 1 > ./events/in_accel_x\|y\|z_mag_rising_en
234
235 root:/sys/bus/iio/devices/iio:device0> iio_event_monitor adxl313
236 Found IIO device with name adxl313 with device number 0
237 <only while moving the sensor>
238 Event: time: 1748795762298351281, type: accel(x|y|z), channel: 0, evtype: mag, direction: rising
239 Event: time: 1748795762302653704, type: accel(x|y|z), channel: 0, evtype: mag, direction: rising
240 Event: time: 1748795762304340726, type: accel(x|y|z), channel: 0, evtype: mag, direction: rising
241 ...
242
243 Disabling activity detection:
244
245 .. code-block:: bash
246
247 root:/sys/bus/iio/devices/iio:device0> echo 0 > ./events/in_accel_x\|y\|z_mag_rising_en
248 root:/sys/bus/iio/devices/iio:device0> iio_event_monitor adxl313
249 <nothing>
250
251 Enabling inactivity detection:
252
253 .. code-block:: bash
254
255 root:/sys/bus/iio/devices/iio:device0> echo 1.234375 > ./events/in_accel_mag_falling_value
256 root:/sys/bus/iio/devices/iio:device0> echo 5 > ./events/in_accel_mag_falling_period
257 root:/sys/bus/iio/devices/iio:device0> echo 1 > ./events/in_accel_x\&y\&z_mag_falling_en
258
259 root:/sys/bus/iio/devices/iio:device0> iio_event_monitor adxl313
260 Found IIO device with name adxl313 with device number 0
261 Event: time: 1748796324115962975, type: accel(x&y&z), channel: 0, evtype: mag, direction: falling
262 Event: time: 1748796329329981772, type: accel(x&y&z), channel: 0, evtype: mag, direction: falling
263 Event: time: 1748796334543399706, type: accel(x&y&z), channel: 0, evtype: mag, direction: falling
264 ...
265 <every 5s now indicates inactivity>
266
267 Now, enabling activity, e.g. the AC coupled counter-part ``ACTIVITY_AC``
268
269 .. code-block:: bash
270
271 root:/sys/bus/iio/devices/iio:device0> echo 1.28125 > ./events/in_accel_mag_rising_value
272 root:/sys/bus/iio/devices/iio:device0> echo 1 > ./events/in_accel_x\|y\|z_mag_rising_en
273
274 root:/sys/bus/iio/devices/iio:device0> iio_event_monitor adxl313
275 Found IIO device with name adxl313 with device number 0
276 <some activity with the sensor>
277 Event: time: 1748796880354686777, type: accel(x|y|z), channel: 0, evtype: mag_adaptive, direction: rising
278 <5s of inactivity, then>
279 Event: time: 1748796885543252017, type: accel(x&y&z), channel: 0, evtype: mag, direction: falling
280 <some other activity detected by accelerating the sensor>
281 Event: time: 1748796887756634678, type: accel(x|y|z), channel: 0, evtype: mag_adaptive, direction: rising
282 <again, 5s of inactivity>
283 Event: time: 1748796892964368352, type: accel(x&y&z), channel: 0, evtype: mag, direction: falling
284 <stays like this until next activity in auto-sleep>
285
286 Note, when AC coupling is in place, the event type will be of ``mag_adaptive``.
287 AC- or DC-coupled (the default) events are used similarly.
288
289 4. IIO Interfacing Tools
290 ========================
291
292 See Documentation/iio/iio_tools.rst for the description of the available IIO
293 interfacing tools.
294

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

장치 개요와 가속도 속성

1-59

이 드라이버는 SPI 또는 I²C 버스에 연결된 Analog Devices ADXL313을 지원합니다.

ADXL313은 잡음 밀도와 소비 전력이 낮은 3축 가속도계이며 측정 범위를 선택할 수 있습니다. 지원 범위는 ±0.5 g, ±1 g, ±2 g, ±4 g입니다.

ADXL313 측정 범위
장치버스선택 범위
ADXL313SPI 또는 I²C±0.5 g, ±1 g, ±2 g, ±4 g

동일한 3축 센서에서 선택할 수 있는 네 full-scale 범위입니다.

가속도계 측정값은 항상 제공됩니다. 각 IIO 장치에는 `/sys/bus/iio/devices/iio:deviceX` 폴더가 있으며 X는 장치 인덱스입니다. 하드웨어 기능에 따른 파일이 이 경로 아래에 생성되고 IIO ABI 규칙을 따릅니다.

3축 가속도계 속성
장치 파일설명
`in_accel_scale`가속도계 채널 배율
`in_accel_x_calibbias`X축 가속도 보정 오프셋
`in_accel_x_raw`X축 가속도 원시 값
`in_accel_y_calibbias`Y축 가속도 오프셋 보정
`in_accel_y_raw`Y축 가속도 원시 값
`in_accel_z_calibbias`Z축 가속도 보정 오프셋
`in_accel_z_raw`Z축 가속도 원시 값

공통 배율과 축별 원시 값·보정 오프셋입니다.

기타 ADXL313 속성
장치 파일설명
`name`IIO 장치 이름
`in_accel_sampling_frequency`현재 선택한 sample rate
`in_accel_sampling_frequency_available`선택 가능한 sampling frequency 목록

장치 식별과 현재·지원 샘플링 주파수입니다.

ADXL313 측정 경로
SPI 또는 I²C로 ADXL313 연결±0.5 g~±4 g 측정 범위 선택X·Y·Z 원시 가속도 취득축별 calibbias와 공통 scale 적용`iio:deviceX` 속성으로 결과 읽기

범위 선택부터 IIO 가속도 값까지의 흐름입니다.

.. SPDX-License-Identifier: GPL-2.0

===============
ADXL313 driver
===============

This driver supports Analog Device's ADXL313 on SPI/I2C bus.

1. Supported devices
====================

* `ADXL313 <https://www.analog.com/ADXL313>`_

The ADXL313is a low noise density, low power, 3-axis accelerometer with
selectable measurement ranges. The ADXL313 supports the ±0.5 g, ±1 g, ±2 g and
±4 g ranges.

2. Device attributes
====================

Accelerometer measurements are always provided.

Each IIO device, has a device folder under ``/sys/bus/iio/devices/iio:deviceX``,
where X is the IIO index of the device. Under these folders reside a set of
device files, depending on the characteristics and features of the hardware
device in questions. These files are consistently generalized and documented in
the IIO ABI documentation.

The following tables show the adxl313 related device files, found in the
specific device folder path ``/sys/bus/iio/devices/iio:deviceX``.

+---------------------------------------------------+----------------------------------------------------------+
| 3-Axis Accelerometer related device files         | Description                                              |
+---------------------------------------------------+----------------------------------------------------------+
| in_accel_scale                                    | Scale for the accelerometer channels.                    |
+---------------------------------------------------+----------------------------------------------------------+
| in_accel_x_calibbias                              | Calibration offset for the X-axis accelerometer channel. |
+---------------------------------------------------+----------------------------------------------------------+
| in_accel_x_raw                                    | Raw X-axis accelerometer channel value.                  |
+---------------------------------------------------+----------------------------------------------------------+
| in_accel_y_calibbias                              | y-axis acceleration offset correction                    |
+---------------------------------------------------+----------------------------------------------------------+
| in_accel_y_raw                                    | Raw Y-axis accelerometer channel value.                  |
+---------------------------------------------------+----------------------------------------------------------+
| in_accel_z_calibbias                              | Calibration offset for the Z-axis accelerometer channel. |
+---------------------------------------------------+----------------------------------------------------------+
| in_accel_z_raw                                    | Raw Z-axis accelerometer channel value.                  |
+---------------------------------------------------+----------------------------------------------------------+

+---------------------------------------+----------------------------------------------+
| Miscellaneous device files            | Description                                  |
+---------------------------------------+----------------------------------------------+
| name                                  | Name of the IIO device.                      |
+---------------------------------------+----------------------------------------------+
| in_accel_sampling_frequency           | Currently selected sample rate.              |
+---------------------------------------+----------------------------------------------+
| in_accel_sampling_frequency_available | Available sampling frequency configurations. |
+---------------------------------------+----------------------------------------------+

Activity·inactivity 이벤트와 처리 단위

60-124

IIO 이벤트 설정 파일은 `/sys/bus/iio/devices/iio:deviceX/events`에 있습니다.

ADXL313 이벤트 속성
이벤트 속성설명
`in_accel_mag_adaptive_falling_period`AC 결합 inactivity 시간
`in_accel_mag_adaptive_falling_value`AC 결합 inactivity 임계값
`in_accel_mag_adaptive_rising_value`AC 결합 activity 임계값
`in_accel_mag_falling_period`DC 결합 inactivity 시간
`in_accel_mag_falling_value`DC 결합 inactivity 임계값
`in_accel_mag_rising_value`DC 결합 activity 임계값
`in_accel_x\&y\&z_mag_adaptive_falling_en`AC 결합 inactivity 이벤트 활성화
`in_accel_x\|y\|z_mag_adaptive_rising_en`AC 결합 activity 이벤트 활성화
`in_accel_x\&y\&z_mag_falling_en`DC 결합 inactivity 이벤트 활성화
`in_accel_x\|y\|z_mag_rising_en`DC 결합 activity 이벤트 활성화

DC 또는 AC 결합 activity·inactivity의 임계값, 기간과 enable 파일입니다.

기본 결합 방식은 DC입니다. DC 이벤트는 설정한 임계값을 직접 사용하고, AC 결합에서는 데이터시트에 설명된 적응형 임계값을 센서가 적용합니다.

Activity인 `ACTIVITY` 또는 `ACTIVITY_AC`와 inactivity인 `INACTIVITY` 또는 `INACTIVITY_AC`를 함께 활성화하면 auto-sleep과 연결됩니다. DC activity와 AC inactivity 같은 교차 조합도 문제없이 사용할 수 있습니다.

Activity·inactivity 결합 규칙
이벤트 그룹선택 가능 방식동작
Activity`ACTIVITY` 또는 `ACTIVITY_AC`둘 중 가장 최근 설정만 활성
Inactivity`INACTIVITY` 또는 `INACTIVITY_AC`둘 중 가장 최근 설정만 활성
Activity + inactivityDC·AC 교차 조합 가능둘 다 켜면 auto-sleep 연동

DC·AC 방식의 선택과 auto-sleep 연동을 정리합니다.

`ACTIVITY`와 `ACTIVITY_AC`는 상호 배타적입니다. 예를 들어 `ACTIVITY`가 켜진 상태에서 `ACTIVITY_AC`를 켜면 드라이버는 앞의 `ACTIVITY`를 끄고 `ACTIVITY_AC`만 켭니다. Inactivity에도 같은 규칙이 적용됩니다.

이벤트를 끌 때는 실제 활성화된 종류와 일치해야 합니다. `ACTIVITY_AC`를 켠 뒤 이미 꺼져 있는 `ACTIVITY`를 끄는 요청은 다른 비활성 이벤트를 끄는 요청처럼 무시됩니다.

채널의 `_raw` 속성은 센서 원시 값을 반환합니다. 처리된 값은 다음 공식으로 계산합니다.

processed value = (_raw + _offset) * _scale

`_offset`과 `_scale`은 장치 속성입니다. `_offset`이 없으면 0으로 간주합니다. ADXL313이 제공하는 채널 유형은 가속도 하나이며 처리 단위는 X·Y·Z축 모두 m/s²입니다.

ADXL313 처리값 단위
채널 유형처리값 단위
X·Y·Z축 가속도m/s²

IIO 프레임워크가 정의하는 가속도 처리값 단위입니다.

이벤트 방식 전환
DC activity 또는 inactivity 활성화같은 그룹의 AC 결합 이벤트 활성화 요청기존 DC 이벤트 자동 비활성화가장 최근 AC 이벤트만 활성 상태 유지Activity와 inactivity가 모두 켜지면 auto-sleep 연동

같은 그룹에서 DC와 AC 결합 설정이 교체되는 규칙입니다.

The iio event related settings, found in ``/sys/bus/iio/devices/iio:deviceX/events``.

+---------------------------------------------------+----------------------------------------------------------+
| in_accel_mag_adaptive_falling_period              | AC coupled inactivity time.                              |
+---------------------------------------------------+----------------------------------------------------------+
| in_accel_mag_adaptive_falling_value               | AC coupled inactivity threshold.                         |
+---------------------------------------------------+----------------------------------------------------------+
| in_accel_mag_adaptive_rising_value                | AC coupled activity threshold.                           |
+---------------------------------------------------+----------------------------------------------------------+
| in_accel_mag_falling_period                       | Inactivity time.                                         |
+---------------------------------------------------+----------------------------------------------------------+
| in_accel_mag_falling_value                        | Inactivity threshold.                                    |
+---------------------------------------------------+----------------------------------------------------------+
| in_accel_mag_rising_value                         | Activity threshold.                                      |
+---------------------------------------------------+----------------------------------------------------------+
| in_accel_x\&y\&z_mag_adaptive_falling_en          | Enable or disable AC coupled inactivity events.          |
+---------------------------------------------------+----------------------------------------------------------+
| in_accel_x\|y\|z_mag_adaptive_rising_en           | Enable or disable AC coupled activity events.            |
+---------------------------------------------------+----------------------------------------------------------+
| in_accel_x\&y\&z_mag_falling_en                   | Enable or disable inactivity events.                     |
+---------------------------------------------------+----------------------------------------------------------+
| in_accel_x\|y\|z_mag_rising_en                    | Enable or disable activity events.                       |
+---------------------------------------------------+----------------------------------------------------------+

The default coupling is DC coupled events. In this case the threshold will
be in place as such, where for the AC coupled case an adaptive threshold
(described in the datasheet) will be applied by the sensor. In general activity,
i.e. ``ACTIVITY`` or ``ACTIVITY_AC`` and inactivity i.e. ``INACTIVITY`` or
``INACTIVITY_AC``, will be linked with auto-sleep enabled when both are enabled.
This means in particular ``ACTIVITY`` can also be linked to ``INACTIVITY_AC``
and vice versa, without problem.

Note here, that ``ACTIVITY`` and ``ACTIVITY_AC`` are mutually exclusive. This
means, that the most recent configuration will be set. For instance, if
``ACTIVITY`` is enabled, and ``ACTIVITY_AC`` will be enabled, the sensor driver
will have ``ACTIVITY`` disabled, but ``ACTIVITY_AC`` enabled. The same is valid
for inactivity. In case of turning off an event, it has to match to what is
actually enabled, i.e. enabling ``ACTIVITY_AC`` and then disabling ``ACTIVITY``
is simply ignored as it is already disabled. Or, as if it was any other not
enabled event, too.

Channels processed values
-------------------------

A channel value can be read from its _raw attribute. The value returned is the
raw value as reported by the devices. To get the processed value of the channel,
apply the following formula:

.. code-block::

        processed value = (_raw + _offset) * _scale

Where _offset and _scale are device attributes. If no _offset attribute is
present, simply assume its value is 0.

The ADXL313 driver offers data for a single types of channels, the table below
shows the measurement units for the processed value, which are defined by the
IIO framework:

+-------------------------------------+---------------------------+
| Channel type                        | Measurement unit          |
+-------------------------------------+---------------------------+
| Acceleration on X, Y, and Z axis    | Meters per Second squared |
+-------------------------------------+---------------------------+

가속도·보정·샘플링 예제

125-178

장치 이름을 읽는 예제 결과는 `adxl313`입니다.

root:/sys/bus/iio/devices/iio:device0> cat name
adxl313

가속도계 예제는 X·Y·Z축 원시 값 2, −57, 2와 배율 0.009576806을 읽습니다.

root:/sys/bus/iio/devices/iio:device0> cat in_accel_x_raw
2
root:/sys/bus/iio/devices/iio:device0> cat in_accel_y_raw
-57
root:/sys/bus/iio/devices/iio:device0> cat in_accel_z_raw
2
root:/sys/bus/iio/devices/iio:device0> cat in_accel_scale
0.009576806
가속도 처리값 예제
원시 값처리값
X20.0191536 m/s²
Y-57-0.5458779 m/s²
Z20.0191536 m/s²

원시 값에 `in_accel_scale = 0.009576806`을 적용한 결과입니다.

가속도계 보정 오프셋은 LSB 단계에 맞춰 반올림됩니다. 예제에서 X축 `calibbias`에 50을 쓰지만 다시 읽으면 48이 반환됩니다.

root:/sys/bus/iio/devices/iio:device0> cat in_accel_x_calibbias
0
root:/sys/bus/iio/devices/iio:device0> echo 50 > in_accel_x_calibbias
root:/sys/bus/iio/devices/iio:device0> cat in_accel_x_calibbias
48

현재 샘플링 주파수는 100 Hz입니다. 사용 가능한 값은 6.25, 12.5, 25, 50, 100, 200, 400, 800, 1600, 3200 Hz이며 예제에서는 400 Hz로 변경합니다.

root:/sys/bus/iio/devices/iio:device0> cat in_accel_sampling_frequency
100.000000
root:/sys/bus/iio/devices/iio:device0> cat in_accel_sampling_frequency_available
6.250000 12.500000 25.000000 50.000000 100.000000 200.000000 400.000000 800.000000 1600.000000 3200.000000
root:/sys/bus/iio/devices/iio:device0> echo 400 > in_accel_sampling_frequency
root:/sys/bus/iio/devices/iio:device0> cat in_accel_sampling_frequency
400.000000
ADXL313 설정 예제
작업요청실제 값
X축 calibbias5048, LSB 단계로 반올림
Sampling frequency400 Hz400.000000 Hz

보정 반올림과 샘플 속도 선택 결과입니다.

ADXL313 값 설정
장치 이름과 축별 raw 확인공통 scale로 가속도 계산축별 calibbias 쓰기반올림된 실제 보정값 재확인available 목록에서 sample rate 선택

원시 측정값 확인과 사용자 설정 순서입니다.

Usage examples
--------------

Show device name:

.. code-block:: bash

        root:/sys/bus/iio/devices/iio:device0> cat name
        adxl313

Show accelerometer channels value:

.. code-block:: bash

        root:/sys/bus/iio/devices/iio:device0> cat in_accel_x_raw
        2
        root:/sys/bus/iio/devices/iio:device0> cat in_accel_y_raw
        -57
        root:/sys/bus/iio/devices/iio:device0> cat in_accel_z_raw
        2
        root:/sys/bus/iio/devices/iio:device0> cat in_accel_scale
        0.009576806

The accelerometer values will be:

- X-axis acceleration = in_accel_x_raw * in_accel_scale = 0.0191536 m/s^2
- Y-axis acceleration = in_accel_y_raw * in_accel_scale = -0.5458779 m/s^2
- Z-axis acceleration = in_accel_z_raw * in_accel_scale = 0.0191536 m/s^2

Set calibration offset for accelerometer channels. Note, that the calibration
will be rounded according to the graduation of LSB units:

.. code-block:: bash

        root:/sys/bus/iio/devices/iio:device0> cat in_accel_x_calibbias
        0

        root:/sys/bus/iio/devices/iio:device0> echo 50 > in_accel_x_calibbias
        root:/sys/bus/iio/devices/iio:device0> cat in_accel_x_calibbias
        48

Set sampling frequency:

.. code-block:: bash

        root:/sys/bus/iio/devices/iio:device0> cat in_accel_sampling_frequency
        100.000000
        root:/sys/bus/iio/devices/iio:device0> cat in_accel_sampling_frequency_available
        6.250000 12.500000 25.000000 50.000000 100.000000 200.000000 400.000000 800.000000 1600.000000 3200.000000

        root:/sys/bus/iio/devices/iio:device0> echo 400 > in_accel_sampling_frequency
        root:/sys/bus/iio/devices/iio:device0> cat in_accel_sampling_frequency
        400.000000

IIO 가속도 버퍼

179-227

이 드라이버는 IIO 버퍼를 지원하며 ADXL313의 원시 X·Y·Z 가속도 값을 버퍼로 읽을 수 있습니다.

버퍼 읽기를 위해 세 축의 scan element를 활성화합니다.

root:/sys/bus/iio/devices/iio:device0> echo 1 > scan_elements/in_accel_x_en
root:/sys/bus/iio/devices/iio:device0> echo 1 > scan_elements/in_accel_y_en
root:/sys/bus/iio/devices/iio:device0> echo 1 > scan_elements/in_accel_z_en

저장할 샘플 수는 `buffer/length`에 10을 쓰고, `buffer/enable`에 1을 써서 버퍼 읽기를 활성화합니다.

root:/sys/bus/iio/devices/iio:device0> echo 10 > buffer/length
root:/sys/bus/iio/devices/iio:device0> echo 1 > buffer/enable

버퍼 데이터는 `hexdump -C /dev/iio\:device0`로 읽습니다. 원문의 16진수 예제는 연속된 X·Y·Z 스캔 레코드의 원시 바이트를 보여 줍니다.

root:/sys/bus/iio/devices/iio:device0> hexdump -C /dev/iio\:device0
ADXL313 버퍼 구성
단계설정
채널`in_accel_x_en`, `in_accel_y_en`, `in_accel_z_en` = 1
길이`buffer/length` = 10
활성화`buffer/enable` = 1
읽기`hexdump -C /dev/iio\:device0`

세 축 선택부터 원시 데이터 읽기까지 필요한 설정입니다.

3축 가속도 버퍼 캡처
X·Y·Z scan element 활성화Buffer length 10 설정Buffer enable장치가 3축 샘플을 연속 저장`hexdump -C`로 레코드 확인

버퍼 채널 선택에서 원시 레코드 확인까지의 흐름입니다.

3. Device buffers and triggers
==============================

This driver supports IIO buffers.

All devices support retrieving the raw acceleration measurements using buffers.

Usage examples
--------------

Select channels for buffer read:

.. code-block:: bash

        root:/sys/bus/iio/devices/iio:device0> echo 1 > scan_elements/in_accel_x_en
        root:/sys/bus/iio/devices/iio:device0> echo 1 > scan_elements/in_accel_y_en
        root:/sys/bus/iio/devices/iio:device0> echo 1 > scan_elements/in_accel_z_en

Set the number of samples to be stored in the buffer:

.. code-block:: bash

        root:/sys/bus/iio/devices/iio:device0> echo 10 > buffer/length

Enable buffer readings:

.. code-block:: bash

        root:/sys/bus/iio/devices/iio:device0> echo 1 > buffer/enable

Obtain buffered data:

.. code-block:: bash

        root:/sys/bus/iio/devices/iio:device0> hexdump -C /dev/iio\:device0
        ...
        000000d0  01 fc 31 00 c7 ff 03 fc  31 00 c7 ff 04 fc 33 00  |..1.....1.....3.|
        000000e0  c8 ff 03 fc 32 00 c5 ff  ff fc 32 00 c7 ff 0a fc  |....2.....2.....|
        000000f0  30 00 c8 ff 06 fc 33 00  c7 ff 01 fc 2f 00 c8 ff  |0.....3...../...|
        00000100  02 fc 32 00 c6 ff 04 fc  33 00 c8 ff 05 fc 33 00  |..2.....3.....3.|
        00000110  ca ff 02 fc 31 00 c7 ff  02 fc 30 00 c9 ff 09 fc  |....1.....0.....|
        00000120  35 00 c9 ff 08 fc 35 00  c8 ff 02 fc 31 00 c5 ff  |5.....5.....1...|
        00000130  03 fc 32 00 c7 ff 04 fc  32 00 c7 ff 02 fc 31 00  |..2.....2.....1.|
        00000140  c7 ff 08 fc 30 00 c7 ff  02 fc 32 00 c5 ff ff fc  |....0.....2.....|
        00000150  31 00 c5 ff 04 fc 31 00  c8 ff 03 fc 32 00 c8 ff  |1.....1.....2...|
        00000160  01 fc 31 00 c7 ff 05 fc  31 00 c3 ff 04 fc 31 00  |..1.....1.....1.|
        00000170  c5 ff 04 fc 30 00 c7 ff  03 fc 31 00 c9 ff 03 fc  |....0.....1.....|
        ...

Activity·inactivity 이벤트 예제와 도구

228-293

DC 결합 activity 감지를 활성화하려면 rising 임계값을 1.28125로 설정하고 `in_accel_x\|y\|z_mag_rising_en`을 1로 설정합니다. `iio_event_monitor adxl313`은 센서를 움직이는 동안 `accel(x|y|z)`, `mag`, `rising` 이벤트와 타임스탬프를 출력합니다.

echo 1.28125 > ./events/in_accel_mag_rising_value
echo 1 > ./events/in_accel_x\|y\|z_mag_rising_en
iio_event_monitor adxl313

Activity 감지를 끄려면 같은 enable 파일에 0을 씁니다. 이후 이벤트 모니터에는 아무 이벤트도 나타나지 않습니다.

echo 0 > ./events/in_accel_x\|y\|z_mag_rising_en
iio_event_monitor adxl313
<nothing>

DC 결합 inactivity 감지는 falling 임계값 1.234375와 기간 5초를 설정한 뒤 `in_accel_x\&y\&z_mag_falling_en`을 켭니다. 모니터는 `accel(x&y&z)`, `mag`, `falling` 이벤트를 약 5초마다 출력해 비활동 상태를 알립니다.

echo 1.234375 > ./events/in_accel_mag_falling_value
echo 5 > ./events/in_accel_mag_falling_period
echo 1 > ./events/in_accel_x\&y\&z_mag_falling_en
iio_event_monitor adxl313

그 상태에서 AC 결합 activity인 `ACTIVITY_AC`를 활성화할 수 있습니다. 센서 활동 시 `mag_adaptive` rising 이벤트가 발생하고, 5초 동안 비활동이면 기존 `mag` falling 이벤트가 발생합니다. Auto-sleep에서는 다음 활동이 감지될 때까지 이 상태가 유지됩니다.

이벤트 모니터 출력 의미
출력의미
`accel(x|y|z), mag, rising`어느 한 축이 DC activity 임계값을 넘음
`accel(x|y|z), mag_adaptive, rising`어느 한 축에서 AC activity 감지
`accel(x&y&z), mag, falling`모든 축이 정해진 기간 동안 inactivity 조건 충족

원문 예제에서 채널 조합·이벤트 유형·방향이 나타내는 조건입니다.

AC 결합이 사용되면 이벤트 유형은 `mag_adaptive`입니다. 그 밖의 사용 절차는 기본 DC 결합 이벤트와 같습니다.

Auto-sleep 이벤트 순환
AC activity 임계값 초과`mag_adaptive` rising 이벤트 발생센서 활동 종료 후 5초 대기`mag` falling inactivity 이벤트 발생Auto-sleep에서 다음 activity 대기

AC activity와 DC inactivity를 함께 사용할 때의 상태 변화를 나타냅니다.

사용 가능한 IIO 인터페이스 도구에 관한 설명은 `Documentation/iio/iio_tools.rst`를 참고합니다.

Enabling activity detection:

.. code-block:: bash

        root:/sys/bus/iio/devices/iio:device0> echo 1.28125 > ./events/in_accel_mag_rising_value
        root:/sys/bus/iio/devices/iio:device0> echo 1 > ./events/in_accel_x\|y\|z_mag_rising_en

        root:/sys/bus/iio/devices/iio:device0> iio_event_monitor adxl313
        Found IIO device with name adxl313 with device number 0
        <only while moving the sensor>
        Event: time: 1748795762298351281, type: accel(x|y|z), channel: 0, evtype: mag, direction: rising
        Event: time: 1748795762302653704, type: accel(x|y|z), channel: 0, evtype: mag, direction: rising
        Event: time: 1748795762304340726, type: accel(x|y|z), channel: 0, evtype: mag, direction: rising
        ...

Disabling activity detection:

.. code-block:: bash

        root:/sys/bus/iio/devices/iio:device0> echo 0 > ./events/in_accel_x\|y\|z_mag_rising_en
        root:/sys/bus/iio/devices/iio:device0> iio_event_monitor adxl313
        <nothing>

Enabling inactivity detection:

.. code-block:: bash

        root:/sys/bus/iio/devices/iio:device0> echo 1.234375 > ./events/in_accel_mag_falling_value
        root:/sys/bus/iio/devices/iio:device0> echo 5 > ./events/in_accel_mag_falling_period
        root:/sys/bus/iio/devices/iio:device0> echo 1 > ./events/in_accel_x\&y\&z_mag_falling_en

        root:/sys/bus/iio/devices/iio:device0> iio_event_monitor adxl313
        Found IIO device with name adxl313 with device number 0
        Event: time: 1748796324115962975, type: accel(x&y&z), channel: 0, evtype: mag, direction: falling
        Event: time: 1748796329329981772, type: accel(x&y&z), channel: 0, evtype: mag, direction: falling
        Event: time: 1748796334543399706, type: accel(x&y&z), channel: 0, evtype: mag, direction: falling
        ...
        <every 5s now indicates inactivity>

Now, enabling activity, e.g. the AC coupled counter-part ``ACTIVITY_AC``

.. code-block:: bash

        root:/sys/bus/iio/devices/iio:device0> echo 1.28125 > ./events/in_accel_mag_rising_value
        root:/sys/bus/iio/devices/iio:device0> echo 1 > ./events/in_accel_x\|y\|z_mag_rising_en

        root:/sys/bus/iio/devices/iio:device0> iio_event_monitor adxl313
        Found IIO device with name adxl313 with device number 0
        <some activity with the sensor>
        Event: time: 1748796880354686777, type: accel(x|y|z), channel: 0, evtype: mag_adaptive, direction: rising
        <5s of inactivity, then>
        Event: time: 1748796885543252017, type: accel(x&y&z), channel: 0, evtype: mag, direction: falling
        <some other activity detected by accelerating the sensor>
        Event: time: 1748796887756634678, type: accel(x|y|z), channel: 0, evtype: mag_adaptive, direction: rising
        <again, 5s of inactivity>
        Event: time: 1748796892964368352, type: accel(x&y&z), channel: 0, evtype: mag, direction: falling
        <stays like this until next activity in auto-sleep>

Note, when AC coupling is in place, the event type will be of ``mag_adaptive``.
AC- or DC-coupled (the default) events are used similarly.

4. IIO Interfacing Tools
========================

See Documentation/iio/iio_tools.rst for the description of the available IIO
interfacing tools.