Measurement of the internal Vddcore voltage differs only slightly from
the Vbat measurement. The main difference is that the Vddcore channel
is enabled differently in the ADC peripheral.
To avoid code duplication, the existing Vbat sensor driver is extended
to also handle the Vddcore measurement.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Refactor the Microchip XEC tachometer driver to use DTS-encoded
GIRQ and PCR properties instead of series-specific ifdefs,
enabling a unified driver across MEC150x, MEC172x, and MEC175x.
Fix build error from incorrect PCR devicetree configuration.
Remove duplicate include and add missing static qualifier to
tach_xec_sample_fetch().
Co-authored-by: Andy Chang <andy.chang@microchip.com>
Signed-off-by: Andy Chang <andy.chang@microchip.com>
Signed-off-by: Srinivas Edireswarapu <srinivas.edireswarapu@microchip.com>
Add a driver for the MS5637-02BA03 digital pressure & temperature
sensor from TE Connectivity (Measurement Specialties).
The driver implements the Zephyr sensor API with support for
SENSOR_CHAN_PRESS (kPa) and SENSOR_CHAN_AMBIENT_TEMP (degrees C).
Oversampling ratio (OSR) is configurable at build time via Kconfig
and at runtime via SENSOR_ATTR_OVERSAMPLING.
Includes full PROM CRC-4 validation per AN520 and second-order
temperature compensation per the MS5637 datasheet.
Signed-off-by: William Markezana <william.markezana@gmail.com>
Read the temperature sensor calibration value through the
NVMEM API instead of the legacy ROM OTP API. The calibration
data is exposed by the OCOTP node as an NVMEM cell, so the
driver no longer depends on fsl_romapi_otp.
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
Add a driver for the HTU31D digital humidity and temperature sensor
from TE Connectivity (Measurement Specialties).
The driver implements the Zephyr sensor API with support for
SENSOR_CHAN_HUMIDITY (%) and SENSOR_CHAN_AMBIENT_TEMP (degrees C).
Measurement data is validated with CRC-8 per the datasheet.
Signed-off-by: William Markezana <william.markezana@gmail.com>
As pointed out in #106786, when disentangling the bitstream from the chip,
for every 8 bits, instead of sampling bit 1, 3, 5, and 7, bit 0, 3, 5, and
7 are erroneously sampled. The behavior of sampling bit 0 is undefined in
the datasheet, and causes data corruption in some cases.
This fix has been tested on actual hardware and no regression is observed.
Fixes#106786
Signed-off-by: Terry Geng <terry@terriex.com>
The straightforward way to convert cycles to nanoseconds with
x * y / z
will easily overflow the multiplication in the numerator. Rewriting the
operation as
y * (x / z + (x % z) / z)
or NSEC_PER_SEC * (quot + (rem / cycles_per_sec)) improves the situation
and allows useful sensor timestamps for a bit longer before overflows are a
concern.
The API in sys/time_units.h handles exactly this type of numerical
manipulation for time units which might overflow. The predefined macros
only handle conversions between the various Z_HZ_* macros so a wrapper for
z_tmcvt_64 is required for the external clock case.
Signed-off-by: Henrik Lindblom <henrik.lindblom@vaisala.com>
Instead of performing series check, use the new common Kconfig option
CONFIG_HAS_STM32_UNCACHED_ACCESS_ONLY_OTP in drivers which access the
internal NVM's OTP/read-only area.
While at it, use the public `sys_cache_xxx()` API in flash_stm32 instead
of the internal `cache_xxx()` API.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
config->adc is of type 'const struct device *', assigned via
DEVICE_DT_GET(). It has no '.dev' member — that field exists only
in 'struct adc_dt_spec'.
The LOG_ERR_DEVICE_NOT_READY() call in lpadc_temp40_init() was
using config->adc.dev, causing a compile error on all platforms
that select NXP_PMC_TMPSNS:
error: 'config->adc' is a pointer; did you mean to use '->'?
Remove the spurious '.dev' dereference. LOG_ERR_DEVICE_NOT_READY()
accepts 'const struct device *' directly, so passing config->adc
is correct and consistent with the device_is_ready() call on the
line above.
Signed-off-by: Bartlomiej Fijal <StaryAnoda@Gmail.com>
config->adc is of type 'const struct device *', assigned via
DEVICE_DT_GET(). It has no '.dev' member — that field exists only
in 'struct adc_dt_spec'.
The LOG_ERR_DEVICE_NOT_READY() call in lpadc_temp40_init() was
using config->adc.dev, causing a compile error on all platforms
that select NXP_LPADC_TEMP40:
error: 'config->adc' is a pointer; did you mean to use '->'?
Remove the spurious '.dev' dereference. LOG_ERR_DEVICE_NOT_READY()
accepts 'const struct device *' directly, so passing config->adc
is correct and consistent with the device_is_ready() call on the
line above.
Signed-off-by: Bartlomiej Fijal <StaryAnoda@Gmail.com>
Add a die temperature sensor driver for Bouffalo Lab SoCs using
the internal TSEN peripheral integrated into the GPADC.
The driver uses the ADC subsystem for hardware initialization and
raw sample acquisition via adc_bflb_tsen_read_phase(). Temperature
is computed from two ADC measurement phases (TSVBE_LOW toggle)
using the formula: temp = (|v0 - v1| - tsen_offset) / 7.753
The TSEN calibration offset is read from efuse when available,
falling back to the default value of 2042.
Includes:
- Sensor driver at drivers/sensor/bflb/bflb_tsen/
- DT binding for compatible "bflb,tsen"
- TSEN nodes (disabled) in bl60x, bl61x, bl70x, bl70xl dtsi files
Tested on BL602, BL616, BL706, and BL704L hardware.
Signed-off-by: William Markezana <william.markezana@gmail.com>
Add QDEC driver support for Realtek Bee series SoCs,
including RTL87x2G (AON QDEC) and RTL8752H (Basic QDEC).
This driver supports:
- X, Y, and Z axis count reading
- Hardware interrupt-based event trigger
Signed-off-by: Yuzhuo Liu <yuzhuo_liu@realsil.com.cn>
Fix multiple minor issues which trigger build warnings with clang,
including:
* label followed by a declaration is a C23 extension
* duplicate 'const' declaration specifier (DEVICE_API already has const)
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Add a comprehensive driver for the Microchip PAC194x/195x family of
multi-channel power monitors. This driver supports VBUS, VSENSE,
and power accumulation measurements.
Key features and implementation details:
- Support for PAC1941/42/43/44 (9V FSR) and PAC1951/52/53/54 (32V FSR).
- Efficient I2C handling: uses per-channel burst reads to optimize
bus bandwidth based on enabled channels.
- Flexible Refresh Modes: introduced SENSOR_ATTR_REFRESH_MODE to
allow users to choose between AUTO_WAIT (synchronous),
AUTO_NOWAIT (asynchronous/latched), and MANUAL modes.
- Broadcast Support: added a force refresh command using I2C
General Call (0x00) to synchronize snapshots across multiple
sensors (up to 16 instances) simultaneously.
- Configurable range: support for Unipolar, Bipolar, and Bipolar
Half FSR modes via Devicetree.
Tested on RISC-V (ESP32-C3) with 16 PAC1944 instances.
Signed-off-by: Wojciech Macek <wmacek@google.com>
Unify all "device not ready" error messages across sensor drivers with
the LOG_ERR_DEVICE_NOT_READY macro, following the pattern established
for input drivers in commit 31b5866.
This improves consistency and makes device readiness errors easier to
grep across the codebase. Using the standardized macro ensures device
names are properly formatted with null-safety checks.
Image size impact (tests/drivers/build_all/sensor on native_sim,
building 211 sensor drivers):
- Before: 1,033 KB (text: 961 KB)
- After: 1,036 KB (text: 964 KB)
- Change: +2.5 KB (+0.25%), text: +2.5 KB
The small size increase is due to the macros adding null-safety checks
and dynamic device name formatting, which generates slightly more code
than some of the simpler static log strings used by drivers previously.
Assisted-by: Claude:claude-sonnet-4.5
Signed-off-by: Maureen Helm <maureen.helm@analog.com>
Several sensor drivers were logging device readiness failures as LOG_DBG
rather than LOG_ERR, making initialization failures harder to diagnose.
These readiness checks occur during device initialization and return error
codes, so they should be logged as errors rather than debug messages.
This change affects drivers that check for bus or GPIO device readiness
and ensures consistent error reporting across the sensor subsystem.
Assisted-by: Claude:claude-sonnet-4.5
Signed-off-by: Maureen Helm <maureen.helm@analog.com>
Align all sensor drivers that are using stmemsc (STdC) HAL i/f
to new APIs of stmemsc v2.13.2
Requires https://github.com/zephyrproject-rtos/hal_st/pull/35
Signed-off-by: Armando Visconti <armando.visconti@st.com>
In adxl362_set_interrupt_mode(), the LINKLOOP field is first cleared
from the register value, but then the original uncleared register
value is OR'd back in on the next line, restoring the old LINKLOOP
bits. This makes it impossible to change the interrupt mode from its
current value.
Remove the erroneous OR of old_act_inact_reg so the cleared field is
properly set to the new mode value.
Fixes: 11295c190b ("drivers: sensor: Add ADXL362 interrupt handling")
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
The get_resolution function returns 13 when the resolution bit is set
and 16 when it is clear. Per the ADT7420 datasheet, bit 7 of the
config register set to 1 means 16-bit resolution and 0 means 13-bit.
This is also confirmed by the driver's own set_resolution and init
code which sets the bit when 16-bit mode is desired.
Swap the return values so that 16 is returned when the resolution bit
is set and 13 when it is clear.
Fixes: d07b8a20f6 ("sensor: adt7420: Extend ADT7420 Driver Support")
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
This reverts commit 1643904ac4.
This change introduced a regression: A build warning when building
with clang, which is visible in the clang workflow in main
causing it to fail. The issue is in the HAL itself and the fix
is not evident.
Let's revert this commit until the issue is fixed in the HAL.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Soft reset is largely equivalent to power cycle. Add dummy read of chip ID
after soft reset in BMI270 initialization function. Dummy read is
performed via bus initialization.
Signed-off-by: Szymon Antkowiak <szymon.antkowiak@nordicsemi.no>
When a request is performed on a single accelerometer axis
(e.g. SENSOR_CHAN_ACCEL_X) the driver must return a single
scalar q31 data.
Signed-off-by: Armando Visconti <armando.visconti@st.com>
In a IMU there might be multiple concurrent asynchronous requests
active at the same time. Increase the size of the RTIO queues.
Signed-off-by: Armando Visconti <armando.visconti@st.com>
Expose mode 3 (ODR-triggered) in gyro_set_mode and gyro_get_mode for
lsm6dsv320x, lsm6dsv80x, and ism6hg256x so gyro mode matches accel mode
as required by datasheet section 6.1.5.
Fixes#106389
Signed-off-by: Nancy Sangani <9d.24.nancy.sangani@gmail.com>
To access the OTP area on STM32C5, the instruction cache needs to be
disabled to prevent a bus fault.
Do it for the OTP driver, as well as the temperature and Vref sensor.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Align all sensor drivers that are using stmemsc (STdC) HAL i/f
to new APIs of stmemsc v2.13.1
Requires https://github.com/zephyrproject-rtos/hal_st/pull/33
Signed-off-by: Armando Visconti <armando.visconti@st.com>
When setting SFLP game gbias the accel/gyro data rate must be temporarily
changed and then restored back to original values. But in the process the
saved rates got mistakenly corrupted.
Signed-off-by: Armando Visconti <armando.visconti@st.com>
If gpio level gets immediately at high level after sensor is started,
then call interrupt stream handler in order to avoid losing it. As a
side effect no data would be ever read.
Co-authored-by:Brenden Adamczak <cerebralasylum1@gmail.com>
Signed-off-by: Brenden Adamczak <cerebralasylum1@gmail.com>
Signed-off-by: Armando Visconti <armando.visconti@st.com>
The HTU21D is register-compatible with the SHT21 and uses the same
measurement commands. Add it as another DT_DRV_COMPAT entry in the
existing Si7006 driver rather than a standalone driver.
Signed-off-by: William Markezana <william.markezana@gmail.com>
Some of the sensore channels (e.g. SENSOR_CHAN_GRAVITY_VECTOR and/or
SENSOR_CHAN_GBIAS_XYZ) are returning three axis values. The current
code was passing a single value and was actually crashing.
Signed-off-by: Armando Visconti <armando.visconti@st.com>
Add SENSOR_ATTR_CHIP_ID entry (last one) in sensor_attribute_name
declaration/initialization. This is fixing a sensor_shell crash.
Signed-off-by: Armando Visconti <armando.visconti@st.com>
The need to monitor battery voltage on nordic devices and nRF7120
in particular is required among other metrics such as die temperature.
Creating a sensor to measure battery voltage allows to easily monitoring
of all required metrics in a consistent way.
This commit adds a new sensor driver to monitor battery.
Signed-off-by: Robert Robinson <robert.robinson@nordicsemi.no>
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within:
- `drivers/rtc`
- `drivers/sdhc`
- `drivers/sensor`
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
If a prescaler is set in the DTS, it should be used also by the qdec
driver, as it is by the counter and the pwm drivers.
Signed-off-by: Ole Morten Haaland <omh@ixys.no>
This patch adds a new driver for the ADXL355 three-axis digital
accelerometer, implementing configuration, sampling,
and full-scale range controls according to the
ADXL355 datasheet (Analog Devices).
Features:
- I2C and SPI register access
- Sampling frequency (ODR) configuration
- Full-scale range selection (±2g/±4g/±8g)
- Standby/measure power modes
- Optional FIFO streaming support via RTIO
- Basic trigger and interrupt handling
Power management is supported via PM_DEVICE callbacks
to place the sensor in standby mode when suspended
and resume continuous measurement on resume.
References:
- ADXL354/ADXL355 Datasheet (Analog Devices)
https://www.analog.com/media/en/technical-documentation/data-sheets/adxl354_adxl355.pdf
Signed-off-by: Francis Roi Manabat <francisroi.manabat@analog.com>
The lower ALS interrupt threshold (SENSOR_ATTR_LOWER_THRESH) was being
converted twice with sys_cpu_to_le16(), effectively canceling the
conversion on big-endian systems. The upper threshold
(SENSOR_ATTR_UPPER_THRESH) correctly uses a single conversion.
This causes the lower threshold register to be written in incorrect
byte order on big-endian architectures.
Signed-off-by: Andre Viegas <andreviegas@piscodeluz.org>
Assisted-by: Claude:claude-opus-4.6 forgeql
Add injected mode support for STM32 Vref sensor.
When in injected mode, this configures the sensor channel and sensor enable
bit at start to prevent any conflict later: some registers can't be written
while a conversion is on-going.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Add injected mode support for STM32 Vbat sensor.
When in injected mode, this configures the sensor channel and sensor enable
bit at start to prevent any conflict later: some registers can't be written
while a conversion is on-going.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>