PN532 Driver library This library provides an abstract API to drive the pn532 nfc chip, with I2C/HSU/SPI interface. Its based on the Seeed Studio's Arduino version.

Dependents:   PN532_ReadUid Nfctest2

Committer:
dotnfc
Date:
Tue Sep 13 06:17:35 2016 +0000
Revision:
1:b5922b3b3257
Parent:
0:db8030e71f55
Remove ununsed files.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dotnfc 0:db8030e71f55 1
dotnfc 0:db8030e71f55 2 #ifndef __PN532_SPI_H__
dotnfc 0:db8030e71f55 3 #define __PN532_SPI_H__
dotnfc 0:db8030e71f55 4
dotnfc 0:db8030e71f55 5 #include "mbed.h"
dotnfc 0:db8030e71f55 6 #include "PN532Interface.h"
dotnfc 0:db8030e71f55 7
dotnfc 0:db8030e71f55 8 class PN532_SPI : public PN532Interface
dotnfc 0:db8030e71f55 9 {
dotnfc 0:db8030e71f55 10 public:
dotnfc 0:db8030e71f55 11 PN532_SPI(SPI &spi, PinName ss);
dotnfc 0:db8030e71f55 12 PN532_SPI(SPI *spi, PinName ss);
dotnfc 0:db8030e71f55 13
dotnfc 0:db8030e71f55 14 virtual void begin();
dotnfc 0:db8030e71f55 15 virtual void wakeup();
dotnfc 0:db8030e71f55 16 virtual int8_t writeCommand(const uint8_t *header, uint8_t hlen, const uint8_t *body, uint8_t blen);
dotnfc 0:db8030e71f55 17 virtual int16_t readResponse(uint8_t buf[], uint8_t len, uint16_t timeout);
dotnfc 0:db8030e71f55 18
dotnfc 0:db8030e71f55 19 private:
dotnfc 0:db8030e71f55 20 SPI *_spi;
dotnfc 0:db8030e71f55 21 DigitalOut _ss;
dotnfc 0:db8030e71f55 22 uint8_t command;
dotnfc 0:db8030e71f55 23
dotnfc 0:db8030e71f55 24 bool isReady();
dotnfc 0:db8030e71f55 25 void writeFrame(const uint8_t *header, uint8_t hlen, const uint8_t *body, uint8_t blen);
dotnfc 0:db8030e71f55 26 int8_t readAckFrame();
dotnfc 0:db8030e71f55 27
dotnfc 0:db8030e71f55 28 inline void write(uint8_t data) {
dotnfc 0:db8030e71f55 29 REVERSE_BITS_ORDER(data);
dotnfc 0:db8030e71f55 30 _spi->write(data);
dotnfc 0:db8030e71f55 31 }
dotnfc 0:db8030e71f55 32 inline uint8_t read() {
dotnfc 0:db8030e71f55 33 uint8_t data = _spi->write(0);
dotnfc 0:db8030e71f55 34 REVERSE_BITS_ORDER(data);
dotnfc 0:db8030e71f55 35 return data;
dotnfc 0:db8030e71f55 36 }
dotnfc 0:db8030e71f55 37 };
dotnfc 0:db8030e71f55 38
dotnfc 0:db8030e71f55 39 #endif