Skip to content

Conversation

@Donny9
Copy link
Contributor

@Donny9 Donny9 commented Dec 30, 2025

Summary

patch1:

drivers/capture: add signal notification support for edge capture events

This commit adds comprehensive signal notification support to the capture
driver, enabling applications to be asynchronously notified when capture
edge events occur on any channel, rather than having to poll for events.

patch2:

drivers/capture: add fake capture driver for testing and development

This commit introduces a software-based fake capture driver that simulates
a 10Hz square wave with 50% duty cycle, enabling development and testing
of capture-related applications without requiring real hardware.

Impact

new function about capture

Testing

examples capture
image

@github-actions github-actions bot added Area: Drivers Drivers issues Size: L The size of the change in this PR is large labels Dec 30, 2025
@xiaoxiang781216
Copy link
Contributor

@Donny9 please fix the conflict

Copy link
Contributor

@acassis acassis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Donny9 please include information to this signal notification and this new fake capture to https://nuttx.apache.org/docs/latest/components/drivers/character/timers/capture.html#capture

@Donny9
Copy link
Contributor Author

Donny9 commented Dec 30, 2025

@Donny9 please include information to this signal notification and this new fake capture to https://nuttx.apache.org/docs/latest/components/drivers/character/timers/capture.html#capture

Done~ @acassis

@github-actions github-actions bot added the Area: Documentation Improvements or additions to documentation label Dec 30, 2025
acassis
acassis previously approved these changes Dec 30, 2025
@xiaoxiang781216
Copy link
Contributor

@Donny9 please fix the conflict

@Donny9 but fail to resolve conflict.

This commit adds comprehensive signal notification support to the capture
driver, enabling applications to be asynchronously notified when capture
edge events occur on any channel, rather than having to poll for events.

Background:
The capture driver is used to measure frequency and duty cycle of external
signals by detecting edges (rising/falling). Previously, applications could
only retrieve captured values through periodic polling via CAPIOC_GETDUTY
and CAPIOC_GETFREQ ioctl commands, which is inefficient for event-driven
applications.

Problem:
Without event notification, applications must:
- Continuously poll the capture device to check for new events
- Waste CPU cycles in polling loops
- Experience higher latency in responding to capture events
- Cannot efficiently handle multiple capture channels simultaneously

Solution:
This commit adds a signal-based notification mechanism that allows
applications to register callbacks for specific capture channels and
edge types (rising, falling, or both). When the hardware detects the
configured edge, a signal is sent to the registered task.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit introduces a software-based fake capture driver that simulates
a 10Hz square wave with 50% duty cycle, enabling development and testing
of capture-related applications without requiring real hardware.

Background:
The capture driver subsystem requires hardware support (timers with input
capture functionality) to measure external signal frequency and duty cycle.
During development, testing, or on platforms without capture hardware, it's
difficult to develop and test applications that use the capture API.

Problem:
Without a fake/simulator driver:
- Developers cannot test capture applications without specific hardware
- Continuous Integration (CI) systems cannot run capture-related tests
- Applications cannot be developed on platforms lacking capture hardware
- Testing edge notification features requires complex hardware setup
- Difficult to reproduce specific timing scenarios for debugging

Solution:
This commit provides a software-simulated capture driver that generates
predictable capture events using a watchdog timer. The fake driver
produces a square wave signal at 10Hz frequency with 50% duty cycle,
allowing applications to test the full capture API without hardware.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
@Donny9
Copy link
Contributor Author

Donny9 commented Dec 31, 2025

@Donny9 please fix the conflict

@Donny9 but fail to resolve conflict.

Done~

These documentation updates correspond to commits:
- drivers/capture: add signal notification support for edge capture events
- drivers/capture: add fake capture driver for testing and development

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
@acassis
Copy link
Contributor

acassis commented Dec 31, 2025

@Donny9 please rebase to get the fix you submitted here #17751

@acassis
Copy link
Contributor

acassis commented Jan 1, 2026

@Donny9 strange, still failing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Documentation Improvements or additions to documentation Area: Drivers Drivers issues Size: L The size of the change in this PR is large

3 participants