-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
stm32 comparator #85022
base: main
Are you sure you want to change the base?
stm32 comparator #85022
Conversation
drivers/comparator/CMakeLists.txt
Outdated
@@ -9,5 +9,6 @@ zephyr_library_sources_ifdef(CONFIG_USERSPACE comparator_handlers.c) | |||
zephyr_library_sources_ifdef(CONFIG_COMPARATOR_FAKE_COMP comparator_fake_comp.c) | |||
zephyr_library_sources_ifdef(CONFIG_COMPARATOR_MCUX_ACMP comparator_mcux_acmp.c) | |||
zephyr_library_sources_ifdef(CONFIG_COMPARATOR_NRF_COMP comparator_nrf_comp.c) | |||
zephyr_library_sources_ifdef(CONFIG_COMPARATOR_STM32_COMP comparator_stm32_comp.c) |
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.
sort alphabetically
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.
done
drivers/comparator/Kconfig
Outdated
@@ -21,6 +21,7 @@ config COMPARATOR_INIT_PRIORITY | |||
rsource "Kconfig.fake_comp" | |||
rsource "Kconfig.mcux_acmp" | |||
rsource "Kconfig.nrf_comp" | |||
rsource "Kconfig.stm32_comp" |
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.
here as well
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.
done
7cc8784
to
455e0ec
Compare
Add comparator sample with simple triggering behaviour Signed-off-by: Alexander Kozhinov <[email protected]>
Add comparator driver for ST's stm32 series. Signed-off-by: Alexander Kozhinov <[email protected]>
455e0ec
to
8dd5b55
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.
The driver looks good :) The sample is not needed I believe. The test suite in tests/drivers/comparator/gpio_loopback
validates the API behavior with a GPIO connected to the comp input. The build all test suite allows you to build varoius dt configurations tests/drivers/build_all/comparator
, and lastly, given the nature of a comparator, just enabling the comparator shell in a blank application is sample enough :)
Please add the comp to the two test suites to validate and build the driver in CI
Thank you for your review.
Makes sense. I have few questions just for my understanding:
Will do of course. Thanks. Regarding comparator sample: I think - the major advantage of the sample is to give a very basic example coupled with physical functionality. Especially in my experience samples allow very fast peripheral testing on new hardware, device-tree problem findings with new BSP. |
Many vendors, including STM I believe, run twister tests on hardware in their own CI, zephyr only runs emulated platforms in CI. That's why we specify fixtures in the zephyr test suites, like I don't know exactly what their
Tests don't require twister to run, they are just normal applications with a nice framework to set up cases without needing a bunch of Simply The reason I favor the shell above a "fixed" scenario like the sample in this PR, is that actually playing around with a comparator usually requires some external signal generator to generate a voltage or an edge, the GPIO case only shows that the API "works", not that the comparator is actually measuring and behaving correctly. That is quick to see using the shell to test "real" varying signals. |
Add stm32 comparator driver and simple comparator sample.
I've used to test it on nucleo_h745zi_q (m7 core only).
Build command with newly added sample:
My build result output:
The resulting output in the console could look like:
NOTE: To see the output value changing and
comp_trigger_cb
called the pins PB0 and PB2 shall be connected physically on the nucleo_h745zi_q board. Please consider the overlay file in the sample to find more about pinouts used.I've not tested the driver with any other stm32, but I am planning to add support for stm32g4 soon.
Any testers with appropriate board (any stm32h7 would be fine as a good first choice) are very welcome.