-
Notifications
You must be signed in to change notification settings - Fork 7.3k
sensor: icm45686: Add I2C-bus support #88681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sensor: icm45686: Add I2C-bus support #88681
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for I2C bus communication to the ICM45686 sensor driver while updating the SPI code paths to a unified flag (REG_READ_BIT) and enhancing the device tree bindings.
- Added new I2C device tree bindings and updated SPI binding where applicable.
- Modified driver code to add I2C-specific handling for read/write operations and conditionally check bus readiness.
- Introduced an enum to distinguish between SPI and I2C bus types in driver initialization and runtime.
Reviewed Changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
dts/bindings/sensor/invensense,icm45686-spi.yaml | New SPI binding file with updated description and include directives. |
dts/bindings/sensor/invensense,icm45686-i2c.yaml | New I2C binding file mirroring SPI file with I2C-specific changes. |
dts/bindings/sensor/invensense,icm45686-common.yaml | Removed redundant description and simplified include directives. |
drivers/sensor/tdk/icm45686/icm45686_stream.c | Updated read flag usage and added I2C conditional handling in SQE setups. |
drivers/sensor/tdk/icm45686/icm45686_reg.h | Renamed SPI read flag to REG_READ_BIT to be used across bus types. |
drivers/sensor/tdk/icm45686/icm45686_bus.h | Updated bus read/write functions with I2C-specific SQE flag additions. |
drivers/sensor/tdk/icm45686/icm45686.h | Introduced an enum for bus type and added it to the data structure. |
drivers/sensor/tdk/icm45686/icm45686.c | Added bus type checks for device readiness and used conditional macros. |
Files not reviewed (2)
- drivers/sensor/tdk/icm45686/Kconfig: Language not supported
- tests/drivers/build_all/sensor/i2c.dtsi: Language not supported
Comments suppressed due to low confidence (2)
drivers/sensor/tdk/icm45686/icm45686_bus.h:39
- The variable 'data' is used without being defined in this function. Consider retrieving the driver data (e.g. via device_get_drvdata(dev)) before using data->rtio.type.
if (data->rtio.type == ICM45686_BUS_I2C) {
drivers/sensor/tdk/icm45686/icm45686_bus.h:79
- The same issue occurs here: 'data' is not defined in the function. Ensure that the driver data pointer is obtained before referencing data->rtio.type in the write function.
if (data->rtio.type == ICM45686_BUS_I2C) {
@ubieda please rebase |
To split bus support into separate files. This patch does not introduce any functionality, but rather precedes a patch introducing I2C bus support. Signed-off-by: Luis Ubieda <[email protected]>
So it's generic irrespective to the bus. Tested for I2C and SPI. Signed-off-by: Luis Ubieda <[email protected]>
Validated for read/decode APIs, as well as Streaming mode (FIFO). Signed-off-by: Luis Ubieda <[email protected]>
To validate build-time functionality. Signed-off-by: Luis Ubieda <[email protected]>
6a75d69
92f063a
to
6a75d69
Compare
Rebased to resolve conflicts in |
Description
This PR adds I2C bus support to ICM45686 driver, making it compatible with all existing driver functionality:
Testing
Run Shell sample on FRDM MCXN947 with Streaming mode enabled and validate sensor interaction:
Build command:
west build -b frdm_mcxn947/mcxn947/cpu0 samples/subsys/shell/shell_module -- -DCONFIG_SENSOR=y -DCONFIG_SENSOR_SHELL=y -DCONFIG_ICM45686_STREAM=y -DCONFIG_SENSOR_SHELL_STREAM=y
boards/frdm_mcxn947_mcxn947_cpu0.overlay
):