daniel-p-carvalho opened a new pull request, #20149:
URL: https://github.com/apache/nuttx/pull/20149

   ## Summary
   
   This PR adds standard IOCTL commands to control analog comparator devices 
and implements them for STM32 (M3/M4 v2 architecture).
   
   1. `include/nuttx/analog/ioctl.h`:
      - Adds `ANIOC_COMP_ENABLE` and `ANIOC_COMP_DISABLE` commands.
      - Bumps `AN_NCMDS` to 14.
   
   2. `arch/arm/src/common/stm32/stm32_comp_m3m4_v2.c`:
      - Implements `ao_ioctl` to handle enable and disable requests via 
`ANIOC_COMP_ENABLE` and `ANIOC_COMP_DISABLE`.
      - Adds `CONFIG_STM32_COMP_INIT_DISABLED` in `Kconfig.comp` to optionally 
keep the comparator disabled during driver setup until explicitly requested.
      - Cleans up coding style alignment.
   
   3. `boards/arm/stm32g4/nucleo-g431kb/configs/comp/defconfig`:
      - Enables `CONFIG_EXAMPLES_COMP=y` and sets default DAC path to 
`/dev/dac5` for comparator verification.
   
   ## Impact
   
   - Allows user-space applications to dynamically control the comparator state 
via standard IOCTL.
   - Backward compatible with existing comparator lower-half drivers (unknown 
commands return `-ENOTTY`).
   
   ## Testing
   
   - **Host OS:** Linux x86_64
   - **Target Board:** STMicroelectronics NUCLEO-G431KB (STM32G431KB)
   - **Configuration:** `nucleo-g431kb:comp`
   - **Toolchain:** `arm-none-eabi-gcc 13.2.1`
   
   ### Execution Logs on Physical Hardware:
   
   ```text
   nsh> comp
   Running comparator test on /dev/comp0...
     1. Initial output state: 0
     2. ANIOC_COMP_DISABLE: OK
     3. Output state when disabled: 0
     4. ANIOC_COMP_ENABLE: OK
     5. Output state when enabled: 1
   Comparator test PASSED on /dev/comp0
   ```
   
   Individual commands:
   ```text
   nsh> comp disable
   /dev/comp0: Comparator disabled successfully
   
   nsh> comp read
   /dev/comp0: output = 0
   
   nsh> comp enable
   /dev/comp0: Comparator enabled successfully
   
   nsh> comp read
   /dev/comp0: output = 1
   ```
   
   - Verified with `checkpatch.sh`: 0 errors, 0 warnings.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to