AppNearMe µNFC stack for the NXP PN532 chip License: You can use the stack free of charge to prototype with mbed; if you want to use the stack with your commercial product, get in touch!
Dependents: IOT_sensor_nfc AppNearMe_MuNFC_PN532_Test p2p_nfc_test NFCMoodLamp ... more
License
You can use the stack free of charge to prototype with mbed; if you want to use the stack with your commercial product, get in touch!
PN532/EventCallback.cpp@13:6f98851e025b, 2013-01-15 (annotated)
- Committer:
- AppNearMe
- Date:
- Tue Jan 15 15:34:39 2013 +0000
- Revision:
- 13:6f98851e025b
- Parent:
- 11:5be631376e5b
renamed rtos.h to platform_rtos.h to prevent insludes mess
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AppNearMe | 11:5be631376e5b | 1 | /* |
AppNearMe | 11:5be631376e5b | 2 | EventCallback.cpp |
AppNearMe | 11:5be631376e5b | 3 | Copyright (c) Donatien Garnier 2012 |
AppNearMe | 11:5be631376e5b | 4 | donatien.garnier@appnearme.com |
AppNearMe | 11:5be631376e5b | 5 | http://www.appnearme.com/ |
AppNearMe | 11:5be631376e5b | 6 | */ |
AppNearMe | 11:5be631376e5b | 7 | |
AppNearMe | 11:5be631376e5b | 8 | #include "EventCallback.h" |
AppNearMe | 11:5be631376e5b | 9 | |
AppNearMe | 11:5be631376e5b | 10 | EventCallback::EventCallback() |
AppNearMe | 11:5be631376e5b | 11 | { |
AppNearMe | 11:5be631376e5b | 12 | |
AppNearMe | 11:5be631376e5b | 13 | } |
AppNearMe | 11:5be631376e5b | 14 | |
AppNearMe | 11:5be631376e5b | 15 | void EventCallback::init(void (*fn)(transaction_event_callback, void*)) |
AppNearMe | 11:5be631376e5b | 16 | { |
AppNearMe | 11:5be631376e5b | 17 | fn(staticCallback, this); |
AppNearMe | 11:5be631376e5b | 18 | } |
AppNearMe | 11:5be631376e5b | 19 | |
AppNearMe | 11:5be631376e5b | 20 | void EventCallback::attach(void (*fn)(NFCEvent, void*), void* arg) |
AppNearMe | 11:5be631376e5b | 21 | { |
AppNearMe | 11:5be631376e5b | 22 | m_inst = NULL; |
AppNearMe | 11:5be631376e5b | 23 | m_fn = fn; |
AppNearMe | 11:5be631376e5b | 24 | m_arg = arg; |
AppNearMe | 11:5be631376e5b | 25 | } |
AppNearMe | 11:5be631376e5b | 26 | |
AppNearMe | 11:5be631376e5b | 27 | void EventCallback::callback(transaction_event event, transaction_type type) |
AppNearMe | 11:5be631376e5b | 28 | { |
AppNearMe | 11:5be631376e5b | 29 | if(m_inst) |
AppNearMe | 11:5be631376e5b | 30 | { |
AppNearMe | 11:5be631376e5b | 31 | m_caller(this, (NFCEvent)event); //At some point, should not cast event directly |
AppNearMe | 11:5be631376e5b | 32 | } |
AppNearMe | 11:5be631376e5b | 33 | else if(m_fn) |
AppNearMe | 11:5be631376e5b | 34 | { |
AppNearMe | 11:5be631376e5b | 35 | m_fn((NFCEvent)event, m_arg); |
AppNearMe | 11:5be631376e5b | 36 | } |
AppNearMe | 11:5be631376e5b | 37 | } |
AppNearMe | 11:5be631376e5b | 38 | |
AppNearMe | 11:5be631376e5b | 39 | /*static*/ void EventCallback::staticCallback(transaction_event event, transaction_type type, void* param) |
AppNearMe | 11:5be631376e5b | 40 | { |
AppNearMe | 11:5be631376e5b | 41 | ((EventCallback*)(param))->callback(event, type); |
AppNearMe | 11:5be631376e5b | 42 | } |
AppNearMe | 11:5be631376e5b | 43 | |
AppNearMe | 11:5be631376e5b | 44 | |
AppNearMe | 11:5be631376e5b | 45 | |
AppNearMe | 11:5be631376e5b | 46 | |
AppNearMe | 11:5be631376e5b | 47 |