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:
Fri Apr 24 12:57:23 2015 +0000
Revision:
0:07fa9c0dd549
Child:
1:1d246e0872c6
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AppNearMe 0:07fa9c0dd549 1 /**
AppNearMe 0:07fa9c0dd549 2 * \file transport.h
AppNearMe 0:07fa9c0dd549 3 * \copyright Copyright (c) AppNearMe Ltd 2015
AppNearMe 0:07fa9c0dd549 4 * \author Donatien Garnier
AppNearMe 0:07fa9c0dd549 5 */
AppNearMe 0:07fa9c0dd549 6 #ifndef SRC_TRANSPORT_H_
AppNearMe 0:07fa9c0dd549 7 #define SRC_TRANSPORT_H_
AppNearMe 0:07fa9c0dd549 8
AppNearMe 0:07fa9c0dd549 9 #include "mbed.h"
AppNearMe 0:07fa9c0dd549 10 #include <cstddef>
AppNearMe 0:07fa9c0dd549 11
AppNearMe 0:07fa9c0dd549 12 class Transport
AppNearMe 0:07fa9c0dd549 13 {
AppNearMe 0:07fa9c0dd549 14 public:
AppNearMe 0:07fa9c0dd549 15 Transport(PinName mosi, PinName miso, PinName sck, PinName cs, PinName irq);
AppNearMe 0:07fa9c0dd549 16
AppNearMe 0:07fa9c0dd549 17 void init();
AppNearMe 0:07fa9c0dd549 18
AppNearMe 0:07fa9c0dd549 19 void reset();
AppNearMe 0:07fa9c0dd549 20
AppNearMe 0:07fa9c0dd549 21 bool statusChanged();
AppNearMe 0:07fa9c0dd549 22
AppNearMe 0:07fa9c0dd549 23 uint32_t status();
AppNearMe 0:07fa9c0dd549 24
AppNearMe 0:07fa9c0dd549 25 void nfcPoll(bool enable);
AppNearMe 0:07fa9c0dd549 26
AppNearMe 0:07fa9c0dd549 27 void nfcOperation(bool readOp, bool writeOp);
AppNearMe 0:07fa9c0dd549 28
AppNearMe 0:07fa9c0dd549 29 void nfcGetInfoIsoA(uint8_t* atqa, uint8_t* sak, uint8_t* uid, size_t* pUidLength);
AppNearMe 0:07fa9c0dd549 30
AppNearMe 0:07fa9c0dd549 31 void nfcGetMessageInfo(size_t* pRecordCount);
AppNearMe 0:07fa9c0dd549 32
AppNearMe 0:07fa9c0dd549 33 void nfcSetMessageInfo(size_t recordCount);
AppNearMe 0:07fa9c0dd549 34
AppNearMe 0:07fa9c0dd549 35 void nfcGetRecordInfo(size_t recordNumber, uint16_t* pType, uint16_t* info, size_t infoCount);
AppNearMe 0:07fa9c0dd549 36
AppNearMe 0:07fa9c0dd549 37 void nfcSetRecordInfo(size_t recordNumber, uint16_t type, uint16_t* info, size_t infoCount);
AppNearMe 0:07fa9c0dd549 38
AppNearMe 0:07fa9c0dd549 39 void nfcGetRecordData(size_t recordNumber, size_t item, size_t offset, uint8_t* data, size_t length);
AppNearMe 0:07fa9c0dd549 40
AppNearMe 0:07fa9c0dd549 41 void nfcSetRecordData(size_t recordNumber, size_t item, size_t offset, uint8_t* data, size_t length);
AppNearMe 0:07fa9c0dd549 42
AppNearMe 0:07fa9c0dd549 43 void nfcPrepareMessage(bool lock, bool generate);
AppNearMe 0:07fa9c0dd549 44
AppNearMe 0:07fa9c0dd549 45 void nfcDecodePrefix(uint8_t prefix, char* data, size_t* pDataLength);
AppNearMe 0:07fa9c0dd549 46
AppNearMe 0:07fa9c0dd549 47 void nfcEncodePrefix(uint8_t* pPrefix, char* data, size_t dataLength);
AppNearMe 0:07fa9c0dd549 48
AppNearMe 0:07fa9c0dd549 49 void leds(bool led1, bool led2);
AppNearMe 0:07fa9c0dd549 50
AppNearMe 0:07fa9c0dd549 51 protected:
AppNearMe 0:07fa9c0dd549 52 enum CommandError
AppNearMe 0:07fa9c0dd549 53 {
AppNearMe 0:07fa9c0dd549 54 OK = 0,
AppNearMe 0:07fa9c0dd549 55 ERR_LENGTH = 1,
AppNearMe 0:07fa9c0dd549 56 ERR_EMPTY = 2,
AppNearMe 0:07fa9c0dd549 57 ERR_UNKNOWN_COMMAND = 3,
AppNearMe 0:07fa9c0dd549 58 ERR_TIMEOUT = 4,
AppNearMe 0:07fa9c0dd549 59 ERR_PARAMS = 5,
AppNearMe 0:07fa9c0dd549 60 ERR_STATUS = 6,
AppNearMe 0:07fa9c0dd549 61 };
AppNearMe 0:07fa9c0dd549 62
AppNearMe 0:07fa9c0dd549 63 enum CommandCode
AppNearMe 0:07fa9c0dd549 64 {
AppNearMe 0:07fa9c0dd549 65 GET_STATUS = 0,
AppNearMe 0:07fa9c0dd549 66 INFO = 1,
AppNearMe 0:07fa9c0dd549 67 RESET = 2,
AppNearMe 0:07fa9c0dd549 68 LEDS = 3,
AppNearMe 0:07fa9c0dd549 69 NFC_POLL = 4,
AppNearMe 0:07fa9c0dd549 70 NFC_OPERATION = 5,
AppNearMe 0:07fa9c0dd549 71 NFC_GET_INFO = 6,
AppNearMe 0:07fa9c0dd549 72 NFC_GET_MESSAGE_INFO = 7,
AppNearMe 0:07fa9c0dd549 73 NFC_GET_RECORD_INFO = 8,
AppNearMe 0:07fa9c0dd549 74 NFC_GET_RECORD_DATA = 9,
AppNearMe 0:07fa9c0dd549 75 NFC_SET_MESSAGE_INFO = 10,
AppNearMe 0:07fa9c0dd549 76 NFC_SET_RECORD_INFO = 11,
AppNearMe 0:07fa9c0dd549 77 NFC_SET_RECORD_DATA = 12,
AppNearMe 0:07fa9c0dd549 78 NFC_PREPARE_MESSAGE = 13,
AppNearMe 0:07fa9c0dd549 79 NFC_DECODE_PREFIX = 14,
AppNearMe 0:07fa9c0dd549 80 NFC_ENCODE_PREFIX = 15
AppNearMe 0:07fa9c0dd549 81 };
AppNearMe 0:07fa9c0dd549 82
AppNearMe 0:07fa9c0dd549 83 CommandError command(CommandCode command, uint8_t* outBuf, size_t outLength, uint8_t* inBuf, size_t inLength);
AppNearMe 0:07fa9c0dd549 84
AppNearMe 0:07fa9c0dd549 85 private:
AppNearMe 0:07fa9c0dd549 86 DigitalOut _cs;
AppNearMe 0:07fa9c0dd549 87 SPI _spi;
AppNearMe 0:07fa9c0dd549 88 DigitalIn _int;
AppNearMe 0:07fa9c0dd549 89 };
AppNearMe 0:07fa9c0dd549 90
AppNearMe 0:07fa9c0dd549 91
AppNearMe 0:07fa9c0dd549 92
AppNearMe 0:07fa9c0dd549 93 #endif /* SRC_TRANSPORT_H_ */