NFC library using PN532 to read/write NDEF Messages to NFC tags
Dependents: Seeed_NFC_Shield_write Nucleo_test_nfc
Fork of PN532 by
PN532_SPI.h
00001 00002 #ifndef __PN532_SPI_H__ 00003 #define __PN532_SPI_H__ 00004 00005 #include "mbed.h" 00006 #include "PN532Interface.h" 00007 00008 class PN532_SPI : public PN532Interface 00009 { 00010 public: 00011 PN532_SPI(SPI &spi, PinName ss); 00012 PN532_SPI(SPI *spi, PinName ss); 00013 00014 virtual void begin(); 00015 virtual void wakeup(); 00016 virtual int8_t writeCommand(const uint8_t *header, uint8_t hlen, const uint8_t *body, uint8_t blen); 00017 virtual int16_t readResponse(uint8_t buf[], uint8_t len, uint16_t timeout); 00018 00019 private: 00020 SPI *_spi; 00021 DigitalOut _ss; 00022 uint8_t command; 00023 00024 bool isReady(); 00025 void writeFrame(const uint8_t *header, uint8_t hlen, const uint8_t *body, uint8_t blen); 00026 int8_t readAckFrame(); 00027 00028 inline void write(uint8_t data) { 00029 REVERSE_BITS_ORDER(data); 00030 _spi->write(data); 00031 } 00032 inline uint8_t read() { 00033 uint8_t data = _spi->write(0); 00034 REVERSE_BITS_ORDER(data); 00035 return data; 00036 } 00037 }; 00038 00039 #endif
Generated on Tue Jul 12 2022 21:59:39 by 1.7.2