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

   ## Summary
   
   Adds a dedicated command-line tool `examples/comp` for testing and 
interacting with analog comparator devices (`/dev/comp*`) from NSH.
   
   Features:
   - Read comparator state: `comp read`
   - Enable/disable comparator via IOCTL: `comp enable`, `comp disable`
   - Automated smoke test: `comp test`
   - Optional dynamic analog threshold test via DAC voltage ramp: `comp ramp` 
(when `CONFIG_DAC` is enabled).
   - Fully portable across architectures (pure POSIX / character driver 
interface).
   
   ## Impact
   
   - Provides an official example tool for the comparator subsystem in NuttX 
(similar to `examples/adc` and `examples/dac`).
   
   ## 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:
   
   1. Static state and IOCTL test:
   ```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
   ```
   
   2. Voltage ramp test against internal DAC3-CH2:
   ```text
   nsh> comp ramp
   === Comparator Ramp Test ===
     COMP device : /dev/comp0
     DAC device  : /dev/dac5
     Sweep range : 0 -> 4095 (step 100, delay 5 ms)
   
        DAC=   0 (~   0 mV) | COMP output: 1
        DAC= 500 (~ 402 mV) | COMP output: 1
        DAC=1000 (~ 805 mV) | COMP output: 1
     -> [TRIP EVENT #1] DAC=1400 (~1128 mV) | COMP output: 1 -> 0
        DAC=1500 (~1208 mV) | COMP output: 0
        DAC=2000 (~1611 mV) | COMP output: 0
        DAC=2500 (~2014 mV) | COMP output: 0
        DAC=3000 (~2417 mV) | COMP output: 0
        DAC=3500 (~2820 mV) | COMP output: 0
        DAC=4000 (~3223 mV) | COMP output: 0
   
   === Test Summary ===
   SUCCESS: Detected comparator transition(s)!
   ```
   
   - Grounded input check: With INP grounded (0V), COMP output stayed at 0 
throughout full DAC ramp.
   - High-rail input check: With INP connected to 3.3V, COMP output stayed at 1 
until DAC reached 3.14V (~3900), tripping as expected.
   - 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