summaryrefslogtreecommitdiff
path: root/apps/examples/adc
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-12-22 00:31:47 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-12-22 00:31:47 +0000
commit0ef224f0edcdc24a123dd2f229256dac3a38c277 (patch)
treed0dc01b41249de6a68c5631669aa60b514cee23f /apps/examples/adc
parent80f67779e93a19f4ead282f5fff0bd070ba93de8 (diff)
downloadnuttx-0ef224f0edcdc24a123dd2f229256dac3a38c277.tar.gz
nuttx-0ef224f0edcdc24a123dd2f229256dac3a38c277.tar.bz2
nuttx-0ef224f0edcdc24a123dd2f229256dac3a38c277.zip
STM32 ADC driver update
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4211 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/examples/adc')
-rw-r--r--apps/examples/adc/adc_main.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/apps/examples/adc/adc_main.c b/apps/examples/adc/adc_main.c
index f0876bb60..2d5414410 100644
--- a/apps/examples/adc/adc_main.c
+++ b/apps/examples/adc/adc_main.c
@@ -149,8 +149,6 @@ int MAIN_NAME(int argc, char *argv[])
* ADC samples.
*/
- message(MAIN_STRING "Entering the main loop\n");
-
#if defined(CONFIG_NSH_BUILTIN_APPS)
for (; nsamples > 0; nsamples--)
#elif defined(CONFIG_EXAMPLES_ADC_NSAMPLES)
@@ -186,21 +184,29 @@ int MAIN_NAME(int argc, char *argv[])
message(MAIN_STRING "Interrupted read...\n");
}
- else if (nbytes != readsize)
+ else if (nbytes == 0)
{
- message(MAIN_STRING "Unexpected read size=%d, expected=%d, Ignoring\n",
- nbytes, readsize);
+ message(MAIN_STRING "No data read, Ignoring\n");
}
/* Print the sample data on successful return */
else
{
- message("Sample :\n");
- for (i = 0; i < CONFIG_EXAMPLES_ADC_GROUPSIZE; i++)
+ int nsamples = nbytes / sizeof(struct adc_msg_s);
+ if (nsamples * sizeof(struct adc_msg_s) != nbytes)
+ {
+ message(MAIN_STRING "read size=%d is not a multiple of sample size=%d, Ignoring\n",
+ nbytes, sizeof(struct adc_msg_s));
+ }
+ else
{
- message("%d: channel: %d value: %d\n",
- i, sample[i].am_channel, sample[i].am_data);
+ message("Sample: ");
+ for (i = 0; i < nsamples ; i++)
+ {
+ message("%d: channel: %d value: %d\n",
+ i, sample[i].am_channel, sample[i].am_data);
+ }
}
}
}