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: add F75303 temperature sensor driver #60833

Merged
merged 2 commits into from
Sep 7, 2023

Conversation

panikiel
Copy link
Contributor

Add driver for F75303 temperature sensor IC.

dts/bindings/vendor-prefixes.txt Outdated Show resolved Hide resolved
Comment on lines 60 to 61
f75303_emul_set_reg(fixture->target, F75303_LOCAL_TEMP_H, temp_local >> 3);
f75303_emul_set_reg(fixture->target, F75303_LOCAL_TEMP_L, (temp_local & 7) << 5);
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for creating an emulator and test! However instead of having the test write register values directly into the emulator, you can use the emulator sensor backend API.

The generic sensor test will then validate your new temperature sensor an emulator.

Your emulator code needs to implement the 'set_channel` API, which will internally write the correct registers corresponding to the set operation.

See the akm09918c emulator for an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

These public routines shouldn't be needed once you use the emulator backend model.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@keith-zephyr
Copy link
Contributor

Note that commit f05fae4 doesn't appear to have any changed from your previous commit.

@panikiel
Copy link
Contributor Author

panikiel commented Aug 1, 2023

Note that commit f05fae4 doesn't appear to have any changed from your previous commit.

Yeah sorry, that was an accidental merge commit

@str4t0m str4t0m changed the title Add F75303 driver drivers: sensor: add F75303 temperature sensor driver Aug 1, 2023
}
res = f75303_fetch_remote2(dev);
break;
case SENSOR_CHAN_AMBIENT_TEMP:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This sort of thing is exactly why we need to support channel type and index pairs and not just channel type

Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any open issues/proposals to to do this?
This could also be modeled as a multi-function device, with each temperature sensor nested under a parent device. But that seems a little heavyweight.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's being discussed in #61163, though to the best of my knowledge, there is no dedicated issue about this.

Copy link
Collaborator

@teburd teburd Aug 8, 2023

Choose a reason for hiding this comment

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

#13718 #1387 both note the need for multiple channels of the same type, it is a long standing issue

Copy link
Member

Choose a reason for hiding this comment

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

MFD for that seems incredibly overkill for this, device specific channels seems reasonable to close the gap and get the code in, easy enough to change it to subchannel later.

}
res = f75303_fetch_remote2(dev);
break;
case SENSOR_CHAN_AMBIENT_TEMP:
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any open issues/proposals to to do this?
This could also be modeled as a multi-function device, with each temperature sensor nested under a parent device. But that seems a little heavyweight.

Comment on lines 124 to 141
val->val1 = sample >> 3;
val->val2 = (sample & 7) * 125000;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment documenting this conversion.

Copy link
Collaborator

@tristan-google tristan-google Aug 8, 2023

Choose a reason for hiding this comment

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

Would also be nice to add some constants for the numbers, e.g.

#define F75303_TEMP_SAMPLE_INT_SHIFT (3)
#define F75303_TEMP_SAMPLE_FRAC_MASK GENMASK(2,0)
#define F75303_TEMP_SAMPLE_MICROCELSIUS_PER_BIT (125000)

These don't need to go in the header as neither tests nor applications need these.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Add vendor prefix for Feature Integration Technology Inc.

Signed-off-by: Paweł Anikiel <[email protected]>
Add driver for F75303 temperature sensor IC.

Signed-off-by: Paweł Anikiel <[email protected]>
@carlescufi carlescufi merged commit 43668c6 into zephyrproject-rtos:main Sep 7, 2023
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hi @semihalf-anikiel-pawel!
Congratulations on getting your very first Zephyr pull request merged 🎉🥳. This is a fantastic achievement, and we're thrilled to have you as part of our community!

To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge.

Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁

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.

9 participants