mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 14:58:13 +08:00
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. 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>
This commit is contained in:
committed by
Alan C. Assis
parent
f6a9f8239d
commit
57217a7983
@@ -31,6 +31,8 @@
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/signal.h>
|
||||
|
||||
#include <nuttx/signal.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
@@ -274,6 +276,27 @@ int cap_register(FAR const char *devpath,
|
||||
int cap_register_multiple(FAR const char *devpath,
|
||||
FAR struct cap_lowerhalf_s **lower, int n);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: fake_capture_initialize
|
||||
*
|
||||
* Description:
|
||||
* This function is called by board-specific logic to initialize
|
||||
* fake capture.
|
||||
*
|
||||
* Input Parameters:
|
||||
* channel - The capture channel number to initialize.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure. The following
|
||||
* possible error values may be returned (most are returned by
|
||||
* register_driver()):
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_FAKE_CAPTURE
|
||||
int fake_capture_initialize(int channels);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user