Change the way that contactless IOCTL commands are defined. All IOCTL commands must be unique.

This commit is contained in:
Gregory Nutt
2016-08-31 11:30:22 -06:00
parent 4b0e8e56cf
commit 7ea9632592
8 changed files with 117 additions and 108 deletions
+93
View File
@@ -0,0 +1,93 @@
/****************************************************************************
* include/wireless/ioclt.h
*
* Copyright(C) 2016 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_CONTACTLESS_IOCTL_H
#define __INCLUDE_NUTTX_CONTACTLESS_IOCTL_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/ioctl.h>
#include <nuttx/irq.h>
#include <nuttx/spi/spi.h>
#include <nuttx/contactless/ioctl.h>
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* MFRC522 IOCTL Commands ***************************************************/
#define MFRC522IOC_GET_PICC_UID _CLIOC(0x0001)
#define MFRC522IOC_GET_STATE _CLIOC(0x0002)
/* PN532 IOCTL Commands *****************************************************/
#define PN532IOC_SET_SAM_CONF _CLIOC(0x0003)
#define PN532IOC_READ_PASSIVE _CLIOC(0x0004)
#define PN532IOC_SET_RF_CONF _CLIOC(0x0005)
#define PN532IOC_SEND_CMD_READ_PASSIVE _CLIOC(0x0006)
#define PN532IOC_GET_DATA_READY _CLIOC(0x0007)
#define PN532IOC_GET_TAG_ID _CLIOC(0x0008)
#define PN532IOC_GET_STATE _CLIOC(0x0009)
#define PN532IOC_READ_TAG_DATA _CLIOC(0x000a)
#define PN532IOC_WRITE_TAG_DATA _CLIOC(0x000b)
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __INCLUDE_NUTTX_CONTACTLESS_IOCTL_H */
+7 -11
View File
@@ -33,18 +33,19 @@
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_WIRELESS_MFRC522_H
#define __INCLUDE_NUTTX_WIRELESS_MFRC522_H
#ifndef __INCLUDE_NUTTX_CONTACTLESS_MFRC522_H
#define __INCLUDE_NUTTX_CONTACTLESS_MFRC522_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/spi/spi.h>
#include <nuttx/irq.h>
#include <sys/ioctl.h>
#include <nuttx/wireless/wireless.h>
#include <nuttx/irq.h>
#include <nuttx/spi/spi.h>
#include <nuttx/contactless/ioctl.h>
/****************************************************************************
* Pre-Processor Definitions
@@ -52,11 +53,6 @@
#define MFRC522_MIFARE_ISO14443A (0x00)
/* IOCTL Commands ***********************************************************/
#define MFRC522IOC_GET_PICC_UID _CLIOC_USER(0x0001)
#define MFRC522IOC_GET_STATE _CLIOC_USER(0x0002)
/****************************************************************************
* Public Types
****************************************************************************/
@@ -113,4 +109,4 @@ int mfrc522_register(FAR const char *devpath, FAR struct spi_dev_s *spi);
}
#endif
#endif /* __INCLUDE_NUTTX_WIRELESS_MFRC522_H */
#endif /* __INCLUDE_NUTTX_CONTACTLESS_MFRC522_H */
+5 -16
View File
@@ -35,8 +35,8 @@
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_WIRELESS_PN532_H
#define __INCLUDE_NUTTX_WIRELESS_PN532_H
#ifndef __INCLUDE_NUTTX_CONTACTLESS_PN532_H
#define __INCLUDE_NUTTX_CONTACTLESS_PN532_H
/****************************************************************************
* Included Files
@@ -46,7 +46,8 @@
#include <nuttx/spi/spi.h>
#include <nuttx/irq.h>
#include <sys/ioctl.h>
#include <nuttx/drivers/contactless.h>
#include <nuttx/contactless/ioctl.h>
/****************************************************************************
* Pre-Processor Definitions
@@ -54,18 +55,6 @@
#define PN532_MIFARE_ISO14443A (0x00)
/* IOCTL Commands ***********************************************************/
#define PN532IOC_SET_SAM_CONF _CLIOC_USER(0x0001)
#define PN532IOC_READ_PASSIVE _CLIOC_USER(0x0002)
#define PN532IOC_SET_RF_CONF _CLIOC_USER(0x0003)
#define PN532IOC_SEND_CMD_READ_PASSIVE _CLIOC_USER(0x0004)
#define PN532IOC_GET_DATA_READY _CLIOC_USER(0x0005)
#define PN532IOC_GET_TAG_ID _CLIOC_USER(0x0006)
#define PN532IOC_GET_STATE _CLIOC_USER(0x0007)
#define PN532IOC_READ_TAG_DATA _CLIOC_USER(0x0008)
#define PN532IOC_WRITE_TAG_DATA _CLIOC_USER(0x0009)
/****************************************************************************
* Public Types
****************************************************************************/
@@ -162,4 +151,4 @@ int pn532_register(FAR const char *devpath, FAR struct spi_dev_s *spi,
}
#endif
#endif /* __INCLUDE_NUTTX_WIRELESS_PN532_H */
#endif /* __INCLUDE_NUTTX_CONTACTLESS_PN532_H */
-67
View File
@@ -1,67 +0,0 @@
/************************************************************************************
* include/nuttx/contactless/contactless.h
*
* Copyright (C) 2011-2013 Gregory Nutt. All rights reserved.
* Author: Laurent Latil <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.
*
************************************************************************************/
/* This file includes common definitions to be used in all contactless drivers
* (when applicable).
*/
#ifndef __INCLUDE_NUTTX_DRIVERS_CONTACTLESS_H
#define __INCLUDE_NUTTX_DRIVERS_CONTACTLESS_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <nuttx/fs/ioctl.h>
#ifdef CONFIG_DRIVERS_CONTACTLESS
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* IOCTL Commands *******************************************************************/
/* Contactless drivers can provide additional, device specific ioctl
* commands, beginning with this value:
*/
#define CLIOC_USER 0x000A /* Lowest, unused CL ioctl command */
#define _CLIOC_USER(nr) _CLIOC(nr + CLIOC_USER)
#endif
#endif /* __INCLUDE_NUTTX_CONTACTLESS_H */
+11 -11
View File
@@ -361,8 +361,8 @@
/* User LED driver ioctl definitions ****************************************/
/* (see nuttx/leds/usersled.h */
#define _ULEDIOCVALID(c) (_IOC_TYPE(c)==_ULEDBASE)
#define _ULEDIOC(nr) _IOC(_ULEDBASE,nr)
#define _ULEDIOCVALID(c) (_IOC_TYPE(c)==_ULEDBASE)
#define _ULEDIOC(nr) _IOC(_ULEDBASE,nr)
/* Zero Cross driver ioctl definitions **************************************/
/* (see nuttx/include/sensor/zerocross.h */
@@ -379,29 +379,29 @@
/* Modem driver ioctl definitions ********************************************/
/* see nuttx/include/modem/*.h */
#define _MODEMIOCVALID(c) (_IOC_TYPE(c)==_MODEMBASE)
#define _MODEMIOC(nr) _IOC(_MODEMBASE,nr)
#define _MODEMIOCVALID(c) (_IOC_TYPE(c)==_MODEMBASE)
#define _MODEMIOC(nr) _IOC(_MODEMBASE,nr)
/* I2C driver ioctl definitions **********************************************/
/* see nuttx/include/i2c/i2c_master.h */
#define _I2CIOCVALID(c) (_IOC_TYPE(c)==_I2CBASE)
#define _I2CIOC(nr) _IOC(_I2CBASE,nr)
#define _I2CIOCVALID(c) (_IOC_TYPE(c)==_I2CBASE)
#define _I2CIOC(nr) _IOC(_I2CBASE,nr)
/* SPI driver ioctl definitions **********************************************/
/* see nuttx/include/spi/spi_transfer.h */
#define _SPIIOCVALID(c) (_IOC_TYPE(c)==_SPIBASE)
#define _SPIIOC(nr) _IOC(_SPIBASE,nr)
#define _SPIIOCVALID(c) (_IOC_TYPE(c)==_SPIBASE)
#define _SPIIOC(nr) _IOC(_SPIBASE,nr)
/* GPIO driver command definitions ******************************************/
/* see nuttx/include/ioexpander/gpio.h */
#define _GPIOCVALID(c) (_IOC_TYPE(c)==_GPIOBASE)
#define _GPIOC(nr) _IOC(_GPIOBASE,nr)
#define _GPIOCVALID(c) (_IOC_TYPE(c)==_GPIOBASE)
#define _GPIOC(nr) _IOC(_GPIOBASE,nr)
/* Contactless driver ioctl definitions ****************************************/
/* (see nuttx/include/contactless/contactless.h */
/* (see nuttx/include/contactless/ioctl.h */
#define _CLIOCVALID(c) (_IOC_TYPE(c)==_CLIOCBASE)
#define _CLIOC(nr) _IOC(_CLIOCBASE,nr)