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