diff options
Diffstat (limited to 'apps/examples/adc')
-rw-r--r-- | apps/examples/adc/Kconfig | 24 | ||||
-rw-r--r-- | apps/examples/adc/adc_main.c | 14 |
2 files changed, 35 insertions, 3 deletions
diff --git a/apps/examples/adc/Kconfig b/apps/examples/adc/Kconfig index b6dca047c..85c875deb 100644 --- a/apps/examples/adc/Kconfig +++ b/apps/examples/adc/Kconfig @@ -6,8 +6,32 @@ config EXAMPLES_ADC bool "ADC example" default n + depends on ADC ---help--- Enable the ADC example if EXAMPLES_ADC + +config EXAMPLES_ADC_DEVPATH + string "ADC device path" + default "/dev/adc0" + ---help--- + The default path to the ADC device. Default: /dev/adc0 + +config EXAMPLES_ADC_NSAMPLES + int "Number of Sample Groups" + default 0 + depends on !NSH_BUILTIN_APPS + ---help--- + If NSH_BUILTIN_APPS is defined, then the number of samples is provided + on the command line and this value is ignored. Otherwise, this number + of samples is collected and the program terminates. Default: 0 (samples + are collected indefinitely). + +config EXAMPLES_ADC_GROUPSIZE + int "Number of Samples per Group" + default 4 + ---help--- + The number of samples to read at once. Default: 4 + endif diff --git a/apps/examples/adc/adc_main.c b/apps/examples/adc/adc_main.c index 4797265db..404fba8c1 100644 --- a/apps/examples/adc/adc_main.c +++ b/apps/examples/adc/adc_main.c @@ -57,6 +57,14 @@ * Pre-processor Definitions ****************************************************************************/ +/* Use CONFIG_EXAMPLES_ADC_NSAMPLES == 0 to mean to collect samples + * indefinitely. + */ + +#ifndef CONFIG_EXAMPLES_ADC_NSAMPLES +# define CONFIG_EXAMPLES_ADC_NSAMPLES 0 +#endif + /**************************************************************************** * Private Types ****************************************************************************/ @@ -249,7 +257,7 @@ int adc_main(int argc, char *argv[]) adc_devpath(&g_adcstate, CONFIG_EXAMPLES_ADC_DEVPATH); -#ifdef CONFIG_EXAMPLES_ADC_NSAMPLES +#if CONFIG_EXAMPLES_ADC_NSAMPLES > 0 g_adcstate.count = CONFIG_EXAMPLES_ADC_NSAMPLES; #else g_adcstate.count = 1; @@ -267,7 +275,7 @@ int adc_main(int argc, char *argv[]) * samples that we collect before returning. Otherwise, we never return */ -#if defined(CONFIG_NSH_BUILTIN_APPS) || defined(CONFIG_EXAMPLES_ADC_NSAMPLES) +#if defined(CONFIG_NSH_BUILTIN_APPS) || CONFIG_EXAMPLES_ADC_NSAMPLES > 0 message("adc_main: g_adcstate.count: %d\n", g_adcstate.count); #endif @@ -290,7 +298,7 @@ int adc_main(int argc, char *argv[]) #if defined(CONFIG_NSH_BUILTIN_APPS) for (; g_adcstate.count > 0; g_adcstate.count--) -#elif defined(CONFIG_EXAMPLES_ADC_NSAMPLES) +#elif CONFIG_EXAMPLES_ADC_NSAMPLES > 0 for (g_adcstate.count = 0; g_adcstate.count < CONFIG_EXAMPLES_ADC_NSAMPLES; g_adcstate.count++) #else for (;;) |