to colorize a colorful pixel with a simple touch using nfc technology
Dependencies: Chainable_RGB_LED mbed
use Arch, NFC Shield and Grove - Chainable RGB LED to DIY a touch pixel. Then use an Android with NFC support to colorize it.
The project is on https://github.com/Seeed-Studio/TouchPixel
nfc/PN532Interface.h@0:88960f3eeb2c, 2013-12-27 (annotated)
- Committer:
- yihui
- Date:
- Fri Dec 27 01:46:32 2013 +0000
- Revision:
- 0:88960f3eeb2c
initial
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yihui | 0:88960f3eeb2c | 1 | |
yihui | 0:88960f3eeb2c | 2 | |
yihui | 0:88960f3eeb2c | 3 | #ifndef __PN532_INTERFACE_H__ |
yihui | 0:88960f3eeb2c | 4 | #define __PN532_INTERFACE_H__ |
yihui | 0:88960f3eeb2c | 5 | |
yihui | 0:88960f3eeb2c | 6 | #include <stdint.h> |
yihui | 0:88960f3eeb2c | 7 | |
yihui | 0:88960f3eeb2c | 8 | #define PN532_PREAMBLE (0x00) |
yihui | 0:88960f3eeb2c | 9 | #define PN532_STARTCODE1 (0x00) |
yihui | 0:88960f3eeb2c | 10 | #define PN532_STARTCODE2 (0xFF) |
yihui | 0:88960f3eeb2c | 11 | #define PN532_POSTAMBLE (0x00) |
yihui | 0:88960f3eeb2c | 12 | |
yihui | 0:88960f3eeb2c | 13 | #define PN532_HOSTTOPN532 (0xD4) |
yihui | 0:88960f3eeb2c | 14 | #define PN532_PN532TOHOST (0xD5) |
yihui | 0:88960f3eeb2c | 15 | |
yihui | 0:88960f3eeb2c | 16 | #define PN532_ACK_WAIT_TIME (10) // ms, timeout of waiting for ACK |
yihui | 0:88960f3eeb2c | 17 | |
yihui | 0:88960f3eeb2c | 18 | #define PN532_INVALID_ACK (-1) |
yihui | 0:88960f3eeb2c | 19 | #define PN532_TIMEOUT (-2) |
yihui | 0:88960f3eeb2c | 20 | #define PN532_INVALID_FRAME (-3) |
yihui | 0:88960f3eeb2c | 21 | #define PN532_NO_SPACE (-4) |
yihui | 0:88960f3eeb2c | 22 | |
yihui | 0:88960f3eeb2c | 23 | #define REVERSE_BITS_ORDER(b) b = (b & 0xF0) >> 4 | (b & 0x0F) << 4; \ |
yihui | 0:88960f3eeb2c | 24 | b = (b & 0xCC) >> 2 | (b & 0x33) << 2; \ |
yihui | 0:88960f3eeb2c | 25 | b = (b & 0xAA) >> 1 | (b & 0x55) << 1 |
yihui | 0:88960f3eeb2c | 26 | |
yihui | 0:88960f3eeb2c | 27 | class PN532Interface |
yihui | 0:88960f3eeb2c | 28 | { |
yihui | 0:88960f3eeb2c | 29 | public: |
yihui | 0:88960f3eeb2c | 30 | virtual void begin() = 0; |
yihui | 0:88960f3eeb2c | 31 | virtual void wakeup() = 0; |
yihui | 0:88960f3eeb2c | 32 | |
yihui | 0:88960f3eeb2c | 33 | /** |
yihui | 0:88960f3eeb2c | 34 | * @brief write a command and check ack |
yihui | 0:88960f3eeb2c | 35 | * @param header packet header |
yihui | 0:88960f3eeb2c | 36 | * @param hlen length of header |
yihui | 0:88960f3eeb2c | 37 | * @param body packet body |
yihui | 0:88960f3eeb2c | 38 | * @param blen length of body |
yihui | 0:88960f3eeb2c | 39 | * @return 0 success |
yihui | 0:88960f3eeb2c | 40 | * not 0 failed |
yihui | 0:88960f3eeb2c | 41 | */ |
yihui | 0:88960f3eeb2c | 42 | virtual int8_t writeCommand(const uint8_t *header, uint8_t hlen, const uint8_t *body = 0, uint8_t blen = 0) = 0; |
yihui | 0:88960f3eeb2c | 43 | |
yihui | 0:88960f3eeb2c | 44 | /** |
yihui | 0:88960f3eeb2c | 45 | * @brief read the response of a command, strip prefix and suffix |
yihui | 0:88960f3eeb2c | 46 | * @param buf to contain the response data |
yihui | 0:88960f3eeb2c | 47 | * @param len lenght to read |
yihui | 0:88960f3eeb2c | 48 | * @param timeout max time to wait, 0 means no timeout |
yihui | 0:88960f3eeb2c | 49 | * @return >=0 length of response without prefix and suffix |
yihui | 0:88960f3eeb2c | 50 | * <0 failed to read response |
yihui | 0:88960f3eeb2c | 51 | */ |
yihui | 0:88960f3eeb2c | 52 | virtual int16_t readResponse(uint8_t buf[], uint8_t len, uint16_t timeout = 1000) = 0; |
yihui | 0:88960f3eeb2c | 53 | }; |
yihui | 0:88960f3eeb2c | 54 | |
yihui | 0:88960f3eeb2c | 55 | #endif |
yihui | 0:88960f3eeb2c | 56 |