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
wiring_constants.h@0:db8030e71f55, 2016-09-13 (annotated)
- Committer:
- dotnfc
- Date:
- Tue Sep 13 06:01:19 2016 +0000
- Revision:
- 0:db8030e71f55
first commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dotnfc | 0:db8030e71f55 | 1 | /* |
dotnfc | 0:db8030e71f55 | 2 | Copyright (c) 2014 BestU. All right reserved. |
dotnfc | 0:db8030e71f55 | 3 | Copyright (c) 2011 Arduino. All right reserved. |
dotnfc | 0:db8030e71f55 | 4 | |
dotnfc | 0:db8030e71f55 | 5 | This library is free software; you can redistribute it and/or |
dotnfc | 0:db8030e71f55 | 6 | modify it under the terms of the GNU Lesser General Public |
dotnfc | 0:db8030e71f55 | 7 | License as published by the Free Software Foundation; either |
dotnfc | 0:db8030e71f55 | 8 | version 2.1 of the License, or (at your option) any later version. |
dotnfc | 0:db8030e71f55 | 9 | |
dotnfc | 0:db8030e71f55 | 10 | This library is distributed in the hope that it will be useful, |
dotnfc | 0:db8030e71f55 | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
dotnfc | 0:db8030e71f55 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
dotnfc | 0:db8030e71f55 | 13 | See the GNU Lesser General Public License for more details. |
dotnfc | 0:db8030e71f55 | 14 | |
dotnfc | 0:db8030e71f55 | 15 | You should have received a copy of the GNU Lesser General Public |
dotnfc | 0:db8030e71f55 | 16 | License along with this library; if not, write to the Free Software |
dotnfc | 0:db8030e71f55 | 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
dotnfc | 0:db8030e71f55 | 18 | */ |
dotnfc | 0:db8030e71f55 | 19 | |
dotnfc | 0:db8030e71f55 | 20 | #ifndef _WIRING_CONSTANTS_ |
dotnfc | 0:db8030e71f55 | 21 | #define _WIRING_CONSTANTS_ |
dotnfc | 0:db8030e71f55 | 22 | |
dotnfc | 0:db8030e71f55 | 23 | #ifdef __cplusplus |
dotnfc | 0:db8030e71f55 | 24 | extern "C"{ |
dotnfc | 0:db8030e71f55 | 25 | #endif // __cplusplus |
dotnfc | 0:db8030e71f55 | 26 | |
dotnfc | 0:db8030e71f55 | 27 | #define HIGH 0x1 |
dotnfc | 0:db8030e71f55 | 28 | #define LOW 0x0 |
dotnfc | 0:db8030e71f55 | 29 | |
dotnfc | 0:db8030e71f55 | 30 | #define INPUT 0x0 |
dotnfc | 0:db8030e71f55 | 31 | #define OUTPUT 0x1 |
dotnfc | 0:db8030e71f55 | 32 | #define ALTERNATE 0x2 |
dotnfc | 0:db8030e71f55 | 33 | #define ANALOG 0x3 |
dotnfc | 0:db8030e71f55 | 34 | |
dotnfc | 0:db8030e71f55 | 35 | #define true 0x1 |
dotnfc | 0:db8030e71f55 | 36 | #define false 0x0 |
dotnfc | 0:db8030e71f55 | 37 | |
dotnfc | 0:db8030e71f55 | 38 | #define PI 3.1415926535897932384626433832795 |
dotnfc | 0:db8030e71f55 | 39 | #define HALF_PI 1.5707963267948966192313216916398 |
dotnfc | 0:db8030e71f55 | 40 | #define TWO_PI 6.283185307179586476925286766559 |
dotnfc | 0:db8030e71f55 | 41 | #define DEG_TO_RAD 0.017453292519943295769236907684886 |
dotnfc | 0:db8030e71f55 | 42 | #define RAD_TO_DEG 57.295779513082320876798154814105 |
dotnfc | 0:db8030e71f55 | 43 | #define EULER 2.718281828459045235360287471352 |
dotnfc | 0:db8030e71f55 | 44 | |
dotnfc | 0:db8030e71f55 | 45 | #define SERIAL 0x0 |
dotnfc | 0:db8030e71f55 | 46 | #define DISPLAY 0x1 |
dotnfc | 0:db8030e71f55 | 47 | |
dotnfc | 0:db8030e71f55 | 48 | enum BitOrder { |
dotnfc | 0:db8030e71f55 | 49 | LSBFIRST = 0, |
dotnfc | 0:db8030e71f55 | 50 | MSBFIRST = 1 |
dotnfc | 0:db8030e71f55 | 51 | }; |
dotnfc | 0:db8030e71f55 | 52 | |
dotnfc | 0:db8030e71f55 | 53 | // LOW 0 |
dotnfc | 0:db8030e71f55 | 54 | // HIGH 1 |
dotnfc | 0:db8030e71f55 | 55 | #define CHANGE 2 |
dotnfc | 0:db8030e71f55 | 56 | #define FALLING 3 |
dotnfc | 0:db8030e71f55 | 57 | #define RISING 4 |
dotnfc | 0:db8030e71f55 | 58 | |
dotnfc | 0:db8030e71f55 | 59 | #define DEFAULT 1 |
dotnfc | 0:db8030e71f55 | 60 | #define EXTERNAL 0 |
dotnfc | 0:db8030e71f55 | 61 | |
dotnfc | 0:db8030e71f55 | 62 | // undefine stdlib's abs if encountered |
dotnfc | 0:db8030e71f55 | 63 | #ifdef abs |
dotnfc | 0:db8030e71f55 | 64 | #undef abs |
dotnfc | 0:db8030e71f55 | 65 | #endif // abs |
dotnfc | 0:db8030e71f55 | 66 | |
dotnfc | 0:db8030e71f55 | 67 | #ifndef min |
dotnfc | 0:db8030e71f55 | 68 | #define min(a,b) ((a)<(b)?(a):(b)) |
dotnfc | 0:db8030e71f55 | 69 | #endif // min |
dotnfc | 0:db8030e71f55 | 70 | |
dotnfc | 0:db8030e71f55 | 71 | #ifndef max |
dotnfc | 0:db8030e71f55 | 72 | #define max(a,b) ((a)>(b)?(a):(b)) |
dotnfc | 0:db8030e71f55 | 73 | #endif // max |
dotnfc | 0:db8030e71f55 | 74 | |
dotnfc | 0:db8030e71f55 | 75 | #define abs(x) ((x)>0?(x):-(x)) |
dotnfc | 0:db8030e71f55 | 76 | #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) |
dotnfc | 0:db8030e71f55 | 77 | #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) |
dotnfc | 0:db8030e71f55 | 78 | #define radians(deg) ((deg)*DEG_TO_RAD) |
dotnfc | 0:db8030e71f55 | 79 | #define degrees(rad) ((rad)*RAD_TO_DEG) |
dotnfc | 0:db8030e71f55 | 80 | #define sq(x) ((x)*(x)) |
dotnfc | 0:db8030e71f55 | 81 | |
dotnfc | 0:db8030e71f55 | 82 | #define interrupts() __enable_irq() |
dotnfc | 0:db8030e71f55 | 83 | #define noInterrupts() __disable_irq() |
dotnfc | 0:db8030e71f55 | 84 | |
dotnfc | 0:db8030e71f55 | 85 | #define lowByte(w) ((uint8_t) ((w) & 0xff)) |
dotnfc | 0:db8030e71f55 | 86 | #define highByte(w) ((uint8_t) ((w) >> 8)) |
dotnfc | 0:db8030e71f55 | 87 | |
dotnfc | 0:db8030e71f55 | 88 | #define bitRead(value, bit) (((value) >> (bit)) & 0x01) |
dotnfc | 0:db8030e71f55 | 89 | #define bitSet(value, bit) ((value) |= (1UL << (bit))) |
dotnfc | 0:db8030e71f55 | 90 | #define bitClear(value, bit) ((value) &= ~(1UL << (bit))) |
dotnfc | 0:db8030e71f55 | 91 | #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) |
dotnfc | 0:db8030e71f55 | 92 | |
dotnfc | 0:db8030e71f55 | 93 | typedef unsigned int word; |
dotnfc | 0:db8030e71f55 | 94 | |
dotnfc | 0:db8030e71f55 | 95 | #define bit(b) (1UL << (b)) |
dotnfc | 0:db8030e71f55 | 96 | |
dotnfc | 0:db8030e71f55 | 97 | // TODO: to be checked |
dotnfc | 0:db8030e71f55 | 98 | typedef uint8_t boolean ; |
dotnfc | 0:db8030e71f55 | 99 | typedef uint8_t byte ; |
dotnfc | 0:db8030e71f55 | 100 | |
dotnfc | 0:db8030e71f55 | 101 | |
dotnfc | 0:db8030e71f55 | 102 | #ifdef __cplusplus |
dotnfc | 0:db8030e71f55 | 103 | } // extern "C" |
dotnfc | 0:db8030e71f55 | 104 | #endif // __cplusplus |
dotnfc | 0:db8030e71f55 | 105 | |
dotnfc | 0:db8030e71f55 | 106 | #endif /* _WIRING_CONSTANTS_ */ |