From 9e388d1d00dc3aca2ee24fa97b330d240ce1073c Mon Sep 17 00:00:00 2001 From: zhangkai25 Date: Thu, 25 Apr 2024 09:55:21 +0800 Subject: [PATCH] Capture adds the function of edges counting Description: Add the function of counting cap edges Signed-off-by: zhangkai25 --- drivers/timers/capture.c | 12 ++++++++++++ include/nuttx/timers/capture.h | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/timers/capture.c b/drivers/timers/capture.c index 9f4cbfa5a3..556f646797 100644 --- a/drivers/timers/capture.c +++ b/drivers/timers/capture.c @@ -304,6 +304,18 @@ static int cap_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } break; + /* CAPIOC_EDGES - Get the pwm edges from the capture. + * Argument: int32_t pointer to the location to return the edges. + */ + + case CAPIOC_EDGES: + { + FAR uint32_t *ptr = (FAR uint32_t *)((uintptr_t)arg); + DEBUGASSERT(lower->ops->getedges != NULL && ptr); + ret = lower->ops->getedges(lower, ptr); + } + break; + /* Any unrecognized IOCTL commands might be platform-specific ioctl * commands */ diff --git a/include/nuttx/timers/capture.h b/include/nuttx/timers/capture.h index 594d72d2af..8271012cee 100644 --- a/include/nuttx/timers/capture.h +++ b/include/nuttx/timers/capture.h @@ -36,6 +36,7 @@ #define CAPIOC_DUTYCYCLE _CAPIOC(1) #define CAPIOC_FREQUENCE _CAPIOC(2) +#define CAPIOC_EDGES _CAPIOC(3) /**************************************************************************** * Public Types @@ -67,6 +68,11 @@ struct cap_ops_s CODE int (*getfreq)(FAR struct cap_lowerhalf_s *lower, FAR uint32_t *freq); + + /* Get the result pwm capture edges value */ + + CODE int (*getedges)(FAR struct cap_lowerhalf_s *lower, + FAR uint32_t *edges); }; /* This structure provides the publicly visible representation of the