analog: add comp enable/disable ioctl and STM32 support - #20149
Open
daniel-p-carvalho wants to merge 4 commits into
Open
daniel-p-carvalho wants to merge 4 commits into
daniel-p-carvalho wants to merge 4 commits into
Conversation
Define standard IOCTL commands to enable and disable analog comparator devices from user-space applications. Assisted-by: Gemini:gemini-2.5-pro Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
Implement ao_ioctl in stm32_comp_m3m4_v2.c to handle ANIOC_COMP_ENABLE and ANIOC_COMP_DISABLE commands. Also add CONFIG_STM32_COMP_INIT_DISABLED to allow keeping the comparator disabled after driver initialization until explicitly enabled. Update nucleo-g431kb:comp defconfig to enable CONFIG_EXAMPLES_COMP and set default DAC path for comparator ramp verification. Assisted-by: Gemini:gemini-2.5-pro Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
daniel-p-carvalho
requested review from
Donny9,
GUIDINGLI,
jerpelea,
michallenc,
raiden00pl and
xiaoxiang781216
as code owners
September 15, 2026 00:14
Contributor
Author
|
Companion example tool PR in apps: apache/nuttx-apps#3783 |
|
xiaoxiang781216
previously approved these changes
Sep 15, 2026
jerpelea
previously approved these changes
Sep 15, 2026
CONFIG_EXAMPLES_COMP_DACPATH matched its Kconfig default value, which make savedefconfig drops as redundant. The stale explicit line made the committed defconfig differ from what a clean savedefconfig produces, failing CI's defconfig-completeness check even though the board builds fine either way. Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
daniel-p-carvalho
dismissed stale reviews from jerpelea and xiaoxiang781216
via
September 15, 2026 09:00
0e83d97
jerpelea
previously approved these changes
Sep 15, 2026
xiaoxiang781216
previously approved these changes
Sep 15, 2026
acassis
previously approved these changes
Sep 15, 2026
michallenc
requested changes
Sep 15, 2026
In comp_ioctl(), propagate the return code of comp_enable() to caller so failures (such as when the comparator CSR register is locked) return -EPERM. Also call comp_lock_set() if the comparator was configured with locking, handling cases where initialization was delayed. Assisted-by: Gemini:gemini-2.5-pro Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
daniel-p-carvalho
dismissed stale reviews from acassis, xiaoxiang781216, and jerpelea
via
September 15, 2026 22:57
5adfc8e
michallenc
approved these changes
Sep 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds standard IOCTL commands to control analog comparator devices and implements them for STM32 (M3/M4 v2 architecture).
include/nuttx/analog/ioctl.h:ANIOC_COMP_ENABLEandANIOC_COMP_DISABLEcommands.AN_NCMDSto 14.arch/arm/src/common/stm32/stm32_comp_m3m4_v2.c:ao_ioctlto handle enable and disable requests viaANIOC_COMP_ENABLEandANIOC_COMP_DISABLE.CONFIG_STM32_COMP_INIT_DISABLEDinKconfig.compto optionally keep the comparator disabled during driver setup until explicitly requested.boards/arm/stm32g4/nucleo-g431kb/configs/comp/defconfig:CONFIG_EXAMPLES_COMP=yand sets default DAC path to/dev/dac5for comparator verification.Impact
-ENOTTY).Testing
nucleo-g431kb:comparm-none-eabi-gcc 13.2.1Execution Logs on Physical Hardware:
Individual commands:
checkpatch.sh: 0 errors, 0 warnings.