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!

Committer:
AppNearMe
Date:
Thu Jul 26 09:12:27 2012 +0000
Revision:
0:480387549d89
Child:
3:0b949b2d3b55
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AppNearMe 0:480387549d89 1 /*
AppNearMe 0:480387549d89 2 EventCallback.cpp
AppNearMe 0:480387549d89 3 Copyright (c) Donatien Garnier 2012
AppNearMe 0:480387549d89 4 donatien.garnier@appnearme.com
AppNearMe 0:480387549d89 5 http://www.appnearme.com/
AppNearMe 0:480387549d89 6 */
AppNearMe 0:480387549d89 7
AppNearMe 0:480387549d89 8 #include "EventCallback.h"
AppNearMe 0:480387549d89 9
AppNearMe 0:480387549d89 10 EventCallback::EventCallback()
AppNearMe 0:480387549d89 11 {
AppNearMe 0:480387549d89 12
AppNearMe 0:480387549d89 13 }
AppNearMe 0:480387549d89 14
AppNearMe 0:480387549d89 15 void EventCallback::init(void (*fn)(target_event_callback, void*))
AppNearMe 0:480387549d89 16 {
AppNearMe 0:480387549d89 17 fn(staticCallback, this);
AppNearMe 0:480387549d89 18 }
AppNearMe 0:480387549d89 19
AppNearMe 0:480387549d89 20 void EventCallback::attach(void (*fn)(NFCEvent, void*), void* arg)
AppNearMe 0:480387549d89 21 {
AppNearMe 0:480387549d89 22 m_inst = NULL;
AppNearMe 0:480387549d89 23 m_fn = fn;
AppNearMe 0:480387549d89 24 m_arg = arg;
AppNearMe 0:480387549d89 25 }
AppNearMe 0:480387549d89 26
AppNearMe 0:480387549d89 27 void EventCallback::callback(target_event event)
AppNearMe 0:480387549d89 28 {
AppNearMe 0:480387549d89 29 if(m_inst)
AppNearMe 0:480387549d89 30 {
AppNearMe 0:480387549d89 31 m_caller((NFCEvent)event); //At some point, should not cast event directly
AppNearMe 0:480387549d89 32 }
AppNearMe 0:480387549d89 33 else if(m_fn)
AppNearMe 0:480387549d89 34 {
AppNearMe 0:480387549d89 35 m_fn((NFCEvent)event, m_arg);
AppNearMe 0:480387549d89 36 }
AppNearMe 0:480387549d89 37 }
AppNearMe 0:480387549d89 38
AppNearMe 0:480387549d89 39 /*static*/ void EventCallback::staticCallback(target_event event, void* param)
AppNearMe 0:480387549d89 40 {
AppNearMe 0:480387549d89 41 ((EventCallback*)(param))->callback(event);
AppNearMe 0:480387549d89 42 }
AppNearMe 0:480387549d89 43
AppNearMe 0:480387549d89 44
AppNearMe 0:480387549d89 45
AppNearMe 0:480387549d89 46
AppNearMe 0:480387549d89 47