apps/examples/adc: Add support for software triggering
This commit is contained in:
parent
097a0952f0
commit
eb39b81b69
@ -697,4 +697,6 @@
|
|||||||
some kruft removal (2013-10-24).
|
some kruft removal (2013-10-24).
|
||||||
* apps/examples/can/can_main.c: Correct an error in a debug
|
* apps/examples/can/can_main.c: Correct an error in a debug
|
||||||
statement. From Martin Lederhilger (2013-10-24).
|
statement. From Martin Lederhilger (2013-10-24).
|
||||||
|
* apps/examples/adc: Add support so that a ADC driven by
|
||||||
|
software triggering can be tested (2013-10-25).
|
||||||
|
|
||||||
|
@ -34,4 +34,15 @@ config EXAMPLES_ADC_GROUPSIZE
|
|||||||
---help---
|
---help---
|
||||||
The number of samples to read at once. Default: 4
|
The number of samples to read at once. Default: 4
|
||||||
|
|
||||||
|
config EXAMPLES_ADC_SWTRIG
|
||||||
|
bool "Use software trigger"
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
Some ADCs may be configured so there is no automatic or periodic
|
||||||
|
conversion of samples. Rather, the ADC sampling must be trigger by
|
||||||
|
software via an ioctl command. Select this option only if
|
||||||
|
applicable for your ADC configuration. In this case, the test will
|
||||||
|
issue the software trigger ioctl before attempting to read from the
|
||||||
|
ADC.
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -310,7 +311,18 @@ int adc_main(int argc, char *argv[])
|
|||||||
|
|
||||||
msgflush();
|
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);
|
readsize = CONFIG_EXAMPLES_ADC_GROUPSIZE * sizeof(struct adc_msg_s);
|
||||||
nbytes = read(fd, sample, readsize);
|
nbytes = read(fd, sample, readsize);
|
||||||
@ -351,7 +363,7 @@ int adc_main(int argc, char *argv[])
|
|||||||
for (i = 0; i < nsamples ; i++)
|
for (i = 0; i < nsamples ; i++)
|
||||||
{
|
{
|
||||||
message("%d: channel: %d value: %d\n",
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user