This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 39d053ef7 apps/examples: Add test of edges counting at capture
39d053ef7 is described below

commit 39d053ef74f32a5cc11ba0f8f4d64faab1036ac9
Author: zhangkai25 <zhangka...@xiaomi.com>
AuthorDate: Thu Apr 25 14:16:44 2024 +0800

    apps/examples: Add test of edges counting at capture
    
    Description: Add test of the function of counting cap edges
    
    Signed-off-by: zhangkai25 <zhangka...@xiaomi.com>
---
 examples/capture/cap_main.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/examples/capture/cap_main.c b/examples/capture/cap_main.c
index d584dad03..f8a47cda5 100644
--- a/examples/capture/cap_main.c
+++ b/examples/capture/cap_main.c
@@ -213,6 +213,7 @@ int main(int argc, FAR char *argv[])
 {
   int8_t dutycycle;
   int32_t frequence;
+  int32_t edges;
   int fd;
   int exitval = EXIT_SUCCESS;
   int ret;
@@ -290,6 +291,24 @@ int main(int argc, FAR char *argv[])
           printf("pwm frequence: %"PRId32" Hz \n", frequence);
         }
 
+      /* Get the edges data using the ioctl */
+
+      ret = ioctl(fd, CAPIOC_EDGES,
+                  (unsigned long)((uintptr_t)&edges));
+      if (ret < 0)
+        {
+          printf("cap_main: ioctl(CAPIOC_EDGES) failed: %d\n", errno);
+          exitval = EXIT_FAILURE;
+          goto errout_with_dev;
+        }
+
+      /* Print the sample data on successful return */
+
+      else
+        {
+          printf("pwm edges counting: %"PRId32" \n", edges);
+        }
+
       /* Delay a little bit */
 
       usleep(g_capexample.delay * 1000);

Reply via email to