Skip to content

Commit 7298bc2

Browse files
authored
Fix PAL events getter (#1715)
***NO_CI***
1 parent c72a2ae commit 7298bc2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/PAL/Events/nanoPAL_Events.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <nanoPAL_events.h>
88
// #include <stdbool.h>
99

10-
volatile uint32_t systemEvents;
10+
static uint32_t systemEvents;
1111

1212
set_Event_Callback g_Event_Callback = NULL;
1313
void *g_Event_Callback_Arg = NULL;
@@ -47,20 +47,20 @@ __nfweak uint32_t Events_Get(uint32_t eventsOfInterest)
4747
{
4848
NATIVE_PROFILE_PAL_EVENTS();
4949

50+
// ... clear the requested flags atomically
51+
// give the caller notice of just the events they asked for ( and were cleared already )
52+
#ifdef __CM0_CMSIS_VERSION
5053
// get the requested flags from system events state and...
5154
uint32_t returnEvents = (systemEvents & eventsOfInterest);
5255

53-
// ... clear the requested flags atomically
54-
#ifdef __CM0_CMSIS_VERSION
5556
GLOBAL_LOCK();
5657
systemEvents &= ~eventsOfInterest;
5758
GLOBAL_UNLOCK();
58-
#else
59-
__atomic_fetch_nand(&systemEvents, eventsOfInterest, __ATOMIC_RELAXED);
60-
#endif
6159

62-
// give the caller notice of just the events they asked for ( and were cleared already )
6360
return returnEvents;
61+
#else
62+
return __atomic_fetch_and(&systemEvents, ~eventsOfInterest, __ATOMIC_RELAXED) & eventsOfInterest;
63+
#endif
6464
}
6565

6666
__nfweak uint32_t Events_MaskedRead(uint32_t eventsOfInterest)

0 commit comments

Comments
 (0)