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:01:19 2016 +0000
Revision:
0:db8030e71f55
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dotnfc 0:db8030e71f55 1 /*
dotnfc 0:db8030e71f55 2 * Copyright (c) 2010 by Cristian Maglie <c.maglie@bug.st>
dotnfc 0:db8030e71f55 3 * SPI Master library for arduino.
dotnfc 0:db8030e71f55 4 *
dotnfc 0:db8030e71f55 5 * This file is free software; you can redistribute it and/or modify
dotnfc 0:db8030e71f55 6 * it under the terms of either the GNU General Public License version 2
dotnfc 0:db8030e71f55 7 * or the GNU Lesser General Public License version 2.1, both as
dotnfc 0:db8030e71f55 8 * published by the Free Software Foundation.
dotnfc 0:db8030e71f55 9 */
dotnfc 0:db8030e71f55 10
dotnfc 0:db8030e71f55 11 #ifndef _SPI_H_INCLUDED
dotnfc 0:db8030e71f55 12 #define _SPI_H_INCLUDED
dotnfc 0:db8030e71f55 13
dotnfc 0:db8030e71f55 14 #include <stdio.h>
dotnfc 0:db8030e71f55 15 #include <Arduino.h>
dotnfc 0:db8030e71f55 16
dotnfc 0:db8030e71f55 17
dotnfc 0:db8030e71f55 18 #define SPI_CLOCK_DIV2 SPI_BaudRatePrescaler_2
dotnfc 0:db8030e71f55 19 #define SPI_CLOCK_DIV4 SPI_BaudRatePrescaler_4
dotnfc 0:db8030e71f55 20 #define SPI_CLOCK_DIV8 SPI_BaudRatePrescaler_8
dotnfc 0:db8030e71f55 21 #define SPI_CLOCK_DIV16 SPI_BaudRatePrescaler_16
dotnfc 0:db8030e71f55 22 #define SPI_CLOCK_DIV32 SPI_BaudRatePrescaler_32
dotnfc 0:db8030e71f55 23 #define SPI_CLOCK_DIV64 SPI_BaudRatePrescaler_64
dotnfc 0:db8030e71f55 24 #define SPI_CLOCK_DIV128 SPI_BaudRatePrescaler_128
dotnfc 0:db8030e71f55 25 #define SPI_CLOCK_DIV256 SPI_BaudRatePrescaler_256
dotnfc 0:db8030e71f55 26
dotnfc 0:db8030e71f55 27 #define SPI_MODE0 0x00
dotnfc 0:db8030e71f55 28 #define SPI_MODE1 0x04
dotnfc 0:db8030e71f55 29 #define SPI_MODE2 0x08
dotnfc 0:db8030e71f55 30 #define SPI_MODE3 0x0C
dotnfc 0:db8030e71f55 31
dotnfc 0:db8030e71f55 32
dotnfc 0:db8030e71f55 33 class SPIClass {
dotnfc 0:db8030e71f55 34 public:
dotnfc 0:db8030e71f55 35 uint8_t transfer(uint8_t _data);
dotnfc 0:db8030e71f55 36
dotnfc 0:db8030e71f55 37 // SPI Configuration methods
dotnfc 0:db8030e71f55 38
dotnfc 0:db8030e71f55 39 inline static void attachInterrupt();
dotnfc 0:db8030e71f55 40 inline static void detachInterrupt(); // Default
dotnfc 0:db8030e71f55 41
dotnfc 0:db8030e71f55 42 void begin(); // Default
dotnfc 0:db8030e71f55 43 void end();
dotnfc 0:db8030e71f55 44
dotnfc 0:db8030e71f55 45 void setBitOrder(uint8_t);
dotnfc 0:db8030e71f55 46 void setDataMode(uint8_t);
dotnfc 0:db8030e71f55 47 void setClockDivider(uint8_t);
dotnfc 0:db8030e71f55 48 private:
dotnfc 0:db8030e71f55 49 SPI_TypeDef *spi;
dotnfc 0:db8030e71f55 50 SPI_InitTypeDef SPI_InitStructure;
dotnfc 0:db8030e71f55 51 uint16_t bitOrder;
dotnfc 0:db8030e71f55 52 };
dotnfc 0:db8030e71f55 53
dotnfc 0:db8030e71f55 54 extern SPIClass SPI;
dotnfc 0:db8030e71f55 55
dotnfc 0:db8030e71f55 56
dotnfc 0:db8030e71f55 57
dotnfc 0:db8030e71f55 58 #endif