-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
sensors: codegen for attr/chan/trig #83077
base: main
Are you sure you want to change the base?
Conversation
bccc75b
to
6fc1215
Compare
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.
cmake indent is 2 spaces, apply comments throughout whole PR
${arg_INPUTS} | ||
${arg_SOURCES} | ||
) | ||
add_custom_target(${NAME}.__generate_constants |
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.
why are there full stops in target names?
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.
Why not? I've used them before in other projects. I'm happy to remove them. I use them to denote subpackage like targets. Makes it harder for things to collide when generating targets.
I'm happy to remove the .
if you feel strongly about it.
# Used to generate the sensor catalog | ||
pigweed>=0.0.20 |
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.
why does every user need this?
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.
The Pigweed python library is where we developed the sensor codegen library. This allowed us to start onboarding teams that don't use Zephyr to use the same sensor standard descriptor without having to add Zephyr as a dependency (yet).
Without these version requirements, existing older sphinx installations satisfy the requirement but fail to build. Signed-off-by: Yuval Peress <[email protected]>
Add the Pigweed python dependency used to generate the sensor catalog Signed-off-by: Yuval Peress <[email protected]>
Add the Pigweed python dependency used to generate sensor headers Signed-off-by: Yuval Peress <[email protected]>
Allow users to generate their own sensor libraries from downstream sensor YAML descriptors. Signed-off-by: Yuval Peress <[email protected]> Signed-off-by: Al Semjonovs <[email protected]>
Add code generation for the sensor attribute, channel, and trigger enums. Included in this is the ability to query the sensor's information statically using the compatible string similar to how devicetree does it. Signed-off-by: Yuval Peress <[email protected]>
6fc1215
to
354b954
Compare
Introduce phase 1 of the sensor code generation. In this phase, we flatten the sensor attribute/channel/trigger enums such that sensors which add their own private values will not collide with others. Downstream users can add their own sensor descriptors by modifying various cmake variables:
ZEPHYR_EXTRA_SENSOR_YAML_FILES
,ZEPHYR_EXTRA_SENSOR_INCLUDE_PATHS
, andZEPHYR_EXTRA_SENSOR_DEFINITION_FILES
.Note:
We're still working on adding the rest of the
sensor.yaml
files.Why is CI failing?
CI doesn't allow new python dependencies to be added in the same PR that they're used. Instead we would need to first check in the python dependencies, then roll out a new version of the docker, then re-run this PR's CI.
Why not devicetree?
When we started off, devicetree was very heavily explored. 2 approaches were taken with devicetree.
Details about devicetree limitations for sensors can be found at #71235. While this PR doesn't yet solve the exact issue in the issue, the additional metadata can/will be added once the basic descriptors are added.
Timeline
This is an MVP for the
sensor.yaml
which allows us feature parity with today + a small improvement where we're able to avoid custom attribute/channel/trigger collision. Along with the ability to statically assert that a sensor driver supports the features we need. The next steps are (keep in mind that some of these may happen in parallel):adi
sensors introduced by Analog Devices Inc we can see a great pattern emerging on how to abstract the bus, model the RTIO submit calls, and attribute handling. A lot of that information can be pulled from thesensor.yaml
and we can generate a fairly comprehensive{compatible.part}.h
and{compatible.part}.c
which would handle the majority of the driver functions while leaving out a few stubs to be added by the developer. For example, this could look like (in cmake):sensor.yaml
specs which would allow modules to append to theZEPHYR_EXTRA_SENSOR_*
cmake variables