mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-16 22:38:41 +08:00
STM32 ADC driver update
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4211 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -149,8 +149,6 @@ int MAIN_NAME(int argc, char *argv[])
|
|||||||
* ADC samples.
|
* ADC samples.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
message(MAIN_STRING "Entering the main loop\n");
|
|
||||||
|
|
||||||
#if defined(CONFIG_NSH_BUILTIN_APPS)
|
#if defined(CONFIG_NSH_BUILTIN_APPS)
|
||||||
for (; nsamples > 0; nsamples--)
|
for (; nsamples > 0; nsamples--)
|
||||||
#elif defined(CONFIG_EXAMPLES_ADC_NSAMPLES)
|
#elif defined(CONFIG_EXAMPLES_ADC_NSAMPLES)
|
||||||
@@ -186,21 +184,29 @@ int MAIN_NAME(int argc, char *argv[])
|
|||||||
|
|
||||||
message(MAIN_STRING "Interrupted read...\n");
|
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",
|
message(MAIN_STRING "No data read, Ignoring\n");
|
||||||
nbytes, readsize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print the sample data on successful return */
|
/* Print the sample data on successful return */
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
message("Sample :\n");
|
int nsamples = nbytes / sizeof(struct adc_msg_s);
|
||||||
for (i = 0; i < CONFIG_EXAMPLES_ADC_GROUPSIZE; i++)
|
if (nsamples * sizeof(struct adc_msg_s) != nbytes)
|
||||||
{
|
{
|
||||||
message("%d: channel: %d value: %d\n",
|
message(MAIN_STRING "read size=%d is not a multiple of sample size=%d, Ignoring\n",
|
||||||
i, sample[i].am_channel, sample[i].am_data);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user