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: ms5611 barometric pressure sensor driver support #67292

Closed
wants to merge 0 commits into from

Conversation

AarC10
Copy link

@AarC10 AarC10 commented Jan 8, 2024

Following up on #48758 since it was closed more than a year ago. Double checked the driver continues to work and added comments for CRC4 calculation, as well as replace <zephyr/zephyr.h> with <zephyr/kernel.h>

Signed-off-by: Aaron Chan [email protected]

@zephyrbot zephyrbot added area: Devicetree Binding PR modifies or adds a Device Tree binding area: Sensors Sensors labels Jan 8, 2024
Copy link

github-actions bot commented Jan 8, 2024

Hello @AarC10, 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. 😊

@AarC10 AarC10 force-pushed the ms5611_driver branch 3 times, most recently from adbc87f to bb2269e Compare January 12, 2024 04:41
@AarC10 AarC10 force-pushed the ms5611_driver branch 3 times, most recently from 81a49da to 10f6629 Compare January 28, 2024 19:40
@AarC10
Copy link
Author

AarC10 commented Feb 5, 2024

Hi @MaureenHelm Could I please get a review of this PR to gain a better understanding of what to fix and how to improve so this could get merged for my org. Thanks!

@AarC10 AarC10 changed the title drivers: ms5611 barometric pressure sensor driver support drivers: sensor: ms5611 barometric pressure sensor driver support Feb 24, 2024
Copy link
Collaborator

@kartben kartben left a comment

Choose a reason for hiding this comment

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

It looks incredibly similar to the ms5607. If I understand correctly, they are virtually the same sensor, only MS5607 has half the resolution of the MS5611.
Please look at making MS5607 driver more generic as it doesn't seem like there is justification for duplicating so much code. What's more, the ms5607 driver has support for both I2C and SPI, which is nice.

@AarC10
Copy link
Author

AarC10 commented Feb 29, 2024

It looks incredibly similar to the ms5607. If I understand correctly, they are virtually the same sensor, only MS5607 has half the resolution of the MS5611. Please look at making MS5607 driver more generic as it doesn't seem like there is justification for duplicating so much code. What's more, the ms5607 driver has support for both I2C and SPI, which is nice.

Yea, I've worked with the MS5607 previously, before switching to the MS5611 for a new board revision. It seems that the only difference would be the coefficients being used during calculation. I agree with your suggestion and I can doing something similar with how the TMP116 driver also supports TMP117 functionality.

@kartben
Copy link
Collaborator

kartben commented Mar 4, 2024

@AarC10 thanks for the update. Does it make sense to leave this PR open or do you want to create another one for the update to the MS5607 driver? It's fine either way.

@AarC10
Copy link
Author

AarC10 commented Mar 4, 2024

@AarC10 thanks for the update. Does it make sense to leave this PR open or do you want to create another one for the update to the MS5607 driver? It's fine either way.

I think it makes more sense to just leave this PR open. I will try to make changes, test and squash soon when I can find the time (hopefully this week). Thanks!

Follow up question actually. Should we rename the ms5607 driver to ms56xx if this is to be a shared driver?

@kartben
Copy link
Collaborator

kartben commented Mar 4, 2024

I think it makes more sense to just leave this PR open. I will try to make changes, test and squash soon when I can find the time (hopefully this week). Thanks!

Excellent!

Follow up question actually. Should we rename the ms5607 driver to ms56xx if this is to be a shared driver?

Yep!

@AarC10
Copy link
Author

AarC10 commented Mar 12, 2024

Alright merged the drivers into one now. Sorry for the delay. Most of my time was spent figuring out macro fun for initializing those coefficients. Pretty much everything is renamed, added a field to the config for storing coefficients and replacing the hardcoded values in the compensate function to use those stored coefficients instead. Also made a comparison table of the values. Tested both drivers as well and the results are below. MS5607 on top and MS5611 on the bottom

Screenshot_20240312_000010
Screenshot_20240312_000249
Screenshot_20240312_000157

@AarC10 AarC10 force-pushed the ms5611_driver branch 2 times, most recently from f515bd3 to cc469a2 Compare March 18, 2024 00:14
@AarC10 AarC10 requested a review from kartben March 25, 2024 04:14
Copy link
Collaborator

@kartben kartben left a comment

Choose a reason for hiding this comment

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

Great stuff!
Main ask would be to document default value in DT binding and add entry to migration guide as compatible has been renamed. Thanks!

compatible: "meas,ms5607"
compatible: "meas,ms56xx"
Copy link
Collaborator

Choose a reason for hiding this comment

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

as you are renaming an existing compatible, it would require an entry in the migration guide to tell people what they need to change in their code that will now break.
Another option would be to keep yaml files for the "old" ms5607 and have them include/inherit the new generic binding, to allow for backward compatibility

# SPDX-License-Identifier: Apache-2.0

menuconfig MS56XX
bool "MS56XX pressure and temperature sensor"
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure if you want to be more consistent: sometimes the driver is referred as being for "MS5607 and MS5611 ... " (ex. in dts bindings), and sometimes as "MS56xx". Don't have a strong preference but it would be good to be consistent.

Comment on lines 14 to 16
default: 7
description: |
Specifies which chip is used to determine calculation coefficients
Copy link
Collaborator

Choose a reason for hiding this comment

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

kartben

This comment was marked as duplicate.

@AarC10
Copy link
Author

AarC10 commented May 24, 2024

Great stuff! Main ask would be to document default value in DT binding and add entry to migration guide as compatible has been renamed. Thanks!

Sounds good! Sorry. Was planning on getting to it, just a lot of stuff going on these past few months. Will handle ASAP

@AarC10
Copy link
Author

AarC10 commented Jun 2, 2024

Hey @kartben Made changes to those suggestions. Also super sorry, but I wasn't thinking when I hit sync fork and it automatically closed this PR. Had a new development machine setup too and had to reclone everything, so couldn't really force push. Don't know if its ok that I had to open a new PR, or if I should just mess with my git a little more to try and get it here if possible.

Also, can't reply to your conversations in review mode, because everything got blasted :/ Anyways, I added to the migration guide. I think we should be explicit that it isn't just MS5607 only that is supported. I remember when I first started using Zephyr there was some sensor I was using that didn't make it explicit, so that's sort of why I want to go in that direction if that was ok. Also updated the KConfig as requested to be a little more consistent. And removed making it a default value and instead making it required to choose between either one. My original intent was to sort of backwards support by not needing to modify devicetree, but I guess that doesn't make sense if the driver itself is renamed anyways. Please let me know if there is anything else you need or anything that might help! Thank you for your time.

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.

4 participants