Skip to content
Snippets Groups Projects
Commit bfac90f7 authored by Alan Carvalho de Assis's avatar Alan Carvalho de Assis Committed by Gregory Nutt
Browse files

Add MFRC522 RFID ISO14443 and Mifare transceiver driver

parent 83c7b4d5
No related branches found
No related tags found
No related merge requests found
......@@ -73,6 +73,37 @@ 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
......
......@@ -55,6 +55,10 @@ 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
......
This diff is collapsed.
This diff is collapsed.
/****************************************************************************
* include/wireless/mfrc522.h
*
* Copyright(C) 2016 Uniquix Ltda. All rights reserved.
* Author: Alan Carvalho de Assis <acassis@gmail.com>
*
* 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 __NUTTX_WIRELESS_MFRC522_H
#define __NUTTX_WIRELESS_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>
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
#define MFRC522_MIFARE_ISO14443A (0x00)
/* IOCTL Commands ***********************************************************/
#define MFRC522IOC_GET_PICC_UID _WLIOC_USER(0x0001)
#define MFRC522IOC_GET_STATE _WLIOC_USER(0x0002)
/****************************************************************************
* Public Types
****************************************************************************/
enum mfrc522_state_E
{
MFRC522_STATE_NOT_INIT,
MFRC522_STATE_IDLE,
MFRC522_STATE_CMD_SENT,
MFRC522_STATE_DATA_READY,
};
struct mfrc522_dev_s;
struct picc_uid_s
{
uint8_t size; /* Number of bytes in the UID. 4, 7 or 10 */
uint8_t uid_data[10];
uint8_t sak; /* The SAK (Select Acknowledge) return by the PICC */
};
/****************************************************************************
* Public Functions
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Name: mfrc522_register
*
* Description:
* Register the MFRC522 character device as 'devpath'
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/rfid0"
* spi - An instance of the SPI interface to use to communicate with MFRC522
* config - Device persistent board data
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int mfrc522_register(FAR const char *devpath, FAR struct spi_dev_s *spi);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __NUTTX_WIRELESS_MFRC522_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment