Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PAL events getter #1715

Merged
merged 2 commits into from
Oct 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/PAL/Events/nanoPAL_Events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <nanoPAL_events.h>
// #include <stdbool.h>

volatile uint32_t systemEvents;
static uint32_t systemEvents;

set_Event_Callback g_Event_Callback = NULL;
void *g_Event_Callback_Arg = NULL;
Expand Down Expand Up @@ -47,20 +47,20 @@ __nfweak uint32_t Events_Get(uint32_t eventsOfInterest)
{
NATIVE_PROFILE_PAL_EVENTS();

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

// ... clear the requested flags atomically
#ifdef __CM0_CMSIS_VERSION
GLOBAL_LOCK();
systemEvents &= ~eventsOfInterest;
GLOBAL_UNLOCK();
#else
__atomic_fetch_nand(&systemEvents, eventsOfInterest, __ATOMIC_RELAXED);
#endif

// give the caller notice of just the events they asked for ( and were cleared already )
return returnEvents;
#else
return __atomic_fetch_and(&systemEvents, ~eventsOfInterest, __ATOMIC_RELAXED) & eventsOfInterest;
#endif
}

__nfweak uint32_t Events_MaskedRead(uint32_t eventsOfInterest)
Expand Down