Commit graph

1951 commits

Author SHA1 Message Date
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
Jeppe Odgaard 40ec70fd2a drivers: sensor: mcux qdec single-phase option
Add binding and sensor attribute to allow single phase
mode where only one signal is required from the encoder.
The signal must be connected to Phase A input.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-03-27 22:13:56 +00:00
Maureen Helm 59fe77a6b4 drivers: sensor: lsm9ds0_gyro: Store sensor trigger as a pointer
Fixes the lsm9ds0_gyro 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-03-23 12:56:20 +01:00
Maureen Helm 0d4f0deaad drivers: sensor: lsm6dso: Store sensor trigger as a pointer
Fixes the lsm6dso 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-03-23 12:56:20 +01:00
Maureen Helm 1157df85a7 drivers: sensor: lsm6dsl: Store sensor trigger as a pointer
Fixes the lsm6dsl 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-03-23 12:56:20 +01:00
Maureen Helm 5354bffc6b drivers: sensor: lps22hh: Store sensor trigger as a pointer
Fixes the lps22hh 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-03-23 12:56:20 +01:00
Maureen Helm 54433a9610 drivers: sensor: lis3mdl: Store sensor trigger as a pointer
Fixes the lis3mdl 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-03-23 12:56:20 +01:00
Maureen Helm 8cb81ff371 drivers: sensor: lis2mdl: Store sensor trigger as a pointer
Fixes the lis2mdl 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-03-23 12:56:20 +01:00
Maureen Helm 363b1876f8 drivers: sensor: lis2dw12: Store sensor trigger as a pointer
Fixes the lis2dw12 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-03-23 12:56:20 +01:00
Maureen Helm 281f61672b drivers: sensor: lis2ds12: Store sensor trigger as a pointer
Fixes the lis2ds12 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-03-23 12:56:20 +01:00
Maureen Helm 5bb2323435 drivers: sensor: lis2dh: Store sensor trigger as a pointer
Fixes the lis2dh 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-03-23 12:56:20 +01:00
Maureen Helm 0461ff22d5 drivers: sensor: ite_vcmp_it8xxx2: Store sensor trigger as a pointer
Fixes the ite_vcmp_it8xxx2 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-03-23 12:56:20 +01:00
Maureen Helm 0ed618c609 drivers: sensor: ism330dhcx: Store sensor trigger as a pointer
Fixes the ism330dhcx 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-03-23 12:56:20 +01:00
Maureen Helm 16140bf485 drivers: sensor: isl29035: Store sensor trigger as a pointer
Fixes the isl29035 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-03-23 12:56:20 +01:00
Maureen Helm 0c3bfc2762 drivers: sensor: ina23x: Store sensor trigger as a pointer
Fixes the ina23x 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-03-23 12:56:20 +01:00
Maureen Helm c2951ef7c6 drivers: sensor: iis3dhhc: Store sensor trigger as a pointer
Fixes the iis3dhhc 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-03-23 12:56:20 +01:00
Gerson Fernando Budke dc45d7a922 drivers: sensors: qdec_sam: Update to use clock control
This update Atmel SAM QDEC driver to use clock control driver.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2023-03-21 14:12:25 -07:00
Maureen Helm b079316b4e drivers: sensor: iis2mdc: Store sensor trigger as a pointer
Fixes the iis2mdc 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-03-20 09:52:35 +01:00
Maureen Helm 99f9ef36af drivers: sensor: iis2iclx: Store sensor trigger as a pointer
Fixes the iis2iclx 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-03-20 09:52:35 +01:00
Maureen Helm 7b4ea85a0b drivers: sensor: iis2dlpc: Store sensor trigger as a pointer
Fixes the iis2dlpc 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-03-20 09:52:35 +01:00
Maureen Helm e0e4fa5d43 drivers: sensor: iis2dh: Store sensor trigger as a pointer
Fixes the iis2dh 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-03-20 09:52:35 +01:00
Maureen Helm 1ea5bb32f3 drivers: sensor: icm42605: Store sensor trigger as a pointer
Fixes the icm42605 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-03-20 09:52:35 +01:00
Maureen Helm 466c5501bc drivers: sensor: hts221: Store sensor trigger as a pointer
Fixes the hts221 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-03-20 09:52:35 +01:00
Maureen Helm 73ddc98ea0 drivers: sensor: hmc5883l: Store sensor trigger as a pointer
Fixes the hmc5883l 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-03-20 09:52:35 +01:00
Maureen Helm 1b05a2ce8b drivers: sensor: grow_r502a: Store sensor trigger as a pointer
Fixes the grow_r502a 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-03-20 09:52:35 +01:00
Maureen Helm e20357e7ac drivers: sensor: fxos8700: Store sensor trigger as a pointer
Fixes the fxos8700 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-03-20 09:52:35 +01:00
Maureen Helm 2a72e0eaf3 drivers: sensor: fxas21002: Store sensor trigger as a pointer
Fixes the fxas21002 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-03-20 09:52:35 +01:00
Maureen Helm 77cb3aeeb5 drivers: sensor: fdc2x1x: Store sensor trigger as a pointer
Fixes the fdc2x1x 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-03-20 09:52:35 +01:00
Maureen Helm c45595e164 drivers: sensor: ccs811: Store sensor trigger as a pointer
Fixes the ccs811 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-03-20 09:52:35 +01:00
Maureen Helm 9024a3cf97 drivers: sensor: bq274xx: Store sensor trigger as a pointer
Fixes the bq274xx 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-03-20 09:52:35 +01:00
Maureen Helm 7f59286f98 drivers: sensor: bmp388: Store sensor trigger as a pointer
Fixes the bmp388 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-03-20 09:52:35 +01:00
Maureen Helm eac3ac2d87 drivers: sensor: bmi160: Store sensor trigger as a pointer
Fixes the bmi160 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-03-20 09:52:35 +01:00
Maureen Helm 666a0dffd2 drivers: sensor: bmg160: Store sensor trigger as a pointer
Fixes the bmg160 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-03-20 09:52:35 +01:00
Maureen Helm 7875025cdb drivers: sensor: bmc150_magn: Store sensor trigger as a pointer
Fixes the bmc150_magn 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-03-20 09:52:35 +01:00
Maureen Helm ad07044679 drivers: sensor: bma280: Store sensor trigger as a pointer
Fixes the bma280 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-03-20 09:52:35 +01:00
Maureen Helm 9d74370e74 drivers: sensor: amg88xx: Store sensor trigger as a pointer
Fixes the amg88xx 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-03-20 09:52:35 +01:00
Maureen Helm a8b74ff5e7 drivers: sensor: adxl372: Store sensor trigger as a pointer
Fixes the adxl372 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-03-20 09:52:35 +01:00
Maureen Helm cb51090d3a drivers: sensor: adxl362: Store sensor trigger as a pointer
Fixes the adxl362 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-03-20 09:52:35 +01:00
Maureen Helm ae5342afba drivers: sensor: adt7420: Store sensor trigger as a pointer
Fixes the adt7420 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-03-20 09:52:35 +01:00
Oleg Ryjkov c194cb76ad drivers: sensor: bmi270: Use bulk SPI reads
BMI270 supports bulk register reads, use them to make
trasnfers faster.
See the discussion on
6cbb84c3ee (r104543405)
Tested on an nrf52840 board connected to a bmi270 sensor via SPI.

Signed-off-by: Oleg Ryjkov <oryjkov@gmail.com>
2023-03-17 13:17:08 -05:00
Nick Ward f3cbd34d3f drivers: sensor: bq274xx: add CONFIG_BQ274XX_PM
This symbol allows users of the driver to disable the
power management feature of just this sensor if they are
not using the int_gpios pin of the BQ274XX.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-03-16 21:40:18 -04:00
Michael Kaplan a818d06cf2 drivers: sensors: apds9960 fix trigger callback context
In the current implementation, the apds9960 trigger callback function
is called with the pointer of a driver-internal allocated trigger
structure. This structure is not initialized anywhere, so essentially
the trigger callback gets called with junk data.

Besides the missing initialization, it would be better instead to hold
a const pointer to a user allocated sensor_trigger object.
This way user code can establish a context with related user data (for
example a pointer to a C++ object) by storing its sensor_trigger object
within a structure alongside the user data, and then using
CONTAINER_OF() macro to get the pointer of the container struct (and
thus the user data).

Signed-off-by: Michael Kaplan <m.kaplan@evva.com>
2023-03-15 22:39:45 +00:00
Andrei Emeltchenko 4bb9ad929f drivers: fxos8700: Remove unneeded assignment
Remove unneeded assignment fixing issue with using uninitialized
variable.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-03-15 09:12:22 +01:00
Yuval Peress d6c45ad27b sensor: implement drdy trigger for icm42688
Add support for the data ready trigger in the icm42688 driver.

Signed-off-by: Yuval Peress <peress@google.com>
2023-03-06 10:44:52 -06:00
Mark Watson 1f178ca935 drivers: sensor: VL53L1X time-of-flight sensor.
The driver utilizes ST Microelectronics library (which
exists in modules\hal\st\sensor\vl53l1x. Platform specific
headers and source files used by the library are included
and adapted for Zephyr.

The driver can be configured in proj.conf to use a
interrupt/polling methods and the use of the XSHUT pin on
the VL53L1X. All uses were tested successfully.

Signed-off-by: Mark Watson <mwatson@prosaris.ca>
2023-03-03 10:01:55 -06:00
Matthias Hauser d4e9e5f46c drivers: sensor: Added driver for the Würth Elektronik WSEN-TIDS sensor
Added sample for the WSEN-TIDS temperature sensor.

Signed-off-by: Matthias Hauser <Matthias.Hauser@we-online.de>
2023-03-03 11:01:10 +01:00
Jeppe Odgaard 9a2997fac9 drivers: sensor: mcux qdec rework rotation
Remove modulus feature and return degrees larger than
count_per_revolution.
This makes it possible to detect if a full rotation has occured.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-03-03 10:59:55 +01:00
Aaron Massey 1657860320 emul: Fix endianness fault in sbs gauge emulator
The sbs gauge emulator intercepts SMBus messages for an sbs gauge
compatible IC. However, it was incorrectly interpreting the byte order of
received register write values based on the endianness of the SoC
architecture instead of SMBus' defined little-endianness. This fault was
not caught earlier because native posix and the majority of qemu
architectures use little-endian.

Explicitly interpret the write values as little-endian.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-03-02 21:14:44 +01:00
Ruibin Chang f77f02c032 ITE drivers/sensor/vcmp/it8xxx2: add work queue for voltage comparator
Voltage comparator driver submits notifications into system work queue,
this change will make driver to use dedicated work queue, and priority
of dedicated work queue are configurable as well.

Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2023-03-01 09:12:49 -06:00
Benjamin Cabé ca90bdacf3 drivers: sensor: th02: Handle unsupported channels
Fixed th02_channel_get() code to return -ENOTSUP when the channel is not
supported.
Fixes #55160.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-02-28 10:58:52 -06:00
Gerard Marull-Paretas 27b73a116f soc: arm: nordic_nrf: replace NRF_DT_CHECK_PIN_ASSIGNMENTS
Since PINCTRL and pinctrl-0 is now required, there's no point in doing
extra validation at driver level. Modify the macro to just check that
sleep state is present when needed, since it was the only remaining
assertion that was not covered. Renamed the macro to make it more clear
what it does: NRF_DT_CHECK_NODE_HAS_PINCTRL_SLEEP

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-02-28 08:42:05 -08:00
Gerard Marull-Paretas 401334446d drivers: sensor: qdec_nrfx: drop -pin support
QDEC driver will only use pinctrl now.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-02-28 08:42:05 -08:00
Yuval Peress ebfd9aaba5 sensor: Implement driver and tests for akm09918c
Add the implementation for the akm09918c magnetometer driver.
Additionally, add the appropriate node to the TDK robokit1 device
tree. In order to prevent regressions, add the sensor to the sensor
build_all tests and specific tests using an emulator.

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 17:00:14 -05:00
Yuval Peress 0e003cdbee test: verify accel/gyro data for icm42688
Verify the conversion of register values in both accel and gyro to
sensor_value for the icm42688.

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Yuval Peress e6514d4dc9 icm42688: Add test for data read and temperature regisers
Add tests that verify the behavior of the REG_INT_STATUS, REG_TEMP_DATA1,
and REG_TEMP_DATA0 registers

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Yuval Peress 591958752a icm42688: fix configure call
The icm42688 introduced a safe configure function to make the
configuration more atomic, but the main driver was never updated
to call it so the new config values were discarded.

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Yuval Peress a3f59fd86f icm42688: Fix temperature calculation
Fix the calculation which was adding the 25 degree offset too late.

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Yuval Peress 8ac822e69c emul: Cleanup emul directory
Avoid implementations in the subsys emul directory to keep the directory
focused on emulator subsystem instead of consumers. Consumers should be
implemented side-by-side to their drivers

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Yuval Peress a6326f1f7f bmi160: move emulator to driver directory
Allow the emulator to sit in the same directory as the driver
implementation. This will make working on the emulator much easier and
keep the emulator subsystem directory clean by allowing it to focus on
the actual subsystem and not the use cases of the subsystem.

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Yuval Peress 2bb4de9a0b emul: Add emulator for icm426888
Add an implementation for the icm42688 emulator that supports reading
any registers.

Signed-off-by: Yuval Peress <peress@google.com>
2023-02-24 11:50:10 +01:00
Garrett Battaglia 65e3f5b23d drivers: sensor: add MAX31855
add MAX31855 cold-junction compensated thermocouple-to-digital
converter sensor driver and sample

Signed-off-by: Garrett Battaglia <garrett@garrettbattaglia.com>
2023-02-23 09:06:28 +01:00
Tim Lin 00e6c19ab5 ITE: drivers/adc: Add config of ADC reference voltage full-scale 3300mV
This option can enable ADC internal reference voltage as
full-scale 3300mV.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2023-02-23 08:59:54 +01:00
Tom Burdick 2ae6b7bd75 sensor: icm42688 configuration and regmap fixes
The int config and fifo config register addresses were wrong, fix those.

Adds lots of debug information (when LOG_DBG=y) to the configuration of the
device which is incredibly helpful for diagnosing configuration issues.

Disables the device interrupts while reconfiguring. Adds a safely
reconfigure function which will rollback to previous configuration
on misconfiguration.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-02-22 08:51:30 +01:00
Andriy Gelman 0079cabb49 drivers: sensor: Add infineon xmc4xxx die temperature sensor
Adds die temperature driver for infineon xmc4xxx SoCs.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2023-02-20 11:14:15 +01:00
Giuliano Franchetto 67767df8c0 drivers: iis2dlpc: adding activity interrupt
This commit adds the activity/inactivity recognition as well as the
stationary/motion detection as defined in the IIS2DLPC application
note.

For now, there is no possibility to configure this interrupt using
device tree binding, as I would like to keep the configuration updatable
and not set at boot time. This behaviour is fine for prototypes and
samples, but is too restrictive on products that may want to change the
interrupt configuration at run-time.

The interrupt is configured using the attributes SENSOR_ATTR_SLOPE_TH and
SENSOR_ATTR_SLOPE_DUR.

Signed-off-by: Giuliano Franchetto <giuliano.franchetto@intellinium.com>
2023-02-19 20:55:09 -05:00
Michal morsisko 2e4d8761be drivers: sensor: Add support for BH1750 ambient light sensor
This commit adds support for BH1750 ambient light sensor.
The driver works using I2C peripheral in one-time mode.

Signed-off-by: Michal morsisko <morsisko@gmail.com>
2023-02-19 20:44:34 -05:00
Zhang Lixu b67e33fc50 sensor: bmi160: fix the issue of missing gpio cfg for i2c
Add BMI160_TRIGGER_CFG in bmi160_cfg for i2c instance when
trigger mode enabled.

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
2023-02-19 20:41:56 -05:00
Zhang Lixu 21436b27bf sensor: bmi160: fix the issue with interrupt status
When enabling trigger mode of bmi160 on i2c bus, I've come across
an issue where the readings register STATUS. The issue comes from
the dummy byte in the beginning of the buf.raw which is not necessary.
In addition, for bmi160 on spi bus, the dummy byte has already been
handled in bmi160_transceive while reading register.
So the dummy byte should be removed.

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
2023-02-19 20:41:56 -05:00
Wouter Cappelle 0934f705eb sensor: SHT3x: Fix low repeatability in single shot mode
Fix the low readability read command which was swapped with high
readability. This should fix an issue which caused a sensor fetch
fail in low repeatability single shot mode (no data ready)

Signed-off-by: Wouter Cappelle <wouter.cappelle@crodeon.com>
2023-01-27 18:11:02 +09:00
Yuval Peress e7443bb203 sensors: Add attribute configuration for icm42688
Implement the attribute get/set for the icm426888

Signed-off-by: Yuval Peress <peress@google.com>
2023-01-25 09:48:05 -06:00
Yuval Peress ad4cb88494 sensor_shell: add attribute support
Add 2 new sub-commands to the sensor command (attr_get and attr_set).
These commands can be used to access the driver's attr_set and attr_get
functions.

Signed-off-by: Yuval Peress <peress@google.com>
2023-01-25 09:48:05 -06:00
Yuval Peress 3f4c568f71 sensor_shell: run clang-format
Run clang-format on the sensor_shell.c to make diffs easier for the
next commit.

Signed-off-by: Yuval Peress <peress@google.com>
2023-01-25 09:48:05 -06:00
Jeppe Odgaard a76b908f4c drivers: sensor: add mcux quadrature encoder
Add a driver for the NXP MCUX Quadrature Decoder. The driver
is simple and only implements the phase a and phase b inputs. The
module has additional features which can be added in future PRs.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-01-24 10:21:39 -06:00
Benjamin Lindqvist 7ffc200820 drivers: sensor: bmi270: don't force val2 > 0
The struct sensor_value type does NOT require val2 to be positive. The
removed code is in fact a rather serious bug, probably put in place
because it makes printing sensor_values easier.

Signed-off-by: Benjamin Lindqvist <benjamin@eub.se>
2023-01-23 12:02:30 -08:00
Trent Piepho c45bc68e5c drivers/sensor: lsm6dso: Remove busy wait on bank change
It's not necessary to busy wait 150 µs after changing register banks.
Nothing in the data sheet nor app note suggests this.  ST's own HAL,
which is used by this driver, does not delay when changing banks.  It
does a bank change around every function that accesses a non-user bank
register (it's quite inefficient).

So if it was necessary it would be broken now, as most of the bank
changes have no delay.

One of the few page changes that did have this delay are the those done
before and after reading a sensor sample.  Which is where the speed is
significant and is limiting the update rate the driver is capable of.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Trent Piepho 0cfe9560d9 drivers/sensor: lsm6dso: Remove unneeded read/modify/write in shub read
The code in the ST HAL does a read/modify/write to change the bits in
the LSM6DSO_FUNC_CFG_ACCESS register that control which register bank is
active.

All the other bits in the register are defined as zero.  It's possible
to simply set the register to the desired value without reading the
contents first.

This bank switch needs to be done twice for every sensor read when the
sensor hub is used.  The driver as it is can not keep up with the higher
update rates of the lsm6dso.  So any speed increase in this code allows
for a higher update rate as well as reduced latency.

Previously, a read of the lsm6dso's accel and gyro on a 400 kHz I2C bus
with a 3-axis magnetometer on the sensor hub takes 2.69 ms.  This drops
that to 2.26 ms.  This is enough to support the 417 Hz ODR.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Trent Piepho 8e80661db7 drivers/sensor: lsm6dso: Fix shub init and configuration failures
There is a flaw with I2C communication to peripherals behind the shub
that causes sporadic failures.  Especially calls to configure a device
after the lsm6dso initialization is finished, e.g. to set the ODR, can
fail to work correctly.

Access to shub peripheral registers is done by putting the parameters of
the operation into SLV0 and then waiting for the lsm6dso to perform the
xfer on the shub I2C bus.  The lsm6dso does this in sync with the
accelerometer update rate.  Once the shub is enabled, it peforms the
xfer repeatedly as the accelermeter is sampled.

The wait has a problem:  It might detect that a previous shub xfer has
finished, which was done before SLV0 was programmed with new parameters.

The shub status register is read-to-clear.  This isn't in the data sheet
or app note, but it is.  By reading the status before enabling the
sensor and after programming SLV0, we can be sure when it becomes set it
has finished the current operation and not a previous one.

Also set the write-once flag before shub init.  This causes the shub to
only perform I2C writes once instead of continuously.  This was set at
the end of init, so any writes done during it would repeat until the
shub was disabled.

Put a timeout in the code that polls for the sensor hub op complete.  It
could possibly poll forever.  More importantly, if there is no device
connected to the sensor hub, the lsm6dso does not timeout on the
operation for ~13 seconds.  Since the shub init does a probe for devices
on startup, this will happen if shub support is enabled but a lsm6dso
has no sensor hub devices.  There could be multiple devices, some with
additional sensors and some without.  Initialization of the devices
without additional sensors takes tens of seconds without this timeout
being added.

Add a 300 µs wait after disabling the sensor hub.  This is necessary
according to the ST app note AN5192 §7.2.1.

Read the shub status from the main bank register instead of the shub
bank register.  This avoids an extra bank switch before and after each
status poll.  Actually two bank switches on each side, since the lsm6dso
driver switched banks and then the ST HAL function to get the status
register switches again.

The wait for the shub I2C transaction to finish is not needed when the
shub is enabled at the end of init.  We aren't starting a new I2C write
or reading the result of a read.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Trent Piepho c379f86dbd drivers/sensor: lsm6dso: Set to user bank on init
The lsm6dso initialization will fail if the device is not already set to
the user register bank.  All the registers used will be the wrong ones
from whatever bank it is in, e.g. sensor hub bank.  This includes the
registers to reset the device!

The bank will default to the user bank on reset, but the chip has no
hardware reset line.  On a reboot it will be in whatever bank it was
last in.  If the sensor hub is enabled, it will switch banks on every
sample, so it's entirely possible to reset or reboot when it happens
to be set to the sensor hub bank, which will cause the driver to
fail to initialize.  It will not work again until the lsm6dso is power
cycled.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Trent Piepho 25579d95b1 drivers/sensor: lsm6dso: Disable sensor hub before reset
Per an ST app note, the sensor hub I2C controller should be disabled
before doing a software reset.  Possibly, this is because the sensor hub
could be in the middle of the an I2C transaction to a sensor when it is
reset.  Disabling it and then waiting makes sure it has quiesced before
resetting.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Trent Piepho 7cf6d75a11 drivers/sensor: lsm6dso: Move interrupt config to after chip reset
The initialization code would configure the lsm6dso interrupt, then
configure the rest of the chip.  The chip init includes a reset that
would undo the register setting done during interrupt configuration.

It's also not a good idea to enable the interrupt on the SoC when the
lsm6dso has not yet been reset or configured.  It might be generating
interrupts.

The lsm6dso has no hardware reset line, so it will not be reset on
reboot unless a power cycle is involved.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Trent Piepho d14732b541 drivers/sensor: lsm6dso: Set thread name
When the driver creates its own thread, set the name.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
TOKITA Hiroshi 10ef1a7cba drivers: sensors: Add support for RaspberryPi Pico CPU temperature
Support for the measuring the CPU die temperature
for the RaspberryPi Pico.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2023-01-19 15:32:41 -06:00
Felipe Neves cd04926d6b sensors: as5600: added as5600
magnetic angle sensor driver.

Signed-off-by: Felipe Neves <felipe.neves@linaro.org>
2023-01-19 15:18:24 -06:00
Tom Burdick 15786ce648 sensor: tdk 42688 driver
Adds a driver for TDK InvenSense 42688 six axis IMU. Verified using
the sensor shell sample app via:

- sensor info
- sensor get icm42688p@0

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
Signed-off-by: Yuval Peress <peress@google.com>
2023-01-10 14:45:36 -06:00
Mizuki Agawa 687d1f0ae5 drivers: sensor: Add support ICP10125 pressure and temperature sensor
Product Homepage:
https://invensense.tdk.com/products/1-axis/icp-10125/

DataSheet:
https://3cfeqx1hf82y3xcoull08ihx-wpengine.netdna-ssl.com/wp-content/uploads/2021/04/DS-000329-ICP-10125-v1.1.pdf

Testing Environment:
STMicroelectronics NUCLEO-F401RE

Signed-off-by: Mizuki Agawa <agawa.mizuki@fujitsu.com>
2022-12-28 10:44:16 +01:00
Marek Matej 45d55205db drivers: esp32: temp: CPU die temperature sensor
Support for the measuring the CPU die temperature
for the ESP32 targets S2,C3. The ESP32 support
was ommited due to lack of offset calibration.

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2022-12-15 18:21:39 +01:00
Dinesh Kumar K f050e18798 drivers: sensor: Add support for grow_r502a fingerprint sensor
Add driver support for grow_r502a fingerprint sensor

Signed-off-by: Dinesh Kumar K <dinesh@linumiz.com>
2022-12-14 18:44:29 +01:00
Marco Argiolas 3540ae1df9 drivers: sensor: bmm150: fix mispelling
Build error appearing only when enabling CONFIG_BMM150_PRESET_LOW_POWER

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2022-12-12 10:54:40 -06:00
Bartosz Bilas e077fb73ec drivers: tests: replace usage of spi_is_ready with spi_is_ready_dt
`spi_is_ready` function is being deprecated in favor of
`spi_is_ready_dt` so let's replace the old usage in the tree.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-12-07 09:40:23 -06:00
Armando Visconti 20ea61be35 drivers/sensor: lsm6dso: Add drdy_pulsed property in DT
Add drdy_pulsed property in Device Tree in order to select how
data ready irq should behave (either pulsed or latched mode).
Moreover change/fix the API called to set drdy irq mode.
(fix #51944)

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2022-11-25 20:03:21 +01:00
Anas Nashif cffe98d9de crc: Make the build of crc function dependent on a Kconfig
Add CONFIG_CRC for building CRC related routines.
CRC routines are now being built for each application, whether used or
not and are add in the build system unconditionally.

Keep CONFIG_CRC enabled by default for now and until all users have
converted to use the new option.

Partial fix for #50654

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-23 13:30:00 +01:00
Philipp Schilk 6a93975dd7 drivers: sensors: Fix MAX30101 Kconfig description.
Fixes a small typo in the MAX30101 Kconfig file.
The MAX30101_LED3_PA config option mistakenly referd to LED2 in it's
comment.

Signed-off-by: Philipp Schilk <schilk.philipp@gmail.com>
2022-11-22 13:07:03 +09:00
Nick Ward de9a665b31 drivers: sensor: vcnl4040: other small improvements
Fixes the double up test of int_gpio.port.
Addition of VCNL4040_ALS_INT_EN macros.
Use of BIT() macro where it makes sense.
MISRA improvements.

Signed-off-by: Nick Ward <nick.ward@ftpsolutions.com.au>
2022-11-20 12:12:23 +01:00
Nick Ward 3abd63c093 drivers: sensor: vcnl4040: use mutex for locking
Saves some flash and we get priority inheritance.

Also removes lock from vcnl4040_handle_int() as it
is always called from the same thread.

Signed-off-by: Nick Ward <nick.ward@ftpsolutions.com.au>
2022-11-20 12:12:23 +01:00
Nick Ward db8ecd5ec8 drivers: sensor: vcnl4040: fix sensor register init
The driver has a read register, modify value, write value flow due to
needing to modify nibbles of registers at different times.  The issue
this driver previously had was new incoming configurations from the
driver would be corrupted by previous configurations written into the
vcnl4040 (when there's been no power off). This would be in the case
when a device continuously power on and a developer is tweaking the
vcnl4040's configuration or when deploying firmware updates with
a new vcnl4040 configuration.

Signed-off-by: Nick Ward <nick.ward@ftpsolutions.com.au>
2022-11-20 12:12:23 +01:00
Nick Ward d8c107e166 drivers: sensor: vcnl4040: fix I2C write function
The driver was using the i2c_transfer_dt() API incorrectly by not using the
I2C_MSG_STOP flag in the flags field.

The I2C write function can be written more simply with the basic I2C write
API so this commit also switches the code to the basic I2C write API to fix
this bug.

Signed-off-by: Nick Ward <nick.ward@ftpsolutions.com.au>
2022-11-20 12:12:23 +01:00
Kiril Petrov 5801ab2231 drivers: sensors: lis2dh: add attr to set HP filters
Add ability to set High Pass filter on AOI function on interrupt 1 or 2.

Signed-off-by: Kiril Petrov <retfie@gmail.com>
2022-11-18 10:46:52 -06:00
Benjamin Perseghetti 3906860a8f drivers: fxas21002 enablement for SPI and I2C
Added support for fxas21002 sensor over SPI and I2C.
Made the fxas driver APIs generic for I2C and SPI.
Tested with fxas21002 sensor on RDDRONE.

Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
Co-authored-by: Sumit Batra <sumit.batra@nxp.com>
2022-11-16 10:18:46 -06:00
Benjamin Perseghetti 2870b38379 drivers: fxos8700 enablement for SPI and I2C
Added support for fxos8700 sensor over SPI and I2C.
Made the fxos driver APIs generic for I2C and SPI.
Tested with fxos8700 sensor on RDDRONE.

Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
Co-authored-by: Sumit Batra <sumit.batra@nxp.com>
2022-11-16 10:18:46 -06:00
Gerard Marull-Paretas af722062c1 drivers: sensor: ina23x: s/irq-gpios/alert-gpios
The sensor uses the ALERT terminology (pin can be configured to trigger
on certain events such as conversion ready or overvoltage alerts). The
"IRQ" name is not clear.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-15 10:23:17 +01:00
Gerard Marull-Paretas d5734bc003 drivers: sensor: ina23x: specify current LSB in uA and fix units
Specify the units of the current LSB in microamperes, so that we can
measure low maximum currents. Right now it was specified in
milliamperes, but ignored and always hardcoded to 1mA in the driver.
This makes the driver pretty much useless when the maximum current to be
measured is in a range of e.g. 20-50mA.

This patch also removes some unnecessary ifdeffery: since we write the
calibration register, we can always provice measurements with the right
units. It is also wrong to provide sensor readings that do not match
with the units specified by the channel. After this change voltage is
always reported in V, current in A and power in W.

Note that power measurement had the current LSB hardcoded in the
calculation (assuming 1mA/LSB), this has been fixed as well.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-15 10:23:17 +01:00
Gerard Marull-Paretas d7e1e44320 drivers: sensor: ina23x: improve voltage reading code
Adjusted LSB factor to be un uV/LSB to make calculations more clear.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-15 10:23:17 +01:00
Gerard Marull-Paretas a79f5b87c0 drivers: sensor: ina23x: s/rshunt/rshunt-milliohms
Following dtschema practices, add phyisical units to the shunt resistor
value: milliohms.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-15 10:23:17 +01:00
Gerard Marull-Paretas af03ad33e1 drivers: sensor: ina23x: remove redundant build asserts
With the recent introduction of DT_HAS* Kconfig helpers, such build
asserts are highly unlikely, so just remove them.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-15 10:23:17 +01:00
Gerard Marull-Paretas a34158f386 drivers: sensor: ina23x: delete redundant Doxygen docs
Driver had Doxygen stubs for sensor interface calls. First, most were
incomplete, outdated or just wrong. Second, implementations just need to
make sure to adhere to the error codes documented in the public
interface (sensor API in this case).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-15 10:23:17 +01:00
Gerard Marull-Paretas 35eabfcdf0 drivers: ina23x: fix includes
- Add many missing includes so that headers are self-contained
- Sort includes properly (locals first, stdc, zephyr, etc.)

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-15 10:23:17 +01:00
Marco Argiolas be4ee1edef drivers: sensor: sensor_shell: fix channel name collision
Channel SENSOR_CHAN_GAUGE_FULL_CHARGE_CAPACITY was returned in place of
SENSOR_CHAN_GAUGE_FULL_AVAIL_CAPACITY, due to their matching names.
Ensuring that the channel names are unique fixes the issue.

Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
2022-11-09 09:44:27 -06:00
Armando Visconti 2217608c1c drivers/sensor: Call the correct stmemc API to set drdy_pulsed
Call lis2dw12_data_ready_mode_set() API in order to properly
set CLTR7.drdy_pulsed bit.
(Fix #51488)

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2022-11-08 10:45:32 +01:00
Maureen Helm 0ddc2a9b65 drivers: sensor: Remove brackets from sensor info shell command output
Brackets were originally used in the sensor info shell command output to
make it obvious when a field is a null string, however they incorrectly
suggest that a field is an array. Remove the brackets and conditionally
print "(null)" instead.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-11-02 15:40:24 +09:00
Erdem Efe 0e05686d52 sensor: freefall added to lis2dw12 sensor driver.
lis2dw12 supports freefall detection and set related parameters

Signed-off-by: Erdem Efe <erdemefe1@gmail.com>
2022-11-01 08:25:24 -05:00
Parthiban Nallathambi 12eb38c5a5 sensor: dht: fix code stlying
fix indent, change space to tab

Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
2022-10-31 09:28:05 -05:00
Maureen Helm 97defe7095 drivers: sensor: Add shell command to get sensor info iterable section
Adds a new conditional shell command to the sensor shell to get data
from the sensor info iterable section, such as vendor and model name,
for all sensors.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-10-31 11:21:37 +01:00
Maureen Helm eee3d8f566 drivers: sensor: Add sensor info iterable section
Adds an iterable section in ROM to hold constant information, such as
vendor and model name, for all enabled sensor driver instances. This
will be used by the future sensor subsystem to enumerate all available
sensors in the system.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-10-31 11:21:37 +01:00
Maureen Helm a9b223b26b drivers: sensor: Refactor drivers to use SENSOR_DEVICE_DT_INST_DEFINE
Refactors all sensor drivers to use SENSOR_DEVICE_DT_INST_DEFINE, which
is a sensor-specific variant of DEVICE_DT_INST_DEFINE that provides a
common place to instantiate additional data structures for the future
sensor subsystem and/or sensor driver stats.

This approach was inspired by I2C_DEVICE_DT_INST_DEFINE to streamline
adding I2C stats support across all I2C drivers.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-10-27 09:27:14 +00:00
Mehdi Zemzem e8457de662 drivers: sensor: iis2dh: Add macro DT_DRV_COMPAT to iis2dh_trigger.c
Without this define, the structure iis2dh_device_config
is defined incorrectly.

The structure is defined in iis2dh.h file as follows:
struct iis2dh_device_config {
	struct spi_dt_spec spi;
	struct i2c_dt_spec i2c;
	uint8_t pm;
	struct gpio_dt_spec int_gpio;
};

without the macro

the structure is defined as
struct iis2dh_device_config {
 uint8_t pm;
 struct gpio_dt_spec int_gpio;
};

which results in accessing the wrong data when
calling iis2dh_init_interrupt
function (or any other functions in this file)

Signed-off-by: Mehdi Zemzem <mehdi.zemzem2@gmail.com>
2022-10-26 15:58:26 -05:00
Bernardo Perez Priego 810809f96b driver: adc: npcx: enable adding work queue for adc comparator
ADC comparator driver submits notifications into system work queue, this
change will make driver to use dedicated work queue instead by using
`CONFIG_ADC_CMP_NPCX_WORKQUEUE`.

Dedicated work queue and priority are configurable as well.

Signed-off-by: Bernardo Perez Priego <bernardo.perez.priego@intel.com>
2022-10-21 10:29:30 -05:00
Simen S. Røstad b231415343 ADXL362: Do not clear last bits of 16-bit inactivity time value
The inactivity time registers identified by `ADXL362_REG_TIME_INACT_L`
and `ADXL362_REG_TIME_INACT_H` accepts a 16-bit value. (8 in each).
Without this change the last 5 bits of the register value
will be cleared.

Clearing the last bits of the register value greatly reduces the maximum
inactivity time that can be set.

Signed-off-by: Simen S. Røstad <simen.rostad@nordicsemi.no>
2022-10-18 14:11:53 +02:00
Gerard Marull-Paretas 178bdc4afc include: add missing zephyr/irq.h include
Change automated searching for files using "IRQ_CONNECT()" API not
including <zephyr/irq.h>.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 22:57:39 +09:00
Anas Nashif 3d85ae37b6 arm: add missing includes
Add missing includes that were previously included indirectly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-10-11 18:37:53 -04:00
Gerard Marull-Paretas 6a0f554ffa include: add missing kernel.h include
Some files make use of Kernel APIs without including kernel.h, fix this
problem.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Carles Cufi e50a859625 drivers: sensor: qdec_nrfx: Fix build with no optimizations
The build of this driver fails when `CONFIG_NO_OPTIMIZATIONS=y` is set:

error: expression in static assertion is not constant
   98 |  BUILD_ASSERT(steps > 0, "only positive number valid");

error: expression in static assertion is not constant
   99 |  BUILD_ASSERT(steps <= 2048, "overflow possible");

Fix this by using a simple macro to avoid the compiler from getting
confused.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2022-10-11 11:07:28 +02:00
James Johnson 0eaff5a11d drivers: sensor: add ams AS621x Temperature Sensor driver support
Added support for the AMS AS621x series of temperature sensors as a
variant of the TI TMP108 temperature sensor.

Signed-off-by: Jared Baumann <jared.baumann8@t-mobile.com>
Signed-off-by: James Johnson <james.johnson672@t-mobile.com>
2022-10-07 10:01:47 +02:00
Pieter De Gendt 70e99fe575 drivers: sensor: lis2dh: Configurable latch and mode for any movement
Add 2 properties to configure the "any movement" event.
* Ability to disable the interrupt latch
* Select movement mode

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2022-10-03 10:11:45 +02:00
Valerio Setti 1b78f2dfbd drivers: sensor: adding driver for STM32 quadrature encoder
This driver configures STM32's internal timers in order to use
the quadrature encoder mode.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2022-10-03 10:10:31 +02:00
Dominik Chat 67c6f26c93 sensor: Refactor bmi270 driver data names
Make driver data names consistent in code.

Signed-off-by: Dominik Chat <dominik.chat@nordicsemi.no>
2022-10-03 10:06:46 +02:00
Dominik Chat 6cbb84c3ee sensor: dts: Add SPI capability to bmi270 driver
Added SPI bus support for BMI270 gyroscope driver.

Signed-off-by: Dominik Chat <dominik.chat@nordicsemi.no>
2022-10-03 10:06:46 +02:00
William MARTIN 8bbe016f46 drivers: Fix BMI270 initialization
On power on reset, after disable advanced power safe mode,
you need to wait a delay before write again in the device.
The missing wait produce random initialization failure.
See §4.4 of the datasheet "bst-bmi270-ds000.pdf"

Signed-off-by: William MARTIN <william.martin@power-lan.com>
2022-09-23 12:08:24 +02:00
Antoniu Miclaus 9dda350e24 drivers: sensor: adxl372: update driver
Handle SPI/I2c interface in the dts.

Support multiple instances.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
2022-09-21 18:40:06 +00:00
Daniel Leung 34ccd88c12 sensor: lps22hh: extend to support being on I3C bus
This extends the lps22hh driver to support being on I3C bus.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-09-09 17:42:33 -04:00
Daniel Leung eb9cd9242c sensors: stmemsc: add I3C access functions
This adds I3C access functions so that STM sensors connected
on I3C bus can utilize I3C.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-09-09 17:42:33 -04:00
Gerard Marull-Paretas 79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00
Adrian Wojak fb57a4876f drivers: sensor: lsm6dsl: disable high performance in initialization
To reduce energy consumption for accel and gyro frequencies 52 Hz and
lower, disable high performance mode by default.
It doesn't affect for higher frequencies.

Signed-off-by: Adrian Wojak <adrian.wojak@grinn-global.com>
2022-09-01 13:19:08 -05:00
Erwan Gouriou aa8a89a216 drivers: sensors: hts221: Fix trigger mode
1. Use #ifdef around CONFIG_HTS221_TRIGGER instead of #if

2. According to binding (which is in line with datasheet), name of the pin
used for trigger mode should be drdy, not irq.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-09-01 13:15:14 -05:00
Bartosz Bilas d6cf6e7bb2 dt-bindings: sensor: ina237: rename the operating modes
Adjust the names of the operating modes to match them
with the datasheet and INA230 pattern. While at it add
the missing INA237_OPER_MODE_TEMP_TRIG mode.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2022-08-31 21:51:14 +00:00
Yannick Thesen 754c578d79 drivers: sensor: Added driver for the Würth Elektronik WSEN-HIDS sensor.
Added driver for the WSEN-HIDS humidity and temperature sensor.

Signed-off-by: Yannick Thesen <Yannick.Thesen@we-online.de>
2022-08-31 21:47:58 +00:00
Holger Schurig 331572b3f2 drivers: sensors: fix DRDY usage
hts221_trigger.c is pulled in by the CMakeLists.txt file when
CONFIG_HTS221_TRIGGER is defined. Therefore make the source in hts221.c use
the some define.

This removes also the (wrong) warning

    <inf> HTS221: Cannot enable trigger without drdy-gpios

even when "drdy-gpios" is defined in the device-tree.

Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
2022-08-30 10:26:09 +02:00
TLIG Dhaou 546218ad2b drivers: sensor: stm32_temp add the ts cal resolution to the driver
Add the ts cal resolution in the driver in order to calculate temperature
value.

Signed-off-by: TLIG Dhaou <dhaou.tlig-ext@st.com>
2022-08-24 11:35:45 +02:00
Bartosz Bilas 755c0d57e8 drivers: sensor: ina237: add support for triggered mode
Add missing support for the triggered mode using GPIO
interrupt alert pin. It uses mode detection at runtime
which allows working multiple sensors with different
modes simultaneously.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2022-08-22 19:38:06 +02:00
Gerard Marull-Paretas a202341958 devices: constify device pointers initialized at compile time
Many device pointers are initialized at compile and never changed. This
means that the device pointer can be constified (immutable).

Automated using:

```
perl -i -pe 's/const struct device \*(?!const)(.*)= DEVICE/const struct
device *const $1= DEVICE/g' **/*.c
```

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-22 17:08:26 +02:00
Andrzej Głąbek ca4d8cf4ab drivers: sensor: mpu9250: Fix initialization routine
Fix a call that writes Register 29 - Accelerometer Configuration 2.
Due to an obvious copy-paste mistake in the code, this register was
written with a DLPF setting from devicetree intended for gyroscope,
not for accelerometer (and the latter was effectively ignored).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-08-18 16:08:23 +02:00
Jan Kuliga 2ddd221120 bme680: Rework setting the spi_mem_page accordingly to the datasheet
According to the BME680 datasheet, only the spi_mem_page bit can be
changed in its 8-bit register. Therefore we shouldn't just write 0s
to the remaining bits, but update the register content in read-modify-write
fashion instead.
Rework the bme680_set_mem_page(), bme680_init() and register-access
macros.

Signed-off-by: Jan Kuliga <jtkuliga@gmail.com>
2022-08-18 12:44:18 +02:00
Fabio Baltieri 0cba9cb8e9 drivers: sensor: max17055: add VFOCV support
Add support for reading the VFOCV register, which contains the model
estimated open circuit voltage for the cell.

Link: https://pdfserv.maximintegrated.com/en/an/AN6358.pdf
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-18 12:39:20 +02:00
Maureen Helm 0514c3b139 drivers: sensor: Fix apds9960 device pointer initialization
Fixes a bus fault observed in samples/boards/reel_board/mesh_badge
caused by dereferencing an uninitialized device pointer in the apds9960
sensor driver. The device pointer needs to be initialized regardless of
how CONFIG_APDS9960_TRIGGER is configured.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-08-16 14:11:30 +00:00
Jamie McCrae 9433555f0d drivers: sensor: adxl372: Fix default bus issue
The adxl372 device does not select the correct bus that it is on, which
causes undefined operation (usually a fault). This driver should not be
using Kconfig to determine which bus to use, that should be done by
dts, however this works as a quick fix in the interim until the driver
can be fixed properly.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-08-12 17:39:28 +02:00
TOKITA Hiroshi a70627a621 drivers: sensor: adxl345: Correct converting counts to sensor value
Sensor value unit is [m/s^2].
Currently calcs as [g/1000] unit.

Correcting calculation to convert [m/s^2].
Store the integer part to val1, and the fractional part to val2.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2022-08-10 10:54:16 -05:00
Henrik Brix Andersen 78dd25e79e drivers: sensor: check if clock device is ready before accessing
Add check for device_is_ready() before accessing clock control devices.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-09 17:16:16 +02:00
Gerard Marull-Paretas a7c3e7e84a doxygen: remove redundant usages of def
The def command Indicates that a comment block contains documentation
for a #define macro. This is useful if the comment block documents a
macro not adjacent to it, e.g.

```c
/**
 * @def MAX(x,y)
 * @brief Computes the maximum of @a x and @a y.
 */
 #ifdef XXX
 #define MAX(x,y) ...
 #endif
```

However, it is not necessary if the comment is adjacent to the
definition, e.g.

```c
/**
 * @brief Computes the maximum of @a x and @a y.
 */
 #define MAX(x,y) ...
```

This patch removes all unnecessary def entries in-tree.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-09 12:29:28 +02:00
Lucas Tamborrino ffa1c92131 drivers: sensor: esp32: pcnt driver
Add new pcnt peripheral driver.

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2022-08-08 10:51:41 +02:00
Kumar Gala df81fef944 drivers: sensor: Convert Kconfig bus 'depends on' to 'select'
This change in pattern is meant to address a misconfiguration issue
that can occur for sensors that support being on multiple busses
like I2C & SPI.

For example, you can have a configuration in which such a sensor is
on the I2C bus in the devicetree and the sensor is enabled.  However
the application configuration enables CONFIG_SPI=y and CONFIG_I2C=n
and this will cause the sensor driver to be built by default, however
since we don't have the I2C bus enabled the driver will not compile
correctly.

Previously we had been adding to board Kconfig.defconfig something
like:

	config I2C
		default y if SENSOR

This pattern doesn't scale well and may differ from what an application
specific need/use is.

So instead move to a pattern in which we leave the default enablement
up to the devicetree "status" property for the sensor.  We then have
the Kconfig move from 'depends on <BUS>' to 'select <BUS>' and in
the case of drivers that support multiple busses we have the Kconfig
be: 'select <BUS> if $(dt_compat_on_bus,$(<DT_COMPAT>),<BUS>) for
each bus type the sensor supports.

This removes the need to add Kconfig logic to each board and enables
the bus subsystem and bus controller driver if the sensor requires
it by default in the build system.

Fixes: #48518

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-08 06:58:18 +01:00
Pieter De Gendt 114c133fde drivers: sensor: bq274xx: Add interrupt trigger for data ready
Add an optional data ready trigger for the BQ274XX fuel gauge.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2022-08-04 14:17:55 +02:00
Fabio Baltieri 21900c4c33 drivers: sensor: max17055: fix TTE and TTF time units
The unit for SENSOR_CHAN_GAUGE_TIME_TO_EMPTY and
SENSOR_CHAN_GAUGE_TIME_TO_FULL are defined in
zephyr/drivers/sensor.h as being in minutes.

Change the max17055 implementation to match the API spec, fix the
annotation for time register units.

Link: https://datasheets.maximintegrated.com/en/ds/MAX17055.pdf
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-01 14:49:59 -05:00
Maximilian Deubel d8e0dd1804 ADXL372: add names for KConfig choices
This patch adds names to the KConfig choices of the ADXL372 driver.

Signed-off-by: Maximilian Deubel <maximilian.deubel@nordicsemi.no>
2022-07-25 09:33:54 +00:00
Kumar Gala f0441fba58 drivers: sensor: Update drivers to use devicetree Kconfig symbol
Update sensor drivers to use DT_HAS_<compat>_ENABLED Kconfig symbol
to expose the driver and enable it by default based on devicetree.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-22 02:20:18 -05:00
Pieter De Gendt d01934f9e9 drivers: sensor: bq274xx: convert lazy load Kconfig option to dts property
This change allows per-instance configuration of lazy loading and
fixes build issue.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2022-07-20 08:39:45 -05:00
Kumar Gala d77389464b drivers: sensor: shell_battery: Convert to DEVICE_DT_GET
Move to using DEVICE_DT_GET so we can phase out DT_LABEL.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-19 08:45:13 -05:00
Benjamin Björnsson 6098e1894b drivers: sensor: ms5607: Update driver to use spi_dt_spec
Simplify driver by using spi_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-19 12:28:29 +00:00
Benjamin Björnsson e6f9ef4cc7 drivers: sensor: ms5607: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-19 12:28:29 +00:00
Tomislav Milkovic 0fe2c1fe90 everywhere: Fix legacy include paths
Any project with Kconfig option CONFIG_LEGACY_INCLUDE_PATH set to n
couldn't be built because some files were missing zephyr/ prefix in
includes
Re-run the migrate_includes.py script to fix all legacy include paths

Signed-off-by: Tomislav Milkovic <milkovic@byte-lab.com>
2022-07-18 16:16:47 +00:00
Benjamin Björnsson 0649679b98 drivers: sensor: bmp388: Rename spi variable
Rename variable for consistency across drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-18 10:24:35 -05:00
Benjamin Björnsson b6c8148e7e drivers: sensor: bmp389: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-18 10:24:35 -05:00
Andrew McRae 008859a6ba drivers: sensor: npcx_tach: Remove underflow LOG_INF
A LOG_DBG already exists for the underflow check,
and given that reading 0 edges is a valid case, remove
the noisy underflow log.

Signed-off-by: Andrew McRae <amcrae@google.com>
2022-07-18 09:11:04 -05:00
TOKITA Hiroshi 189c8a82d4 drivers: sensor: adxl345: Add support SPI connection
Support SPI connection for ADXL345.
It works as well as an I2C connection.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2022-07-18 10:37:14 +00:00
Benjamin Björnsson 704e366fcf drivers: sensor: iis2mdc: Move bus union inside device config
Simplify driver by moving auxiliary bus union inside device config.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-15 15:35:54 +02:00
Benjamin Björnsson bbff6eb592 drivers: sensor: iis2mdc: move driver to use i2c_dt_spec and spi_dt_spec
Simplify driver by using i2c_dt_spec and spi_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-15 15:35:54 +02:00
Benjamin Björnsson 2259c6771f drivers: sensor: fxas21002: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-14 10:39:40 +02:00
Benjamin Björnsson 05a6c0fe68 drivers: sensor: stm32_temp: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-13 19:06:41 +02:00
Benjamin Björnsson 597be4d4f7 drivers: sensor: ak8975: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-13 15:53:26 +02:00
Benjamin Björnsson 9ed194a00b drivers: sensor: ak8975: Update driver to use i2c_dt_spec
Simplify driver by using i2c_dt_spec for bus access.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-13 05:39:37 -05:00
Kumar Gala 1eeae77621 sensors: ak8975: remove passthrough support for MPU9150
Remove the support for enabling passthrough mode support for MPU9150
on the AK8975.  We don't have a proper MPU9150 driver and the MPU9150
has been EOL.  So its highly unlikely this code is being used.

Additonally we remove the device tree binding for the MPU9150 since
we don't have a proper driver for it.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-12 17:57:18 -05:00
Benjamin Björnsson 6c82570f62 drivers: sensor: ccs811: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-12 12:28:53 +02:00
Benjamin Björnsson bf4b30e848 drivers: sensor: iis3dhhc: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-12 10:56:15 +02:00
Benjamin Björnsson 0364f3ae4d drivers: sensor: ti_hdc: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-12 10:18:29 +02:00
Maximilian Deubel 3d2b04c9a8 ADXL362: add dynamic inact time setting
This patch extends the adxl362 driver by adding an option
to change the inactivity detection timeout at runtime.

Signed-off-by: Maximilian Deubel <maximilian.deubel@nordicsemi.no>
2022-07-11 18:19:45 +00:00
Kiril Petrov 44f651d315 drivers: nordic_nrf_temp: nrfx: Fix build warning into temp_nrf5_init
Building lwm2m_client with CONFIG_NET_L2_OPENTHREAD=y leads to
following warning during build:

west build -s samples/net/lwm2m_client -b nrf52840dk_nrf52840 -- \
				-DCONFIG_NET_L2_OPENTHREAD=y

zephyr/drivers/sensor/nrf5/temp_nrf5.c:115:10:
warning: zero-length gnu_printf format string [-Wformat-zero-length]
115 |  LOG_DBG("");

Signed-off-by: Kiril Petrov <retfie@gmail.com>
2022-07-11 17:57:12 +02:00
Benjamin Björnsson 78af3f39ec drivers: sensor: ism330dhcx: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-08 10:57:18 +02:00
Benjamin Björnsson e0cc66ab6f drivers: sensor: amg88xx: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-07 09:21:34 -05:00
Yann Roth c640392211 typo: fix LSM6DSL_SHIFT_MD2_CFG_INT2_WU
The register MD2_CFG contains INT2_WU and not INT1_WU

Signed-off-by: Yann Roth <yannroth@msn.com>
2022-07-07 10:16:35 +02:00
Benjamin Björnsson 092251017f drivers: sensor: stts751: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-06 18:00:21 +00:00
Benjamin Björnsson 0ce4d8b2da drivers: sensor: stm32_vbat: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-06 18:00:02 +00:00
Anas Nashif 49b36ead95 drivers: add mising braces to single line if statements
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-06 11:00:45 -04:00
Benjamin Björnsson 1cd8a0fb34 drivers: sensor: lsm9ds0_gyro: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-06 09:49:32 -05:00
Benjamin Björnsson ccf9292a52 drivers: sensor: iis2dh: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-06 09:11:06 -05:00
Benjamin Björnsson 6e62bd070f drivers: sensor: bmg160: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-06 09:09:38 -05:00
Benjamin Björnsson 2cff424bea drivers: sensor: tmp007: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-06 09:07:33 -05:00
Aurelien Jarno 869c60e208 drivers: sensor: stm32_vbat: get vref-mv through the ADC API
Get the vref-mv through the ADC API instead of the device tree. This
saves 8 bytes of SRAM and will be future proof in case, one day, support
for a variable vref is added.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2022-07-06 11:10:42 +02:00
Benjamin Björnsson 251755e21d drivers: sensor: iis2dh: Update driver to use gpio_dt_spec
Move driver to use gpio_dt_spec for GPIO interrupt handling.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-06 10:43:10 +02:00
Benjamin Björnsson 5c9f5a12f4 drivers: sensor: iis2dh: Update driver to use spi_dt_spec and i2c_dt_spec
Move driver to use spi_dt_spec and i2c_dt_spec for SPI and I2C bus
access, respectively.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-06 10:43:10 +02:00
Benjamin Björnsson 619c0ee17b drivers: sensor: iis2dh: Change parameter list of helper functions
Change parameter list of functions for consistency with other drivers.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-06 10:43:10 +02:00
Thomas Stranger 3d70711c04 drivers: sensor: add support for ds18b20 1-wire temperatue sensor
This commit adds support for the ds18b20 1-wire temperature sensor.

The sampling resolution of the sensor can be set in DT.
In case only a single device is on the bus, the driver issues
skip_rom commands. However, in case DT defines several devices,
the driver will use match_rom commands and therefore it is necessary
to set the rom_id of the device via the sensor attribute interface before
being able to sample sensor values.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2022-07-05 23:06:45 +02:00
Benjamin Björnsson c2861ffda2 drivers: sensor: th02: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 15:41:10 +00:00
Benjamin Björnsson f5b9635e31 drivers: sensor: adxl345: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 15:39:33 +00:00
Benjamin Björnsson 1d0e5e17d3 drivers: sensor: ams_iAQcode: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 15:39:15 +00:00
Benjamin Björnsson 803fdf6a46 drivers: sensor: vcnl4040: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 09:14:50 -05:00
Benjamin Björnsson b4dffbfb40 drivers: sensor: mcp9808: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 09:10:06 -05:00
Benjamin Björnsson b2b7665b9c drivers: sensor: mpu6050: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 09:08:43 -05:00
Benjamin Björnsson 1409a8f86b drivers: sensor: lis3mdl: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 09:06:13 -05:00
Benjamin Björnsson 131aedc769 drivers: sensor: isl29035: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 09:02:05 -05:00
Benjamin Björnsson 0ab5e7964c drivers: sensor: bmc150_magn: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 08:59:13 -05:00
Benjamin Björnsson 3f42a6a75f drivers: sensor: hmc5883l: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 08:57:59 -05:00
Benjamin Björnsson ff7aa22217 drivers: sensor: adt7420: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 08:53:08 -05:00
Benjamin Björnsson d0a5f5a08d drivers: sensor: adxl362: Add multi-instance support
Move driver to use DT_INST_FOREACH_STATUS_OKAY to add
multi-instance support.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2022-07-05 08:51:13 -05:00