AppNearMe µNFC stack for the NXP PN532 chip License: You can use the stack free of charge to prototype with mbed; if you want to use the stack with your commercial product, get in touch!

Dependents:   IOT_sensor_nfc AppNearMe_MuNFC_PN532_Test p2p_nfc_test NFCMoodLamp ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pn512_cmd.h Source File

pn512_cmd.h

00001 /*
00002   pn512_cmd.h
00003   Copyright (c) Donatien Garnier 2012
00004   donatien.garnier@appnearme.com
00005   http://www.appnearme.com/
00006 */
00007 
00008 #ifndef PN512_CMD_H_
00009 #define PN512_CMD_H_
00010 
00011 #ifdef __cplusplus
00012 extern "C" {
00013 #endif
00014 
00015 #include "core/fwk.h"
00016 
00017 #define PN512_CMD_IDLE        0x00 //No action, cancels current command execution
00018 #define PN512_CMD_MEM         0x01 //Stores 25 bytes into the internal buffer
00019 #define PN512_CMD_CONFIG      0x01 //Configures the PN512 for FeliCa, MIFARE and NFCIP-1 communication
00020 #define PN512_CMD_RNDIDG      0x02 //Generates a 10-byte random ID number
00021 #define PN512_CMD_CRC         0x03 //Activates the CRC coprocessor or performs a self test
00022 #define PN512_CMD_TRANSMIT    0x04 //Transmits data from the FIFO buffer
00023 #define PN512_CMD_NOCHANGE    0x07 //No command change
00024 #define PN512_CMD_RECEIVE     0x08 //Activates the receiver circuits
00025 #define PN512_CMD_TRANSCEIVE  0x0C //Transmits data from FIFO buffer to antenna and automatically activates the receiver after transmission
00026 #define PN512_CMD_AUTOCOLL    0x0D //Handles FeliCa polling (Card Operation mode only) and MIFARE anticollision (Card Operation mode only)
00027 #define PN512_CMD_MFAUTH      0x0E //Performs the MIFARE standard authentication as a reader
00028 #define PN512_CMD_SOFTRST     0x0F //Resets the PN512
00029 
00030 #define PN512_CMD_REG_MASK    0x0F
00031 
00032 void pn512_cmd_init(void);
00033 
00034 //Fifo read / write
00035 size_t pn512_fifo_write(uint8_t* buf, size_t len);
00036 size_t pn512_fifo_read(uint8_t* buf, size_t len);
00037 
00038 //Fifo clear
00039 void pn512_fifo_clear(void);
00040 
00041 //Fifo bytes read
00042 size_t pn512_fifo_space(void);
00043 size_t pn512_fifo_length(void);
00044 
00045 //Execute command
00046 void pn512_cmd_exec(uint8_t cmd);
00047 
00048 //Read executed command
00049 uint8_t pn512_cmd_get(void);
00050 
00051 //Sets xmit last byte bits
00052 void pn512_tx_set_last_byte_size(size_t bits);
00053 
00054 //Gets rcv last byte bits
00055 size_t pn512_rx_get_last_byte_size(void);
00056 
00057 #define PN512_TRANSCEIVE_TX 1
00058 #define PN512_TRANSCEIVE_RX 2
00059 //Start transceive
00060 int pn512_transceive(int option);
00061 
00062 int pn512_target_anticollision(void);
00063 
00064 #ifdef __cplusplus
00065 }
00066 #endif
00067 
00068 #endif /* PN512_CMD_H_ */