Commit graph

1951 commits

Author SHA1 Message Date
Nikodem Kastelik 6a315a4b17 drivers: sensor: qdec_nrfx: Revert spurious samplerdy evt workaround
Underlying nrfx driver was modified so now it forwards the event
to the user callback only if it was enabled.

Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
2023-10-24 11:13:53 +02:00
Markus Becker e51c044216 sensor: ltrf215a: LiteOn LTR-F216A
New driver for I2C illuminance sensor LiteOn LTR-F216A.

Datasheet:
https://optoelectronics.liteon.com/upload/download/DS86-2019-0016/LTR-F216A_Final_DS_V1.4.PDF

* Applied suggestions from code review
* Removed retry mechanism

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
Co-authored-by: Andy Sinclair <andy@aasinclair.co.uk>
2023-10-23 09:47:09 -05:00
Andy Sinclair be83225ee6 drivers: sensor: npm1300: Fixed charge current scaling
The scaling factor for current measurement was incorrect.
Full range scaling during charge is 1.25 * charge current
limit, and there is no additional scaling factor applied
in different charge modes.

Signed-off-by: Andy Sinclair <andy.sinclair@nordicsemi.no>
2023-10-22 19:24:54 +02:00
Karthikeyan Krishnasamy f5ed51c179 drivers: sensors: add MC3419 accel sensor support
add basic sensor support for 3-axis accelerometer, currently
this driver support data acquisition and motion detection
features.

Signed-off-by: Karthikeyan Krishnasamy <karthikeyan@linumiz.com>
2023-10-20 15:25:16 -05:00
Mulin Chao 0d59aa1ab4 sensor: adc_cmp: npcx: use BUILD_ASSERT to check thr-sel value
This CL uses BUILD_ASSERT macro to check whether `thr-sel` is out of
range instead of using NPCX series definitions.

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
2023-10-20 15:07:21 +02:00
Adrian Wojak 5b9a7d0553 drivers/sensor: lis2dw12: add wakeup_duration support
Add wakeup_duration support. (WAKE_DUR in WAKE_UP_DUR)
Value is configurable through DT per instance.

Signed-off-by: Adrian Wojak <adrian.wojak@outlook.com>
2023-10-20 15:02:41 +02:00
Paweł Anikiel 2f7cb40dd2 drivers: sensor: Add driver for SB-TSI
Add a driver for the SB Temperature Sensor Interface. This is an I2C
temperature sensor on AMD SoCs.

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
2023-10-20 14:51:59 +02:00
Keith Packard 8be25e284a drivers/fdc2x1x: Depend on full C library, not just newlib
This driver uses the math library, so it cannot use the minimal C
library. However, it should be fine with any complete C library, not just
newlib.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-10-12 13:00:39 +01:00
Daniel Leung 04a0cf7d79 kernel: deprecate K_THREAD_STACK_MEMBER
The macro K_THREAD_STACK_MEMBER has actually been deprecated
since v2.4.0 in the macro doxygen description, but it was
never marked with __DEPRECATED_MACRO. Since this was being
used in various drivers, make it follow the deprecation
process.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-10-12 11:07:00 +01:00
Cyril Fougeray 49126e2aa9 sensors: vl53l1: fix compilation without xshut or interrupt pin
Fix compilation when CONFIG_VL53L1X_INTERRUPT_MODE=n or
CONFIG_VL53L1X_XSHUT=n

Signed-off-by: Cyril Fougeray <cyril.fougeray@worldcoin.org>
2023-10-11 14:58:15 +01:00
Francois Ramu 1204b18aa3 drivers: sensor: stm32 vref sensor depends on ADC
Set the CONFIG_STM32_VREF depending on the ADC,
like the CONFIG_STM32_VBAT does

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-10-11 11:17:51 +01:00
Fabio Baltieri d53b1a1c0e sensors: default_rtio_sensor: fix build warning
Fix a build warning on 64 bit architectures:

zephyr/drivers/sensor/default_rtio_sensor.c:238:17: error: format '%zu'
expects argument of type 'size_t', but argument 2 has type 'uint32_t'
{aka 'unsigned int'}

num_channels type changed to uint32_t in 96175fcc47.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-10-09 10:48:55 +01:00
Yuval Peress 96175fcc47 sensors: Fix alignment issues
Add padding to the header and remove unnecessary memset in order to fix
alignment faults in cores such as M0 or ones that support
CONFIG_TRAP_UNALIGNED_ACCESS

Signed-off-by: Yuval Peress <peress@google.com>
2023-10-06 14:54:37 +01:00
Benjamin Cabé ba1af3f36b sensors: mpu6050: add missing break statement
Add missing break statement so that SENSOR_CHAN_DIE_TEMP is properly
supported.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-10-04 10:07:43 +02:00
Bernt Johan Damslora 9eac29d532 drivers: sensor: npm1300_charger: Correct temperature order of magnitude
Changes the interpreted unit of the threshold temperatures to match the
description (millidegrees).

Signed-off-by: Bernt Johan Damslora <Bernt.Damslora@nordicsemi.no>
2023-09-29 11:57:23 +02:00
Jeroen Reeskamp 1134245ac9 sensors: lsm6dso: Values now match better with the ODR values.
Values are specified in the datasheet(page 30, table 18).
Values match with values defined in lsm6dso-common.yaml

Signed-off-by: Jeroen Reeskamp <jeroen.reeskamp@vention.nl>
2023-09-28 12:21:54 -05:00
Mulin Chao 21d7c2db6d drivers: sensor: npcx: fix debug message when port B is captured
Fix wrong debug message when port B of tachometer is captured.

Signed-off-by: Evan Chang <MCCHANG1@nuvoton.com>
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
2023-09-28 09:08:29 -05:00
Benjamin Cabé 14c92da96d doc: stm32: Update all st.com links to use HTTPS
While recent browsers seem to transparently try to use https for
http://www.st.com/... URLs, they are effectively not working anymore, so use
https://www.st.com/... URLs instead.

curl http://www.st.com/en/evaluation-tools/nucleo-g070rb.html -m 5 -v
*   Trying 104.89.117.48:80...
* Connected to www.st.com (104.89.117.48) port 80 (#0)
> GET /en/evaluation-tools/nucleo-g070rb.html HTTP/1.1
> Host: www.st.com
> User-Agent: curl/8.1.2
> Accept: */*
>
* Operation timed out after 5002 milliseconds with 0 bytes received
* Closing connection 0
curl: (28) Operation timed out after 5002 milliseconds with 0 bytes
received

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-09-26 16:55:08 +02:00
Jilay Pandya 4e262bf83a fix: drivers: remove redundant config checks in cmake files
This commit does not introduce any functional change to the
codebase. Just removes certain redundant checks from
various CMakeLists.txt files in order to bring more coherence
in the codebase.

Signed-off-by: Jilay Pandya <jilay.pandya@zeiss.com>
2023-09-26 16:54:58 +02:00
Michal Morsisko 8e32b5ee0a drivers: sensor: Add suport for TMAG5170 3D Hall sensor
Introduce support for Texas Instruments TMAG5170
high-precision linear 3D Hall-effect SPI sensor.
This driver allows to configure measurements on
magnetic and temperature channels. It is also
possible to read rotation of the magnet.

Signed-off-by: Michal Morsisko <morsisko@gmail.com>
2023-09-26 08:36:09 +02:00
Benjamin Cabé 4d10c960da drivers: sensor: Add initial support for hm330x dust sensor
Adds initial support for hm330x dust sensor series. Allows to read PM1,
PM2.5 and PM10 concentrations in atmospheric environment. A further
update to the driver may add support for also reading "standard" CF1
concentrations by exposing of a custom sensor attribute or a Kconfig
option. Tested with Grove - Laser PM2.5 Sensor (HM3301) attached to a
Wio Terminal.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-09-25 19:53:49 +02:00
Nick Ward 3dba54b92d drivers: current sense amp: add pm
Enable power management for current sense amp.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-09-25 11:23:45 -05:00
Nick Ward ead0c4f865 drivers: adc: use adc_read_dt api
Where struct adc_dt_spec is in use use adc_read_dt().

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-09-25 09:52:16 +02:00
Tristan Honscheid 80ed7afab2 sensors: akm09918c: Add RTIO one-shot implementation
Implement the RTIO/Sensors V2/Async API for the AKM09918C. Add a decoder
API implementation as well.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2023-09-25 09:47:26 +02:00
Tristan Honscheid 2b06884afe sensors: icm42688: Remove unused function from driver
This function is no longer used and causes a compiler error.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2023-09-25 09:47:26 +02:00
Yuval Peress 5e14088a3f sensors: vertically decode raw data
Update the decoder APIs to vertically decode the raw sensor data. This
means that instead of getting each channel on a frame by frame basis,
the API takes a channel specifier and returns as many frames of that
given channel as there's room.

The goal of this is to make the end decoded result the most useful and
usable for the Zephyr application. See #60944 for details.

Signed-off-by: Yuval Peress <peress@google.com>
2023-09-25 09:47:26 +02:00
Nick Ward 71db188091 drivers: sensor: voltage: add driver
Add voltage sensor driver.

Co-authored-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-09-25 09:47:03 +02:00
Nick Ward ee3b9c117e sensor: vl53l0x: pm resume fix
When active XSHUT resets the chip so we must
re-initialise chip when resuming from PM suspend.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-09-22 08:40:05 -05:00
Guillaume Gautier a1adc17b31 drivers: adc: stm32: move internal path setting to sensor drivers
On some STM32 families (such as F4), temperature and Vbat sensor share the
same ADC channel, which can lead to conflict when reading them, and wrong
measurement can follow.

To alleviate this problem, this commit moves the setting of the common
path internal channel to the sensor drivers themselves instead of doing
it in the ADC driver.

The teardown is still done in the ADC driver, systematically, instead of
channel by channel (which has the same result).

By moving this logic in the sensor drivers, the properties temp-channel,
vbat-channel and vref-channel becomes useless and are thus removed.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-09-22 09:21:34 +02:00
Ian Morris a24460a7db drivers: sensor: tmp116: Added ability to read configuration register
Added ability to read contents of TMP116 configuration register by adding
an attribute get function that supports the SENSOR_ATTR_CONFIGURATION
option. Followed the same approach as the TMP108 driver. Interpretation of
the returned value is left up to the caller.

Tested using Nucleo-F401RE and Temp-Log 2 (TMP116) click board and
confirmed a read of the configuration register returned the expected
value.

Signed-off-by: Ian Morris <ian.d.morris@outlook.com>
2023-09-20 11:35:34 +01:00
Gerard Marull-Paretas 0660719346 drivers: nrf: select PINCTRL
Drivers for nRF SoCs using pinctrl did not select PINCTRL. This means
boards are forced to enable PINCTRL.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-20 08:57:09 +02:00
Paweł Anikiel cd67428fec drivers: sensor: ntc-thermistor: Add PM support
Add support for runtime power management.

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
2023-09-19 09:28:50 -05:00
Paweł Anikiel ebdfb6b5e2 drivers: sensor: ntc-thermistor: Add Murata NCP15WB473 thermistor
Add murata,ncp15wb473 property together with a compensation table. The
table can be found on the vendor's website
(Resistance VS. Temperature tab):
https://www.murata.com/en-us/products/productdetail?partno=NCP15WB473F03RC

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
2023-09-19 09:28:50 -05:00
Paweł Anikiel 5db05878ab drivers: sensor: ntc-thermistor: Remove r25-ohm property
Remove the r25-ohm property. It is not used by the driver, and it is
not present in linux.

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
2023-09-19 09:28:50 -05:00
Paweł Anikiel 83be5fb596 drivers: sensor: ntc-thermistor: Simplify comp lookup
bsearch() tries to find the exact match for the key, otherwise it
returns NULL. However, here we want to find two elements our key lies
in-between. This requires some rather complicated logic that pretends
it found the exact match even if it didn't. Replace this with a simple
implementation of binary search.

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
2023-09-19 09:28:50 -05:00
Paweł Anikiel 694b7fe822 drivers: sensor: ntc-thermistor: Fix wrong n_comp value
The value of n_comp is wrong for ntc-thermistor-generic. Introduce a
helper macro to compute n_comp correctly for both thermistor types.

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
2023-09-19 09:28:50 -05:00
Paweł Anikiel 883a0c46a8 drivers: sensor: ntc-thermistor: Fix voltage & resistance calculation
The pullup resistance was assumed to be the maximum ADC value. This is
incorrect when the reference ADC voltage and the thermistor pullup
voltage differ. Use the pullup_uv property from DT instead.

The equations for the thermistor resistance are also wrong. The correct
equations are (see https://en.wikipedia.org/wiki/Voltage_divider):
R1 = R2 * (Vin / Vout - 1)
for the positive-connected resistor, and
R2 = R1 * (Vin / Vout - 1)^-1
for the negative-connected resistor. These were transformed so that
they can be computed using integer math.

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
2023-09-19 09:28:50 -05:00
Paweł Anikiel 97e15f2923 drivers: sensor: ntc-thermistor: Fix flipped condition
Fix the flipped condition inside this if statement.

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
2023-09-19 09:28:50 -05:00
Jilay Pandya 3384ebb00f driver: sensor: adds basic support for analog devices ltc2990
This commit adds Kconfig variables to configure ADLTC2990. This commit adds
basic driver code for analog devices ltc2990 sensor.

Signed-off-by: Jilay Pandya <jilay.pandya@zeiss.com>
2023-09-18 17:41:38 +02:00
Mathias Storck 4431c4755c drivers: sensor: lis2dh: add tap interrupt
add interrupt for single tap on ST LIS2DH
shared interrupt with any motion

Signed-off-by: Mathias Storck <mathias.storck@gwa-hygiene.de>
2023-09-15 14:42:26 -05:00
Gerard Marull-Paretas 691facc20f include: always use <> for Zephyr includes
Double quotes "" should only be used for local headers.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-14 13:49:58 +02:00
Jeppe Odgaard 30a2326d0b drivers: sensor: qdec_mcux: update phase bit in register
Update single phase bit in register when changing data->qdec_config.
Otherwise the changed settings has no effect.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-09-13 16:35:07 +02:00
Weiwei Guo 2779dd9d9b drivers: sensor: bmm150: Add trigger support for bmm150 magnetometer sensor
Add bmm150 magetometer sensor data ready trigger support.

Signed-off-by: Weiwei Guo <guoweiwei@syriusrobotics.com>
2023-09-13 12:07:57 +02:00
Nick Ward 17f2046821 drivers: sensor: current_amp: add driver
Add current sense amplifier driver.

Implements https://github.com/zephyrproject-rtos/zephyr/issues/60415

Co-authored-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-09-13 12:05:52 +02:00
Rick Talbott a07b79a8bf drivers: sensor: tsl2540
Add the tsl2540 sensor to drivers.

Signed-off-by: Rick Talbott <richard.talbott1@t-mobile.com>
2023-09-11 19:54:59 +02:00
Fabio Baltieri 5e63058deb sensor: bq274xx: use K_TIMEOUT_ABS_MS for the startup delay
Use K_TIMEOUT_ABS_MS to control the startup delay. Same thing, more
compact.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-09-11 08:57:42 -05:00
Mulin Chao d2892c1123 driver: sensor: npcx: add 'thr-sel' prop. for adc comparator
Add `thr-sel` prop. to select the relevant threshold register for adc
comparator since there're two adc modules in npcx4 series.

Signed-off-by: Kate Yen <htyen@nuvoton.com>
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
2023-09-08 14:43:37 +02:00
Mulin Chao 72ee4f75ef driver: adc: npcx: add multi-device support in npcx adc driver
Add multi-device support in npcx adc driver since there is more than one
adc module in npcx4 series. And each adc's reference voltage might be
different, this CL introduces the `vref-mv` prop. to select its own
reference voltage.

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Signed-off-by: Kate Yen <htyen@nuvoton.com>
2023-09-08 14:43:37 +02:00
Fabio Baltieri 22fbd73fab sensor: max17055: fix v_empty setting
Fix the whole v_empty setting code, this was using a wrong scaling
factor, but also incorrectly clearing the recovery voltage part of the
register.

Change the code to read the previous value and mask out the bits not
used by VE.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-09-07 14:25:47 +02:00
Fabio Baltieri 02afefe34a sensor: f75303: fix i2c_dump_msgs_rw argument
i2c_dump_msgs_rw argument should be the device pointer.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-09-07 13:41:12 +02:00
Paweł Anikiel 43668c6416 drivers: sensor: Add F75303 driver
Add driver for F75303 temperature sensor IC.

Signed-off-by: Paweł Anikiel <pan@semihalf.com>
2023-09-07 09:42:59 +02:00
Michał Barnaś 4aac1756a9 i2c: use device instead of name for i2c dump messages
This commit changes the parameter of i2c_dump_msgs function from
string name to pointer to the device structure.
It allows for comparison of device pointers and allow to use
the printed device name in i2c shell commands.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-09-06 17:54:53 +02:00
Albert Jakieła dd4ef7d2b5 drivers: sensor: Add PM support to LM75 digital temperature sensor
Add support for device power management. When the sensor
is not powered, the fetch function will fail. When the
sensor is not connected to a power domain, it will behave
as usual.

Signed-off-by: Albert Jakieła <aja@semihalf.com>
2023-09-05 09:49:42 -05:00
Maxmillion McLaughlin 0df085bb36 drivers: sensor: remove LOG_INF from ntc_thermistor_sample_fetch()
LOG_INF() inside of a sample_fetch create noise in the logs and is
inconsistent with other sensor driver implementations.

Signed-off-by: Maxmillion McLaughlin <github@maxmclau.com>
2023-09-02 15:10:31 +02:00
Francois Ramu 4e070a0867 drivers: sensor: stm32 Vref sensor calibration on 12bit
The Calibration value of the VRef on stm32U5 is acquired on 14Bit by ADC1
and should be adjusted on 12bit becasue the resolution is 12bit
in this stm32_vref driver.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-09-01 13:22:24 +02:00
Francois Gervais 96a887809c drivers: sensor: ism330dhcx: fix pulse mode interrupts
On my end, the ISM330DHCX was stopping working after a few seconds.

After investigation, it seems that the function used to set the device
in pulse mode only works for special modes like tap and embedded functions
and not for data-ready as intended.

The data-ready was then in the default latched mode which does not work
sustainably with the rest of the driver logic. In this mode, the driver
can miss an interrupt and be forever waiting on a new data-ready pulse
which will never happen as the interrupt line is already active.

This calls the correct function to enable pulsed data-ready mode as
described in the datasheet section 9.7 COUNTER_BDR_REG1 (0Bh).

Signed-off-by: Francois Gervais <francoisgervais@gmail.com>
2023-08-30 08:35:39 -05:00
Benjamin Lemouzy d2e420029b drivers: sensor: add NXP TEMPMON driver
Add driver for the NXP TEMPMON to retrieve on-die operational
temperature.

Signed-off-by: Benjamin Lemouzy <blemouzy@centralp.fr>
2023-08-30 10:18:27 +02:00
Fabio Baltieri e3f5e1f496 sensor: bq274xx: fix few data units
Change few data units that are currently reported three order of
magnitude off from what the sensors API specifies.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-30 10:17:27 +02:00
Fabio Baltieri 5d1a4d4589 sensor: bq274xx: add an initialization delay
The various BQ27xxx datasheet seems to indicate a typical power-up or
shutdown to communication time of 250ms typical.

Adjust the driver to include:
- a check to ensure that the MCU has been powered for at least 300ms
  before any communicaton
- the same delay when exiting shutdown state

Link: https://www.ti.com/lit/gpn/BQ27427
Suggested-by: Nick Ward <nix.ward@gmail.com>
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-30 10:17:27 +02:00
Fabio Baltieri 72a2b81f75 sensor: bq274xx: implement the bq27427 ccgain workaround
The BQ27427 appears to work incorrectly with the ROM configuration
value, it battery power and current are the inverse of what they should
be, and SoC is decresing when charging and increasing when discharging
as a consequence.

At this time this only appears documented in the TI E2E forums, and the
workaround seems to be to invert the sign of the CC Sense register of
the device.

This register is not documented on the BQ27427 device technical
reference manual, as the device has an internal shut and the sense value
should not have to be tweaked, so the CC Sense details are taken from
the BQ27426 one instead, which is supposedly the same silicon with an
external shunt.

Also the CC Sense value, which is just documented as "F4" (as in 4 bytes
float) is actually in a proprietary floating point format, so instead of
trying to decode, just swap the known sign bit as documented in the E2E
forum post.

Link: https://e2e.ti.com/support/power-management-group/power-management/f/power-management-forum/1215460/bq27427evm-misbehaving-stateofcharge
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-30 10:17:27 +02:00
Fabio Baltieri 34bae6c497 sensor: bq274xx: rewrite the configuration function
Rework the device configuration code. The current code has a bunch of
leftover functions that read data and compute checksums that are never
used, but that break the initialization sequence if removed because
there are also some missing delays in their place.

Redo the initialization code from scratch, this is mainly inspired from
the Linux driver and taking some part from the (somewhat confusing and
incomplete) datasheet.

This drops the dead code and adds the necessary sleeps to guarantee
correct operation.

The device configuration is also now changing the local copy of the data
block, and soft reset is also issued only if the device configuration
has changed, which should only happens if the battery is replaced or
went completely flat. This should also result in a consistent battery
measurement operation across resets.

Link: https://elixir.bootlin.com/linux/latest/source/drivers/power/supply/bq27xxx_battery.c
Link: https://www.ti.com/lit/ug/sluucd5/sluucd5.pdf
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-30 10:17:27 +02:00
Fabio Baltieri 69a5e64f8c sensor: bq274xx: use sys_put_le16 in bq274xx_ctrl_reg_write
Use sys_put_le16 in bq274xx_ctrl_reg_write to convert the two bytes
value. This is coherent with the rest of the file.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-30 10:17:27 +02:00
Fabio Baltieri aae140cadb sensor: bq274xx: add few links to the device documentation
Link few docs to the top so they don't have to be referenced around.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-30 10:17:27 +02:00
Eric Holmberg f5b78270bc drivers: sensor: ina230: fix current sign issue
Fix sign handling for ina230 current calculation.

Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
2023-08-29 09:44:20 -05:00
Eric Holmberg f0f7f8b146 dt-bindings: sensor: ina230: add configuration properties
Add properties to replace the configuration register value.

Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
2023-08-29 09:44:20 -05:00
Eric Holmberg 19e44ae9a0 drivers: sensor: ina237: add shunt voltage support
Add ability to retrieve the shunt voltage if the end user wants to do
the power calculation manually to handle negative power values.

Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
2023-08-29 09:44:20 -05:00
Eric Holmberg a70d056513 drivers: sensor: ina237: add high-precision mode
The current-shunt calibration requires a factor of 4x if high-precision
mode is selected.

Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
2023-08-29 09:44:20 -05:00
Eric Holmberg 2d3a391191 drivers: sensor: ina237: fix current sign issue
Fix current sign extension logic and consolidate sensor scaling code
into a single block.

Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
2023-08-29 09:44:20 -05:00
Eric Holmberg 19da119c17 test: sensor: ina237: add emulator unit test
Add emulator unit test of the INA237.

Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
2023-08-29 09:44:20 -05:00
Eric Holmberg c7135a2ac5 dt-bindings: sensor: ina237: add configuration properties
Add properties to replace the configuration register values.

Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
2023-08-29 09:44:20 -05:00
Nick Ward 2d65acca3a drivers: gpio: use gpio_is_ready_dt helper function
Update `struct gpio_dt_spec` use with gpio_is_ready_dt()

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-08-28 08:48:35 -05:00
Fabio Baltieri ec71be5d9d drivers,subsys: fix few missing k_work_delayable_from_work
Fix few instances of delayable work handlers using the k_work pointer
directly in a CONTAINER_OF pointing to a k_work_delayable.

This is harmless since the k_work is the first element in
k_work_delayable, but using k_work_delayable_from_work is the right way
of handling it.

Change a couple of explicit CONTAINER_OF doing the same work as the
macro in the process.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-28 10:12:21 +02:00
Ryan McClelland 7b6b1328a0 drivers: sensor: bmi08x: fix fs prop for gyro
The full scale prop was incorrectly using the enum idx which was then
to be used with a look up table which used the actual range number.
This changes it to use the int directly from the dts.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2023-08-25 13:48:26 -05:00
Andy Sinclair 075a859869 drivers: sensor: npm1300: Additional charger configuration
Added configuration of termination current and trickle voltage
Added option to bypass low voltage charge inhibit
Added option to disable automatic recharge

Signed-off-by: Andy Sinclair <andy.sinclair@nordicsemi.no>
2023-08-24 18:42:37 -05:00
Andy Sinclair e2dd071afc drivers: sensor: npm1300: Attributes and enable/disable
Added support for attribute get/set, and enabling/disabling
of charge.

Signed-off-by: Andy Sinclair <andy.sinclair@nordicsemi.no>
2023-08-24 18:42:37 -05:00
Ryan McClelland b05e104acb drivers: sensor: bmi08x: adjust logging level of certain issues
Some log messages could be too noisy, especially if the sensor shell was
used which would call all attr and samples even though just a few are
supported.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2023-08-24 18:24:39 -05:00
Daniel Stuart d9e7af6cdd drivers: sensor: vl53l1x: Allow for SENSOR_CHAN_ALL channel to be used
It mirrors the functionality of the vl53l0x driver.
Also removes an assert not needed, as the channel is checked.

Signed-off-by: Daniel Stuart <daniel.stuart14@gmail.com>
2023-08-24 17:21:10 +02:00
Ryan McClelland b92e749c3e drivers: sensor: ina3221: fix double-promotion
channel_get was doing using floating point constants with it's calculation.
The result is changed to be a float as this was generating a double
promotion warning.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2023-08-23 07:51:53 -05:00
Armando Visconti e1ca18e757 modules/hal_st: Align sensor drivers to stmemsc HAL i/f v2.3
Align all sensor drivers that are using stmemsc (STdC) HAL i/f
to new APIs of stmemsc v2.3

Requires https://github.com/zephyrproject-rtos/hal_st/pull/16

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2023-08-22 18:12:27 +02:00
Anas Nashif 66b0472d6f drivers: imply CRC where applicable
Do not depend on CRC, imply it, as it is disabled by default now.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-08-18 08:52:16 +03:00
Manimaran A a3d6b423c6 drivers: tacho: mchp: low power feature enabled
Updated Tacho driver to support low power feature.

Signed-off-by: Manimaran A <manimaran.a@microchip.com>
2023-08-16 10:20:12 +02:00
Matthias Hauser 6975262047 drivers: sensor: correct scale in WSEN_ITDS driver
correct scale in WSEN_ITDS driver to overcome sign extension issues

Signed-off-by: Matthias Hauser <Matthias.Hauser@we-online.de>
2023-08-15 12:26:28 -05:00
Fabio Baltieri 4488a41f8c Revert "sensors: Fix overflow in default decoder"
This reverts commit b2a78ff679.

Causes CI fail on:

west build -p -b native_posix_64 -T
	tests/drivers/build_all/sensor/sensors.generic_test

Assertion failed at
WEST_TOPDIR/zephyr/tests/drivers/build_all/sensor/src/generic_test.c:204:
run_generic_test: (expected_shifted not within actual_shifted +/-
epsilon_shifted)

Expected -105484396736, got -103734438144 (shift 6, ch 8, iteration 1/5,
Error -1749958592, Epsilon 3221184)

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-09 11:11:37 +00:00
Yuval Peress b2a78ff679 sensors: Fix overflow in default decoder
The default decoder would take the micro-unit value of the old sensor
value and multiply it by INT32_MAX. This would, at times, cause an
overflow for the int64_t which is the cause of some bugs like when
-7952 was used (-7952000000 * INT32_MAX < INT64_MIN). Instead the new
math converts:
- `value_u * INT32_MAX / ((1 << header->shift) * 1000000)`

to a bitmap:
- `sample.val1` consumes the upper `N` bits
- `sample.val2 * BIT(32 - N) / 1000000` consumes the lower `32-N`
    bits

This both improves the accuracy, and avoids the overflow since
`shift` is guaranteed to be between 0 and 31.

Signed-off-by: Yuval Peress <peress@google.com>
2023-08-09 08:28:32 +00:00
Tristan Honscheid 128b466dd1 emul: icm42688: Implement backend sensor emul API
Implement the backend emul API for the ICM42688 motion sensor so it can
be automatically tested by the generic sensor test (see #60394).
Supports all channels (temp, accel XYZ, and gyro XYZ) at each of the
programmable full-scale accel and gyro ranges.

Also fixes an arithmetic bug in the driver that was causing a minor
error in the returned readings.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2023-08-09 08:27:59 +00:00
Fabio Baltieri 2cfffda32a sensor: max17055: support fetching individual channels
Add support for fetching individual channels rather than forcing the
application to always fetch them all. Potentially saves few i2c
transactions.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-09 08:27:13 +00:00
Fabio Baltieri fa2481e6fb sensor: max17055: convert floating point operation to integer
Convert a few floating point operation to fixed point. May save some
stack and some flash as well on soft-fp systems.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-09 08:27:13 +00:00
Fabio Baltieri 2f9b120860 sensor: max17055: change register access function addr to uint8_t
The register space for the device is on 8 bit, use uint8_t for register
address to the low level read and write functions.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-09 08:27:13 +00:00
Fabio Baltieri 510a206cf0 sensor: max17055: use sys_get_le16 for data format conversion
Use sys_get_le16 instead of the manual byte order conversion.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-09 08:27:13 +00:00
Ryan McClelland cea56b0409 drivers: sensor: icp10125 fix double-promotion warnings
sensor_value_from_double was used, but sensor_value_from_float
should be used as the parameter is a float

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2023-08-07 16:12:13 -07:00
Aedan Cullen 5fc2586b8f drivers: sensor: lis3mdl: always use continuous mode
The LIS3MDL driver misunderstands the MD[1:0] bits in CTRL_REG3.
Correct this so that all ODR settings are functional.

Currently, single-conversion mode is enabled when fast ODR is set,
resulting in only one measurement being taken before the device
immediately returns to power-down mode. The result is that all fast-ODR
rates (155 and higher) are not usable when assigned to CONFIG_LIS3MDL_ODR.

Continuous mode is the only mode truly supported by this driver and should
always be used.

Signed-off-by: Aedan Cullen <aedan@aedancullen.com>
2023-08-07 11:28:02 +02:00
Fabio Baltieri 13dfa0ac27 sensors: shell: implement rounding for q31_t
Since the sensor shell command was converted to use qt31_t, all the
integer values started to show up as rounded up by a fractional unit
when displayed, due to the conversion always rounding down.

Fix that by using the recently introduced DIV_ROUND_CLOSEST and handling
rounding up to next integer explicitly.

Before:

channel idx=44 gauge_state_of_charge value=83.999999

after:

channel idx=44 gauge_state_of_charge value=84.000000

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-07 11:26:02 +02:00
Peter van der Perk 86812b1551 sensors: ist8310: New driver
Adds support for the Isentek IST8310
3-axis magnetic sensor

Signed-off-by: Peter van der Perk <peter.vanderperk@nxp.com>
2023-08-04 17:30:02 -05:00
Tristan Honscheid cfc3a3b024 sensors: max17262: Run clang-format
Format the file `drivers/sensor/max17262/max17262.c` but exclude the
regsiter lookup table in `max17262_sample_fetch()`

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2023-08-02 09:53:45 +00:00
Tristan Honscheid ef5899e5a0 sensors: max17262: Error-check init I2C operations
The init function of the MAX17262 sensor doesn't check the return value
of its I2C read and write functions. In case a read operation fails, the
output variable is not updated but the driver proceeds anyways. This can
cause unintended operation due to the potentially un-initialized memory,
such as getting stuck in the polling loop on line max17262.c:245. Update
the init function to abort and pass along the error code when I2C
transactions fail.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2023-08-02 09:53:45 +00:00
Maureen Helm 598fd31d51 drivers: sensor: Fix return value for unsupported channels
Fixes sensor drivers to consistently return -ENOTSUP when an unsupported
channel argument is passed to the sensor_channel_get function.

Signed-off-by: Maureen Helm <maureen.helm@analog.com>
2023-08-01 11:59:34 +02:00
Josep Puigdemont eb3a56d8cd sensor: dht: return error if channel not supported
The driver would return the temperature for all channels requested
except relative humidity. Instead, ENOTSUP should be returned for
unsupported channels.

Signed-off-by: Josep Puigdemont <josep.puigdemont@gmail.com>
2023-08-01 09:51:25 +02:00
Matthias Hauser ee5c998257 drivers: sensor: fetch all channels on WSEN_ITDS sensor
fetch all channels on WSEN_ITDS sensor

Signed-off-by: Matthias Hauser <Matthias.Hauser@we-online.de>
2023-07-31 09:29:16 -05:00
Tristan Honscheid 171c1fc9d9 emul: Introduce emulator backend API and generic sensor test
This PR introduces a backend API to be implemented by sensor emulators
that creates a standardized mechanism for setting expected sensor
readings in tests. This unlocks the ability to create a generic sensor
test that can automatically set expected values in supported sensor
emulators and verify them through the existing sensor API. An
implementation of this API is provided for the AKM09918C magnetometer.

A generic sensor test is also created to exercise this implementation.
Observe that this test knows nothing about the AKM09918C; info about
supported channels and sample ranges is discovered through the backend
API. The test iterates over all devices attached to the virtual I2C and
SPI buses in the test binary's device tree, which (theoretically) covers
all sensors. Sensors whose emulator does not exist yet or does not
support the backend API are skipped.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2023-07-28 17:48:31 +02:00
Tristan Honscheid 4f8c90ead2 sensor: akm09918c: Fix conversion constant
The sensor driver uses the value 500 to convert bit counts to microgauss
values, but it should actually be 1500. Edit the driver unit test to use
the macro instead of a magic number.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2023-07-28 17:48:31 +02:00
Josep Puigdemont 677d377299 sensor: bme280: BMP280 has no humidity sensor
Return ENOTSUP when getting the humidity channel if the driver is used
with a BMP280, since this device does not provide humidity readings.

Signed-off-by: Josep Puigdemont <josep.puigdemont@gmail.com>
2023-07-27 08:46:40 -05:00
Josep Puigdemont 17fb2a1fb5 sensor: bme280: return ENOTSUP on invalid channel
ENOTSUP should be returned for unsupported channels.

Signed-off-by: Josep Puigdemont <josep.puigdemont@gmail.com>
2023-07-27 08:46:40 -05:00
Marco Argiolas 5fc1777055 drivers: sensor: add mutex to cmd_get_sensor()
Add a mutex to protect shared data-structures, since shell can have
multiple backends.

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2023-07-26 09:35:57 -05:00
Oliver King fbc6a91a5a drivers: sensor: a01nyub: added driver
Added a driver for the DFRobot A01NYUB distance sensor. This sensor
sends its readings via UART at 9600 baud. This driver uses interrupts
to read the data from the sensor.

Signed-off-by: Oliver King <oliver.king@steadconnect.com>
2023-07-26 13:28:28 +02:00
Marek Matej 6b57b3b786 soc: xtensa,riscv: esp32xx: refactor folder structure
Refactor the ESP32 target SOCs together with
all related boards. Most braking changes includes:

- changing the CONFIG_SOC_ESP32* to refer to
  the actual soc line (esp32,esp32s2,esp32s3,esp32c3)
- replacing CONFIG_SOC with the CONFIG_SOC_SERIES
- creating CONFIG_SOC_FAMILY_ESP32 to embrace all
  the ESP32 across all used architectures
- introducing CONFIG_SOC_PART_NUMBER_* to
  provide a SOC model config
- introducing the 'common' folder to hide all
  commonly used configs and files.
- updating west.yml to reflect previous changes in hal

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2023-07-25 18:12:33 +02:00
Andrzej Głąbek f89ca1164c drivers: sensor: qdec_nrfx: Clean up driver instantiation
- use CONFIG_HAS_HW_NRF_* symbols consistently in nRF multi-instance
  drivers when creating particular driver instances
- remove unnecessary hidden Kconfig options that indicated the type of
  peripheral to be used by a given instance (e.g. SPI, SPIM, or SPIS)
  and enabled proper nrfx driver instance; instead, use one option per
  peripheral type and include the corresponding shim driver flavor into
  compilation basing on that option (not the one that enables the nrfx
  driver as it was incorrectly done so far in some cases)

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-07-25 13:41:51 +02:00
Peter van der Perk 2bf38b46ec drivers: sensor: qdec_mcux: fix fixed point conversion
Use macro to convert sensor q31 representation

Signed-off-by: Peter van der Perk <peter.vanderperk@nxp.com>
2023-07-24 08:29:21 -05:00
Peter van der Perk aa7ed78827 sensors: bmp388: allow mix of instances with and without int gpio
makes int_gpios optional so we can mix both bmp388
with and without DRDY triggers

Signed-off-by: Peter van der Perk <peter.vanderperk@nxp.com>
2023-07-24 09:08:18 +00:00
Fabio Baltieri 502ecaeac5 sensors: icm42688: ensure SENSOR_ASYNC_API is selected
This fix a build issue where ICM42688_DECODER is enabled but
SENSOR_ASYNC_API is not, which results in some structures in an
orphan section:

warning: orphan section
`._sensor_decoder_api.static.invensense_icm42688__decoder_api_' from
`libdrivers__sensor__icm42688.a(icm42688_decoder.c.obj)'
being placed in section
`._sensor_decoder_api.static.invensense_icm42688__decoder_api_'

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-07-21 14:12:13 +00:00
Fabio Baltieri bb0135b64c sensor: bq274xx: use two bytes write for settings
Use a combination of sys_cpu_to_be16 and i2c_burst_write_dt for setting
16 bits registers. Get rid of a bunch of temporary variables, custom
conversions and few bus writes.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-07-21 09:07:46 -05:00
Fabio Baltieri ec98bf7cbc sensor: bq274xx: add support for bq27427
The current ID for BQ274XX_DEVICE_ID is actually the one for the
BQ27421. The driver seems to work with the BQ27427 as well, at least the
common and extended commands are the same, so add that variant as well,
rename the existing one and print the currently read ID when the ID
check fails.

The configuration registers have a different offset though, so add a
register offset table and make the device rcognize the right one un
runtime based on the device ID.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-07-21 09:07:46 -05:00
Fabio Baltieri 6390dd582a sensor: bq274xx: drop bq274xx_ctrl_reg_write
Use i2c_reg_write_byte_dt instead of bq274xx_cmd_reg_write. The wrapper
does not add anything anyway.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-07-21 09:07:46 -05:00
Fabio Baltieri 4dc7437d45 sensor: bq274xx: support fetching all channels
Change bq274xx_sample_fetch to support SENSOR_CHAN_ALL. This makes it
possible to get the sensor data using the sensor shell, besides being
generally convenient.

Also drop a redundant comment.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-07-21 09:07:46 -05:00
Fabio Baltieri 76509a73b1 sensor: bq274xx: clarify the unseal sequence
The device technical reference manual says "The Sealed to Unsealed key
has two identical words". Use two different defines with the same value
in the code so it's somewhat less ambiguous that the double write is
intentional.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-07-21 09:07:46 -05:00
Fabio Baltieri 7b6430cc80 sensor: bq274xx: limit config update mode check loops
Add a retry count limit to config update mode loops, this way the system
can still boot if there's an issue with the device. The normal sleep
should be enough for correct operation, adding a conservative limit.

Rework the delays to be unambiguous while at it.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-07-21 09:07:46 -05:00
Fabio Baltieri 71bd63d007 sensor: bq274xx: fix few parameter calculations
Fix the calculation for designenergy_mwh, as right now it's using a
float casted straight to an int, which results in the factor rounded
from 3.7 to 3. Also rework both that and taperrate so that they don't
use floating point.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-07-21 09:07:46 -05:00
Fabio Baltieri 35bb28abaf sensor: bq274xx: add few defines for magic numbers
Add a couple of define for the data memory block size and config flag
bit.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-07-21 09:07:46 -05:00
Fabio Baltieri 9bc43ac3ce sensor: bq274xx: simplify i2c write code
Control reg write seems to support two bytes mode (the technical
reference shows example of that), so use a single i2c_write_dt there.
Also drop a couple alias variables from bq274xx_cmd_reg_write.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-07-21 09:07:46 -05:00
Fabio Baltieri 2dcaed3252 sensor: bq274xx: drop a bunch of redundant initialization
Drop various unnecessarily initialized variables from the driver.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-07-21 09:07:46 -05:00
Fabio Baltieri 1e2b7de13b sensor: bq274xx: remove forward declaration
Move bq274xx_gauge_configure up in the code, remove the forward
declaration.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-07-21 09:07:46 -05:00
Fabio Baltieri f6f568b712 sensor: bq274xx: drop unnecessary casting
Drop unnecessary casting from uint16_t to uint8_t.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-07-21 09:07:46 -05:00
Fabio Baltieri e68e623963 sensor: bq274xx: re-add function prefixes
Add the bq274xx_ back to the static function prefixes for the bq274xx
driver.

These have been removed recently but every other sensor and most Zephyr
driver have static function prefixed, this helps avoiding ambiguity in
list files, stack traces, setting debugging breakpoints etc.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-07-21 09:07:46 -05:00
Al Semjonovs f856e7ba63 icm42688: Fix channels read BIT shift error
channel_pos_read bit was being cleared with a sensor channel enum value
instead of the encoded bit position.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2023-07-20 14:19:20 -05:00
Tom Burdick 0b6b970f0a sensors: icm42688: Do not force rc oscillator
Forcing the usage of the RC oscillator and keeping it on turns out
to have detrimental effects to the readings by default. The default
clock mode settings are perfectly fine.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-07-20 16:24:46 +02:00
Tristan Honscheid f119d5341a drivers: fdc2x1x: Fix compilation error
When CONFIG_PM_DEVICE is enabled, the FDC2x1x driver includes code that
doesn't access the name of the shutdown pin's GPIO port correctly.
Correct this so the code derefences the right struct members.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2023-07-18 11:09:08 +00:00
Tristan Honscheid 4ac8000bf2 drivers: fdc2x1x: Loosen newlib dependency
The FDC2X1X driver depends on newlib in Kconfig. This prevents the
driver from being built in a native_posix testing environment, which uses
an external libc from the host. Allow the driver to be built with an
external libc as well.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2023-07-18 11:09:08 +00:00
Armando Visconti a29261c5f4 drivers/sensor: check xyz_mem_bank_set() ret value
Check xyz_mem_bank_set() API return value to catch and report as soon
as possible the error condition. Impacted stmemsc API:

  - lsm6dso_mem_bank_set()
  - lsm6dso16is_mem_bank_set()
  - lsm6dsv16x_mem_bank_set()

Fix:

  Coverity-CID: 316212 (issue #58579)
  Coverity-CID: 316224 (issue #58580)
  Coverity-CID: 316307 (issue #58586)

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2023-07-18 09:54:44 +00:00
Nick Ward 371f0f2503 drivers: adc: use adc_is_ready_dt helper function
Update  `struct adc_dt_spec` use with adc_is_ready_dt()

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-07-17 10:16:22 +00:00
Ryan McClelland f1a992c87a drivers: sensors: bmi08x: add initial support for bmi08x
This adds support for the bosch bmi085 and bmi088. This also includes
support for data sync mode.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2023-07-12 14:53:16 -05:00
Thomas Stranger ce74b60d77 drivers: sensor: adxl362: coverity: 316152 unchecked return value
Check and propagate two return values.
Don't need to check return of the part id request, but make
sure that the value is initialized before the comparison.

Fixes #58575
Coverity-CID: 316152

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2023-07-12 10:53:56 -05:00
Thomas Stranger 7c6a340413 drivers: sensor: tmd2620: coverity 316443 unchecked return value
The return value is consciously not checked, because the operation
is expected to fail. And the real request is executed afterwards.

Fixes #58593
Coverity-CID: 316443

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2023-07-12 10:53:56 -05:00
Marek Pieta 1601725354 drivers: sensor: qdec_nrfx: Workaround spurious samplerdy event
The underlying HAL driver may improperly forward an samplerdy event even
if it's disabled in the configuration. Ignore the event to prevent error
logs until the issue is fixed in HAL.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2023-07-12 10:16:41 +02:00
Thomas Stranger cf29b8caad drivers: sensor: mx5837: address integer overflow.
Avoid integer overflow in temp_sq calculation.
For an analysis of the value ranges for the temp_sq calculation
of mx5837-02 see below:

calculation:
dT = adc_temperature - ((int32_t)(data->t_ref) << 8);
data->temperature = 2000 + (dT * data->tempsens) / (1ll << 23);
temp_sq = (data->temperature - 2000) * (data->temperature - 2000);

given needed storage sizes:
t_ref is uint16_t,
adc_temperature is uint24_t,
data->tempsens is uint16_t,

ranges
=> dT:                -16776960 <= dT <= 16777215         (25 bit)

=> data->temperature (TEMP):
  intermed.(mult): -1099478073600 <=  x   <= 1099494785025 (41 bit)
  TEMP:         2.000 - 131068 <= TEMP <= 2.000 + 131.069
  TEMP:                -129068 <= TEMP <= 133069     (17 bit)

So worst case we need 17 bit for TEMP, so the square of it would
overflow an int32_t. The nominal measurement range is
only -40 to 85°C, meaning a range of -4000 to 8500.
So normally the result for temp_seq would fit into a int32_t,
but we cast to be better safe than sorry. Also the 64-bit
multiplication won't be the dominating operation of the
whole calculation.

Fixes #58585
Coverity-CID: 316294
Fixes #58594
Coverity-CID: 316521

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2023-07-11 09:43:10 +02:00
Armando Visconti 76e5760545 drivers/sensor: lis2dh: move h/w reg debug print right after it is read
Move LOG_DBG print just after the printed h/w register is read, to avoid
coverity complaining about uninitialized variable.

  Fix:
     Coverity-CID: 316407 (issue #58591)

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2023-07-10 10:00:48 +00:00
Tristan Honscheid 3b59d6842f sensor: ism330dhcx: Incorrect handle passed to ctx struct in SPI mode
The ISM330DHCX driver immediately segfaults when run in SPI mode. A bad
pointer is being passed into the `dev` param of `ism330dhcx_spi_read`.
Tracing this back, it appears that the handle field of the ctx struct
is being set to the device's data struct while `ism330dhcx_spi_read`
expects `ctx->handle` to be a pointer to a device struct.

Modify `ism330dhcx_spi_init()` to insert the correct pointer into the
context struct. Unfortunately this requires a cast to discard the
`const` qualifier, but this is how it is done in I2C mode (see
`ism330dhcx_i2c_init()`). The only other way would be to change the
declaration of `stmdev_ctx_t`, which is owned by the HAL module.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2023-07-07 09:18:41 +00:00
Benjamin Perseghetti da95a407bf drivers: sensor: ina23x: calculate cal at compile.
Calculate the calibration value at compile for ina23x.
Maximizes the precision of the calcualtion value by
using 64bit math at compile, allows for removal
of rshunt config option.

Code cleaned up with clang-format.

Co-authored-by: Trent Piepho <tpiepho@gmail.com>
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
2023-07-07 09:21:23 +02:00
Benjamin Perseghetti 5336e7fd14 drivers: sensor: ina23x: Use micro-ohms for rshunt
Changes rshunt-milliohms to rshunt-micro-ohms allowing for current
sensing of greater than 16.4A (1mOhm resistor). This is commonly
set to 100 uOhm for VMU/FMU boards/applications.

Co-authored-by: James Goppert <james.goppert@gmail.com>
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
2023-07-07 09:21:23 +02:00
Andy Sinclair 7e3f6f1290 drivers: sensor: npm1300_charger: Added Ntc threshold config
The NTC thresholds (cold, cool, warm, hot) are now configured
during initialisation

Signed-off-by: Andy Sinclair <andy.sinclair@nordicsemi.no>
2023-07-05 12:59:38 +02:00
Andy Sinclair 725d45e6d4 drivers: sensor: npm1300_charger: Auto temp measurements
Enable automatic temperature measurements during charging.
Allows the PMIC to charge when the host is in low power mode.

Signed-off-by: Andy Sinclair <andy.sinclair@nordicsemi.no>
2023-07-05 12:59:38 +02:00
Andy Sinclair f93da64ec8 drivers: sensor: npm1300_charger: Startup vbus current limit
The vbus current limit is now written to the vbus startup
register. It is now applied at all times and does not need
to be updated on charger insertion.

Signed-off-by: Andy Sinclair <andy.sinclair@nordicsemi.no>
2023-07-05 12:59:38 +02:00
Al Semjonovs 2a31c4c530 sensors: icm42688 async API
Implementation of the async API for the icm42688

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2023-06-29 21:04:33 +02:00
Nick Ward e0cdb0178c drivers: sensor: bmm150: add PM
Add PM

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-06-20 15:15:47 +02:00
Nick Ward ce9eb7a353 drivers: sensor: bmm150: improve initialisation
Update driver with low level power control and OpMode
functions to better represent operations used in power
mode transition diagram Figure 2 from the datasheet.
This also prepares the driver for use of these functions
for PM actions.

Extend the soft reset at initialisation to a full POR.

Add defines for maximum POR time and start up time.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-06-20 15:15:47 +02:00
Nick Ward 49ff2a5add drivers: sensor: bmm150: fix soft reset
Bit 7 and 1 is 0x82 not 0x81.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-06-20 15:15:47 +02:00
Nick Ward 264d3f0b1a drivers: sensor: bq274xx: apply clang format
Fix unnecessarily broken lines.
Also make logging sentences more concise.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-06-20 15:15:40 +02:00
Oleh Lozynskyy 845d880773 drivers: sensor: bq274xx: shorten macro names
Shorten lines lengths.

Signed-off-by: Oleh Lozynskyy <oleh.lozynskyy@gmail.com>
2023-06-20 15:15:40 +02:00
Oleh Lozynskyy 0f37378a95 drivers: sensor: bq274xx: remove bq274xx prefixes
Shorten lines lengths.
Remove bq274xx prefixes from static function names.
Removes repetition of bq274xx in logging.

Signed-off-by: Oleh Lozynskyy <oleh.lozynskyy@gmail.com>
2023-06-20 15:15:40 +02:00
Oleh Lozynskyy 765698e3a2 drivers: sensor: bq274xx: rename bq274xx to data
Shorten lines lengths.

data is a common driver data struct point name.

Signed-off-by: Oleh Lozynskyy <oleh.lozynskyy@gmail.com>
2023-06-20 15:15:40 +02:00
Oleh Lozynskyy f3668dfdff drivers: sensor: bq274xx: rename status to ret
Shorten lines lengths.
ret is a more common return variable name.

Signed-off-by: Oleh Lozynskyy <oleh.lozynskyy@gmail.com>
2023-06-20 15:15:40 +02:00
Andy Sinclair b31f60470f drivers: sensor: npm1300_charger: use MFD register functions
Local register read/write functions have been removed and replaced
with calls to the new MFD functions.

Signed-off-by: Andy Sinclair <andy.sinclair@nordicsemi.no>
2023-06-19 11:02:58 +02:00
Daniel DeGrasse 6c10da7957 drivers: sensor: introduce driver for TCN75A temperature sensor
Add driver for TCN75A temperature sensor. The following features are
supported:
- TCN75A oneshot mode, which allows single shot conversions with lower
  power consumtion
- Resolution selection, up to 12 bit resolution (9 bit default)
- Triggering based on temperatue thresholds. If the TCN75A exits a set
  threshold range, the application can be notified via a callback.

Signed-off-by: Daniel DeGrasse <daniel@degrasse.com>
2023-06-17 08:01:16 -04:00
Daniel Leung 26ecaba4af drivers: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Nick Ward f14d06f82e drivers: sensor: bmm150: use common conversion function
Better to reuse.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-06-17 07:52:09 -04:00
Nick Ward bb87a875c2 drivers: sensor: adxl362: remove \n from logs
Tidy

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-06-17 07:52:09 -04:00
Thomas Stranger c9f8b8b78a drivers: sensor: shtcx: fix val2 calculation
The calculation of the sensor val2 did not correctly take the sign into
account.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2023-06-15 08:47:30 -04:00
Nick Ward fe2de0a8c0 drivers: sensor: mcp970x: fix temperature conversion
Fractional part of the conversion was a thousandth of
what it should have been.

Also removes LOG_ERR use which causes excessive output
when logging enabled and using the sensor shell.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-06-01 13:44:28 -04:00
Kornel Dulęba 057888836e drivers: sensors: npcx_tach: Clear stale data
The tachometer collects the data continuously setting a "data ready" bit
when it's ready. The availability bit has to be cleared before the
register is updated.
The driver also supports underflow detection, when the bit indicating it
is set the reading of "0" is returned.
The problem here is that there is that once the underflow bit is cleared
we might end up reading stale data.
To prevent that clear the "data ready" bit when underflow is detected

Signed-off-by: Kornel Dulęba <mindal@semihalf.com>
2023-05-30 13:04:28 -04:00
Andrzej Głąbek b6f266a500 drivers: sensor: qdec_nrfx: Add missing REPORTRDY interrupt activation
This is a follow-up to commit 09fa46ee4e.

Before nrfx 3.0, the QDEC interrupt on REPORTRDY event was activated
implicitly when a `reportper` value other than `DISABLED` was used.
Now, the `reportper_inten` field needs to be used to activate this
interrupt.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-05-30 14:01:04 +02:00
Nick Ward 65bbca4a07 drivers: sensor: vl53l0x: small fixes
Remove redundant casts.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-05-27 06:19:29 -04:00
Nick Ward 7f01f65cd5 drivers: sensor: vl53l0x: add PM
Add power management code utilising XSHUT pin.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-05-27 06:19:29 -04:00
Nick Ward af4363bc47 drivers: sensor: vl53l0x: use datasheet specified fw boot time
Improve boot time.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-05-27 06:19:29 -04:00
Nick Ward c5f725e672 drivers: sensor: vl53l0x: fix XSHUT pin as active low
Also utilises gpio_pin_configure_dt() API to configure and set pin
state at the same time.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-05-27 06:19:29 -04:00
Tristan Honscheid dc9bd3afe3 sensors: Create sensor trig subcommand
This PR relocates the sensor trigger sample application from the
`sensor_shell` sample to a subcommand in the actual sensor shell. The
subcommand has a UI for enabling a given trigger on a given sensor.
A built-in handler for the data_ready trigger is included that prints
the latest data to the log. Currently, only `SENSOR_TRIG_DATA_READY` is
supported but the groundwork is there to add others. Tested on a
`tdk_robokit1` board.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2023-05-27 05:33:11 -04:00
Antoniu Miclaus eda63195f4 drivers: sensor: adxl372: fix software reset delay
The indended value for the delay after the software reset of adxl372 is
1ms. Adjust the value accordingly.

Fixes: a3e7cea
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
2023-05-26 14:56:55 -04:00
Yuval Peress 3e9b750d85 icm42699: Only clear interrupt status when setting trigger
Always clearing the interrupt status register was causing issues for
the sensor shell when interrupts were enabled but trying to read
one-off samples.

Signed-off-by: Yuval Peress <peress@google.com>
2023-05-26 11:04:54 -05:00
Yuval Peress ca5bf10143 sensor_shell: Update to new sensor_read API
Update the sensor shell logic to use the new sensor_read() APIs and
make triggers an option of the sensor_shell sample (this avoids the
trigger stealing the interrupt status from one-shot reads).

Signed-off-by: Yuval Peress <peress@google.com>
2023-05-26 11:04:54 -05:00
Yuval Peress ed380de152 sensors: Add new async one-shot reading API
Add a new async API based on the RTIO subsystem. This new API allows:
1. Users to create sampling configs (telling the sensor which channels
   they want to sample together).
2. Sample data in an asynchronous manner which provides greater control
   over the data processing priority.
3. Fully backwards compatible API with no driver changes needed for
   functionality (they are needed to improve performance).
4. Helper functions for processing loop.

Signed-off-by: Yuval Peress <peress@google.com>
2023-05-26 11:04:54 -05:00
Fabio Baltieri 37c2a0d4a6 sensor: use ALLOW_EMPTY instead of the conditional for empty library
This should be the proper way of allowing an empty library for CMake.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-05-25 12:32:17 -05:00
Fabio Baltieri 83db8c17ab sensors: clean up CMakeLists and Kconfig
Clean up the include/source lists in the sensors subsystem. Sort the
list, drop the empty lines that makes it look super long for no good
reason, get away with the tabs to align the file names that does not
really work anyway.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-05-25 12:32:17 -05:00
Fabio Baltieri 3431c1b59d drivers: sensors: add a sensor driver for TCS3400
Add a sensor driver for the TCS3400 color light-to-digital converter.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-05-25 13:30:45 +00:00
Maxmillion McLaughlin 477e7264ca drivers: sensor: mcp9600 add intial driver support
Implementation of MCP9600 i2c thermoouple amplifier - K, J, T, N, S, E, B
and R type T

Signed-off-by: Maxmillion McLaughlin <github@maxmclau.com>
2023-05-23 13:33:45 -05:00
Kenneth J. Miller e2c0e220fd drivers: sensor: Add STM32 VREF+ sensor
Add VREF+ sensor driver and DT node definition.

This driver allows determining the actual voltage applied to an SoC's
VREF+ pin, by comparing the VREFINT internal bandgap voltage reference
with its factory calibration data.

In packages where VREF+ is bonded to VDDA, this permits direct measurement
of VDDA voltage.

Signed-off-by: Kenneth J. Miller <ken@miller.ec>
2023-05-23 08:54:20 +02:00
Gerard Marull-Paretas dacb3dbfeb iterable_sections: move to specific header
Until now iterable sections APIs have been part of the toolchain
(common) headers. They are not strictly related to a toolchain, they
just rely on linker providing support for sections. Most files relied on
indirect includes to access the API, now, it is included as needed.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-22 10:42:30 +02:00
Armando Visconti 2b6dc7d778 drivers/sensor: lsm6dso16is: fix coding style issues
1. spi.h is included twice. Remove one of the two "#include"
   declarations.

2. The 'if' clause requires braces even for one line body.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2023-05-18 11:43:36 -05:00
Armando Visconti e5b7799ce3 drivers/sensor: add support to LSM6DSV16X IMU sensor
The LSM6DSV16X is a system-in-package featuring a 3-axis digital
accelerometer and a 3-axis digital gyroscope for industrial and IoT
solutions. The LSM6DSV16X embeds advanced dedicated features such as
a finite state machine (FSM) for configurable motion tracking and a
machine learning core (MLC) for context awareness.

https://www.st.com/en/mems-and-sensors/lsm6dsv16x.html

This driver is based on stmemsc HAL i/f v2.02

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2023-05-18 11:43:36 -05:00
Jackie Yang 38e81e38f9 drivers: sensor: lsm6dsl: Fix lsm6dsl gyroscope full range setting
Bug 1: Fix lsm6dsl_gyro_set_fs_raw does not clear FS125 to register when
setting the full range to be other values.

Bug 2: Fix lsm6dsl_gyro_channel_get does not use the current
gyro_sensitivity when getting data from the gyroscope.

Signed-off-by: Jackie Yang <jackie@jackieyang.me>
2023-05-16 11:22:58 -05:00
Marcin Niestroj 2da9be1583 drivers: sensor: lsm6dsl: use more precise ODR values
LSM6DSL's datasheet [1] lists 1666, 3332 and 6664 as valid ODR values for
accel and gyro. Update those from 1660, 3330 and 6660.

[1] http://www.st.com/en/mems-and-sensors/lsm6dsl.html

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-05-11 07:46:24 -05:00
Marcin Niestroj edfc08879d drivers: sensor: lsm6dsl: fix 250dps gyro range
Commit e015c00300 ("sensor: add lsm6dsl sensor driver") that introduced
initial support for lsm6dsl used 245dps instead of 250dps. According to
referenced documentation at [1] the latter is correct.

Use value of 250 instead of 245 for gyro range.

[1] http://www.st.com/en/mems-and-sensors/lsm6dsl.html

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-05-11 07:46:24 -05:00
Marcin Niestroj 56c0e166ff drivers: sensor: lsm6dsl: drop double assign of 'accel_freq'
This instance member is set as part of lsm6dsl_accel_set_odr_raw()
function, so there is no need to do it right before calling it.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-05-11 07:46:24 -05:00
Marcin Niestroj 86b60c34af drivers: sensor: lsm6dsl: remove unused accel_fs and gyro_{fs,freq}
Those are not used, so drop them from instance data.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-05-11 07:46:24 -05:00
Armando Visconti 7ea422af84 drivers/sensor: add support to LSM6DSO16IS IMU sensor
The LSM6DSO16IS is a system-in-package featuring a 3-axis digital
accelerometer and a 3-axis digital gyroscope for industrial and IoT
solutions. The LSM6DSO16IS embeds a new ST category of processing,
ISPU (intelligent sensor processing unit) to support real-time applications
that rely on sensor data. The ISPU is an ultra-low-power, high-performance
programmable core which can execute signal processing and AI algorithms
in the edge.

https://www.st.com/en/mems-and-sensors/lsm6dso16is.html

This driver is based on stmemsc HAL i/f v2.02

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2023-05-09 16:23:15 +09:00
Armando Visconti a4337af69f drivers/sensor: stmemsc: add macros to populate stmdev_ctx_t structure
Add STMEMSC_CTX I2C/SPI/I3C macros that can be reused among all STMEMSC
based ST sensor drivers to populate the stmdev_ctx_t stucture.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2023-05-09 16:23:15 +09:00
Armando Visconti e7ddb6466b tests: drivers: build_all: add sensorhub test case
Add test case for all drivers that are supporting the sensorhub
feature, and fix right away all the yet undiscovered issues.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2023-05-09 16:23:15 +09:00
Bjarki Arge Andreasen d1bcc90160 drivers/sensor/bmi323: Add BMI323 driver support
This PR adds a driver for the BMI323, which implements
the following features:

* Enable and disable accelerometer and gyroscope respectively
* Set full scale for accelerometer and gyroscope respectively
* Set data rate for accelerometer and gyroscope respectively
* Get samples (x,y,z) from accelerometer and gyroscope respectively
* Get die temperature
* Set trigger to accelerometer data ready, and accelerometer any motion.

The driver implements device and device runtime power management. If
runtime management is used, it is initialized into the suspended state,
which soft-resets the device to achieve the lowest possible power
consumption, otherwise it is resumed when initialized. When resumed,
the bus is initialized, the feature engine is enabled, and INT1 is
initialized.

The driver only implements the SPI bus at this time. The driver is
prepared to be expanded with I2C support in the future.

Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
2023-05-08 09:57:40 +02:00
Adam Wojasinski 09fa46ee4e drivers: sensor: qdec_nrfx: Add multi-instance support for QDEC SHIM
Reworked QDEC SHIM to suppor multi-instance peripheral. Patch includes
Kconfig alignment for proper instance handling.

Signed-off-by: Adam Wojasinski <adam.wojasinski@nordicsemi.no>
2023-05-05 11:47:53 +02:00
Gerard Marull-Paretas 84fd4e671f drivers: sensor: ntc_thermistor: add support for generic NTC
Add support for a generic NTC, `ntc-thermistor-generic`. In this case,
the compensation table is provided via devicetree. Note that DT property
is prefixed with `zephyr,`, because while hardware related, it is linked
to a particular software implementation.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-04 20:49:48 +02:00
Gerard Marull-Paretas 44f48f6da7 drivers: sensor: zephyr_thermistor: refactor driver
Refactor driver to align a bit more with its Linux counterpart, ie,
ntc_thermistor. This driver did quite a few _unconventional_ things,
like using "zephyr," compatibles, a dedicated node for pre-computed
compensation table (referenced by the actual pseudo-device node), etc.
The comparison helper function should likely be simplified as well (to
avoid the need for custom wrapper for bsearch), but this can be done
later.

In this refactor, each thermistor gets a compatible, e.g. "epcos,xxxx".
Compatibles are known by the driver, so are compensation tables. This
simplifies devicetree files. There's no need to bother about
compensation tables in **every** board file if Zephyr supports a certain
NTC model.

In general we should respect Linux bindings, which in the end influence
how drivers are implemented. In this case, this principle resulted in
simplified, easier to use code.

For future developers, this is how support for a new NTC can be added:

1. Add to the end of the driver:

```c
 #undef DT_DRV_COMPAT
 #define DT_DRV_COMPAT vnd_model

 static __unused const struct ntc_compensation comp_vnd_model[] = {
     { x, y },
     ...,
 };

 #define DT_INST_FOREACH_STATUS_OKAY_VARGS(NTC_THERMISTOR_DEV_INIT,
                                           DT_DRV_COMPAT, comp_vnd_model)
```
3. In driver's Kconfig make sure it depends on
   DT_HAS_$DT_DRV_COMPAT$_ENABLED

Note: $X$ means _value_ of X.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-04 20:49:48 +02:00
Gerard Marull-Paretas c60e4ec989 drivers: sensor: zephyr_thermistor: align connection type with Linux
It looks like the Zephyr thermistor driver bindings were half-copied
from Linux ntc-thermistor. Zephyr principle is to maintain compatibility
with Linux, when possible, so there's no reason to deviate here. Convert
the connection type from a custom enum to a boolean, as Linux does.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-04 20:49:48 +02:00
Armando Visconti 390c036900 drivers/sensor: lsm6dso: improve sensorhub code
1. Fix sensorhub names using the zephyr A.2 rule (use inclusive language).
   The only exception is names within STMEMSC API and h/w register names.

2. Extend the STMEMSC API usage. It is always better to not code again
   already existing functionalities.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2023-05-04 10:45:10 +02:00
Tom Burdick dba487e480 icm42688: Interrupt pulse for 4khz+ sampling
Always set the interrupt pulse settings when sampling at greater than 4khz
to better ensure the interrupt line is toggled and caught correctly.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-05-03 08:46:37 -05:00
Andy Sinclair d700ab5a88 drivers: sensor: npm1300_charger: NPM1300 charger driver
Initial sensor driver for NPM1300 PMIC charger.
Includes basic configuration of charger voltage and current.

Signed-off-by: Andy Sinclair <andy.sinclair@nordicsemi.no>
2023-05-03 15:04:18 +02:00
Brian Juel Folkmann 065a8f25e1 drivers: stm32_temp stm32h5 device must disable icache to access cal
Reading the temperature calibration data requires disabling the icache
of the stm32h5x mcu.
Else a bus fault error occurs reading Address: 0x8fff8014-0x8fff818
Enable afterwards.

Signed-off-by: Brian Juel Folkmann <bju@trackunit.com>
2023-05-02 10:53:58 +02:00
Aaron Massey 07ee466591 emul: Migrate all emulation use to use DT_HAS_
Remove all enabling of CONFIG_EMUL_.* in favor of automatically enabling
peripheral emulators based on the compatible string presence in the device
tree and the one true CONFIG_EMUL.

Zephyr has long since moved to a model of enabling drivers based on the
presence of their associated IC's compatible string in the final devicetree
overlay. There is no reason that emulators can't align in just the same
way, and probably ought to to remove superfluous enabling of configs.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-04-28 08:37:33 -05:00
Maximilian Deubel 3746074073 drivers: sensor: Add driver for TI INA3221
This patch adds support for the TI INA3221 current monitor.
This is the datasheet used for reference:
https://www.ti.com/lit/gpn/ina3221

Since this device has three channels, there is a custom attribute to
select which channel is to be used when getting a sample.
Measurements are done on all enabled channels.

Signed-off-by: Maximilian Deubel <maximilian.deubel@nordicsemi.no>
2023-04-26 20:08:04 +02:00
Andreas Kilian a665fc0829 drivers: sensor: Vishay VEML7700 ambient light sensor
Added support for Vishay VEML7700 ambient light sensor
See https://www.vishay.com/doc?84286

Signed-off-by: Andreas Kilian <andreas_kilian@gmx.net>
2023-04-26 12:52:46 +02:00
Gerard Marull-Paretas f6061a5ea0 drivers: sensor: lm77: use DT_ANY_INST_HAS_PROP_STATUS_OKAY
Replace custom macrology that was checking if any instance had the
int_gpios property with DT_ANY_INST_HAS_PROP_STATUS_OKAY.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-24 09:21:36 -05:00
Gerard Marull-Paretas b2d9212ea0 drivers: all: mchp_xec: remove conditional support for pinctrl
The Microchip XEC platform always uses pinctrl, there's no need to keep
extra macrology around pinctrl. Also updated driver's Kconfig options to
`select PINCTRL`.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-24 13:34:22 +02:00
Gerard Marull-Paretas 989d103d53 drivers: all: mcux: remove conditional support for pinctrl
The MCUX platform always uses pinctrl, there's no need to keep extra
macrology around pinctrl. Also updated driver's Kconfig options to
`select PINCTRL` (note that some already did).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-24 13:34:22 +02:00
Matthias Hauser 73ed8ccb5f drivers: sensor: Added driver for the Würth Elektronik WSEN-PDUS sensor
Added driver for the Würth Elektronik WSEN-PDUS sensor

Signed-off-by: Matthias Hauser <Matthias.Hauser@we-online.de>
2023-04-21 07:16:15 -05:00
Aaron Massey 75b2f5abed emul: Fuel gauge tests direct access to emul_sbs
The fuel gauge tests should *not* have to enable CONFIG_SENSOR in order to
get access to the sbs gauge emulator.

Allow fuel_gauge sbs_gauge direct access to emul_sbs_gauge.c

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-04-21 09:39:00 +02:00
Jackie Yang c8c67feab0 drivers: sensor: lsm6dsl: Added support for lis3mdl as a external sensor
Added code to support lis3mdl to be used as an external sensor for
lsm6dsl in sensorhub mode

Signed-off-by: Jackie Yang <jackie@jackieyang.me>
2023-04-20 10:48:03 +02:00
Hiroki Tada 943158326c drivers: sensor: Support Hamamatsu Photonics S11059 Color Sensor
DataSheet:
https://datasheetspdf.com/pdf/1323325/Hamamatsu/S11059-02DT/1

Testing Environment:
esp32

Signed-off-by: Hiroki Tada <tada.hiroki@fujitsu.com>
2023-04-18 17:07:48 -05:00
Andriy Gelman b8244fdabd drivers: sensor: Add adt7310 temperature sensor
Adds adt7310 temperature controlled via spi.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2023-04-17 10:06:04 -05:00
Matthias Hauser 6789c0d400 drivers: sensor: Added driver for the Würth Elektronik WSEN-PADS sensor
Added driver for the absolute pressure sensor WSEN-PADS

Signed-off-by: Matthias Hauser <Matthias.Hauser@we-online.de>
2023-04-17 11:49:35 +02:00
Peter Johanson 1432b6e870 drivers: sensor: qdec_nrfx: Typo fix from trigger work.
Fix a typo introduced during move to store pointer to the
user supplied trigger.

Signed-off-by: Peter Johanson <peter@peterjohanson.com>
2023-04-17 10:20:06 +02:00
Alberto Escolar Piedras 83377046ba drivers: temp_nrf5: Fix warning in ISR prototype
The ISR prototype was changed some time ago
(6df8b3995e)
to (const void*) => fix isr function definition
to avoid a compile warning.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-04-17 10:19:33 +02:00
Armando Visconti 15389ea902 modules/hal_st: Align sensor drivers to stmemsc HAL i/f v2.02
Align all sensor drivers that are using stmemsc (STdC) HAL i/f
to new APIs of stmemsc v2.02. Please note that now a new function
callback, mdelay(), must be provided in case the stmemsc HAL requires
to wait for a certain amount of milliseconds before or after some
special operations.

Requires https://github.com/zephyrproject-rtos/hal_st/pull/13
(merged as 5948f7b3304f1628a45ee928cd607619a7f53bbb)

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2023-04-14 10:51:15 -05:00
Gerard Marull-Paretas 667eeb11fb shell: fix MISRA 5.7 violations on struct shell
MISRA Rule 5.7 requires uniqueness of tag identifiers. Shell is
frequently problematic because many code uses `const struct shell
*shell`. This causes CI noise every time one of these shell files is
edited, so let's update all of them with `const struct shell *sh`
instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00
Guillaume Gautier b323c0f227 drivers: sensor: stm32_temp: add negative temperature coefficient
Add support for negative temperature coefficient for single calibration
chips in the STM32 temperature driver.
That feature is necessary for STM32F0x0.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-04-13 09:11:45 -05:00
Benjamin Björnsson 818738b366 drivers: sensor: stm32_temp: Add support for STM32C0-series
Add new compatible to separate production calibrated sensors
with single and dual calibration temperatures. Also update
stm32_temp driver to support single calibration sensors.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2023-04-13 09:59:52 +02:00
Benjamin Björnsson 2f20bcfa0a drivers: sensor: stm32_temp: Remove multi-instancing
STM32 only has one temp instance in hardware.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2023-04-13 09:59:52 +02:00
Gerard Marull-Paretas a5fd0d184a init: remove the need for a dummy device pointer in SYS_INIT functions
The init infrastructure, found in `init.h`, is currently used by:

- `SYS_INIT`: to call functions before `main`
- `DEVICE_*`: to initialize devices

They are all sorted according to an initialization level + a priority.
`SYS_INIT` calls are really orthogonal to devices, however, the required
function signature requires a `const struct device *dev` as a first
argument. The only reason for that is because the same init machinery is
used by devices, so we have something like:

```c
struct init_entry {
	int (*init)(const struct device *dev);
	/* only set by DEVICE_*, otherwise NULL */
	const struct device *dev;
}
```

As a result, we end up with such weird/ugly pattern:

```c
static int my_init(const struct device *dev)
{
	/* always NULL! add ARG_UNUSED to avoid compiler warning */
	ARG_UNUSED(dev);
	...
}
```

This is really a result of poor internals isolation. This patch proposes
a to make init entries more flexible so that they can accept sytem
initialization calls like this:

```c
static int my_init(void)
{
	...
}
```

This is achieved using a union:

```c
union init_function {
	/* for SYS_INIT, used when init_entry.dev == NULL */
	int (*sys)(void);
	/* for DEVICE*, used when init_entry.dev != NULL */
	int (*dev)(const struct device *dev);
};

struct init_entry {
	/* stores init function (either for SYS_INIT or DEVICE*)
	union init_function init_fn;
	/* stores device pointer for DEVICE*, NULL for SYS_INIT. Allows
	 * to know which union entry to call.
	 */
	const struct device *dev;
}
```

This solution **does not increase ROM usage**, and allows to offer clean
public APIs for both SYS_INIT and DEVICE*. Note that however, init
machinery keeps a coupling with devices.

**NOTE**: This is a breaking change! All `SYS_INIT` functions will need
to be converted to the new signature. See the script offered in the
following commit.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

init: convert SYS_INIT functions to the new signature

Conversion scripted using scripts/utils/migrate_sys_init.py.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

manifest: update projects for SYS_INIT changes

Update modules with updated SYS_INIT calls:

- hal_ti
- lvgl
- sof
- TraceRecorderSource

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: devicetree: devices: adjust test

Adjust test according to the recently introduced SYS_INIT
infrastructure.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: kernel: threads: adjust SYS_INIT call

Adjust to the new signature: int (*init_fn)(void);

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 14:28:07 +00:00
Zhang Lixu 9c9304218b drivers: sensor: lsm6dso: round up to the nearest odr
It was too strict to require the caller to pass in an accurate odr as a
parameter. This patch is to round the odr up to the nearest one, when odr
does not match.

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
2023-04-12 09:17:05 -05:00
Maureen Helm e0915eb6ac drivers: sensor: Fix sx9500 build with trigger disabled
Extending tests/drivers/build_all/sensor/ to include missing driver
trigger configurations revealed that some sensor drivers failed to build
with triggers disabled.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-11 19:25:46 -04:00
Maureen Helm 4c6478dcea drivers: sensor: Fix bmg160 build with trigger disabled
Extending tests/drivers/build_all/sensor/ to include missing driver
trigger configurations revealed that some sensor drivers failed to build
with triggers disabled.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-11 19:25:46 -04:00
Maureen Helm ca3e667ac2 drivers: sensor: Fix icm42688 build with trigger enabled
Extending tests/drivers/build_all/sensor/ to include missing driver
trigger configurations revealed that some sensor drivers failed to build
with triggers enabled.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-11 19:25:46 -04:00
Maureen Helm 6643733f26 drivers: sensor: Fix ccs811 build with trigger enabled
Extending tests/drivers/build_all/sensor/ to include missing driver
trigger configurations revealed that some sensor drivers failed to build
with triggers enabled.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-11 19:25:46 -04:00
Maureen Helm b562807d4f drivers: sensor: Fix bmi270 build with trigger enabled
Extending tests/drivers/build_all/sensor/ to include missing driver
trigger configurations revealed that some sensor drivers failed to build
with triggers enabled.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-11 19:25:46 -04:00
Weiwei Guo 08ece57b9e sensor: bmm150: Add I2C-base or SPI-base interface in build time
move DT_DRV_COMPAT to bmm150.h. so that can be decide which interface
to use.

define struct bmm150_bus_io interface for bmm150_i2c.c and bmm150_spi.c
in bmm150.h.

redefined bus operation interface in bmm150.c, this allow the driver
to decide which interface to use during construction.

Signed-off-by: Weiwei Guo <guoweiwei@syriusrobotics.com>
2023-04-11 11:26:47 +02:00
Maureen Helm da633c6148 drivers: sensor: wsen_tids: Store sensor trigger as a pointer
Fixes the wsen_tids sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm a392d8727c drivers: sensor: wsen_itds: Store sensor trigger as a pointer
Fixes the wsen_itds sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm cb28e8321e drivers: sensor: wsen_hids: Store sensor trigger as a pointer
Fixes the wsen_hids sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 078024515b drivers: sensor: vcnl4040: Store sensor trigger as a pointer
Fixes the vcnl4040 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 07632a931f drivers: sensor: tmp108: Store sensor trigger as a pointer
Fixes the tmp108 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm e43edc95d5 drivers: sensor: tmp007: Store sensor trigger as a pointer
Fixes the tmp007 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 56927686b3 drivers: sensor: sx9500: Store sensor trigger as a pointer
Fixes the sx9500 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 5ca231ae91 drivers: sensor: stts751: Store sensor trigger as a pointer
Fixes the stts751 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 4a97373f15 drivers: sensor: sm351lt: Store sensor trigger as a pointer
Fixes the sm351lt sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 0c1c77889c drivers: sensor: sht3xd: Store sensor trigger as a pointer
Fixes the sht3xd sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 6836d03dc0 drivers: sensor: qdec_nrfx: Store sensor trigger as a pointer
Fixes the qdec_nrfx sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm ddf78eb7b8 drivers: sensor: pcnt_esp32: Store sensor trigger as a pointer
Fixes the pcnt_esp32 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 19b9bb800a drivers: sensor: mpu9250: Store sensor trigger as a pointer
Fixes the mpu9250 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm b7e97e2807 drivers: sensor: mpu6050: Store sensor trigger as a pointer
Fixes the mpu6050 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 6ae88621d2 drivers: sensor: mcux_acmp: Store sensor trigger as a pointer
Fixes the mcux_acmp sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Maureen Helm 958b7abd26 drivers: sensor: mcp9808: Store sensor trigger as a pointer
Fixes the mcp9808 sensor driver to store the user-supplied sensor
trigger as a pointer rather than a copy. This enables the trigger
handler to use CONTAINER_OF to retrieve a context pointer when the
trigger is embedded in a larger struct.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2023-04-08 18:38:02 +02:00
Al Semjonovs 5d4352f322 sensor: Generic driver for NTC Thermistor
Driver for NTC Thermistors attached to ADC

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2023-04-07 16:23:17 -05:00
Benjamin Lindqvist 7d23e03566 drivers: sensor: bmi270: Add support for motion, DRDY triggers
This commit adds support for ANY_MOTION and DATA_READY interrupts for
the BMI270. To implement this, a different config blob than the
"max_fifo" blob has to be used.

Signed-off-by: Benjamin Lindqvist <benjamin@eub.se>
2023-04-07 18:58:16 +02:00
Nick Ward 162c47ffc4 drivers: sensor: add mcp970x thermistor IC
Add driver for:
  MCP9700/9700A and MCP9701/9701A
  Low-Power Linear Active Thermistor ICs

http://ww1.microchip.com/downloads/en/devicedoc/20001942g.pdf

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-04-07 13:30:59 +02:00
Weiwei Guo 88f0793025 sensor: bmp388: Add I2C-base or SPI-base interface in build time
move DT_DRV_COMPAT to bmp388.h. so that can be decide which
interface to use.

define struct bmp388_bus_io interface bmp388_i2c.c and bmp388_spi.c.

redefined bus operation interface in bmp388.c, this allow the driver
to decide which interface to use during construction

Signed-off-by: Weiwei Guo <guoweiwei@syriusrobotics.com>
2023-04-07 13:14:00 +02:00
Marc Reilly d485824926 sensor: ms5837: support -02 variant
This adds support for the -02 variant, as well as the existing -30.
The sensor type is automatically read from configuration register at
device init, an appropriate compensation func is set up

Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
2023-04-07 13:13:01 +02:00
Marc Reilly 99ce8cf910 sensor: ms5837. fix unsigned underflow in compensation calc
This fixes a bug where the temperature difference was being done as
unsigned and so could underflow.

Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
2023-04-07 13:13:01 +02:00
Marc Reilly b4c31fd438 sensor: ms5837: pressure values in kPa
The sensor interface specifies pressure values in units of kPa, so change
here to be consistent.

Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
2023-04-07 13:13:01 +02:00
Pieter De Gendt 6b532ff43e treewide: Update clock control API usage
Replace all (clock_control_subsys_t *) casts with (clock_control_subsys_t)

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-05 10:55:46 +02:00
Jeppe Odgaard 1ef0649825 drivers: sensor: mcux qdec add filter parameters
Add optional filter value properties. The filter is disabled by default
but can be enabled by setting the filter-sample-period > 0 in the dts
file. A latency is introduced if the filter is enabled. The latency can
be printed by setting sensor log level to debug.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-04-04 08:54:43 +00:00
Jeppe Odgaard 8820f95199 drivers: sensor: mcux qdec improve counts_per_revolution checks
Fix inconsistency between compile-time and runtime check on
counts_per_revolution. Add macro to simplify compile-time prop value
checks.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-04-04 08:54:43 +00:00
Fin Maaß cabc30c725 drivers: sensors: Implement MAX31865 sensor
This commit implements the temperature sensor interface for
the Maxim MAX31865 SPI Temperature Sensor.

Signed-off-by: Fin Maaß <fin.maass@haw-hamburg.de>
Co-authored-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-04-03 12:32:50 -04:00
Madhurima Paruchuri 9727cafb41 drivers: sbs_gauge: Add support for AtRate properties
BatteryMode(w), AtRate(r/w), AtRateTimeToFull(r), AtRateTimeToEmpty(r)
and AtRateOK(r)

Signed-off-by: Madhurima Paruchuri <mparuchuri@google.com>
2023-04-03 17:53:42 +02:00
Peter Fecher 924ac2265d drivers: sensor: Add tmd2620 driver
Adds tmd2620 driver and devicetree bindings to work in
trigger and polling mode supporting Power management.

Signed-off-by: Peter Fecher <p.fecher@phytec.de>
2023-03-31 09:20:36 +02:00
Tom Burdick 171e5159b8 sensor: bmi160: Runtime power management support
Add support for device runtime power management. When suspended sampling
is suspended. When active sampling resumes at the configured rate.

When suspended fetch/get will return an errno and 0'ed out samples.

By default the device will start in a suspended state when
PM_DEVICE_RUNTIME is enabled.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-03-30 17:33:22 -04:00
Henrik Brix Andersen c41dd36de2 drivers: kconfig: unify menuconfig title strings
Unify the drivers/*/Kconfig menuconfig title strings to the format
"<class> [(acronym)] [bus] drivers".

Including both the full name of the driver class and an acronym makes
menuconfig more user friendly as some of the acronyms are less well-known
than others. It also improves Kconfig search, both via menuconfig and via
the generated Kconfig documentation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-03-28 15:06:06 +02:00