Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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!
Diff: PN532/MuNFC.cpp
- Revision:
- 2:913eb8fdfd9d
- Parent:
- 0:480387549d89
- Child:
- 3:0b949b2d3b55
diff -r 1074716d0111 -r 913eb8fdfd9d PN532/MuNFC.cpp
--- a/PN532/MuNFC.cpp	Thu Jul 26 09:13:04 2012 +0000
+++ b/PN532/MuNFC.cpp	Thu Jul 26 10:02:19 2012 +0000
@@ -11,7 +11,7 @@
 
 #include "mbed.h"
 #if MUNFC_RTOS
-#include "rtos.h"
+#include "rtos/rtos.h"
 #endif
 
 #include "munfc/core/fwk.h"
@@ -35,7 +35,7 @@
     PinName mosi, PinName miso, PinName sclk, PinName cs, PinName isr) :
    /* m_irq_pin_int(isr),*/ m_irq_pin_isr(isr), m_cs_pin(cs), m_spi(mosi, miso, sclk)
 #if MUNFC_RTOS
-  , m_thread(MuNFC::staticCallback, (void*)this)
+  , m_pThread(NULL)//m_thread(MuNFC::staticCallback, (void*)this)
 #endif
 {
   //nfc_irq_pin_int = &m_irq_pin_int;
@@ -49,8 +49,20 @@
   m_decodeCb.init(appnearme_ndef_register_decode_callback);
 }
 
+MuNFC::~MuNFC()
+{
+  if(m_pThread != NULL)
+  {
+    delete m_pThread;
+  }
+}
+
 bool MuNFC::init()
 {
+  if(m_pThread == NULL)
+  {
+    m_pThread = new Thread(MuNFC::staticCallback, (void*)this);
+  }
 #if NFC_CONTROLLER == PN512
   int ret = target_nfctype2_start();
 #elif NFC_CONTROLLER == PN532
@@ -67,7 +79,7 @@
 void MuNFC::run()
 {
   //Start NFC thread
-  m_thread.signal_set(SIGNAL_START);
+  m_pThread->signal_set(SIGNAL_START);
 }
 
 void MuNFC::process()