You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/12/09 18:00:50 UTC

[incubator-nuttx-apps] 01/02: timer_gpout example: use /dev/gpioN instead of /dev/gpoutN

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/incubator-nuttx-apps.git

commit 128996fb5f76a6c677587eed6fd68db64f12b4a0
Author: Jari van Ewijk <ja...@nxp.com>
AuthorDate: Thu Dec 9 14:44:28 2021 +0100

    timer_gpout example: use /dev/gpioN instead of /dev/gpoutN
---
 examples/README.md                      |  4 ++--
 examples/timer_gpout/Kconfig            |  6 +++---
 examples/timer_gpout/timer_gpout_main.c | 28 ++++++++++++++--------------
 3 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/examples/README.md b/examples/README.md
index c2b2c28..8293abf 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -1740,8 +1740,8 @@ Example configuration:
 
 - `EXAMPLES_TIMER_GPOUT_TIM_DEVNAME` – This is the name of the timer device that will be used.
    Default: `/dev/timer0`.
-- `EXAMPLES_TIMER_GPOUT_GPOUT_DEVNAME` – This is the name of the gpout device that will be used.
-  Default: `/dev/gpout0`.
+- `EXAMPLES_TIMER_GPOUT_GPIO_DEVNAME` – This is the name of the gpout device that will be used.
+  Default: `/dev/gpio0`.
 - `EXAMPLES_TIMER_GPOUT_INTERVAL` – This is the timer interval in microseconds.
   Default: `1000000`.
 - `EXAMPLES_TIMER_GPOUT_SIGNO` – This is the signal number that is used to notify that a timer
diff --git a/examples/timer_gpout/Kconfig b/examples/timer_gpout/Kconfig
index ff7eb26..69946a4 100644
--- a/examples/timer_gpout/Kconfig
+++ b/examples/timer_gpout/Kconfig
@@ -27,11 +27,11 @@ config EXAMPLES_TIMER_GPOUT_TIM_DEVNAME
 	---help---
 		This is the name of the timer device that will be used.
 
-config EXAMPLES_TIMER_GPOUT_GPOUT_DEVNAME
+config EXAMPLES_TIMER_GPOUT_GPIO_DEVNAME
 	string "GPOUT device name"
-	default "/dev/gpout0"
+	default "/dev/gpio0"
 	---help---
-		This is the name of the gpout device that will be used.
+		This is the name of the gpio device that will be used.
 
 config EXAMPLES_TIMER_GPOUT_INTERVAL
 	int "Timer interval (microseconds)"
diff --git a/examples/timer_gpout/timer_gpout_main.c b/examples/timer_gpout/timer_gpout_main.c
index 7a64975..1af30da 100644
--- a/examples/timer_gpout/timer_gpout_main.c
+++ b/examples/timer_gpout/timer_gpout_main.c
@@ -38,7 +38,7 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-#define DEVNAME_SIZE 16
+#define DEVNAME_SIZE 32
 
 /****************************************************************************
  * Private Types
@@ -49,7 +49,7 @@
  ****************************************************************************/
 
 static char g_devtim[DEVNAME_SIZE];
-static char g_devgpout[DEVNAME_SIZE];
+static char g_devgpio[DEVNAME_SIZE];
 static bool g_timer_gpout_daemon_started = false;
 
 /****************************************************************************
@@ -104,7 +104,7 @@ static int timer_gpout_daemon(int argc, char *argv[])
   sigset_t set;
   struct siginfo value;
   int fd_timer;
-  int fd_gpout;
+  int fd_gpio;
   int ret;
   bool state = false;
 
@@ -128,14 +128,14 @@ static int timer_gpout_daemon(int argc, char *argv[])
 
   /* Open the GPIO driver */
 
-  printf("Open %s\n", g_devgpout);
+  printf("Open %s\n", g_devgpio);
 
-  fd_gpout = open(g_devgpout, O_RDWR);
-  if (fd_gpout < 0)
+  fd_gpio = open(g_devgpio, O_RDWR);
+  if (fd_gpio < 0)
     {
       int errcode = errno;
       printf("timer_gpout_daemon: Failed to open %s: %d\n",
-              g_devgpout, errcode);
+              g_devgpio, errcode);
       close(fd_timer);
       return EXIT_FAILURE;
     }
@@ -214,26 +214,26 @@ static int timer_gpout_daemon(int argc, char *argv[])
           goto errout;
         }
 
-      /* Change the gpout state */
+      /* Change the gpio state */
 
       state = !state;
 
       /* Write the pin value */
 
-      ret = ioctl(fd_gpout, GPIOC_WRITE, (unsigned long)state);
+      ret = ioctl(fd_gpio, GPIOC_WRITE, (unsigned long)state);
       if (ret < 0)
         {
           int errcode = errno;
           printf("timer_gpout_daemon: Failed to write value"
                  " %u from %s: %d\n",
-                (unsigned int)state, g_devgpout, errcode);
+                (unsigned int)state, g_devgpio, errcode);
           goto errout;
         }
     }
 
 errout:
   close(fd_timer);
-  close(fd_gpout);
+  close(fd_gpio);
   g_timer_gpout_daemon_started = false;
 
   printf("timer_gpout_daemon: Terminating!\n");
@@ -264,7 +264,7 @@ int main(int argc, FAR char *argv[])
   /* Use the ones configured on menuconfig */
 
   strcpy(g_devtim, CONFIG_EXAMPLES_TIMER_GPOUT_TIM_DEVNAME);
-  strcpy(g_devgpout, CONFIG_EXAMPLES_TIMER_GPOUT_GPOUT_DEVNAME);
+  strcpy(g_devgpio, CONFIG_EXAMPLES_TIMER_GPOUT_GPIO_DEVNAME);
 
   /* Or the ones passed as arguments */
 
@@ -276,13 +276,13 @@ int main(int argc, FAR char *argv[])
             strcpy(g_devtim, optarg);
             break;
         case 'g':
-            strcpy(g_devgpout, optarg);
+            strcpy(g_devgpio, optarg);
             break;
         case ':':
             fprintf(stderr, "ERROR: Option needs a value\n");
             exit(EXIT_FAILURE);
         default: /* '?' */
-            fprintf(stderr, "Usage: %s [-d /dev/timerx] [-d /dev/gpoutx]\n",
+            fprintf(stderr, "Usage: %s [-d /dev/timerx] [-d /dev/gpiox]\n",
                     argv[0]);
             exit(EXIT_FAILURE);
       }