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

Committer:
SandraK
Date:
Thu Apr 21 19:09:42 2016 +0000
Revision:
1:e4e03060b32f
Parent:
0:d156731c291b
added hearthbeat-mode for iOS

Who changed what in which revision?

UserRevisionLine numberNew contents of line
SandraK 0:d156731c291b 1
SandraK 0:d156731c291b 2 #ifndef BM019_H
SandraK 0:d156731c291b 3 #define BM019_H
SandraK 0:d156731c291b 4
SandraK 0:d156731c291b 5 #include "log.h"
SandraK 0:d156731c291b 6 #include "mbed.h"
SandraK 0:d156731c291b 7
SandraK 0:d156731c291b 8 #define BM019_MOSI p4
SandraK 0:d156731c291b 9 #define BM019_MISO p3
SandraK 0:d156731c291b 10 #define BM019_CLK p5
SandraK 0:d156731c291b 11
SandraK 0:d156731c291b 12 #define BM019_CS p2
SandraK 0:d156731c291b 13 #define BM019_IRQ p1
SandraK 0:d156731c291b 14
SandraK 0:d156731c291b 15 #define BM019_MAX_RX 512
SandraK 0:d156731c291b 16 #define BM019_READY_TIMEOUT 50 /* 0 for endless waiting else ms to wait */
SandraK 0:d156731c291b 17
SandraK 0:d156731c291b 18 enum BM019_PROTOCOL_ISO_IEC_15693_BYTE_0 {
SandraK 0:d156731c291b 19 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_0_NO_CRC = 0x00,
SandraK 0:d156731c291b 20 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_0_CRC = 0x01,
SandraK 0:d156731c291b 21
SandraK 0:d156731c291b 22 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_1_SINGLE_SUBCARRIER = 0x00,
SandraK 0:d156731c291b 23 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_1_DUAL_SUBCARRIER = 0x02,
SandraK 0:d156731c291b 24
SandraK 0:d156731c291b 25 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_2_100_MODULATION = 0x00,
SandraK 0:d156731c291b 26 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_2_10_MODULATION = 0x04,
SandraK 0:d156731c291b 27
SandraK 0:d156731c291b 28 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_3_RESPECT_312U_DELAY = 0x00,
SandraK 0:d156731c291b 29 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_3_WAIT_FOR_SOF = 0x08,
SandraK 0:d156731c291b 30
SandraK 0:d156731c291b 31 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_45_26_KBPS = 0x00,
SandraK 0:d156731c291b 32 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_45_52_KBPS = 0x10,
SandraK 0:d156731c291b 33 BM019_PROTOCOL_ISO_IEC_15693_BYTE_0_45_6_KBPS = 0x20
SandraK 0:d156731c291b 34 };
SandraK 0:d156731c291b 35
SandraK 0:d156731c291b 36 enum BM019_CODES {
SandraK 0:d156731c291b 37 EFrameRecvOK = 0x80, // Frame correctly received (additionally see CRC/Parity information)
SandraK 0:d156731c291b 38 EUserStop = 0x85, // Stopped by user (used only in Card mode)
SandraK 0:d156731c291b 39 ECommError = 0x86, // Hardware communication error
SandraK 0:d156731c291b 40 EFrameWaitTOut = 0x87, // Frame wait time out (no valid reception)
SandraK 0:d156731c291b 41 EInvalidSof = 0x88, // Invalid SOF
SandraK 0:d156731c291b 42 EBufOverflow = 0x89, // Too many bytes received and data still arriving
SandraK 0:d156731c291b 43 EFramingError = 0x8A, // if start bit = 1 or stop bit = 0
SandraK 0:d156731c291b 44 EEgtError = 0x8B, // EGT time out
SandraK 0:d156731c291b 45 EInvalidLen = 0x8C, // Valid for ISO/IEC 18092, if Length <3
SandraK 0:d156731c291b 46 ECrcError = 0x8D, // CRC error, Valid only for ISO/IEC 18092
SandraK 0:d156731c291b 47 ERecvLost = 0x8E, // When reception is lost without EOF received (or subcarrier was lost)
SandraK 0:d156731c291b 48 ENoField = 0x8F, // When Listen command detects the absence of external field
SandraK 0:d156731c291b 49 EUnintByte = 0x90, //Residual bits in last byte. Useful for ACK/NAK reception of ISO/IEC 14443 Type A.
SandraK 0:d156731c291b 50 };
SandraK 0:d156731c291b 51
SandraK 0:d156731c291b 52 enum BM019_STATE {
SandraK 0:d156731c291b 53 BM019_STATE_UNKNOWN = 0, //intial condition
SandraK 0:d156731c291b 54 BM019_STATE_ANSWERING = 1, //if any communiaction has been successful
SandraK 0:d156731c291b 55 BM019_STATE_PROTOCOL = 2, //a protocol (other then off) has been set
SandraK 0:d156731c291b 56
SandraK 0:d156731c291b 57 };
SandraK 0:d156731c291b 58
SandraK 0:d156731c291b 59 extern BM019_STATE stateBM019;
SandraK 0:d156731c291b 60
SandraK 0:d156731c291b 61 struct BM019_IDN
SandraK 0:d156731c291b 62 {
SandraK 0:d156731c291b 63 char deviceID[13];
SandraK 0:d156731c291b 64 char romCRC[2];
SandraK 0:d156731c291b 65 };
SandraK 0:d156731c291b 66
SandraK 0:d156731c291b 67 struct BM019_TAG {
SandraK 0:d156731c291b 68 uint8_t crc[2];
SandraK 0:d156731c291b 69 uint8_t uid[8];
SandraK 0:d156731c291b 70 };
SandraK 0:d156731c291b 71
SandraK 0:d156731c291b 72 BM019_STATE getStateBM019();
SandraK 0:d156731c291b 73
SandraK 0:d156731c291b 74 bool initBM019();
SandraK 0:d156731c291b 75
SandraK 0:d156731c291b 76 bool resetBM019();
SandraK 0:d156731c291b 77 bool wakeBM019(int timeout = BM019_READY_TIMEOUT);
SandraK 0:d156731c291b 78 bool hybernateBM019();
SandraK 0:d156731c291b 79
SandraK 0:d156731c291b 80 bool idnBM019(BM019_IDN *idn);
SandraK 0:d156731c291b 81
SandraK 0:d156731c291b 82 bool setProtocolOFF();
SandraK 0:d156731c291b 83 bool setProtocolISO_EIC_15693BM019(BM019_PROTOCOL_ISO_IEC_15693_BYTE_0 configuration);
SandraK 0:d156731c291b 84
SandraK 0:d156731c291b 85 bool echoBM019(int timeout = BM019_READY_TIMEOUT, bool log = true);
SandraK 0:d156731c291b 86
SandraK 0:d156731c291b 87 bool inventoryISO_IES_15693BM019(BM019_TAG *tag, int timeout = BM019_READY_TIMEOUT);
SandraK 0:d156731c291b 88
SandraK 0:d156731c291b 89 int readBM019(uint8_t adr, uint8_t *buf, int len, int timeout = BM019_READY_TIMEOUT);
SandraK 0:d156731c291b 90 int readMultiBM019(uint8_t adr, int count, uint8_t *buf, int len, int timeout = BM019_READY_TIMEOUT);
SandraK 0:d156731c291b 91 #endif /* BM019_H */