forked from ATrappmann/PN5180-Library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PN5180ISO15693.h
69 lines (59 loc) · 2.4 KB
/
PN5180ISO15693.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// NAME: PN5180ISO15693.h
//
// DESC: ISO15693 protocol on NXP Semiconductors PN5180 module for Arduino.
//
// Copyright (c) 2018 by Andreas Trappmann. All rights reserved.
//
// This file is part of the PN5180 library for the Arduino environment.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
#ifndef PN5180ISO15693_H
#define PN5180ISO15693_H
#include "PN5180.h"
enum ISO15693ErrorCode {
EC_NO_CARD = -1,
ISO15693_EC_OK = 0,
ISO15693_EC_NOT_SUPPORTED = 0x01,
ISO15693_EC_NOT_RECOGNIZED = 0x02,
ISO15693_EC_OPTION_NOT_SUPPORTED = 0x03,
ISO15693_EC_UNKNOWN_ERROR = 0x0f,
ISO15693_EC_BLOCK_NOT_AVAILABLE = 0x10,
ISO15693_EC_BLOCK_ALREADY_LOCKED = 0x11,
ISO15693_EC_BLOCK_IS_LOCKED = 0x12,
ISO15693_EC_BLOCK_NOT_PROGRAMMED = 0x13,
ISO15693_EC_BLOCK_NOT_LOCKED = 0x14,
ISO15693_EC_CUSTOM_CMD_ERROR = 0xA0
};
class PN5180ISO15693 : public PN5180 {
public:
PN5180ISO15693(uint8_t SSpin, uint8_t BUSYpin, uint8_t RSTpin);
private:
ISO15693ErrorCode issueISO15693Command(uint8_t *cmd, uint8_t cmdLen, uint8_t **resultPtr);
public:
ISO15693ErrorCode getInventory(uint8_t *uid);
ISO15693ErrorCode readSingleBlock(uint8_t *uid, uint8_t blockNo, uint8_t *blockData, uint8_t blockSize);
ISO15693ErrorCode writeSingleBlock(uint8_t *uid, uint8_t blockNo, uint8_t *blockData, uint8_t blockSize);
ISO15693ErrorCode getSystemInfo(uint8_t *uid, uint8_t *blockSize, uint8_t *numBlocks);
// ICODE SLIX2 specific commands, see https://www.nxp.com/docs/en/data-sheet/SL2S2602.pdf
ISO15693ErrorCode getRandomNumber(uint8_t *randomData);
ISO15693ErrorCode setPassword(uint8_t *password, uint8_t *random);
ISO15693ErrorCode enablePrivacy(uint8_t *password, uint8_t *random);
ISO15693ErrorCode unlockICODESLIX2(uint8_t *password);
ISO15693ErrorCode lockICODESLIX2(uint8_t *password);
/*
* Helper functions
*/
public:
bool setupRF();
const __FlashStringHelper *strerror(ISO15693ErrorCode errno);
};
#endif /* PN5180ISO15693_H */