NFC API for mbed using the MicroNFCBoard as a peripheral

Dependents:   MicroNFCBoardAPI_P2P_Client MicroNFCBoardAPI_Blink MicroNFCBoardAPI_Tag_Emulator MicroNFCBoardAPI_Tag_Reader ... more

Committer:
AppNearMe
Date:
Thu May 14 16:41:27 2015 +0000
Revision:
2:9b0733b8fa95
Parent:
1:1d246e0872c6
https://github.com/AppNearMe/micronfcboard-mbed-peripheral/commit/ed5d798243e8eb6a959c756dbcdfdad4c6e59979

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AppNearMe 1:1d246e0872c6 1 /*
AppNearMe 1:1d246e0872c6 2 MicroNFCBoard mbed API
AppNearMe 1:1d246e0872c6 3
AppNearMe 1:1d246e0872c6 4 Copyright (c) 2014-2015 AppNearMe Ltd
AppNearMe 1:1d246e0872c6 5
AppNearMe 1:1d246e0872c6 6 Licensed under the Apache License, Version 2.0 (the "License");
AppNearMe 1:1d246e0872c6 7 you may not use this file except in compliance with the License.
AppNearMe 1:1d246e0872c6 8 You may obtain a copy of the License at
AppNearMe 1:1d246e0872c6 9
AppNearMe 1:1d246e0872c6 10 http://www.apache.org/licenses/LICENSE-2.0
AppNearMe 1:1d246e0872c6 11
AppNearMe 1:1d246e0872c6 12 Unless required by applicable law or agreed to in writing, software
AppNearMe 1:1d246e0872c6 13 distributed under the License is distributed on an "AS IS" BASIS,
AppNearMe 1:1d246e0872c6 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
AppNearMe 1:1d246e0872c6 15 See the License for the specific language governing permissions and
AppNearMe 1:1d246e0872c6 16 limitations under the License.
AppNearMe 0:07fa9c0dd549 17 */
AppNearMe 2:9b0733b8fa95 18
AppNearMe 0:07fa9c0dd549 19 #ifndef SRC_TRANSPORT_H_
AppNearMe 0:07fa9c0dd549 20 #define SRC_TRANSPORT_H_
AppNearMe 0:07fa9c0dd549 21
AppNearMe 0:07fa9c0dd549 22 #include "mbed.h"
AppNearMe 0:07fa9c0dd549 23 #include <cstddef>
AppNearMe 0:07fa9c0dd549 24
AppNearMe 0:07fa9c0dd549 25 class Transport
AppNearMe 0:07fa9c0dd549 26 {
AppNearMe 0:07fa9c0dd549 27 public:
AppNearMe 0:07fa9c0dd549 28 Transport(PinName mosi, PinName miso, PinName sck, PinName cs, PinName irq);
AppNearMe 0:07fa9c0dd549 29
AppNearMe 0:07fa9c0dd549 30 void init();
AppNearMe 0:07fa9c0dd549 31
AppNearMe 0:07fa9c0dd549 32 void reset();
AppNearMe 0:07fa9c0dd549 33
AppNearMe 0:07fa9c0dd549 34 bool statusChanged();
AppNearMe 0:07fa9c0dd549 35
AppNearMe 0:07fa9c0dd549 36 uint32_t status();
AppNearMe 0:07fa9c0dd549 37
AppNearMe 2:9b0733b8fa95 38 void nfcPoll(bool readerWriter, bool emulator, bool p2p);
AppNearMe 0:07fa9c0dd549 39
AppNearMe 0:07fa9c0dd549 40 void nfcOperation(bool readOp, bool writeOp);
AppNearMe 0:07fa9c0dd549 41
AppNearMe 0:07fa9c0dd549 42 void nfcGetInfoIsoA(uint8_t* atqa, uint8_t* sak, uint8_t* uid, size_t* pUidLength);
AppNearMe 0:07fa9c0dd549 43
AppNearMe 0:07fa9c0dd549 44 void nfcGetMessageInfo(size_t* pRecordCount);
AppNearMe 0:07fa9c0dd549 45
AppNearMe 0:07fa9c0dd549 46 void nfcSetMessageInfo(size_t recordCount);
AppNearMe 0:07fa9c0dd549 47
AppNearMe 0:07fa9c0dd549 48 void nfcGetRecordInfo(size_t recordNumber, uint16_t* pType, uint16_t* info, size_t infoCount);
AppNearMe 0:07fa9c0dd549 49
AppNearMe 2:9b0733b8fa95 50 void nfcSetRecordInfo(size_t recordNumber, uint16_t type, const uint16_t* info, size_t infoCount);
AppNearMe 0:07fa9c0dd549 51
AppNearMe 0:07fa9c0dd549 52 void nfcGetRecordData(size_t recordNumber, size_t item, size_t offset, uint8_t* data, size_t length);
AppNearMe 0:07fa9c0dd549 53
AppNearMe 2:9b0733b8fa95 54 void nfcSetRecordData(size_t recordNumber, size_t item, size_t offset, const uint8_t* data, size_t length);
AppNearMe 0:07fa9c0dd549 55
AppNearMe 0:07fa9c0dd549 56 void nfcPrepareMessage(bool lock, bool generate);
AppNearMe 0:07fa9c0dd549 57
AppNearMe 0:07fa9c0dd549 58 void nfcDecodePrefix(uint8_t prefix, char* data, size_t* pDataLength);
AppNearMe 0:07fa9c0dd549 59
AppNearMe 2:9b0733b8fa95 60 void nfcEncodePrefix(uint8_t* pPrefix, const char* data, size_t* pDataLength);
AppNearMe 0:07fa9c0dd549 61
AppNearMe 0:07fa9c0dd549 62 void leds(bool led1, bool led2);
AppNearMe 0:07fa9c0dd549 63
AppNearMe 0:07fa9c0dd549 64 protected:
AppNearMe 0:07fa9c0dd549 65 enum CommandError
AppNearMe 0:07fa9c0dd549 66 {
AppNearMe 0:07fa9c0dd549 67 OK = 0,
AppNearMe 0:07fa9c0dd549 68 ERR_LENGTH = 1,
AppNearMe 0:07fa9c0dd549 69 ERR_EMPTY = 2,
AppNearMe 0:07fa9c0dd549 70 ERR_UNKNOWN_COMMAND = 3,
AppNearMe 0:07fa9c0dd549 71 ERR_TIMEOUT = 4,
AppNearMe 0:07fa9c0dd549 72 ERR_PARAMS = 5,
AppNearMe 0:07fa9c0dd549 73 ERR_STATUS = 6,
AppNearMe 0:07fa9c0dd549 74 };
AppNearMe 0:07fa9c0dd549 75
AppNearMe 0:07fa9c0dd549 76 enum CommandCode
AppNearMe 0:07fa9c0dd549 77 {
AppNearMe 0:07fa9c0dd549 78 GET_STATUS = 0,
AppNearMe 0:07fa9c0dd549 79 INFO = 1,
AppNearMe 0:07fa9c0dd549 80 RESET = 2,
AppNearMe 0:07fa9c0dd549 81 LEDS = 3,
AppNearMe 0:07fa9c0dd549 82 NFC_POLL = 4,
AppNearMe 0:07fa9c0dd549 83 NFC_OPERATION = 5,
AppNearMe 0:07fa9c0dd549 84 NFC_GET_INFO = 6,
AppNearMe 0:07fa9c0dd549 85 NFC_GET_MESSAGE_INFO = 7,
AppNearMe 0:07fa9c0dd549 86 NFC_GET_RECORD_INFO = 8,
AppNearMe 0:07fa9c0dd549 87 NFC_GET_RECORD_DATA = 9,
AppNearMe 0:07fa9c0dd549 88 NFC_SET_MESSAGE_INFO = 10,
AppNearMe 0:07fa9c0dd549 89 NFC_SET_RECORD_INFO = 11,
AppNearMe 0:07fa9c0dd549 90 NFC_SET_RECORD_DATA = 12,
AppNearMe 0:07fa9c0dd549 91 NFC_PREPARE_MESSAGE = 13,
AppNearMe 0:07fa9c0dd549 92 NFC_DECODE_PREFIX = 14,
AppNearMe 0:07fa9c0dd549 93 NFC_ENCODE_PREFIX = 15
AppNearMe 0:07fa9c0dd549 94 };
AppNearMe 0:07fa9c0dd549 95
AppNearMe 0:07fa9c0dd549 96 CommandError command(CommandCode command, uint8_t* outBuf, size_t outLength, uint8_t* inBuf, size_t inLength);
AppNearMe 0:07fa9c0dd549 97
AppNearMe 0:07fa9c0dd549 98 private:
AppNearMe 0:07fa9c0dd549 99 DigitalOut _cs;
AppNearMe 0:07fa9c0dd549 100 SPI _spi;
AppNearMe 0:07fa9c0dd549 101 DigitalIn _int;
AppNearMe 0:07fa9c0dd549 102 };
AppNearMe 0:07fa9c0dd549 103
AppNearMe 0:07fa9c0dd549 104
AppNearMe 0:07fa9c0dd549 105
AppNearMe 0:07fa9c0dd549 106 #endif /* SRC_TRANSPORT_H_ */