Merged in slorquet/nuttx/contactless (pull request #128)

Contactless
This commit is contained in:
Gregory Nutt 2016-08-31 07:07:23 -06:00
commit ebdd72dc53
16 changed files with 245 additions and 108 deletions

View File

@ -43,13 +43,13 @@
#include <debug.h>
#include <nuttx/spi/spi.h>
#include <nuttx/wireless/mfrc522.h>
#include <nuttx/contactless/mfrc522.h>
#include "stm32.h"
#include "stm32_spi.h"
#include "stm32f103_minimum.h"
#if defined(CONFIG_SPI) && defined(CONFIG_STM32_SPI1) && defined(CONFIG_WL_MFRC522)
#if defined(CONFIG_SPI) && defined(CONFIG_STM32_SPI1) && defined(CONFIG_CL_MFRC522)
/************************************************************************************
* Pre-processor Definitions

View File

@ -595,4 +595,13 @@ menuconfig DRIVERS_WIRELESS
Drivers for various wireless devices.
source drivers/wireless/Kconfig
menuconfig DRIVERS_CONTACTLESS
bool "Contactless Device Support"
default n
---help---
Drivers for various contactless devices.
source drivers/contactless/Kconfig
source drivers/syslog/Kconfig

View File

@ -76,6 +76,7 @@ include usbhost$(DELIM)Make.defs
include usbmonitor$(DELIM)Make.defs
include video$(DELIM)Make.defs
include wireless$(DELIM)Make.defs
include contactless$(DELIM)Make.defs
ifneq ($(CONFIG_NFILE_DESCRIPTORS),0)
CSRCS += dev_null.c dev_zero.c

View File

@ -0,0 +1,69 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
if DRIVERS_CONTACTLESS
config CL_MFRC522
bool "NXP MFRC522 ISO14443/Mifare Transceiver"
default n
select SPI
---help---
This options adds driver support for the MFRC522 ISO14443/Mifare chip.
if CL_MFRC522
config MFRC522_SPI_FREQ
int "SPI frequency for MFRC522"
default 1000000
depends on CL_MFRC522
config CL_MFRC522_DEBUG
bool "Enable MFRC522 debug"
default n
depends on CL_MFRC522
config CL_MFRC522_DEBUG_TX
bool "trace TX frames"
default n
depends on MFRC522_DEBUG
config CL_MFRC522_DEBUG_RX
bool "trace RX frames"
default n
depends on MFRC522_DEBUG
endif # CL_MFRC522
config CL_PN532
bool "pn532 NFC-chip support"
default n
select SPI
---help---
This options adds driver support for the PN532 NFC chip.
if CL_PN532
config PN532_SPI_FREQ
int "SPI frequency for PN532"
default 1000000
depends on CL_PN532
config CL_PN532_DEBUG
bool "Enable PN532 debug"
default n
depends on CL_PN532
config CL_PN532_DEBUG_TX
bool "trace TX frames"
default n
depends on CL_PN532_DEBUG
config CL_PN532_DEBUG_RX
bool "trace RX frames"
default n
depends on CL_PN532_DEBUG
endif # CL_PN532
endif # DRIVERS_CONTACTLESS

View File

@ -0,0 +1,53 @@
############################################################################
# drivers/contactless/Make.defs
#
# Copyright (C) 2011-2012, 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.
#
############################################################################
ifeq ($(CONFIG_DRIVERS_CONTACTLESS),y)
# Include contactless drivers
ifeq ($(CONFIG_CL_MFRC522),y)
CSRCS += mfrc522.c
endif
ifeq ($(CONFIG_CL_PN532),y)
CSRCS += pn532.c
endif
# Include contactless devices build support
DEPPATH += --dep-path contactless
VPATH += :contactless
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)drivers$(DELIM)contactless}
endif

View File

@ -1,5 +1,5 @@
/****************************************************************************
* drivers/wireless/mfrc522.c
* drivers/contactless/mfrc522.c
*
* Copyright(C) 2016 Uniquix Ltda. All rights reserved.
* Author: Alan Carvalho de Assis <acassis@gmail.com>
@ -50,7 +50,8 @@
#include <unistd.h>
#include <nuttx/kmalloc.h>
#include <nuttx/wireless/wireless.h>
#include <nuttx/drivers/contactless.h>
#include <nuttx/contactless/mfrc522.h>
#include "mfrc522.h"
@ -58,7 +59,7 @@
* Pre-processor Definitions
****************************************************************************/
#ifdef CONFIG_MFRC522_DEBUG
#ifdef CONFIG_CL_MFRC522_DEBUG
# define mfrc522err _err
# define mfrc522info _info
#else
@ -71,13 +72,13 @@
# endif
#endif
#ifdef CONFIG_MFRC522_DEBUG_TX
#ifdef CONFIG_CL_MFRC522_DEBUG_TX
# define tracetx errdumpbuffer
#else
# define tracetx(x...)
#endif
#ifdef CONFIG_MFRC522_DEBUG_RX
#ifdef CONFIG_CL_MFRC522_DEBUG_RX
# define tracerx errdumpbuffer
#else
# define tracerx(x...)
@ -173,12 +174,12 @@ static inline void mfrc522_configspi(FAR struct spi_dev_s *spi)
static inline void mfrc522_select(struct mfrc522_dev_s *dev)
{
SPI_SELECT(dev->spi, SPIDEV_WIRELESS, true);
SPI_SELECT(dev->spi, SPIDEV_CONTACTLESS, true);
}
static inline void mfrc522_deselect(struct mfrc522_dev_s *dev)
{
SPI_SELECT(dev->spi, SPIDEV_WIRELESS, false);
SPI_SELECT(dev->spi, SPIDEV_CONTACTLESS, false);
}
/****************************************************************************

View File

@ -1,5 +1,5 @@
/****************************************************************************
* drivers/wireless/mfrc522.h
* drivers/contactless/mfrc522.h
*
* Copyright(C) 2016 Uniquix Ltda. All rights reserved.
* Authors: Alan Carvalho de Assis <acassis@gmail.com>
@ -33,8 +33,8 @@
*
****************************************************************************/
#ifndef __DRIVERS_WIRELESS_MFRC522_H
#define __DRIVERS_WIRELESS_MFRC522_H 1
#ifndef __DRIVERS_CONTACTLESS_MFRC522_H
#define __DRIVERS_CONTACTLESS_MFRC522_H 1
/****************************************************************************
* Included Files
@ -46,7 +46,6 @@
#include <nuttx/spi/spi.h>
#include <nuttx/wqueue.h>
#include <nuttx/wireless/mfrc522.h>
/****************************************************************************
* Pre-Processor Definitions
@ -427,4 +426,4 @@ struct mfrc522_dev_s
bool mfrc522_set_config(struct mfrc522_dev_s *dev, uint8_t flags);
#endif /* __DRIVERS_WIRELESS_MFRC522_H */
#endif /* __DRIVERS_CONTACTLESS_MFRC522_H */

View File

@ -1,5 +1,5 @@
/****************************************************************************
* drivers/wireless/pn532.c
* drivers/contactless/pn532.c
*
* Copyright(C) 2012, 2013, 2016 Offcode Ltd. All rights reserved.
* Authors: Janne Rosberg <janne@offcode.fi>
@ -48,7 +48,7 @@
#include <unistd.h>
#include <nuttx/kmalloc.h>
#include <nuttx/wireless/wireless.h>
#include <nuttx/drivers/contactless.h>
#include "pn532.h"
@ -69,7 +69,7 @@
# warning This platform does not support SPI LSB-bit order
#endif
#ifdef CONFIG_WL_PN532_DEBUG
#ifdef CONFIG_CL_PN532_DEBUG
# define pn532err _err
# define pn532info _info
#else
@ -82,13 +82,13 @@
# endif
#endif
#ifdef CONFIG_WL_PN532_DEBUG_TX
#ifdef CONFIG_CL_PN532_DEBUG_TX
# define tracetx errdumpbuffer
#else
# define tracetx(x...)
#endif
#ifdef CONFIG_WL_PN532_DEBUG_RX
#ifdef CONFIG_CL_PN532_DEBUG_RX
# define tracerx errdumpbuffer
#else
# define tracerx(x...)
@ -202,7 +202,7 @@ static inline void pn532_select(struct pn532_dev_s *dev)
}
else
{
SPI_SELECT(dev->spi, SPIDEV_WIRELESS, true);
SPI_SELECT(dev->spi, SPIDEV_CONTACTLESS, true);
}
}
@ -214,7 +214,7 @@ static inline void pn532_deselect(struct pn532_dev_s *dev)
}
else
{
SPI_SELECT(dev->spi, SPIDEV_WIRELESS, false);
SPI_SELECT(dev->spi, SPIDEV_CONTACTLESS, false);
}
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* drivers/wireless/pn532.h
* drivers/contactless/pn532.h
*
* Copyright(C) 2012, 2013, 2016 Offcode Ltd. All rights reserved.
* Authors: Janne Rosberg <janne@offcode.fi>
@ -35,8 +35,8 @@
*
****************************************************************************/
#ifndef __DRIVERS_WIRELESS_PN532_H
#define __DRIVERS_WIRELESS_PN532_H 1
#ifndef __DRIVERS_CONTACTLESS_PN532_H
#define __DRIVERS_CONTACTLESS_PN532_H 1
/****************************************************************************
* Included Files
@ -48,7 +48,7 @@
#include <nuttx/spi/spi.h>
#include <nuttx/wqueue.h>
#include <nuttx/wireless/pn532.h>
#include <nuttx/contactless/pn532.h>
/****************************************************************************
* Pre-Processor Definitions
@ -168,4 +168,4 @@ struct pn532_dev_s
bool pn532_set_config(struct pn532_dev_s *dev, uint8_t flags);
#endif /* __DRIVERS_WIRELESS_PN532_H */
#endif /* __DRIVERS_CONTACTLESS_PN532_H */

View File

@ -72,66 +72,4 @@ config WL_NRF24L01_RXFIFO_LEN
endif # WL_NRF24L01_RXSUPPORT
endif # WL_NRF24L01
config WL_MFRC522
bool "NXP MFRC522 ISO14443/Mifare Transceiver"
default n
select SPI
---help---
This options adds driver support for the MFRC522 ISO14443/Mifare chip.
if WL_MFRC522
config MFRC522_SPI_FREQ
int "SPI frequency for MFRC522"
default 1000000
depends on WL_MFRC522
config MFRC522_DEBUG
bool "Enable MFRC522 debug"
default n
depends on WL_MFRC522
config MFRC522_DEBUG_TX
bool "trace TX frames"
default n
depends on MFRC522_DEBUG
config MFRC522_DEBUG_RX
bool "trace RX frames"
default n
depends on MFRC522_DEBUG
endif # WL_MFRC522
config WL_PN532
bool "pn532 NFC-chip support"
default n
select SPI
---help---
This options adds driver support for the PN532 NFC chip.
if WL_PN532
config PN532_SPI_FREQ
int "SPI frequency for PN532"
default 1000000
depends on WL_PN532
config WL_PN532_DEBUG
bool "Enable PN532 debug"
default n
depends on WL_PN532
config WL_PN532_DEBUG_TX
bool "trace TX frames"
default n
depends on WL_PN532_DEBUG
config WL_PN532_DEBUG_RX
bool "trace RX frames"
default n
depends on WL_PN532_DEBUG
endif # WL_PN532
endif # DRIVERS_WIRELESS

View File

@ -55,14 +55,6 @@ ifeq ($(CONFIG_WL_CC3000),y)
include wireless$(DELIM)cc3000$(DELIM)Make.defs
endif
ifeq ($(CONFIG_WL_MFRC522),y)
CSRCS += mfrc522.c
endif
ifeq ($(CONFIG_WL_PN532),y)
CSRCS += pn532.c
endif
# Include wireless devices build support
DEPPATH += --dep-path wireless

View File

@ -54,8 +54,8 @@
/* IOCTL Commands ***********************************************************/
#define MFRC522IOC_GET_PICC_UID _WLIOC_USER(0x0001)
#define MFRC522IOC_GET_STATE _WLIOC_USER(0x0002)
#define MFRC522IOC_GET_PICC_UID _CLIOC_USER(0x0001)
#define MFRC522IOC_GET_STATE _CLIOC_USER(0x0002)
/****************************************************************************
* Public Types

View File

@ -46,7 +46,7 @@
#include <nuttx/spi/spi.h>
#include <nuttx/irq.h>
#include <sys/ioctl.h>
#include <nuttx/wireless/wireless.h>
#include <nuttx/drivers/contactless.h>
/****************************************************************************
* Pre-Processor Definitions
@ -56,15 +56,15 @@
/* IOCTL Commands ***********************************************************/
#define PN532IOC_SET_SAM_CONF _WLIOC_USER(0x0001)
#define PN532IOC_READ_PASSIVE _WLIOC_USER(0x0002)
#define PN532IOC_SET_RF_CONF _WLIOC_USER(0x0003)
#define PN532IOC_SEND_CMD_READ_PASSIVE _WLIOC_USER(0x0004)
#define PN532IOC_GET_DATA_READY _WLIOC_USER(0x0005)
#define PN532IOC_GET_TAG_ID _WLIOC_USER(0x0006)
#define PN532IOC_GET_STATE _WLIOC_USER(0x0007)
#define PN532IOC_READ_TAG_DATA _WLIOC_USER(0x0008)
#define PN532IOC_WRITE_TAG_DATA _WLIOC_USER(0x0009)
#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

View File

@ -0,0 +1,67 @@
/************************************************************************************
* 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 */

View File

@ -85,6 +85,7 @@
#define _I2CBASE (0x2000) /* I2C driver commands */
#define _SPIBASE (0x2100) /* SPI driver commands */
#define _GPIOBASE (0x2200) /* GPIO driver commands */
#define _CLIOCBASE (0x1200) /* Contactless modules ioctl commands */
/* boardctl() commands share the same number space */
@ -399,6 +400,12 @@
#define _GPIOCVALID(c) (_IOC_TYPE(c)==_GPIOBASE)
#define _GPIOC(nr) _IOC(_GPIOBASE,nr)
/* Contactless driver ioctl definitions ****************************************/
/* (see nuttx/include/contactless/contactless.h */
#define _CLIOCVALID(c) (_IOC_TYPE(c)==_CLIOCBASE)
#define _CLIOC(nr) _IOC(_CLIOCBASE,nr)
/* boardctl() command definitions *******************************************/
#define _BOARDIOCVALID(c) (_IOC_TYPE(c)==_BOARDBASE)

View File

@ -451,6 +451,7 @@ enum spi_dev_e
SPIDEV_BAROMETER, /* Select SPI Pressure/Barometer device */
SPIDEV_TEMPERATURE, /* Select SPI Temperature sensor device */
SPIDEV_IEEE802154, /* Select SPI IEEE 802.15.4 wireless device */
SPIDEV_CONTACTLESS, /* Select SPI Contactless device */
SPIDEV_USER /* Board-specific values start here */
};