@@ -11,16 +11,24 @@ class TimerTask;
1111
1212#if defined(__MBED__) || defined(ARDUINO_ARDUINO_NANO33BLE)
1313
14+ #if !defined(TM_DONT_USE_CAPTURE)
1415#define TM_ALLOW_CAPTURED_LAMBDA
16+ #endif
1517
1618// check if this is Arduino mbed or regular mbed.
1719#if defined(ARDUINO_ARDUINO_NANO33BLE)
1820# define IOA_USE_ARDUINO
1921# define ARDUINO_MBED_MODE
2022# include " Arduino.h"
23+ # define IOA_MULTITHREADED
24+ #include " rtos/rtos.h"
25+ inline void * getCurrentThreadId () { return rtos::ThisThread::get_id (); }
2126#else
2227# define IOA_USE_MBED
2328# include " mbed.h"
29+ # define IOA_MULTITHREADED
30+ inline void * getCurrentThreadId () { return ThisThread::get_id (); }
31+
2432# if !defined(PIO_NEEDS_RTOS_WORKAROUND)
2533# include " rtos.h"
2634# endif // PIO_NEED_RTOS_WORKAROUND
@@ -81,8 +89,9 @@ namespace tm_internal {
8189#include " Arduino.h"
8290typedef uint8_t pintype_t ;
8391# define IOA_USE_ARDUINO
92+ #if !defined(TM_DONT_USE_CAPTURE)
8493# define TM_ALLOW_CAPTURED_LAMBDA
85-
94+ # endif
8695
8796#if defined(ESP8266)
8897#include < atomic>
@@ -151,6 +160,9 @@ namespace tm_internal {
151160 }
152161}
153162#else
163+ # define IOA_MULTITHREADED
164+ inline void * getCurrentThreadId () { return xTaskGetCurrentTaskHandle () ; }
165+
154166namespace tm_internal {
155167
156168 typedef TimerTask* volatile TimerTaskAtomicPtr;
@@ -261,7 +273,7 @@ inline void atomicWritePtr(TimerTaskAtomicPtr* pPtr, TimerTask* newValue) {
261273
262274// for all mbed and ESP boards we already enable lambda captures, SAMD is a known extra case that works.
263275// we can only enable on larger boards with enough memory to take the extra size of the structures.
264- #if !defined(TM_DONT_USE_LAMBDA ) && defined(ARDUINO_ARCH_SAMD)
276+ #if !defined(TM_DONT_USE_CAPTURE ) && defined(ARDUINO_ARCH_SAMD)
265277# define TM_ALLOW_CAPTURED_LAMBDA
266278#endif
267279
@@ -345,10 +357,10 @@ namespace tm_internal {
345357// Here we have one last go at determining if we should enable capture lambdas by checking if the functional include
346358// is available, we only do so if we are on GCC > 5
347359//
348- # if !defined(TM_ALLOW_CAPTURED_LAMBDA) && __GNUC__ >= 5
360+ # if !defined(TM_ALLOW_CAPTURED_LAMBDA) && !defined(TM_DONT_USE_CAPTURE) && __GNUC__ >= 5
349361#if __has_include(<functional>)
350362# define TM_ALLOW_CAPTURED_LAMBDA
351- #endif
363+ #endif // _has_include
352364#endif // GCC>=5 and !TM_ALLOW_CAPTURED_LAMBDA
353365
354366#endif // TASKMANGERIO_PLATFORMDETERMINATION_H
0 commit comments