This application provides a set of demos with X-NUCLEO-NFC01A1 expansion board.
Dependencies: NDefLib X_NUCLEO_NFC01A1 mbed
Fork of X-MBED-NFC1 by
This application provides a set of demos with X-NUCLEO-NFC01A1 expansion board.
The available demos are:
- SAMPLE_WRITE_URL: write a tag with the ST home page URL
- SAMPLE_COUNT_CLICK: create a custom tag to count and report the user button clicks.
- SAMPLE_WRITE_AND_CHANGE_ALL: write a tag with all the supported records and update the tag contents when the user button is pressed.
- SAMPLE_LOCK_TAG_CONTENT: use the M24SR component API to set the NFC tag as read-only.
To enable the different demos comment/uncomment the SAMPLE_* macros provided in main.cpp .
X_NUCLEO_NFC01A1.h@3:f7f818ee694e, 2015-12-01 (annotated)
- Committer:
- giovannivisentini
- Date:
- Tue Dec 01 16:01:24 2015 +0000
- Revision:
- 3:f7f818ee694e
- Parent:
- 2:0648c1561eb2
create a sample main + semplify the class constuction
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| giovannivisentini | 0:674813bd5ec9 | 1 | /* |
| giovannivisentini | 0:674813bd5ec9 | 2 | * X_NUCLEO_NFC01A1.h |
| giovannivisentini | 0:674813bd5ec9 | 3 | * |
| giovannivisentini | 0:674813bd5ec9 | 4 | * Created on: Nov 5, 2015 |
| giovannivisentini | 0:674813bd5ec9 | 5 | * Author: giovanni visentini |
| giovannivisentini | 0:674813bd5ec9 | 6 | */ |
| giovannivisentini | 0:674813bd5ec9 | 7 | |
| giovannivisentini | 0:674813bd5ec9 | 8 | #ifndef X_NUCLEO_NFC01A1_H_ |
| giovannivisentini | 0:674813bd5ec9 | 9 | #define X_NUCLEO_NFC01A1_H_ |
| giovannivisentini | 2:0648c1561eb2 | 10 | #include <stdint.h> |
| giovannivisentini | 0:674813bd5ec9 | 11 | |
| giovannivisentini | 0:674813bd5ec9 | 12 | #include "mbed.h" |
| giovannivisentini | 0:674813bd5ec9 | 13 | |
| giovannivisentini | 0:674813bd5ec9 | 14 | #include "m24sr/m24sr_class.h" |
| giovannivisentini | 0:674813bd5ec9 | 15 | |
| giovannivisentini | 2:0648c1561eb2 | 16 | /** |
| giovannivisentini | 2:0648c1561eb2 | 17 | * singleton class that controls all the electronics inside the X_NUCLEO_NFC01A1 expansion board |
| giovannivisentini | 2:0648c1561eb2 | 18 | */ |
| giovannivisentini | 0:674813bd5ec9 | 19 | class X_NUCLEO_NFC01A1 { |
| giovannivisentini | 0:674813bd5ec9 | 20 | |
| giovannivisentini | 0:674813bd5ec9 | 21 | private: |
| giovannivisentini | 2:0648c1561eb2 | 22 | /** |
| giovannivisentini | 2:0648c1561eb2 | 23 | * ponter to the singleton instance, NULL if we did't build one |
| giovannivisentini | 2:0648c1561eb2 | 24 | */ |
| giovannivisentini | 1:6d202b62ed68 | 25 | static X_NUCLEO_NFC01A1 *mInstance; |
| giovannivisentini | 2:0648c1561eb2 | 26 | /** |
| giovannivisentini | 2:0648c1561eb2 | 27 | * i2c address of the m24sr chip |
| giovannivisentini | 2:0648c1561eb2 | 28 | */ |
| giovannivisentini | 2:0648c1561eb2 | 29 | static const uint8_t M24SR_ADDR; |
| giovannivisentini | 0:674813bd5ec9 | 30 | |
| giovannivisentini | 3:f7f818ee694e | 31 | static const PinName GPO_PIN; |
| giovannivisentini | 3:f7f818ee694e | 32 | static const PinName RF_DISABLE_PIN; |
| giovannivisentini | 3:f7f818ee694e | 33 | static const PinName LED1_PIN; |
| giovannivisentini | 3:f7f818ee694e | 34 | static const PinName LED2_PIN; |
| giovannivisentini | 3:f7f818ee694e | 35 | static const PinName LED3_PIN; |
| giovannivisentini | 3:f7f818ee694e | 36 | |
| giovannivisentini | 2:0648c1561eb2 | 37 | /** |
| giovannivisentini | 2:0648c1561eb2 | 38 | * constructor |
| giovannivisentini | 2:0648c1561eb2 | 39 | * @param devI2C i2c channel used for communicate with the board |
| giovannivisentini | 2:0648c1561eb2 | 40 | * @param gpoName pin of the gpio pin of the M24SR chip |
| giovannivisentini | 2:0648c1561eb2 | 41 | * @param RFDisableName pin for disable the rf antenna |
| giovannivisentini | 2:0648c1561eb2 | 42 | * @param led1Name pin for control the led1 status |
| giovannivisentini | 2:0648c1561eb2 | 43 | * @param led2Name pin for control the led1 status |
| giovannivisentini | 2:0648c1561eb2 | 44 | * @param led3Name pin for control the led1 status |
| giovannivisentini | 2:0648c1561eb2 | 45 | */ |
| giovannivisentini | 2:0648c1561eb2 | 46 | //TODO FIX all this the pin name? |
| giovannivisentini | 3:f7f818ee694e | 47 | X_NUCLEO_NFC01A1(I2C &devI2C) : |
| giovannivisentini | 3:f7f818ee694e | 48 | mM24SR(M24SR_ADDR, devI2C, GPO_PIN, RF_DISABLE_PIN), mNfcLed1( |
| giovannivisentini | 3:f7f818ee694e | 49 | LED1_PIN), mNfcLed2(LED2_PIN), mNfcLed3(LED3_PIN) { } |
| giovannivisentini | 0:674813bd5ec9 | 50 | |
| giovannivisentini | 0:674813bd5ec9 | 51 | public: |
| giovannivisentini | 3:f7f818ee694e | 52 | const static PinName DEFAULT_SDA_PIN; |
| giovannivisentini | 3:f7f818ee694e | 53 | const static PinName DEFAULT_SDL_PIN; |
| giovannivisentini | 3:f7f818ee694e | 54 | |
| giovannivisentini | 3:f7f818ee694e | 55 | static X_NUCLEO_NFC01A1* Instance(I2C &devI2C); |
| giovannivisentini | 0:674813bd5ec9 | 56 | |
| giovannivisentini | 2:0648c1561eb2 | 57 | /** |
| giovannivisentini | 2:0648c1561eb2 | 58 | * @return board led1 |
| giovannivisentini | 2:0648c1561eb2 | 59 | */ |
| giovannivisentini | 1:6d202b62ed68 | 60 | DigitalOut& getLed1() { |
| giovannivisentini | 1:6d202b62ed68 | 61 | return mNfcLed1; |
| giovannivisentini | 1:6d202b62ed68 | 62 | } |
| giovannivisentini | 2:0648c1561eb2 | 63 | |
| giovannivisentini | 2:0648c1561eb2 | 64 | /** |
| giovannivisentini | 2:0648c1561eb2 | 65 | * @return board led2 |
| giovannivisentini | 2:0648c1561eb2 | 66 | */ |
| giovannivisentini | 1:6d202b62ed68 | 67 | DigitalOut& getLed2() { |
| giovannivisentini | 1:6d202b62ed68 | 68 | return mNfcLed2; |
| giovannivisentini | 1:6d202b62ed68 | 69 | } |
| giovannivisentini | 2:0648c1561eb2 | 70 | |
| giovannivisentini | 2:0648c1561eb2 | 71 | /** |
| giovannivisentini | 2:0648c1561eb2 | 72 | * @return board led3 |
| giovannivisentini | 2:0648c1561eb2 | 73 | */ |
| giovannivisentini | 1:6d202b62ed68 | 74 | DigitalOut& getLed3() { |
| giovannivisentini | 1:6d202b62ed68 | 75 | return mNfcLed3; |
| giovannivisentini | 1:6d202b62ed68 | 76 | } |
| giovannivisentini | 0:674813bd5ec9 | 77 | |
| giovannivisentini | 2:0648c1561eb2 | 78 | /** |
| giovannivisentini | 2:0648c1561eb2 | 79 | * @return NFC Chip |
| giovannivisentini | 2:0648c1561eb2 | 80 | */ |
| giovannivisentini | 1:6d202b62ed68 | 81 | M24SR& getM24SR() { |
| giovannivisentini | 1:6d202b62ed68 | 82 | return mM24SR; |
| giovannivisentini | 1:6d202b62ed68 | 83 | } |
| giovannivisentini | 0:674813bd5ec9 | 84 | |
| giovannivisentini | 1:6d202b62ed68 | 85 | virtual ~X_NUCLEO_NFC01A1() { |
| giovannivisentini | 1:6d202b62ed68 | 86 | } |
| giovannivisentini | 0:674813bd5ec9 | 87 | |
| giovannivisentini | 0:674813bd5ec9 | 88 | private: |
| giovannivisentini | 0:674813bd5ec9 | 89 | |
| giovannivisentini | 0:674813bd5ec9 | 90 | M24SR mM24SR; |
| giovannivisentini | 0:674813bd5ec9 | 91 | DigitalOut mNfcLed1; |
| giovannivisentini | 0:674813bd5ec9 | 92 | DigitalOut mNfcLed2; |
| giovannivisentini | 0:674813bd5ec9 | 93 | DigitalOut mNfcLed3; |
| giovannivisentini | 0:674813bd5ec9 | 94 | |
| giovannivisentini | 0:674813bd5ec9 | 95 | }; |
| giovannivisentini | 0:674813bd5ec9 | 96 | |
| giovannivisentini | 0:674813bd5ec9 | 97 | #endif /* X_NUCLEO_NFC01A1_H_ */ |
