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>
Add injected mode support for STM32 temperature 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>
All trigger related variables will be defined only if pinctrl has name
`trigger`. This can save some RAM when having multiple hx711 configured
but only using trigger for some of them.
Signed-off-by: Terry Geng <terry@terriex.com>
HX711 pulls DOUT low when data is ready. This commit enabled pin config
to switch from SPI to GPIO and set up GPIIO interrupts for the falling
edge.
The implementation is similar to the `infineon,airoc-wifi` driver, by
using pinctrl.
Signed-off-by: Terry Geng <terry@terriex.com>
HX711 is a specialized 24-bit ADC for load cell and strain gauge sensors.
It uses a two-wire (PD_SCK and DOUT) serial protocol that
- first 24 clock cycles reads out the sample
- last 1 to 3 clock cycles set the PGA gain for the next sample
The requirement of control the exact number of clock cycles makes the
SCK for SPI unsuitable for clocking HX711. Instead, in this commit, the
clock is implemented as a series of 0xAA on the MOSI.
Signed-off-by: Terry Geng <terry@terriex.com>
Add Power Management Subsystem to ADT7420 driver for
suspending and resuming device operations.
Signed-off-by: Jan Carlo Roleda <jancarlo.roleda@analog.com>
Extended ADT7420 driver to support:
- extend dtbindings for comprehensive configuration control
- Support 13-bit and 16-bit ADC resolution
- extend Sensor API support
- extend interrupt support to include CT pin
Signed-off-by: Jan Carlo Roleda <jancarlo.roleda@analog.com>
Fix I2C transaction len using the correct size of the data to be sent
and not the returned length of the allocated buffer. This change is
applied to iis3dwb, lis2dux12 and lsm6dsv16x drivers, and mimic what
is also done for lsm6dsvxxx driver.
Signed-off-by: Armando Visconti <armando.visconti@st.com>
Nordic's nPM10 Series PMIC Sensor Devicetree bindings and minimal driver
supporting only battery current, voltage and temperature measurements.
Signed-off-by: Sergei Ovchinnikov <sergei.ovchinnikov@nordicsemi.no>
Add driver for the QST QMI8658A 6-axis inertial measurement unit
with accelerometer and gyroscope. Supports I2C bus, configurable
full-scale range and ODR via devicetree, temperature readout, and
optional data-ready interrupt trigger on INT2.
Signed-off-by: William Markezana <william.markezana@gmail.com>
Fix I2C transaction len using the correct size of the data to be sent
and not the returned length of the allocated buffer.
Signed-off-by: Armando Visconti <armando.visconti@st.com>
Signed-off-by: Brenden Adamczak <cerebralasylum1@gmail.com>
Co-authored-by: Armando Visconti <armando.visconti@st.com>
For the ina226 shunt voltage is implemented and supported,
unfortunatly it was forgotten to select
INA2XX_HAS_CHANNEL_SHUNT_VOLTAGE.
Since 70423db9d1c69d32597ba1f7b2fe66569014a4b0 it will
no longer build. This fixes it.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
The driver was using a packet count value read directly from the
hardware to control a loop bound and a register read size. If the
hardware reported a value exceeding the internal buffer size, it
could lead to a buffer overflow or an untrusted loop bound.
Add a check to cap the packet_count based on the actual size of
the driver's FIFO data buffer.
Fixes#90512
Signed-off-by: David J. Leach, Jr. <tasmar@gmail.com>
The IS_ACCEL macro checks if a channel is within the accelerometer
range. Because SENSOR_CHAN_ACCEL_X currently evaluates to 0 and
the channel type is unsigned, Coverity flags this as a redundant
comparison.
Added a coverity[unsigned_compare] annotation to silence the warning.
This preserves the macro's logic, ensuring the check remains valid
even if the underlying enum order is modified in the future.
Fixes#100002
Signed-off-by: David J. Leach, Jr. <tasmar@gmail.com>
Several of the ST sensor implementations do not return a value to
the fetch caller, even when a fetch fails internally. This is
fixed by returning the value from the internal calls.
Signed-off-by: Eira Siegel <eira@the.cy>
Add driver for the Sensirion STCC4 miniature CO2 sensor. The STCC4
measures CO2 concentration (ppm), temperature, and humidity via I2C
using Sensirion's standard word+CRC protocol.
Features:
- Continuous and single-shot measurement modes
- CRC-8 validation on all sensor data
- Product ID readout at init
- Graceful handling of first measurement delay in continuous mode
Signed-off-by: William Markezana <william.markezana@gmail.com>
This adds a new sensor driver (with custom channels) for the S3KM1110, a
24GHz mmWave radar sensor from Iclegend that uses a UART interface.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Clearing the status register in adxl367_thread_cb() introduces
a one-sample latency since any trigger handler invoking
adxl367_get_accel_data() has to wait until the next sample sets the
DATA_READY bit again. To fix this, identify trigger source by
reading status_copy register in adxl367_thread_cb(). This preserves
the status register contents for verification prior to fetching data.
Signed-off-by: Shiril Tichkule <Shiril.Tichkule@analog.com>
Compress the `struct ina2xx_channels` to only the channels that are
supported. This has the added benefit that trying to access an
unsupported channel (in the driver) is now a compile-time error.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Use `#ifdef`, `#else`, `#endif` to block out implementations, instead
of putting the checks inside an `if`, which results in all the
implementations being indented.
It also makes it much clearer to any user with syntax highlighting
configured, since the unsupported channels are greyed out.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Fix calling `sensor_channel_get` on a channel that is not supported by
the hardware from faulting with a NULL de-reference.
This fixes the following pattern (used by `fuel_guage/composite`):
```
sensor_sample_fetch(dev);
if (sensor_channel_get(dev, chan, val) == -EINVAL) {
printk("Not supported\n");
}
````
Signed-off-by: Jordan Yates <jordan@embeint.com>
This reverts commit ae44e1e7b7.
The only consequence of removing NULL checks is enabling NULL
dereference exceptions. The sensor API is a generic API, a generic
library built on top of that API does not always know which channels a
device supports.
Signed-off-by: Jordan Yates <jordan@embeint.com>
This reverts commit 8340e8c264.
The only consequence of removing NULL checks is enabling NULL
dereference exceptions. The sensor API is a generic API, a generic
library built on top of that API does not always know which channels a
device supports.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Use micro-units when converting readings to struct sensor_value.
The previous implementation used 100000-based scaling for fractional
values, while sensor_value expects 10^-6 units. As a result, converted
magnetic field values were reported as 10x the expected gauss value
instead of gauss, and the incorrect scaling caused apparent jumps in
the reported sensor readings.
Fix the conversions by using 1000000-based scaling and
sensor_value_from_micro().
Signed-off-by: Bernhard Reiter <bernhard.reiter@swarovskioptik.com>
Add driver support for NXP MCUX Quadrature Decoder (QDC) sensor.
The driver provides:
- Position tracking via SENSOR_CHAN_ROTATION channel
- Configurable counts per revolution
- Single phase and normal decoder work modes
- Input filtering with configurable count and sample period
- INPUTMUX integration for flexible signal routing
- Modulo count mode support
Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
There are many lm75 variants differing in temperature resolution.
Typical values are 9, 10, 11, and 12 bit. They all use the same
format (16 bit signed integer with LSB at 1/256 degree C).
Depending on the on the actual variant some of the LSB are not
defined. The new calculation scheme uses all 16 bits independent
on the actual sensor resolution. In the worst this leads to
some pseudo-resolution in case the undefined bits are not
reported as 0 by the sensor.
Signed-off-by: Lutz Dittrich <dittrich@netwake.com>
Update bindings to consume a NVMEM cell instead of raw addresses, and
update the driver to support obtaining calibration data using the NVMEM
subsystem. For backwards compatibility and reduced footprint, the old
mechanism (direct MMIO read) is retained; a Kconfig option is introduced
to allow selecting which mechanism is used.
The sensor binding and SoC DTSI is updated accordingly.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Update bindings to consume a NVMEM cell instead of raw addresses, and
update the driver to support obtaining calibration data using the NVMEM
subsystem. For backwards compatibility and reduced footprint, the old
mechanism (direct MMIO read) is retained; a Kconfig option is introduced
to allow selecting which mechanism is used.
The sensor binding and SoC DTSI is updated accordingly.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
I2C_RTIO, I3C_RTIO and SPI_RTIO should be selected in the driver
itself on the basis of which busses have these devices instances.
Signed-off-by: Armando Visconti <armando.visconti@st.com>
Fix interrupt enable/disable sequence per ADXL345 datasheet
recommendations.
The ADXL345 datasheet (page 19) states: "When initially configuring
the interrupt pins, it is recommended that the functions and interrupt
mapping be done before enabling the interrupts."
Main changes:
1. Remove adxl345_interrupt_config() which incorrectly enabled
interrupts during driver initialization without proper sequencing.
It's not clear to me what was the purpose of this function as all
the required logic (setting gpio interrups, adxl mapping and enabling
happens already in tigger_set).
I checked other drivers and this seems to be the common pattern.
2. Implement proper INT_ENABLE disable/enable sequence in
adxl345_submit_stream() when reconfiguring watermark interrupts:
- Disable watermark interrupt in INT_ENABLE
- Configure interrupt mapping in INT_MAP
- Flush FIFO
- Re-enable watermark interrupt in INT_ENABLE
3. Add datasheet-based comments in adxl345_trigger.c explaining
non-obvious register operations:
- AC/DC coupling modes (ACT_INACT_CTL register)
- INT_MAP routing logic (0=INT1, 1=INT2)
- Interrupt clearing by reading data registers
4. Fix bug in adxl345_trigger_set() where ADXL345_INT_MAP_DATA_RDY_MSK
was hardcoded instead of using the correct int_mask variable.
Fixes#100891
Tested on ebyte_e73_tbb with samples `accel_polling` and `accel_trig`
Signed-off-by: Tobias Kässer <t.kaesser@gmail.com>
Add initial support for Analog Devices ADE7978 isolated energy
metering IC for polyphase shunt meters.
The driver implements the Zephyr sensor API and provides:
- SPI communication (read/write 8/16/32-bit registers)
- Phase A RMS current measurement (SENSOR_CHAN_CURRENT)
- Phase A RMS voltage measurement (SENSOR_CHAN_VOLTAGE)
- Device Tree bindings
This is an initial minimal working implementation. Future enhancements
will include:
- Multi-phase support (Phase B, C, Neutral)
- Active and reactive power measurement
- Interrupt support
- Calibration API
Signed-off-by: Filip Stojanovic <filipembedded@gmail.com>
Use official TDK Invensense driver for icm45686 sensor in tdk_hal module.
Supports icm456xx variants.
Signed-off-by: Remi Buisson <remi.buisson@tdk.com>
Correct a bitmask issue on the temperature alert threshold
as per the datasheet (Section 7.5.7.4.2).
Signed-off-by: Jeremy Thompson <jthompson@blackberry.com>
Adds device power manager support to TMAG5273 driver.
Suspending the device will put it into its SLEEP mode, resuming will
restore it to the mode configured in devicetree.
Before communicating with a device in sleep mode, an extra I2C transfer
is needed. Something like this is briefly mentioned in the datasheet,
but without any more specific details. The wake up has also been added
to the init function, even in case PM is disabled.
The device is marked as busy for the whole sample_fetch function.
Signed-off-by: Marek Maškarinec <marek.maskarinec@hardwario.com>
If the clock device (i.e., RCC) failed to initialize, we have bigger
problems than trying to call clock_control_{off,on,configure} on it.
Don't bother checking to save some footprint.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>