ongoing Development Project for interfacing a BM019 Module with nrf51-dk, acting as a nfc 2 ble bridge. Base project for opensource blueReader Device
Dependencies: BLE_API mbed nRF51822
bm019.h
00001 00002 #ifndef BM019_H 00003 #define BM019_H 00004 00005 #include "log.h" 00006 #include "mbed.h" 00007 00008 #define BM019_MOSI p4 00009 #define BM019_MISO p3 00010 #define BM019_CLK p5 00011 00012 #define BM019_CS p2 00013 #define BM019_IRQ p1 00014 00015 #define BM019_MAX_RX 512 00016 #define BM019_READY_TIMEOUT 50 /* 0 for endless waiting else ms to wait */ 00017 00018 enum BM019_PROTOCOL_ISO_IEC_15693_BYTE_0 { 00019 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_0_NO_CRC = 0x00, 00020 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_0_CRC = 0x01, 00021 00022 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_1_SINGLE_SUBCARRIER = 0x00, 00023 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_1_DUAL_SUBCARRIER = 0x02, 00024 00025 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_2_100_MODULATION = 0x00, 00026 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_2_10_MODULATION = 0x04, 00027 00028 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_3_RESPECT_312U_DELAY = 0x00, 00029 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_3_WAIT_FOR_SOF = 0x08, 00030 00031 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_45_26_KBPS = 0x00, 00032 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_45_52_KBPS = 0x10, 00033 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_45_6_KBPS = 0x20 00034 }; 00035 00036 enum BM019_CODES { 00037 EFrameRecvOK = 0x80, // Frame correctly received (additionally see CRC/Parity information) 00038 EUserStop = 0x85, // Stopped by user (used only in Card mode) 00039 ECommError = 0x86, // Hardware communication error 00040 EFrameWaitTOut = 0x87, // Frame wait time out (no valid reception) 00041 EInvalidSof = 0x88, // Invalid SOF 00042 EBufOverflow = 0x89, // Too many bytes received and data still arriving 00043 EFramingError = 0x8A, // if start bit = 1 or stop bit = 0 00044 EEgtError = 0x8B, // EGT time out 00045 EInvalidLen = 0x8C, // Valid for ISO/IEC 18092, if Length <3 00046 ECrcError = 0x8D, // CRC error, Valid only for ISO/IEC 18092 00047 ERecvLost = 0x8E, // When reception is lost without EOF received (or subcarrier was lost) 00048 ENoField = 0x8F, // When Listen command detects the absence of external field 00049 EUnintByte = 0x90, //Residual bits in last byte. Useful for ACK/NAK reception of ISO/IEC 14443 Type A. 00050 }; 00051 00052 enum BM019_STATE { 00053 BM019_STATE_UNKNOWN = 0, //intial condition 00054 BM019_STATE_ANSWERING = 1, //if any communiaction has been successful 00055 BM019_STATE_PROTOCOL = 2, //a protocol (other then off) has been set 00056 00057 }; 00058 00059 extern BM019_STATE stateBM019; 00060 00061 struct BM019_IDN 00062 { 00063 char deviceID[13]; 00064 char romCRC[2]; 00065 }; 00066 00067 struct BM019_TAG { 00068 uint8_t crc[2]; 00069 uint8_t uid[8]; 00070 }; 00071 00072 BM019_STATE getStateBM019(); 00073 00074 bool initBM019(); 00075 00076 bool resetBM019(); 00077 bool wakeBM019(int timeout = BM019_READY_TIMEOUT); 00078 bool hybernateBM019(); 00079 00080 bool idnBM019(BM019_IDN *idn); 00081 00082 bool setProtocolOFF(); 00083 bool setProtocolISO_EIC_15693BM019(BM019_PROTOCOL_ISO_IEC_15693_BYTE_0 configuration); 00084 00085 bool echoBM019(int timeout = BM019_READY_TIMEOUT, bool log = true); 00086 00087 bool inventoryISO_IES_15693BM019(BM019_TAG *tag, int timeout = BM019_READY_TIMEOUT); 00088 00089 int readBM019(uint8_t adr, uint8_t *buf, int len, int timeout = BM019_READY_TIMEOUT); 00090 int readMultiBM019(uint8_t adr, int count, uint8_t *buf, int len, int timeout = BM019_READY_TIMEOUT); 00091 #endif /* BM019_H */
Generated on Sun Jul 17 2022 04:39:52 by 1.7.2