fix mfrc522
This commit is contained in:
parent
d4048f3eeb
commit
1d1affdd2b
@ -51,6 +51,7 @@
|
|||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/drivers/contactless.h>
|
#include <nuttx/drivers/contactless.h>
|
||||||
|
#include <nuttx/contactless/mfrc522.h>
|
||||||
|
|
||||||
#include "mfrc522.h"
|
#include "mfrc522.h"
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/contactless/contactless.h>
|
#include <nuttx/drivers/contactless.h>
|
||||||
|
|
||||||
#include "pn532.h"
|
#include "pn532.h"
|
||||||
|
|
||||||
|
116
include/nuttx/contactless/mfrc522.h
Normal file
116
include/nuttx/contactless/mfrc522.h
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* 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 __INCLUDE_NUTTX_WIRELESS_MFRC522_H
|
||||||
|
#define __INCLUDE_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 _CLIOC_USER(0x0001)
|
||||||
|
#define MFRC522IOC_GET_STATE _CLIOC_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 /* __INCLUDE_NUTTX_WIRELESS_MFRC522_H */
|
@ -58,7 +58,7 @@
|
|||||||
* commands, beginning with this value:
|
* commands, beginning with this value:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define CLIOC_USER 0x0001 /* Lowest, unused CL ioctl command */
|
#define CLIOC_USER 0x0003 /* Lowest, unused CL ioctl command */
|
||||||
|
|
||||||
#define _CLIOC_USER(nr) _CLIOC(nr + CLIOC_USER)
|
#define _CLIOC_USER(nr) _CLIOC(nr + CLIOC_USER)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user