11 #include "../Common.h" 14 #define ISO15693_ADDR_FLAGS 0x00 15 #define ISO15693_REQ_ADDR_CMD 0x01 16 #define ISO15693_REQ_ADDR_PARAM 0x02 18 #define ISO15693_RES_ADDR_PARAM 0x01 21 #define ISO15693_CMD_INVENTORY 0x01 22 #define ISO15693_CMD_STAY_QUIET 0x02 23 #define ISO15693_CMD_READ_SINGLE 0x20 24 #define ISO15693_CMD_WRITE_SINGLE 0x21 25 #define ISO15693_CMD_LOCK_BLOCK 0x22 26 #define ISO15693_CMD_READ_MULTIPLE 0x23 27 #define ISO15693_CMD_WRITE_MULTIPLE 0x24 28 #define ISO15693_CMD_SELECT 0x25 29 #define ISO15693_CMD_RESET_TO_READY 0x26 30 #define ISO15693_CMD_WRITE_AFI 0x27 31 #define ISO15693_CMD_LOCK_AFI 0x28 32 #define ISO15693_CMD_WRITE_DSFID 0x29 33 #define ISO15693_CMD_LOCK_DSFID 0x2A 34 #define ISO15693_CMD_GET_SYS_INFO 0x2B 35 #define ISO15693_CMD_GET_BLOCK_SEC 0x2C 37 #define ISO15693_REQ_FLAG_SUBCARRIER 0x01 38 #define ISO15693_REQ_FLAG_DATARATE 0x02 39 #define ISO15693_REQ_FLAG_INVENTORY 0x04 40 #define ISO15693_REQ_FLAG_PROT_EXT 0x08 41 #define ISO15693_REQ_FLAG_OPTION 0x40 42 #define ISO15693_REQ_FLAG_RFU 0x80 44 #define ISO15693_REQ_FLAG_SELECT 0x10 45 #define ISO15693_REQ_FLAG_ADDRESS 0x20 47 #define ISO15693_REQ_FLAG_AFI 0x10 48 #define ISO15693_REQ_FLAG_NB_SLOTS 0x20 50 #define ISO15693_RES_FLAG_NO_ERROR 0x00 51 #define ISO15693_RES_FLAG_ERROR 0x01 52 #define ISO15693_RES_FLAG_PROT_EXT 0x08 54 #define ISO15693_RES_ERR_NOT_SUPP 0x01 55 #define ISO15693_RES_ERR_NOT_REC 0x02 56 #define ISO15693_RES_ERR_OPT_NOT_SUPP 0x03 57 #define ISO15693_RES_ERR_GENERIC 0x0F 58 #define ISO15693_RES_ERR_BLK_NOT_AVL 0x10 59 #define ISO15693_RES_ERR_BLK_ALRD_LKD 0x11 60 #define ISO15693_RES_ERR_BLK_CHG_LKD 0x12 61 #define ISO15693_RES_ERR_BLK_NOT_PRGR 0x13 62 #define ISO15693_RES_ERR_BLK_NOT_LKD 0x14 64 #define ISO15693_RES_INVENTORY_DSFID 0x00 66 #define ISO15693_MIN_FRAME_SIZE 0x04 68 #define ISO15693_GENERIC_UID_SIZE 0x08 69 #define ISO15693_GENERIC_MEM_SIZE 8192 71 #define ISO15693_CRC16_SIZE 0x2 72 #define ISO15693_CRC16_POLYNORMAL 0x8408 73 #define ISO15693_CRC16_PRESET 0xFFFF 76 #define ISO15693_MASK_UNLOCKED ( 0 << 0 ) 77 #define ISO15693_MASK_USER_LOCK ( 1 << 0 ) 78 #define ISO15693_MASK_FACTORY_LOCK ( 1 << 1 ) 88 extern CurrentFrame FrameInfo;
91 extern uint16_t ResponseByteCount;
93 void ISO15693AppendCRC(uint8_t *FrameBuf, uint16_t FrameBufSize);
94 bool ISO15693CheckCRC(
void *FrameBuf, uint16_t FrameBufSize);
95 bool ISO15693PrepareFrame(uint8_t *FrameBuf, uint16_t FrameBytes, CurrentFrame *FrameStruct, uint8_t IsSelected, uint8_t *MyUid, uint8_t MyAFI);
96 bool ISO15693AntiColl(uint8_t *FrameBuf, uint16_t FrameBytes, CurrentFrame *FrameStruct, uint8_t *MyUid);
99 bool ISO15693CompareUid(uint8_t *Uid1, uint8_t *Uid2) {
100 if ((Uid1[0] == Uid2[7])
101 && (Uid1[1] == Uid2[6])
102 && (Uid1[2] == Uid2[5])
103 && (Uid1[3] == Uid2[4])
104 && (Uid1[4] == Uid2[3])
105 && (Uid1[5] == Uid2[2])
106 && (Uid1[6] == Uid2[1])
107 && (Uid1[7] == Uid2[0])) {
115 void ISO15693CopyUid(uint8_t *DstUid, uint8_t *SrcUid) {
116 DstUid[0] = SrcUid[7];
117 DstUid[1] = SrcUid[6];
118 DstUid[2] = SrcUid[5];
119 DstUid[3] = SrcUid[4];
120 DstUid[4] = SrcUid[3];
121 DstUid[5] = SrcUid[2];
122 DstUid[6] = SrcUid[1];
123 DstUid[7] = SrcUid[0];
127 bool ISO15693Addressed(uint8_t *Buffer) {
128 return (Buffer[ISO15693_ADDR_FLAGS] & ISO15693_REQ_FLAG_ADDRESS);
133 bool ISO15693AddressedLegacy(uint8_t *Buffer, uint8_t *MyUid) {
134 if (Buffer[0] & ISO15693_REQ_FLAG_ADDRESS) {
136 if (ISO15693CompareUid(&Buffer[2], MyUid)) {