Coverity identified out-of-bounds access. A uint8_t being cast to
an enum is undefined in that the enum can be allocated 4bytes.
Change the internal function to use the base type of the variable,
uint8_t to avoid potential compiler size alignement problems.
Fixes#81927
Signed-off-by: David Leach <david.leach@nxp.com>
Add wsen_pads_2511020213301 driver with
the corrected name and compatibility with
the hal update as well as added new features.
Signed-off-by: Wajdi ELMuhtadi <wajdi.elmuhtadi@we-online.com>
Previously, the Kconfig option CONFIG_STMEMSC_I3C_I2C_WRITE_BUFFER_SIZE
has been introduced to replace i2c_burst_write with i2c_write using a
buffer combining the address and data.
See commit 5f8da77ad3eaf0593107fd99253c1c13b3a98de0
Add missing buffer size config to stmemsc_i2c_write_incr to replace
fixed buffer size.
Signed-off-by: Jonas Spinner <jonas.spinner@burkert.com>
Fix a runtime bug when both CONFIG_LIS3MDL_TRIGGER and CONFIG_ASSERT
are set. The correct assertion should verify that sensor channel is
either SENSOR_CHAN_ALL or SENSOR_CHAN_MAGN_XYZ.
Signed-off-by: Armando Visconti <armando.visconti@st.com>
The TSL2591 driver fails to initialize because the sensor responds with a
NACK on the initial RESET. Although the datasheet from Adafruit claims that
this is operation should be valid (RESET is part of the CONTROL register),
other sample non-Zephyr drivers provided by Arduino don't explicitly reset
the sensor on initialization (see
https://github.com/adafruit/Adafruit_TSL2591_Library/blob/master/Adafruit_TSL2591.cpp).
Thus, the assumption is that when the sensor is reset via software, it
doesn't respond to an ACK.
After removing the check for this initial RESET, the driver initializes
successfully.
Signed-off-by: Mohammed Billoo <mab@mab-labs.com>
As the C language treats 'cases' similar to 'labels' the following
error can also occur when using switch statements when it encounters
a declaration immediately after a label:
drivers/sensor/maxim/ds3231/ds3231.c:77:3: error: a label can only
be part of a statement and a declaration is not a statement
77 | const uint16_t raw_temp = data->raw_temp;
| ^~~~~
Signed-off-by: Stephan Linz <linz@li-pro.net>
Fix correct use of serif_type if the driver is compiled with both SPI
and I2C enabled by storing it in device config.
Signed-off-by: Aurelie Fontaine <aurelie.fontaine@tdk.com>
Explicitly add default trigger mode as none in the kconfig trigger
template for better readability.
Signed-off-by: Mayank Narang <narang.may77@gmail.com>
Fixes a multitude of Kconfigs that wrongly appear on devices
where support is literally impossible
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
i2/3c_burst_write comes with a warning where this combined write
synthesized by thsi API may not be supported by all I2/3C
devices. Replace with i2c_write instead with a buffer combining
the address and data.
The Kconfig STMEMSC_I2C_WRITE_BUFFER_SIZE was added to set the
size of the buffer pushed to the stack.
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Makes driver actually build again.
Fixes scaling, q32 encoding, bit shifts, and register mappings.
Also enables High Resolution mode (a unique and beneficial
feature of the chip when used with streaming).
Co-authored-by: James Goppert <james.goppert@gmail.com>
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
Add shell device filtering using the existing sensor_device_check to all
remaining sensor shell commands.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Added support for vin supply which seems to be needed for the radio
boards in order to power on the sensor.
Signed-off-by: Yishai Jaffe <yishai1999@gmail.com>
Add wsen_tids_2521020222501 driver with
the corrected name and compatibility with
the hal update as well as added new features.
Signed-off-by: Wajdi ELMuhtadi <wajdi.elmuhtadi@we-online.com>
Added a length check in the spi write incr routine to handle both
single and multi byte write operations properly.
Signed-off-by: Mayank Narang <narang.may77@gmail.com>
The lis2de12 sensor driver spi interface was calling spi read api.
This leads to a single byte operation on reading acceleration data
which is a multi byte operation. Fix it by adding a call to spi read
incr api instead. Added a length check to handle both single and multi
byte read properly.
Signed-off-by: Mayank Narang <narang.may77@gmail.com>
The TMP435 is a remote temperature sensor monitor
with a built-in local temperature sensor.
Signed-off-by: Jaakko Rautiainen <jaakko.rautiainen@bittium.com>
Set ctrl9_xl.device_conf bit to 1 in ism330dhcx_init_chip()
prior to start device configuration, as stated in paragraph
9.20 of the datasheet.
Signed-off-by: Armando Visconti <armando.visconti@st.com>
Have the application enable this feature explicitcly, so that
simple applications do not need to disable this to get the
expected behavior.
Signed-off-by: Luis Ubieda <luisf@croxel.com>
Otherwise with its default configuration (25-Hz, 32-level FIFO),
getting individual samples could be up to 1-second old.
Signed-off-by: Luis Ubieda <luisf@croxel.com>
The following fixes have been applied to this decoder:
- The Q-scale factor was fixed, both for full-scale and non
full-scale modes.
- The data-type decoded is struct sensor_three_axis_data, as
it should for read/decode API.
Signed-off-by: Luis Ubieda <luisf@croxel.com>
Added private channels for metadata associated with
distance measurement according to datasheet and API manual.
Signed-off-by: Michal Piekos <michal.piekos@wp.pl>
The function fxls8974_get_temp_data always returns zero, indicating
success.Therefore, the error checking if condition is unnecessary and
can be removed.
Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
The lis2dh driver has the ability to enable the hp filter.
However it was only possible to set the first 2 bits of the hp register.
These bits indicate wether the hp filter is enabled for the interrupts.
This commit moves lis2dh_acc_hp_filter_set to lis2dh.
It also removes the mask so that all bits are able to be set.
Signed-off-by: Maarten Nieuwenhuize <maarten.nieuwenhuize@picoo.nl>
sample_fetch function has quite a high cyclomatic complexity, this
refactoring aims to reduce cyclomatic complexity by refactoring.
- introduce fetch current on pin function
- introduce fetch voltage on pin function
- introduce fetch temperature on pin
Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
This commit replaces a hack where is_busy status of adltc2990 was
checked by fetching SENSOR_CHAN_ALL with a dedicated function
expose adltc2990_trigger_measurement function to public api
Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
Add wsen_pdus_25131308XXXXX driver with
the corrected name and compatibility with
the hal update as well as added new features..
Signed-off-by: Wajdi ELMuhtadi <wajdi.elmuhtadi@we-online.com>
1. Temperature Interface
According to BMI08x datasheet, temperature reading
requires both MSB and LSB bytes to be read and
processed correctly.
Temp data processing should follow the formula:
Temp in °C = (temp_msb * 8) + (temp_lsb / 32)
This patch implements the correct reading
sequence and calculation method as specified
in the datasheet.
2. Trigger Setting
Previously we set handler and then trigger struct.
However under some situation, as long as we set
the handler, we get into ISR immediately and never
set trigger struct.
I simply changed the sequence.
Testing:
- Verified temperature readings match datasheet
- Tested on stm32f407igh board with BMI08x sensor
Fixes: #82375
Signed-off-by: Wenxi Xu <xuwenxi0517@gmail.com>
`sensor_sample_fetch` is documented as blocking until the fetch
operation is complete. Update the implementation so that this is true.
Since the fetch operation now blocks, there is no need for the data
ready trigger.
Signed-off-by: Jordan Yates <jordan@embeint.com>
When configuring the device to run in one-shot mode, the AS6212 requires
the sleep mode bit to be set. From the datasheet:
```
The sleep mode is activated by setting the bit SM in the configuration
register to 1. This shuts the device down immediately and reduces the
power consumption to a minimum value.
Entering the sleep mode will take some time (120 ms maximum) and the
first conversion after the sleep mode has been entered takes longer than
the values specified in Figure 7. It is therefore recommended when
entering sleep mode to trigger a single shot conversion at the same
time. After 150 ms (max), the device has then entered the sleep mode and
subsequent conversion times are as specified in Figure 7.
```
Signed-off-by: Jordan Yates <jordan@embeint.com>
Use the common `sensor_value_*` helper functions instead of implementing
the conversions again in the driver.
Signed-off-by: Jordan Yates <jordan@embeint.com>
This commit introduces a new Sensor Clock API, enabling the retrieval
of cycle counts and conversion to nanoseconds based on the system or
external clock. The API includes:
- `sensor_clock_get_cycles()` to get the current cycle count from the
sensor clock.
- `sensor_clock_cycles_to_ns()` to convert cycles to nanoseconds using
the clock's frequency.
The implementation supports both system clocks and external clocks
defined in the device tree, making the sensor clock integration more
flexible for various sensor use cases.
Signed-off-by: Mark Chen <mark.chen@cienet.com>
Some ADCs (e.g. SAM0) can only convert one channel at a time
and therefore need to be reconfigured for every voltage
divider prior to startin the conversion
Signed-off-by: Patrick Günzel <patrick.guenzel@kinexon.com>
Add new SENSOR_CHAN_FREQUENCY constant to allow implement sensors that
output frequency values in Hertz.
Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
Instead of assuming that an individual axis must contain all
data-values. Additionally, for determining that there's XYZ data, all
three channels must be present in the header.
Signed-off-by: Luis Ubieda <luisf@croxel.com>
For the supported channels, instead of just allowing 3-axis data being
printed out, allow individual channels to be processed (e.g: accel_x,
gyro_y, etc).
Signed-off-by: Luis Ubieda <luisf@croxel.com>
Wait until the typical time that the sample would be ready before
starting to poll the status register.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Fixes issue introduced in #76460
The previous code attempted to detect whether TMAG5273 or TMAG3001 was
connected based on DEVICE ID register. This doesn't work as the bits that
denote the version on one part are undefined on the other part, and cannot
be relied on to be zero.
This commit adds a TMAG3001 compatible which (for now) is just derived from
the TMAG5273 compatible. This allows TMAG3001 to be specified directly in
the DT. The driver code is updated to support both compatibles.
Signed-off-by: Yiding Jia <yiding.jia@gmail.com>