Hi !
I'm using nrf52 + SDK 17.1.0.
I found sd_mutex_acquire/sd_mutex_release, which is great for locking variables that are set/get asynchronously.
Next, I'd like to use something like a semaphore, so I can indicate from my interrupt to the main loop that an event has occurred.
The closest thing I've found is nrf_atomic, but I'm not clear on how to use this like a semaphore.
Question - What are the *_fetch() APIs? eg - nrf_atomic_flag_clear() vs nrf_atomic_flag_clear_fetch()
Is it as simple as the following?
nrf_atomic_flag_t event1_flag = 0;
void interrupt() {
nrf_atomic_flag_set(&event1_flag);
} void main() {
while(1) {
if (event1_flag) {
nrf_atomic_flag_clear(&event1_flag);
//execute semaphore triggered code ?
}
}
}