summaryrefslogtreecommitdiff
path: root/apps/examples/adc/adc_main.c
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-10-25 14:17:29 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-10-25 14:17:29 -0600
commit1038145bb042e8cd252595e5fe18d132349cb26d (patch)
tree4449af8ae383b860fb7afd5d0667bdd1598a96de /apps/examples/adc/adc_main.c
parent451eff8c4797c5d452e20464fe32f992bdad4c5d (diff)
downloadnuttx-1038145bb042e8cd252595e5fe18d132349cb26d.tar.gz
nuttx-1038145bb042e8cd252595e5fe18d132349cb26d.tar.bz2
nuttx-1038145bb042e8cd252595e5fe18d132349cb26d.zip
apps/examples/adc: Add support for software triggering
Diffstat (limited to 'apps/examples/adc/adc_main.c')
-rw-r--r--apps/examples/adc/adc_main.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/apps/examples/adc/adc_main.c b/apps/examples/adc/adc_main.c
index 553658fee..b0ed43897 100644
--- a/apps/examples/adc/adc_main.c
+++ b/apps/examples/adc/adc_main.c
@@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <sys/types.h>
+#include <sys/ioctl.h>
#include <stdio.h>
#include <stdlib.h>
@@ -310,7 +311,18 @@ int adc_main(int argc, char *argv[])
msgflush();
- /* Read CONFIG_EXAMPLES_ADC_GROUPSIZE samples */
+#ifdef CONFIG_EXAMPLES_ADC_SWTRIG
+ /* Issue the software trigger to start ADC conversion */
+
+ ret = ioctl(fd, ANIOC_TRIGGER, 0);
+ if (ret < 0)
+ {
+ int errcode = errno;
+ message("adc_main: ANIOC_TRIGGER ioctl failed: %d\n", errcode);
+ }
+#endif
+
+ /* Read up to CONFIG_EXAMPLES_ADC_GROUPSIZE samples */
readsize = CONFIG_EXAMPLES_ADC_GROUPSIZE * sizeof(struct adc_msg_s);
nbytes = read(fd, sample, readsize);
@@ -351,7 +363,7 @@ int adc_main(int argc, char *argv[])
for (i = 0; i < nsamples ; i++)
{
message("%d: channel: %d value: %d\n",
- i, sample[i].am_channel, sample[i].am_data);
+ i+1, sample[i].am_channel, sample[i].am_data);
}
}
}