diff --git a/examples/qencoder/Kconfig b/examples/qencoder/Kconfig index 8afd9443e..fca26f426 100644 --- a/examples/qencoder/Kconfig +++ b/examples/qencoder/Kconfig @@ -33,4 +33,13 @@ config EXAMPLES_QENCODER_DELAY If CONFIG_NSH_BUILTIN_APPS is defined, then this value is the default delay if no other delay is provided on the command line. +config EXAMPLES_QENCODER_HAVE_MAXPOS + bool "Enable the maximum encoder position" + default n + +config EXAMPLES_QENCODER_MAXPOS + int "Maximum encoder position" + default 0 + depends on EXAMPLES_QENCODER_HAVE_MAXPOS + endif diff --git a/examples/qencoder/qe_main.c b/examples/qencoder/qe_main.c index 84c9ba125..eb23b5b3c 100644 --- a/examples/qencoder/qe_main.c +++ b/examples/qencoder/qe_main.c @@ -45,6 +45,12 @@ * Pre-processor Definitions ****************************************************************************/ +#ifdef CONFIG_EXAMPLES_QENCODER_HAVE_MAXPOS +# if CONFIG_EXAMPLES_QENCODER_MAXPOS == 0 +# error CONFIG_EXAMPLES_QENCODER_MAXPOS not specified +# endif +#endif + /**************************************************************************** * Private Types ****************************************************************************/ @@ -245,6 +251,19 @@ int main(int argc, FAR char *argv[]) goto errout; } +#ifdef CONFIG_EXAMPLES_QENCODER_HAVE_MAXPOS + /* Set the maximum encoder positions */ + + ret = ioctl(fd, QEIOC_SETPOSMAX, + (unsigned long)CONFIG_EXAMPLES_QENCODER_MAXPOS); + if (ret < 0) + { + printf("qe_main: ioctl(QEIOC_SETMAXPOS) failed: %d\n", errno); + exitval = EXIT_FAILURE; + goto errout_with_dev; + } +#endif + /* Reset the count if so requested */ if (g_qeexample.reset)