nfc-types.h

Go to the documentation of this file.
00001 
00024 #ifndef __NFC_TYPES_H__
00025 #define __NFC_TYPES_H__
00026 
00033 #include <stddef.h>
00034 #include <stdint.h>
00035 #include <stdbool.h>
00036 #include <stdio.h>
00037 
00038 typedef uint8_t byte_t;
00039 
00040 typedef enum {
00041   NC_PN531                    = 0x10,
00042   NC_PN532                    = 0x20,
00043   NC_PN533                    = 0x30,
00044 } nfc_chip_t;
00045 
00046 struct driver_callbacks;                // Prototype the callback struct
00047 
00048 typedef void*               nfc_device_spec_t; // Device connection specification
00049 
00050 #define DEVICE_NAME_LENGTH  256
00051 
00055 typedef struct {
00057   const struct driver_callbacks* pdc;
00059   char acName[DEVICE_NAME_LENGTH];
00061   nfc_chip_t nc;
00063  nfc_device_spec_t nds;
00065   bool bActive;
00067   bool bCrc;
00069   bool bPar;
00071   uint8_t ui8TxBits;
00072 } nfc_device_t;
00073 
00074 
00081 typedef struct {
00083   char acDevice[DEVICE_NAME_LENGTH];
00085   char* pcDriver;
00087   char* pcPort;
00089   uint32_t uiSpeed;
00091   uint32_t uiBusIndex;
00092 } nfc_device_desc_t;
00093 
00098 struct driver_callbacks {
00100   const char* acDriver;
00102   nfc_device_desc_t *(*pick_device)(void);
00104   bool (*list_devices)(nfc_device_desc_t pnddDevices[], size_t szDevices, size_t *pszDeviceFound);
00106   nfc_device_t* (*connect)(const nfc_device_desc_t* pndd);
00108   bool (*transceive)(const nfc_device_spec_t nds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen);
00110   void (*disconnect)(nfc_device_t* pnd);
00111 };
00112 
00113 // Compiler directive, set struct alignment to 1 byte_t for compatibility
00114 #pragma pack(1)
00115 
00120 typedef enum {
00122   NDO_HANDLE_CRC              = 0x00,
00124   NDO_HANDLE_PARITY           = 0x01,
00126   NDO_ACTIVATE_FIELD          = 0x10,
00128   NDO_ACTIVATE_CRYPTO1        = 0x11,
00130   NDO_INFINITE_SELECT         = 0x20,
00132   NDO_ACCEPT_INVALID_FRAMES   = 0x30,
00134   NDO_ACCEPT_MULTIPLE_FRAMES  = 0x31
00135 } nfc_device_option_t;
00136 
00138 // nfc_reader_list_passive - using InListPassiveTarget 
00139 
00144 typedef enum {
00146   NM_ISO14443A_106  = 0x00,
00148   NM_FELICA_212     = 0x01,
00150   NM_FELICA_424     = 0x02,
00152   NM_ISO14443B_106  = 0x03,
00154   NM_JEWEL_106      = 0x04,
00156   NM_ACTIVE_DEP = 0x05,
00158   NM_PASSIVE_DEP = 0x06
00159 } nfc_modulation_t;
00160 
00165 typedef struct {
00166   byte_t NFCID3i[10];
00167   byte_t btDID;
00168   byte_t btBSt;
00169   byte_t btBRt;
00170 } nfc_dep_info_t;
00171 
00176 typedef struct {
00177   byte_t abtAtqa[2];
00178   byte_t btSak;
00179   size_t szUidLen;
00180   byte_t abtUid[10];
00181   size_t szAtsLen;
00182   byte_t abtAts[36];
00183 } nfc_iso14443a_info_t;
00184 
00189 typedef struct {
00190   size_t szLen;
00191   byte_t btResCode;
00192   byte_t abtId[8];
00193   byte_t abtPad[8];
00194   byte_t abtSysCode[2];
00195 } nfc_felica_info_t;
00196 
00201 typedef struct {
00202   byte_t abtAtqb[12];
00203   byte_t abtId[4];
00204   byte_t btParam1;
00205   byte_t btParam2;
00206   byte_t btParam3;
00207   byte_t btParam4;
00208   byte_t btCid;
00209   size_t szInfLen;
00210   byte_t abtInf[64];
00211 } nfc_iso14443b_info_t;
00212 
00217 typedef struct {
00218   byte_t btSensRes[2];
00219   byte_t btId[4];
00220 } nfc_jewel_info_t;
00221 
00226 typedef union {
00227   nfc_iso14443a_info_t nai;
00228   nfc_felica_info_t nfi;
00229   nfc_iso14443b_info_t nbi;
00230   nfc_jewel_info_t nji;
00231   nfc_dep_info_t ndi;
00232 } nfc_target_info_t;
00233 
00235 // InDataExchange, MIFARE Classic card 
00236 
00237 typedef enum {
00238   MC_AUTH_A         = 0x60,
00239   MC_AUTH_B         = 0x61,
00240   MC_READ           = 0x30,
00241   MC_WRITE          = 0xA0,
00242   MC_TRANSFER       = 0xB0,
00243   MC_DECREMENT      = 0xC0,
00244   MC_INCREMENT      = 0xC1,
00245   MC_STORE          = 0xC2
00246 }mifare_cmd;
00247 
00248 // MIFARE Classic command params
00249 typedef struct {
00250   byte_t abtKey[6];
00251   byte_t abtUid[4];
00252 }mifare_param_auth;
00253 
00254 typedef struct {
00255   byte_t abtData[16];
00256 }mifare_param_data;
00257 
00258 typedef struct {
00259   byte_t abtValue[4];
00260 }mifare_param_value;
00261 
00262 typedef union {
00263   mifare_param_auth mpa;
00264   mifare_param_data mpd;
00265   mifare_param_value mpv;
00266 }mifare_param;
00267 
00268 // Reset struct alignment to default
00269 #pragma pack()
00270 
00271 #endif // _LIBNFC_TYPES_H_
Generated by  doxygen 1.6.2-20100208