Swatantra-66 opened a new pull request, #21052:
URL: https://github.com/apache/nuttx/pull/21052

   ## Summary
   This PR implements pulse edge counting and the `getedges` callback in the 
timer capture lower-half drivers for STM32H7, STM32H5, and common STM32 (M3/M4).
   
   Previously, these drivers did not implement the `.getedges` operation. 
Consequently:
   
   Querying `ioctl(fd, CAPIOC_EDGES, &edges)` failed with `-ENOTTY`.
   Applications such as `examples/capture` aborted execution upon querying edge 
counts.
   On older builds, this triggered a fatal assertion panic in 
`drivers/timers/capture.c:344` (`DEBUGASSERT(lower[i]->ops->getedges != NULL)`).
   
   Changes made across STM32 capture lower-half drivers:
   1. Added `uint32_t edges;` to `struct stm32_lowerhalf_s`.
   2. Incremented `lower->edges++` on each captured edge in the timer interrupt 
handler (`stm32_cap_handler`).
   3. Cleared `priv->edges = 0` upon capture initialization in `stm32_start()`.
   4. Implemented `stm32_getedges()` to return `priv->edges` atomically inside 
a critical section.
   5. Registered `.getedges = stm32_getedges` in `g_cap_ops`.
   
   Fixes #16828
   
   ## Impact
   - **Is new feature added?** Yes, adds edge counting support to STM32 timer 
capture drivers.
   - **User impact:** Users can now query pulse edge counts via `CAPIOC_EDGES` 
and `CAPIOC_ALL`.
   - **Build impact:** None.
   - **Hardware impact:** STM32H7, STM32H5, and STM32 M3/M4 MCUs using timer 
capture.
   - **Documentation impact:** None.
   - **Security impact:** None.
   - **Compatibility:** Backward and forward compatible.
   
   ## Testing
   - **Host:** Windows 11 / WSL2
   - **Target Configurations:** `nucleo-h743zi:capture`, `nucleo-h563zi:capture`
   - **Verification:**
     - Code inspection against upper-half requirements in 
`drivers/timers/capture.c` and `include/nuttx/timers/capture.h`.
     - CodeRabbit review passed on all 3 modified files.
     - Formatted strictly according to NuttX coding style (0 lines exceeding 78 
cols, no trailing whitespace, no tabs).
   


-- 
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