Skip to content
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

drivers: sensor: sdp3x: add driver #74376

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ygaillard
Copy link

This is a proposition for a driver using the SDP3x family differential pressure sensors. The related documentation can be found via https://sensirion.com/media/documents/4D045D69/6375F34F/DP_DS_SDP3x_digital_D1.pdf. The code was tested using a SDP31 chip on custom hardware in ambient conditions and return plausible data.

Trigger and continous mode can be selected via project file. The board file select the different mesure mode provided by the sensor.

Copy link

Hello @ygaillard, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

@carlescufi
Copy link
Member

Thanks for the PR! Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request.

@ygaillard ygaillard changed the title sensor: add driver for SDP3x sensors drivers: sensor: sdp3x: add driver Jun 17, 2024
@ygaillard

This comment was marked as outdated.

@ygaillard ygaillard force-pushed the main branch 2 times, most recently from 3064a11 to b614b2e Compare June 17, 2024 18:45
@ygaillard
Copy link
Author

@carlescufi , finally fixed my issues.

Copy link
Member

@MaureenHelm MaureenHelm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

Please add this sensor to tests/drivers/build_all/sensor

drivers/sensor/sensirion/sdp3x/sdp3x.c Outdated Show resolved Hide resolved
const struct sdp3x_config *cfg = dev->config;
int rc = 0;

if (!device_is_ready(cfg->bus.bus)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use i2c_is_ready_dt

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to cause an invalid pointer. Could you provide more information on how to use this function? Note that the other implemented sensirion drivers use device_is_ready.

Log:

In function 'sdp3x_init':
/home/ygaillard/ML_sens_board/external/zephyr/drivers/sensor/sdp3x/sdp3x.c:168:38: warning: passing argument 1 of 'i2c_is_ready_dt' from incompatible pointer type [-Wincompatible-pointer-types]
  168 |         if (!i2c_is_ready_dt(cfg->bus.bus)) {
      |                              ~~~~~~~~^~~~
      |                                      |
      |                                      const struct device *

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reference:

if (!i2c_is_ready_dt(&config->bus)) {

drivers/sensor/sensirion/sdp3x/sdp3x.h Outdated Show resolved Hide resolved
dts/bindings/sensor/sensirion,sdp3x.yaml Outdated Show resolved Hide resolved
@ygaillard
Copy link
Author

Thanks for the contribution!

Please add this sensor to tests/drivers/build_all/sensor

Can you please point in the coding guidelines how to implement the test? I could not find any for the other sensirion sensors and therefore difficult how to implement them.

@ygaillard
Copy link
Author

I implemented the changes. Did I miss something in the workflow?

Add device driver for the SDP3x temperature and
differential pressure sensors.
Datasheet https://sensirion.com/media/documents/4D045D69/6375F34F/DP_DS_SDP3x_digital_D1.pdf
Signed-off-by: Yann Gaillard <yann@gaillard.onl>
@kartben
Copy link
Collaborator

kartben commented Aug 2, 2024

rebased to re-trigger stuck CI

@decsny decsny removed their request for review August 19, 2024 19:26
Copy link
Member

@ubieda ubieda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! Code looks good but needs the indentation fixed and address Maureen's comment.

const struct sdp3x_config *cfg = dev->config;
int rc = 0;

if (!device_is_ready(cfg->bus.bus)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reference:

if (!i2c_is_ready_dt(&config->bus)) {

#define SDP3X_CRC_INIT 0xFF

struct sdp3x_config {
struct i2c_dt_spec bus;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix indentation (various places): spaces -> tabs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree Binding PR modifies or adds a Device Tree binding area: Sensors Sensors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants