ongoing Development Project for interfacing a BM019 Module with nrf51-based ble, acting as a nfc 2 ble bridge. Base project for opensource blueReader Device

Dependencies:   BLE_API mbed nRF51822

Committer:
SandraK
Date:
Fri Apr 22 06:06:15 2016 +0000
Revision:
0:6bb3a59b5028
initial commit of uart based bm019 firmware

Who changed what in which revision?

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