mirror of
https://github.com/apache/nuttx.git
synced 2026-06-08 01:42:58 +08:00
include/nuttx/analog: Add an ioctl.h header file to coordinate analogic driver IOCTL commands.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/sensors/ads1242.h
|
||||
* include/nuttx/analog/ads1242.h
|
||||
*
|
||||
* Copyright (C) 2016, DS-Automotion GmbH. All rights reserved.
|
||||
* Author: Alexander Entinger <a.entinger@ds-automotion.com>
|
||||
@@ -41,7 +41,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/analog/ioctl.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
|
||||
#if defined(CONFIG_SPI) && defined(CONFIG_ADC_ADS1242)
|
||||
@@ -59,12 +59,12 @@
|
||||
* Cmd: ANIOC_ADS2142_DO_SYSTEM_OFFSET_CALIB Arg: None
|
||||
*/
|
||||
|
||||
#define ANIOC_ADS2142_READ _ANIOC(ANIOC_USER + 0)
|
||||
#define ANIOC_ADS2142_SET_GAIN _ANIOC(ANIOC_USER + 1)
|
||||
#define ANIOC_ADS2142_SET_POSITIVE_INPUT _ANIOC(ANIOC_USER + 2)
|
||||
#define ANIOC_ADS2142_SET_NEGATIVE_INPUT _ANIOC(ANIOC_USER + 3)
|
||||
#define ANIOC_ADS2142_IS_DATA_READY _ANIOC(ANIOC_USER + 4)
|
||||
#define ANIOC_ADS2142_DO_SYSTEM_OFFSET_CALIB _ANIOC(ANIOC_USER + 5)
|
||||
#define ANIOC_ADS2142_READ _ANIOC(AN_ADS2142_FIRST + 0)
|
||||
#define ANIOC_ADS2142_SET_GAIN _ANIOC(AN_ADS2142_FIRST + 1)
|
||||
#define ANIOC_ADS2142_SET_POSITIVE_INPUT _ANIOC(AN_ADS2142_FIRST + 2)
|
||||
#define ANIOC_ADS2142_SET_NEGATIVE_INPUT _ANIOC(AN_ADS2142_FIRST + 3)
|
||||
#define ANIOC_ADS2142_IS_DATA_READY _ANIOC(AN_ADS2142_FIRST + 4)
|
||||
#define ANIOC_ADS2142_DO_SYSTEM_OFFSET_CALIB _ANIOC(AN_ADS2142_FIRST + 5)
|
||||
|
||||
/* ADS1242 REGISTER *********************************************************/
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/analog/ioctl.h
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_ANALOG_IOCTL_H
|
||||
#define __INCLUDE_NUTTX_ANALOG_IOCTL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* The analog driver sub-system uses the standard character driver framework.
|
||||
* However, since the driver is a devices control interface rather than a
|
||||
* data transfer interface, the majority of the functionality is implemented
|
||||
* in driver ioctl calls. Standard ioctl commands are listed below:
|
||||
*/
|
||||
|
||||
/* DAC/ADC */
|
||||
|
||||
#define ANIOC_TRIGGER _ANIOC(0x0001) /* Trigger one conversion
|
||||
* IN: None
|
||||
* OUT: None */
|
||||
|
||||
#define AN_FIRST 0x0001 /* First required command */
|
||||
#define AN_NCMDS 1 /* Two required commands */
|
||||
|
||||
/* User defined ioctl commands are also supported. These will be forwarded
|
||||
* by the upper-half QE driver to the lower-half QE driver via the ioctl()
|
||||
* method fo the QE lower-half interface. However, the lower-half driver
|
||||
* must reserve a block of commands as follows in order prevent IOCTL
|
||||
* command numbers from overlapping.
|
||||
*/
|
||||
|
||||
/* See include/nuttx/sensors/ads1242.h */
|
||||
|
||||
#define AN_ADS2142_FIRST (AN_FIRST + AN_NCMDS)
|
||||
#define AN_ADS2142_NCMDS 6
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_ANALOG_IOCTL_H */
|
||||
@@ -242,21 +242,16 @@
|
||||
#define _TSIOCVALID(c) (_IOC_TYPE(c)==_TSIOCBASE)
|
||||
#define _TSIOC(nr) _IOC(_TSIOCBASE,nr)
|
||||
|
||||
/* NuttX sensor ioctl definitions (see nuttx/sensor/xxx.h) ******************/
|
||||
/* NuttX sensor ioctl definitions (see nuttx/sensor/ioctl.h) ****************/
|
||||
|
||||
#define _SNIOCVALID(c) (_IOC_TYPE(c)==_SNIOCBASE)
|
||||
#define _SNIOC(nr) _IOC(_SNIOCBASE,nr)
|
||||
|
||||
/* Nuttx Analog (DAC/ADC_ ioctl commands ************************************/
|
||||
/* Nuttx Analog (DAC/ADC) ioctl commands (see nuttx/analog/ioctl.h **********/
|
||||
|
||||
#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 */
|
||||
#define ANIOC_USER 0x0002 /* Device specific IOCTL commands
|
||||
* may follow */
|
||||
/* NuttX PWM ioctl definitions (see nuttx/drivers/pwm.h) ********************/
|
||||
|
||||
#define _PWMIOCVALID(c) (_IOC_TYPE(c)==_PWMIOCBASE)
|
||||
|
||||
@@ -54,9 +54,9 @@
|
||||
|
||||
/* IOCTL Commands ***********************************************************/
|
||||
/* The Quadrature Encode module uses a standard character driver framework.
|
||||
* However, since the driver is a devices control interface and not a data
|
||||
* transfer interface, the majority of the functionality is implemented in
|
||||
* driver ioctl calls. The PWM ioctl commands are listed below:
|
||||
* However, since the driver is a device control interface rather than a
|
||||
* data transfer interface, the majority of the functionality is implemented
|
||||
* in driver ioctl calls. The PWM ioctl commands are listed below:
|
||||
*
|
||||
* QEIOC_POSITION - Get the current position from the encoder.
|
||||
* Argument: int32_t pointer to the location to return the position.
|
||||
|
||||
Reference in New Issue
Block a user