Add ioctl to support software triggering of ADC/DAC conversions

This commit is contained in:
Gregory Nutt 2013-10-25 14:19:09 -06:00
parent b3afc8bd75
commit f39467339e
4 changed files with 49 additions and 9 deletions

View File

@ -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).

17
TODO
View File

@ -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/)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -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)
{
struct sam_adc_s *priv = (struct sam_adc_s *)dev->ad_priv;
int ret = OK;
avdbg("cmd=%d arg=%ld\n", cmd, arg);
/* No ioctl commands supported:
*
* REVISIT: Need to implement a ioctl to support software triggering
*/
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;
}
/****************************************************************************

View File

@ -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)