examples/qencoder: add an option to configure the encoder maximum position
Signed-off-by: raiden00pl <raiden00@railab.me>
This commit is contained in:
parent
b8fd862965
commit
4fa7248036
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user