NFC API for mbed using the MicroNFCBoard as a peripheral

Dependents:   MicroNFCBoardAPI_P2P_Client MicroNFCBoardAPI_Blink MicroNFCBoardAPI_Tag_Emulator MicroNFCBoardAPI_Tag_Reader ... more

Revision:
0:07fa9c0dd549
Child:
1:1d246e0872c6
diff -r 000000000000 -r 07fa9c0dd549 transport.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/transport.h	Fri Apr 24 12:57:23 2015 +0000
@@ -0,0 +1,93 @@
+/**
+ * \file transport.h
+ * \copyright Copyright (c) AppNearMe Ltd 2015
+ * \author Donatien Garnier
+ */
+#ifndef SRC_TRANSPORT_H_
+#define SRC_TRANSPORT_H_
+
+#include "mbed.h"
+#include <cstddef>
+
+class Transport
+{
+public:
+  Transport(PinName mosi, PinName miso, PinName sck, PinName cs, PinName irq);
+
+  void init();
+
+  void reset();
+
+  bool statusChanged();
+
+  uint32_t status();
+
+  void nfcPoll(bool enable);
+
+  void nfcOperation(bool readOp, bool writeOp);
+
+  void nfcGetInfoIsoA(uint8_t* atqa, uint8_t* sak, uint8_t* uid, size_t* pUidLength);
+
+  void nfcGetMessageInfo(size_t* pRecordCount);
+
+  void nfcSetMessageInfo(size_t recordCount);
+
+  void nfcGetRecordInfo(size_t recordNumber, uint16_t* pType, uint16_t* info, size_t infoCount);
+
+  void nfcSetRecordInfo(size_t recordNumber, uint16_t type, uint16_t* info, size_t infoCount);
+
+  void nfcGetRecordData(size_t recordNumber, size_t item, size_t offset, uint8_t* data, size_t length);
+
+  void nfcSetRecordData(size_t recordNumber, size_t item, size_t offset, uint8_t* data, size_t length);
+
+  void nfcPrepareMessage(bool lock, bool generate);
+
+  void nfcDecodePrefix(uint8_t prefix, char* data, size_t* pDataLength);
+
+  void nfcEncodePrefix(uint8_t* pPrefix, char* data, size_t dataLength);
+
+  void leds(bool led1, bool led2);
+
+protected:
+  enum CommandError
+  {
+    OK                  = 0,
+    ERR_LENGTH          = 1,
+    ERR_EMPTY           = 2,
+    ERR_UNKNOWN_COMMAND = 3,
+    ERR_TIMEOUT         = 4,
+    ERR_PARAMS          = 5,
+    ERR_STATUS          = 6,
+  };
+
+  enum CommandCode
+  {
+    GET_STATUS = 0,
+    INFO = 1,
+    RESET = 2,
+    LEDS = 3,
+    NFC_POLL = 4,
+    NFC_OPERATION = 5,
+    NFC_GET_INFO = 6,
+    NFC_GET_MESSAGE_INFO = 7,
+    NFC_GET_RECORD_INFO = 8,
+    NFC_GET_RECORD_DATA = 9,
+    NFC_SET_MESSAGE_INFO = 10,
+    NFC_SET_RECORD_INFO = 11,
+    NFC_SET_RECORD_DATA = 12,
+    NFC_PREPARE_MESSAGE = 13,
+    NFC_DECODE_PREFIX = 14,
+    NFC_ENCODE_PREFIX = 15
+  };
+
+  CommandError command(CommandCode command, uint8_t* outBuf, size_t outLength, uint8_t* inBuf, size_t inLength);
+
+private:
+  DigitalOut _cs;
+  SPI _spi;
+  DigitalIn _int;
+};
+
+
+
+#endif /* SRC_TRANSPORT_H_ */