SENSOR_CHAN_AMBIENT_TEMP shared a case block with SENSOR_CHAN_ALL that
required both the accelerometer and the gyroscope to be enabled, so
fetching the die temperature returned -ENOTSUP whenever either ODR was
set to the power-down entry. Give the temperature channel its own case
that derives the poll step from whichever engine is enabled.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The SENSOR_ATTR_FULL_SCALE getter for SENSOR_CHAN_GYRO_XYZ returned the
raw dps value from the full scale list, while the setter converts its
input with sensor_rad_to_degrees(), so a get-then-set round trip failed
with -EINVAL. Convert the reported range to rad/s to match the setter.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The SENSOR_ATTR_FULL_SCALE getter for the accelerometer returned the
raw range from the full scale list, which is expressed in g, while the
setter expects m/s^2 as mandated by the sensor API. Convert the value
with sensor_g_to_ms2() so the getter is the exact inverse of the
setter.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
ccs811_baseline_fetch() tested the i2c_write_read_dt() result with
"rc <= 0", which is also true on failure, so a failed transfer returned
the uninitialised stack value of baseline instead of the negative errno
the API documents. Test for success with "rc == 0".
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
adt7420_trigger_set() unconditionally disabled both the INT and CT GPIO
interrupts but only re-enabled the line matching trig->chan, silently
killing a previously registered trigger on the other pin. Each disable
now happens in its own branch, guarded by that pin's presence, and the
trigger type is validated before any GPIO is touched.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
Attributes flagged MAX30009_ATTR_PLL_OFF cycle the PLL, and the
re-enable path polls the clear-on-read STATUS1 register. Running that
poll while streaming or triggers are active eats pending A_FULL /
FIFO_DATA_RDY events (permanently stalling an assert-once FIFO
watermark stream) or lets those readers consume the lock bits, causing
spurious -ETIMEDOUT. Return -EBUSY instead when a stream request is
pending or a trigger handler is registered.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The streamed FIFO sample period was computed from the const devicetree
ADC OSR code, so runtime SENSOR_ATTR_MAX30009_ADC_OSR changes were
ignored and decoded per-sample timestamps were wrong. Cache the OSR
code in driver data, update it on attribute writes, and use it when
computing the sample period.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
max30009_flush_rtio is only called after the streaming request was
already completed with rtio_iodev_sqe_ok and data->sqe was set to
NULL, so calling rtio_iodev_sqe_err(data->sqe, -ENOMEM) on SQE
acquire failure dereferenced NULL. Drop any partially acquired SQE
with rtio_sqe_drop_all instead, matching the other error paths.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The decoder wrote a full struct sensor_q31_data per decoded FIFO
sample, striding ~32 bytes per frame, while get_size_info advertises
frame_size = sizeof(struct sensor_q31_sample_data) (8 bytes),
overflowing contract-sized buffers when max_count > 1. Fill a single
header/shift once and append samples to out->readings[] with proper
timestamp deltas, matching the sibling FIFO decoders.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
Add device power management so the sensor can sit under a power domain
that may be unpowered at init. Bring-up moves to a PM_DEVICE_ACTION_TURN_ON
handler, and RESUME/SUSPEND toggle the config register shutdown bit.
Signed-off-by: Corey Wharton <xodus7@cwharton.com>
The akm09918c driver imposes and unconditional wait time on fetch. This
is only neccesary for single-shot sampling. If the sensor is configured in
continuous mode, an application can time the fetch to align with the sensor
ODR. For continous mode operation it does not make sense to have an
artificial delay added - if the application is trying to fetch values at a
higher frequency than the ODR it can just handle the -EBUSY by adding
its own delay and retrying the fetch or reading the old values.
Verified this change testing parallel sampling with an LSM6DSO IMU,
Fetching all channels on DRDY of the IMU with the same ODR configured
for both IMU and magnetometer.
Signed-off-by: Jose Morales <josfemova@gmail.com>
Implement SENSOR_ASYNC_API for the MS5637 driver using RTIO
submission chains for non-blocking pressure/temperature reads.
- Add RTIO SQE chain helper (ms5637_prep_conv_chain) to
reduce duplication between pressure and temperature paths
- Add sensor data decoder with q31 output format
- Refactor ms5637_compensate to accept calibration struct
and output reading pointer, eliminating dependency on the
full ms5637_data struct for use in decoder context
- Add Kconfig selections for I2C_RTIO and RTIO_OP_DELAY
when SENSOR_ASYNC_API is enabled
- Fix CMakeLists.txt to use CONFIG_SENSOR_ASYNC_API
Signed-off-by: Sudarshan Iyengar <sudarshan.iyengar@alifsemi.com>
Assisted-by: Claude:claude-opus-4.7
Add missing dependencies on the HAL module for sensors that use the HAL
headers. This fixes compile time errors for `build_all` tests downstream
that don't have the HAL checked out.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Add missing dependencies on the HAL module for sensors that use the HAL
headers. This fixes compile time errors for `build_all` tests downstream
that don't have the HAL checked out.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Adjust base_timestamp_ns backward from the trigger timestamp by
(N-1)*period so it reflects the time of the first FIFO sample,
matching the lsm6dsv16x reference implementation.
Fixes: #98720
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
(cherry picked from commit 2e9f16f337e5ae2748257871328d2bc29f442bd5)
Enable FIFO_TMST_FSYNC_EN in FIFO_CONFIG4 so the sensor inserts a
16-bit hardware timestamp into every 20-byte FIFO packet. Set
TMST_RESOL=1 (16us/tick) to support batch spans up to ~524ms.
In the decoder, anchor the batch to the host IRQ time via the last
packet's hardware timestamp, then compute base_timestamp_ns and
per-sample timestamp_delta using the signed 16-bit delta between
packet timestamps. This handles wraparound naturally and gives exact
inter-sample timing without assuming a uniform ODR.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
The thermometer sample uses sensor hardware that depends on a GPIO
device, but GPIO is not enabled in the board-specific sample
configuration for nucleo_h7a3zi_q.
Automatically enable CONFIG_GPIO when ti,tmp1075 is enabled with
alert-gpios property set,to ensure the required GPIO device is
instantiated and allow the sample to build successfully.
Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>
Code guarded by BMM150_SET_ATTR_REP used the nonexistent
dev->driver->data and the undefined bmm150_magn_data type. Use
dev->data and struct bmm150_data.
Drop unused config variable as well.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
In Multi-LED mode, nothing prevents adding zeros between numbers in
the slot sequence. This is not recommended by the datasheet and can
actually render the translation map unusable because a shift appears
when reading the sensor FIFO data register. To prevent this, additional
build asserts have been added to check the slot sequence at compile time.
The default led-slot from bindings has been corrected: each type of
sensor will make all accessible LEDs available to the user by default.
Signed-off-by: Alban Chauvel <a.chauvel@catie.fr>
Implements an emulated I2C device for register access of the LTC4286,
used to test driver conversion and register access logic.
Signed-off-by: Jan Carlo Roleda <jancarlo.roleda@analog.com>
Added Driver support for LTC4286 Hot-Swap Controller and Power Monitor.
Supports power telemetry and interrupt support to alert host device of
fault and warning events.
Signed-off-by: Jan Carlo Roleda <jancarlo.roleda@analog.com>
The TMP112 can stay in shutdown (SD) mode and perform a single
conversion on demand via the one-shot (OS) bit. This is the lowest
idle-current mode and suits battery-powered designs that sample
infrequently.
Expose this mode through the conversion-rate property: setting it to 0
keeps the sensor shut down and triggers a one-shot conversion on every
sample_fetch call, blocking until the OS bit reads back as 1 (typ.
10 ms per datasheet 7.4.3) or a timeout elapses. The same mode can be
selected at runtime by setting a 0 Hz sampling frequency through
sensor_attr_set().
Because a new value (0) is prepended to the conversion-rate enum, the
device-tree enum index no longer maps directly onto the CR register
field, so the init path subtracts one for the periodic rates.
Tested on an nRF54L15-DK with a TMP112 over I2C: the periodic rates are
unchanged and conversion-rate = 0 returns correct readings on demand
while the sensor is held in shutdown between fetches.
Assisted-by: Claude:claude-opus-4.8
Signed-off-by: Martin Hubáček <martin.hubacek@hardwario.com>
The default case of the angle_magnitude_axis switch programs
TMAG5273_ANGLE_EN_POS. This value sets bits outside the ANGLE_EN
field and overlaps with the adjacent range configuration bits in
SENSOR_CONFIG_2.
Use TMAG5273_ANGLE_EN_NONE instead to be corrrectly configured.
Signed-off-by: Stefan Prisacariu <stefan.prisacariu@prevas.dk>
Use the active channel's configuration when converting raw sensor data
to frequency and capacitance.
The conversion helpers were using cfg->ch_cfg->fin_sel and
cfg->ch_cfg->inductance, which always reference channel 0. This gives
incorrect results for multi-channel configurations where channels use
different fin_sel or inductance values.
Index ch_cfg with the selected channel so each conversion uses the
correct per-channel configuration.
Signed-off-by: Sundareswar Palanichamy <sundareswarp@gmail.com>
lis2dh_fetch_xyz did not return -ENODATA when LIS2DH_STATUS_DRDY_MASK
was clear. Because the successful read returned 0, the data-ready check
was masked and old data was silently reported as fresh.
Signed-off-by: Markus Grafen <markus.grafen@medicassist.de>
The driver so far hardcoded INT1 (INTMAP1_LOWER at 0x2A) for all
interrupt mappings, so a board that routes only INT2 to the host could
never receive trigger or FIFO watermark interrupts. INT1 and INT2 have
bit-for-bit identical event mapping registers (INTMAP2_LOWER at 0x2B).
Select the connected pin from the int1-gpios/int2-gpios devicetree
properties and route the interrupt mappings to the matching register,
following the pattern already used by the adxl345 driver. When only
int1-gpios is present the driver keeps using INT1, so existing device
trees continue to work unchanged.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Add an I2C driver for the Analog Devices ADXL313 3-axis accelerometer
with classic sensor API support for range and ODR configuration.
Use i2c_reg_update_byte_dt for register read-modify-write, reconfigure
range/ODR in standby, and add build_all coverage plus a release-notes
entry.
Signed-off-by: Leo Li <leo.li@rakwireless.com>
Fix for RTIO streaming. When stream is canceled
with rtio_sqe_cancel before IRQ or when sequence
for getting data from FIFO, data->sqe is set to NULL.
This will result with early exit from some functions.
Because data->fifo_watermark_irq remain set, it was
not possible to start new stream.
Signed-off-by: Vladislav Pejic <vladislav.pejic@orioninc.com>
The BMP581 SPI protocol requires every data byte in a multi-byte write
to be preceded by its register address. The driver currently submits
one address followed by all data bytes, so the second data byte is
interpreted as another register address.
Build one two-byte RTIO SQE for each register-address/data pair and
chain the SQEs as one transaction to keep CSB asserted. Leave the I2C
and I3C paths unchanged.
Update the SPI emulator to parse address/data pairs independently of
SPI buffer boundaries. This supports the corrected transaction layout
and rejects the previous malformed write sequence.
This allows OSR_CONFIG and ODR_CONFIG to be programmed correctly
during initialization and prevents the data registers from remaining
at their reset values.
Tested by building samples/sensor/pressure_polling for an STM32F407
target.
Assisted-by: Codex:gpt-5.6-sol
Signed-off-by: Yu He <auhy@mail.scut.edu.cn>
After a soft reset, BMP581 returns to its power-up I2C/I3C mode.
The first SPI transaction selects SPI mode and returns invalid data.
The driver performs the post-reset dummy read only after soft_reset()
returns. However, soft_reset() reads INT_STATUS first, so the status read
is consumed as the SPI activation transaction and initialization fails
with -EFAULT.
Move the dummy read into soft_reset(), after the reset delay and before
reading INT_STATUS. The I2C and I3C paths remain unchanged.
Tested by building samples/sensor/sensor_shell for
arcap/stm32f407xx.
Link: https://github.com/zephyrproject-rtos/zephyr/pull/109240
Link: https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp581-ds004.pdf
Assisted-by: Codex:gpt-5.6-sol
Signed-off-by: Yu He <auhy@mail.scut.edu.cn>
Capture the timestamp at GPIO callback time (IRQ time) rather than
in the RTIO completion callback after the data has been read. Add odr
to the encoded header, fix base_timestamp_ns to reflect the time of
the first FIFO sample, and add timestamp_delta per sample, matching
the lsm6dsv16x reference implementation.
Fixes: #98720
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
(cherry picked from commit 8cdcdeb189e63e0fed1cc06b2eb7a74fd9e9ce5d)
The mux subsystem redefines the "nxp,inputmux" binding as a mux
controller (#mux-control-cells / #mux-state-cells), which collided with
the EQDC driver's use of the same compatible through a
"specifier-space: inputmux" phandle-array. Reconcile the two by moving
the EQDC PHASEA/PHASEB input routing onto the generic mux model:
- nxp,mcxa156 / nxp,mcxa344 / nxp,mcxaxx6: switch the inputmux node
from #inputmux-cells to #mux-control-cells / #mux-state-cells so it
validates against the new binding (nxp,mcxa153 was already done).
- nxp,mcux-eqdc.yaml: drop the local inputmux-connections property and
include mux-consumer.yaml; routing is now described with "mux-states".
- eqdc_mcux: drop the direct fsl_inputmux HAL calls and apply the
routing through mux_state_apply(), guarded by device_is_ready(). The
mux controllers init at priority 40, before the sensor at 90, so they
are ready at EQDC init time.
- Migrate the frdm_mcxa153/156/266/344/346/366 QDEC sample overlays to
the mux-states syntax.
Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
Drop the direct MCUX_XBARA HAL coupling in the QDEC driver in
favour of the new generic mux subsystem: the driver now selects
CONFIG_MUX, defines mux states from a "mux-states" devicetree
property and applies them at init time via mux_state_apply(),
which makes it agnostic to the underlying mux hardware.
Update the nxp,mcux-qdec binding to include mux-consumer.yaml,
augment the i.MX RT10xx XBAR nodes with CCM clock phandles plus
the new #mux-control-cells / #mux-state-cells declarations, and
migrate the MIMXRT1050-EVK QDEC overlay to the mux-states syntax.
Add the matching XBAR clock support to the i.MX CCM clock driver
(IMX_CCM_XBAR1_CLK / IMX_CCM_XBAR2_CLK gate/ungate, guarded by
CONFIG_MUX_NXP_XBAR) so the XBAR controllers referenced by those
nodes can be clocked.
Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
Drop the direct INPUTMUX_AttachSignal() coupling in the QDC driver
in favour of the new generic mux subsystem: the driver now selects
CONFIG_MUX, defines mux states from a "mux-states" devicetree
property, and applies them at init time via mux_state_apply().
This makes the driver mux-hardware-agnostic.
Update the nxp,mcux-qdc binding to use mux-consumer.yaml, expose
the inputmux0 node on the MCXNx4x family DTSI, and migrate the
FRDM-MCXN947 / MCXN5xx-EVK QDC overlays to the new mux-states
syntax.
Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
Rework the esp32 pcnt driver to expose every counting unit of a
single device. The read-and-decode api threads the unit index
through sensor_chan_spec.chan_idx so sensor_read returns an
encoded buffer that the driver's decoder unpacks per unit. The
legacy sensor_channel_get path is kept on unit 0 for backward
compatibility.
The new sensor_chan_pcnt_esp32_unit(n) helper (in a public
header) packs the unit index into the legacy sensor_channel
field so sensor_attr_set and sensor_trigger_set can target a
specific unit. A new sensor_attr_pcnt_esp32_reset attribute
clears the hardware counter.
Dt binding gains counts-per-revolution (enables degrees output
on sensor_chan_rotation), high-limit and low-limit watchpoints
(counter auto-resets on reach and raises the trigger), and
zero-cross-event. Filter is documented in apb cycles with the
correct 1023 clamp.
Threshold trigger demultiplexes per unit in the isr and fixes
the old behaviour that silently re-allocated the isr on every
trigger_set. Interrupt alloc moves to init.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
To avoid assuming that ZVFS_O_RDONLY matches O_RDONLY, compile the
Linux file access code directly with the host libc.
This also removes the need for the nsi_host file operation wrappers and
makes the host-side code easier to read.
Signed-off-by: Bayrem Gharsellaoui <bayrem.gharsellaoui@gmail.com>
Add a native_sim driver to read a Linux host temperature using the
Zephyr sensor API.
Signed-off-by: Bayrem Gharsellaoui <bayrem.gharsellaoui@gmail.com>
Stream Sensor HUB data in FIFO and decode them properly.
Currently two channels are handled:
- SENSOR_CHAN_MAGN_XYZ
- SENSOR_CHAN_PRESS
Signed-off-by: Armando Visconti <armando.visconti@st.com>
Set the read number of operation to 0 at the end of
lsm6dsv16x_shub_read_target_reg(), just to avoid issues
when reading data from FIFO.
Signed-off-by: Armando Visconti <armando.visconti@st.com>
Add a sensor decoder for the MAX30009 streaming path, decoding the I and
Q BioZ channels from the FIFO sample sets pushed by the RTIO submit
path.
The decoder is compiled in with the streaming path via
CONFIG_MAX30009_STREAM.
Signed-off-by: Francis Roi Manabat <francisroi.manabat@analog.com>
Add RTIO streaming of the I and Q BioZ channels. The submit path reads
the FIFO on a watermark/data-ready interrupt and pushes sample sets into
the RTIO buffer; one-shot (non-streaming) reads are rejected.
Streaming is compiled in via CONFIG_MAX30009_STREAM.
Signed-off-by: Francis Roi Manabat <francisroi.manabat@analog.com>
Add own-thread and global-thread trigger support for the MAX30009.
Handlers are provided for the FIFO watermark, data-ready and DC
lead-off / range status events, dispatched from the interrupt GPIO.
The trigger source is compiled in via CONFIG_MAX30009_TRIGGER.
Signed-off-by: Francis Roi Manabat <francisroi.manabat@analog.com>
Add a driver for the Analog Devices MAX30009 bioimpedance analog
front-end. The device is supported over both SPI and I2C.
This base commit provides the core acquisition-path driver:
- Full BioZ acquisition-path configuration from devicetree (clock/PLL,
drive, receive channel, digital filters, thresholds, mux, DC leads and
lead bias), with a dt-bindings header of MAX30009_DT_* constants for
the enumerated properties.
- Runtime attribute access (attr_set / attr_get) for the meaningful BioZ
parameters via a descriptor table, cycling the PLL where the datasheet
requires the acquisition path to be quiesced.
- Power management (suspend / resume) following the datasheet's
bandgap / PLL / channel enable sequence.
Trigger and RTIO streaming support are added in follow-up commits; the
full Kconfig describing those options is included here so the driver's
configuration surface is complete.
Signed-off-by: Francis Roi Manabat <francisroi.manabat@analog.com>
The echo-timeout defines the maximum range of the ultrasonic sensor and
was hardcoded to 10ms (~1.5m).
This commit creates a dts property for the timeout,
so users can configure the maximum range per sensor instance.
The default setting of the property is 10ms for compatibility.
Signed-off-by: Nils Harder <harder@metratec.com>
Header file include/zephyr/sys_clock.h is deprecated and will be removed
someday. Update the whole file tree to include zephyr/sys/clock.h
straight instead of zephyr/sys_clock.h.
This change was made running the sed shell command below:
$ sed -i 's/zephyr\/sys_clock\.h/zephyr\/sys\/clock\.h/' \
`grep -rsl "zephyr/sys_clock\.h" drivers/`
Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
There is no 'config UART' base definition in the tree; the only
definition was an accidental bare declaration in the
cy8cproto_062_4343w board Kconfig.defconfig, so every
'select UART' resolved against a phantom bool that gates nothing.
- bluetooth: hci: BT_AIROC: drop the select. BT_H4 already selects
BT_UART, which selects SERIAL and UART_INTERRUPT_DRIVEN, so the
H4 transport is fully covered.
- sensor: explorir_m, fcx_mldx5, s3km1110: drop the select. These
drivers already have 'depends on UART_INTERRUPT_DRIVEN', which
requires SERIAL; replacing the select with 'select SERIAL' would
create a Kconfig dependency loop through UART_INTERRUPT_DRIVEN.
- input: ch9350l: drop the select for the same reason (it depends
on SERIAL_SUPPORT_INTERRUPT and selects UART_INTERRUPT_DRIVEN).
- stepper: adi_tmc: STEPPER_ADI_TMC_UART: replace with
'select SERIAL', matching the sibling STEPPER_ADI_TMCM_RS485
symbol, so enabling the UART bus variant actually enables the
serial drivers.
Found by a full-tree Kconfig audit cross-referencing every defined
symbol against its uses.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>