Skip to content

Commit 91c71ad

Browse files
committed
drivers: sensor: Add asynchronous sensor simulator driver
Introduces a new sensor simulator driver with asynchronous API support. The driver allows for the simulation of sensor data with an internal FIFO. Signed-off-by: Lars Thiemann <thiemann@cognid.de>
1 parent 00cc444 commit 91c71ad

File tree

12 files changed

+981
-0
lines changed

12 files changed

+981
-0
lines changed

drivers/sensor/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ add_subdirectory_ifdef(CONFIG_QDEC_SAM qdec_sam)
6060
add_subdirectory_ifdef(CONFIG_RPI_PICO_TEMP rpi_pico_temp)
6161
add_subdirectory_ifdef(CONFIG_S11059 s11059)
6262
add_subdirectory_ifdef(CONFIG_SBS_GAUGE sbs_gauge)
63+
add_subdirectory_ifdef(CONFIG_SENSOR_SIM_ASYNC sensor_sim_async)
6364
add_subdirectory_ifdef(CONFIG_SX9500 sx9500)
6465
add_subdirectory_ifdef(CONFIG_TH02 th02)
6566
add_subdirectory_ifdef(CONFIG_TSIC_XX6 tsic_xx6)

drivers/sensor/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ source "drivers/sensor/qdec_sam/Kconfig"
148148
source "drivers/sensor/rpi_pico_temp/Kconfig"
149149
source "drivers/sensor/s11059/Kconfig"
150150
source "drivers/sensor/sbs_gauge/Kconfig"
151+
source "drivers/sensor/sensor_sim_async/Kconfig"
151152
source "drivers/sensor/sx9500/Kconfig"
152153
source "drivers/sensor/th02/Kconfig"
153154
source "drivers/sensor/tsic_xx6/Kconfig"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
zephyr_library()
4+
zephyr_library_sources(sensor_sim_async.c)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Sensor data simulator
2+
3+
# Copyright (c) 2025 COGNID Telematik GmbH
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
DT_COMPAT_SENSOR_SIM_ASYNC := zephyr,sensor-sim-async
7+
8+
config SENSOR_SIM_ASYNC
9+
bool "Simple sensor simulator with Async API"
10+
default y if $(dt_compat_enabled,$(DT_COMPAT_SENSOR_SIM_ASYNC))
11+
select RING_BUFFER
12+
select SENSOR_ASYNC_API
13+
help
14+
Enable the sensor simulator.
15+
16+
if SENSOR_SIM_ASYNC
17+
18+
config SENSOR_SIM_ASYNC_SCALE
19+
int "Internal scaling of the values"
20+
default 1024
21+
help
22+
Sensor values are internally saved as 16-bit integers with 1 LSB = 1 / SENSOR_SIM_ASYNC_SCALE.
23+
Default value is 1024 as it allows for a range of +/- 32 and a ~0.001 accuracy, which is a good compromise for
24+
sensors like accelerometers.
25+
26+
endif

0 commit comments

Comments
 (0)