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