STM32 ADC driver update

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4211 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo
2011-12-22 00:31:47 +00:00
parent fbd1db66e1
commit 59f355daeb
8 changed files with 90 additions and 68 deletions
+15 -9
View File
@@ -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("%d: channel: %d value: %d\n",
i, sample[i].am_channel, sample[i].am_data);
message(MAIN_STRING "read size=%d is not a multiple of sample size=%d, Ignoring\n",
nbytes, sizeof(struct adc_msg_s));
}
else
{
message("Sample: ");
for (i = 0; i < nsamples ; i++)
{
message("%d: channel: %d value: %d\n",
i, sample[i].am_channel, sample[i].am_data);
}
}
}
}