summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-10-25 14:19:09 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-10-25 14:19:09 -0600
commit55810f06f49bae6146eb18f7199fc39c04ebf87b (patch)
tree3c546f0337bbe273585f364fd2f0be2a60033394
parent1038145bb042e8cd252595e5fe18d132349cb26d (diff)
downloadnuttx-55810f06f49bae6146eb18f7199fc39c04ebf87b.tar.gz
nuttx-55810f06f49bae6146eb18f7199fc39c04ebf87b.tar.bz2
nuttx-55810f06f49bae6146eb18f7199fc39c04ebf87b.zip
Add ioctl to support software triggering of ADC/DAC conversions
-rw-r--r--nuttx/ChangeLog3
-rw-r--r--nuttx/TODO17
-rw-r--r--nuttx/arch/arm/src/sama5/sam_adc.c27
-rw-r--r--nuttx/include/nuttx/fs/ioctl.h11
4 files changed, 49 insertions, 9 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 2e1c0b830..1aeb41e3f 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -5879,4 +5879,7 @@
(2013-10-24).
* configs/sama5d3x-ek/src/sam_adc.c: Integrate support for the
apps/examples/adc into the SAMA5D3x-EK configuration (2013-10-24).
+ * include/nuttx/fs/ioctl.h and arch/arm/src/sama5/sam_adc.c: Add
+ and ioctl command that can be used to trigger ADC/DAC conversion
+ (2015-10-25).
diff --git a/nuttx/TODO b/nuttx/TODO
index 4736b88b3..c94130875 100644
--- a/nuttx/TODO
+++ b/nuttx/TODO
@@ -18,7 +18,7 @@ nuttx/
(16) Network (net/, drivers/net)
(4) USB (drivers/usbdev, drivers/usbhost)
(11) Libraries (libc/, )
- (10) File system/Generic drivers (fs/, drivers/)
+ (11) File system/Generic drivers (fs/, drivers/)
(5) Graphics subystem (graphics/)
(1) Pascal add-on (pcode/)
(1) Documentation (Documentation/)
@@ -1163,6 +1163,21 @@ o File system / Generic drivers (fs/, drivers/)
Priority: Low. Nothing is broken. This is an enhancement that would
improve the OS design and possible reduce some FLASH usage
+ Title: UNIFIED DESCRIPTOR REPRESENTATION
+ Descripton: There are two separate ranges of descriptors for file and
+ socket descriptors: if a descriptor is in one range then it is
+ recognized as a file descriptor; if it is in another range
+ then it is recognized as a socket descriptor. These separate
+ descriptor ranges can cause problems, for example, they makes
+ dup'ing descriptors with dup2() problematic. The two groups
+ of descriptors are really indices into two separate tables:
+ On an array of file structures and the other an array of
+ socket structures. There really should be one array that
+ is a union of file and socket descriptors. Then socket and
+ file decriptors could lie in the same range.
+ Status: Open
+ Priority: Low
+
o Graphics subystem (graphics/)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/nuttx/arch/arm/src/sama5/sam_adc.c b/nuttx/arch/arm/src/sama5/sam_adc.c
index cd7ca45fe..5af5f0d4e 100644
--- a/nuttx/arch/arm/src/sama5/sam_adc.c
+++ b/nuttx/arch/arm/src/sama5/sam_adc.c
@@ -50,6 +50,8 @@
#include <nuttx/config.h>
#include <sys/types.h>
+#include <sys/ioctl.h>
+
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
@@ -1081,18 +1083,29 @@ static void sam_adc_rxint(struct adc_dev_s *dev, bool enable)
static int sam_adc_ioctl(struct adc_dev_s *dev, int cmd, unsigned long arg)
{
- avdbg("cmd=%d arg=%ld\n", cmd, arg);
+ struct sam_adc_s *priv = (struct sam_adc_s *)dev->ad_priv;
+ int ret = OK;
- /* No ioctl commands supported:
- *
- * REVISIT: Need to implement a ioctl to support software triggering
- */
+ avdbg("cmd=%d arg=%ld\n", cmd, arg);
+ switch (cmd)
+ {
#ifdef CONFIG_SAMA5_ADC_SWTRIG
-# error Need an ioctl to perform software triggering
+ case ANIOC_TRIGGER: /* Software trigger */
+ {
+ sam_adc_putreg(priv, SAM_ADC_CR, ADC_CR_START); /* Start conversion */
+ }
+ break;
#endif
- return -ENOTTY;
+ /* Unsupported or invalid command */
+
+ default:
+ ret = -ENOTTY;
+ break;
+ }
+
+ return ret;
}
/****************************************************************************
diff --git a/nuttx/include/nuttx/fs/ioctl.h b/nuttx/include/nuttx/fs/ioctl.h
index 852113a4c..5c2fbb67b 100644
--- a/nuttx/include/nuttx/fs/ioctl.h
+++ b/nuttx/include/nuttx/fs/ioctl.h
@@ -219,7 +219,16 @@
#define _SNIOCVALID(c) (_IOC_TYPE(c)==_SNIOCBASE)
#define _SNIOC(nr) _IOC(_SNIOCBASE,nr)
-/* NuttX PWM ioctl definitions (see nuttx/pwm.h) ***************************/
+/* Nuttx Analog (DAC/ADC_ ioctl commands ************************************/
+
+#define _ANIOCVALID(c) (_IOC_TYPE(c)==_ANIOCBASE)
+#define _ANIOC(nr) _IOC(_ANIOCBASE,nr)
+
+#define ANIOC_TRIGGER _ANIOC(0x0001) /* Trigger one conversion
+ * IN: None
+ * OUT: None */
+
+/* NuttX PWM ioctl definitions (see nuttx/pwm.h) ****************************/
#define _PWMIOCVALID(c) (_IOC_TYPE(c)==_PWMIOCBASE)
#define _PWMIOC(nr) _IOC(_PWMIOCBASE,nr)