diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-12-16 00:32:11 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-12-16 00:32:11 +0000 |
commit | df5aca04bdf127475b90bf6fdc246f402f039649 (patch) | |
tree | fa8d7ebc153e98273b925eb661c86da5c96e9519 /apps/examples/adc/adc.h | |
parent | fdaf3f62925632d5c98d019511acd22934653b0c (diff) | |
download | nuttx-df5aca04bdf127475b90bf6fdc246f402f039649.tar.gz nuttx-df5aca04bdf127475b90bf6fdc246f402f039649.tar.bz2 nuttx-df5aca04bdf127475b90bf6fdc246f402f039649.zip |
Updated STM32 ADC driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4189 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/examples/adc/adc.h')
-rwxr-xr-x | apps/examples/adc/adc.h | 57 |
1 files changed, 52 insertions, 5 deletions
diff --git a/apps/examples/adc/adc.h b/apps/examples/adc/adc.h index a8f225532..e6d9dd7bd 100755 --- a/apps/examples/adc/adc.h +++ b/apps/examples/adc/adc.h @@ -54,8 +54,10 @@ * and this value is ignored. Otherwise, this number of samples is * collected and the program terminates. Default: Samples are collected * indefinitely. - * CONFIG_EXAMPLES_ADC_SAMPLESIZE - The number of bytes to read in one sample. - * Default: 8 + * CONFIG_EXAMPLES_ADC_GROUPSIZE - The number of samples to read at once. + * Default: 4 + * CONFIG_EXAMPLES_ADC_SAMPLEWIDTH - The width (in bits) of the on ADC sample. + * Default: 16 */ #ifndef CONFIG_ADC @@ -66,10 +68,43 @@ # define CONFIG_EXAMPLES_ADC_DEVPATH "/dev/adc0" #endif -#ifndef CONFIG_EXAMPLES_ADC_SAMPLESIZE -# define CONFIG_EXAMPLES_ADC_SAMPLESIZE 8 +#ifndef CONFIG_EXAMPLES_ADC_GROUPSIZE +# define CONFIG_EXAMPLES_ADC_GROUPSIZE 4 #endif +#ifndef CONFIG_EXAMPLES_ADC_SAMPLEWIDTH +# define CONFIG_EXAMPLES_ADC_SAMPLEWIDTH 16 +#endif + +/* Sample characteristics ***************************************************/ + +#undef ADC_SAMPLE_BYTEWIDTH +#if CONFIG_EXAMPLES_ADC_SAMPLEWIDTH <= 8 +# undef CONFIG_EXAMPLES_ADC_SAMPLEWIDTH +# define CONFIG_EXAMPLES_ADC_SAMPLEWIDTH 8 +# define ADC_SAMPLE_BYTEWIDTH 1 +# define SAMPLE_FMT "%02x" +#elif CONFIG_EXAMPLES_ADC_SAMPLEWIDTH <= 16 +# undef CONFIG_EXAMPLES_ADC_SAMPLEWIDTH +# define CONFIG_EXAMPLES_ADC_SAMPLEWIDTH 16 +# define ADC_SAMPLE_BYTEWIDTH 2 +# define SAMPLE_FMT "%04x" +#elif CONFIG_EXAMPLES_ADC_SAMPLEWIDTH <= 24 +# undef CONFIG_EXAMPLES_ADC_SAMPLEWIDTH +# define CONFIG_EXAMPLES_ADC_SAMPLEWIDTH 24 +# define ADC_SAMPLE_BYTEWIDTH 3 +# define SAMPLE_FMT "%06x" +#elif CONFIG_EXAMPLES_ADC_SAMPLEWIDTH <= 32 +# undef CONFIG_EXAMPLES_ADC_SAMPLEWIDTH +# define CONFIG_EXAMPLES_ADC_SAMPLEWIDTH 32 +# define ADC_SAMPLE_BYTEWIDTH 4 +# define SAMPLE_FMT "%08x" +#else +# error "Unsupported sample width" +#endif + +#undef ADC_SAMPLE_SIZE (CONFIG_EXAMPLES_ADC_GROUPSIZE * ADC_SAMPLE_BYTEWIDTH) + /* Debug ********************************************************************/ #ifdef CONFIG_CPP_HAVE_VARARGS @@ -94,6 +129,18 @@ * Public Types ****************************************************************************/ +#if CONFIG_EXAMPLES_ADC_SAMPLEWIDTH == 8 +typedef uint8_t adc_sample_t; +#elif CONFIG_EXAMPLES_ADC_SAMPLEWIDTH == 16 +typedef uint16_t adc_sample_t; +#elif CONFIG_EXAMPLES_ADC_SAMPLEWIDTH == 24 +typedef uint32_t adc_sample_t; +#elif CONFIG_EXAMPLES_ADC_SAMPLEWIDTH == 32 +typedef uint32_t adc_sample_t; +#else +# error "Unsupported sample width" +#endif + /**************************************************************************** * Public Variables ****************************************************************************/ @@ -111,6 +158,6 @@ * ****************************************************************************/ -void adc_devinit(void); +int adc_devinit(void); #endif /* __APPS_EXAMPLES_ADC_ADC_H */ |