-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sensors: generate attributes/channels/triggers
Add code generation for the sensor attribute, channel, and trigger enums. Included in this is the ability to query the sensor's information statically using the compatible string similar to how devicetree does it. Signed-off-by: Yuval Peress <[email protected]>
- Loading branch information
Showing
24 changed files
with
1,245 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright (c) 2024 Google Inc | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from typing import Any | ||
|
||
from sphinx.application import Sphinx | ||
|
||
__version__ = "0.0.1" | ||
|
||
def setup(app: Sphinx) -> dict[str, Any]: | ||
"""Introduce the sensor utilities""" | ||
|
||
# Add the sensor_yaml_files configuration value | ||
app.add_config_value( | ||
name="sensor_yaml_files", default="", rebuild="html", types=str | ||
) | ||
|
||
return { | ||
"version": __version__, | ||
"parallel_read_safe": True, | ||
"parallel_write_safe": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright (c) 2024 Google Inc | ||
# SPDX-License-Identifier: BDS-3-Clause | ||
|
||
deps: | ||
- "drivers/sensor/attributes.yaml" | ||
- "drivers/sensor/channels.yaml" | ||
- "drivers/sensor/triggers.yaml" | ||
- "drivers/sensor/units.yaml" | ||
compatible: | ||
org: "asahi-kasei" | ||
part: "akm09918c" | ||
supported-buses: | ||
- i2c | ||
channels: | ||
magn_xyz: [] | ||
magn_x: [] | ||
magn_y: [] | ||
magn_z: [] | ||
attributes: | ||
- attribute: "sampling_frequency" | ||
channel: "magn_xyz" | ||
units: "frequency" | ||
extras: | ||
doc-link: "asahi_kasei_akm09918c_driver" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Copyright (c) 2024 Google Inc | ||
# SPDX-License-Identifier: BDS-3-Clause | ||
|
||
attributes: | ||
sampling_frequency: | ||
name: "sampling rate" | ||
description: > | ||
Sensor sampling frequency, i.e. how many times a second the sensor takes a measurement. | ||
lower_thresh: | ||
name: "lower threshold" | ||
description: "Lower threshold for trigger." | ||
upper_thresh: | ||
name: "upper threshold" | ||
description: "Upper threshold for trigger." | ||
slope_th: | ||
name: "any motion threshold" | ||
description: "Threshold for any-motion (slope) trigger." | ||
slope_dur: | ||
name: "slope value threshold duration" | ||
description: > | ||
Duration for which the slope values needs to be outside the threshold for the trigger to | ||
fire. | ||
hysteresis: | ||
name: "hysteresis" | ||
description: "Hysteresis for trigger thresholds." | ||
oversampling: | ||
name: "oversampling factor" | ||
description: "Oversampling factor" | ||
full_scale: | ||
name: "range" | ||
description: "Sensor range, in SI units." | ||
offset: | ||
name: "value offset" | ||
description: > | ||
The sensor value returned will be altered by the amount indicated by offset: final_value = | ||
sensor_value + offset. | ||
calib_target: | ||
name: "calibration target" | ||
description: > | ||
Calibration target. This will be used by the internal chip's algorithms to calibrate itself | ||
on a certain axis, or all of them. | ||
configuration: | ||
name: "operating mode" | ||
description: "Configure the operating modes of a sensor." | ||
calibration: | ||
name: "calibration value" | ||
description: "Set a calibration value needed by a sensor." | ||
feature_mask: | ||
name: "enabled/disabled feature" | ||
description: "Enable/disable sensor features" | ||
alert: | ||
name: "alert threshold" | ||
description: "Alert threshold or alert enable/disable" | ||
ff_dur: | ||
name: "free-fall duration" | ||
description: > | ||
Free-fall duration represented in milliseconds. If the sampling frequency is changed during | ||
runtime, this attribute should be set to adjust freefall duration to the new sampling | ||
frequency. | ||
batch_duration: | ||
name: "batch duration" | ||
description: "Hardware batch duration in ticks" | ||
gain: | ||
name: "gain" | ||
description: "Configure the gain of a sensor." | ||
resolution: | ||
name: "resolution" | ||
description: "Configure the resolution of a sensor." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (c) 2024 Google Inc | ||
# SPDX-License-Identifier: BDS-3-Clause | ||
|
||
deps: | ||
- "drivers/sensor/attributes.yaml" | ||
- "drivers/sensor/channels.yaml" | ||
- "drivers/sensor/triggers.yaml" | ||
- "drivers/sensor/units.yaml" | ||
compatible: | ||
org: "bosch" | ||
part: "bma4xx" | ||
supported-buses: | ||
- i2c | ||
- spi | ||
description: | | ||
Sensor driver implementation for bma422 and bma423. | ||
channels: | ||
accel_x: [] | ||
accel_y: [] | ||
accel_z: [] | ||
accel_xyz: [] | ||
die_temp: [] | ||
attributes: | ||
- attribute: "sampling_frequency" | ||
channel: "accel_xyz" | ||
units: "frequency" | ||
- attribute: "full_scale" | ||
channel: "accel_xyz" | ||
units: "acceleration" | ||
- attribute: "offset" | ||
channel: "accel_xyz" | ||
units: "acceleration" | ||
extras: | ||
doc-link: "bosch_bma4xx_driver" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright (c) 2024 Google Inc | ||
# SPDX-License-Identifier: BDS-3-Clause | ||
|
||
deps: | ||
- "drivers/sensor/attributes.yaml" | ||
- "drivers/sensor/channels.yaml" | ||
- "drivers/sensor/triggers.yaml" | ||
- "drivers/sensor/units.yaml" | ||
compatible: | ||
org: "bosch" | ||
part: "bmi160" | ||
supported-buses: | ||
- i2c | ||
- spi | ||
description: | | ||
Sensor driver implementation for bmi160. | ||
channels: | ||
accel_x: [] | ||
accel_y: [] | ||
accel_z: [] | ||
accel_xyz: [] | ||
gyro_x: [] | ||
gyro_y: [] | ||
gyro_z: [] | ||
gyro_xyz: [] | ||
die_temp: [] | ||
attributes: | ||
- attribute: "sampling_frequency" | ||
channel: "accel_xyz" | ||
units: "frequency" | ||
- attribute: "sampling_frequency" | ||
channel: "gyro_xyz" | ||
units: "frequency" | ||
- attribute: "full_scale" | ||
channel: "accel_xyz" | ||
units: "acceleration" | ||
- attribute: "full_scale" | ||
channel: "gyro_xyz" | ||
units: "angular_velocity" | ||
- attribute: "offset" | ||
channel: "accel_xyz" | ||
units: "acceleration" | ||
- attribute: "offset" | ||
channel: "gyro_xyz" | ||
units: "angular_velocity" | ||
triggers: | ||
- data_ready | ||
- delta | ||
extras: | ||
doc-link: "bosch_bmi160_driver" |
Oops, something went wrong.