ruuvi.drivers.c
${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
|
Go to the source code of this file.
Macros | |
#define | RI_ATOMIC_FLAG_INIT 0 |
Enable implementation selected by application. More... | |
Typedefs | |
typedef volatile uint32_t | ri_atomic_t |
define atomic type - not portable to 8-bit. More... | |
Functions | |
bool | ri_atomic_flag (ri_atomic_t *const flag, const bool set) |
Atomic flag check and set/clear function. More... | |
Interface for basic atomic operations.
Definition in file ruuvi_interface_atomic.h.
#define RI_ATOMIC_FLAG_INIT 0 |
Enable implementation selected by application.
Initial value for atomic flag.
Definition at line 29 of file ruuvi_interface_atomic.h.
typedef volatile uint32_t ri_atomic_t |
define atomic type - not portable to 8-bit.
Definition at line 31 of file ruuvi_interface_atomic.h.
bool ri_atomic_flag | ( | ri_atomic_t *const | flag, |
const bool | set | ||
) |
Atomic flag check and set/clear function.
Uses whatever mechanism underlying platform provides to check and set or clear flag. When implementing mutex, check-and-set flag to reserve a mutex and check-and-clear to free it.
Generally used like this:
It's important to return if lock can't be had rather than busylooping: if the interrupt level which fails to get lock is higher than the call which has the lock program will deadlock in the busyloop. Likewise failure to release the lock will cause deadlock in the next execution, fail immediately.
[in] | flag | uint32_t address of bitfield to check. |
[in] | set | true to set flag, false to clear flag. |
true
if operation was successful. false
otherwise.