sync.h File Reference
#include "pico.h"
#include "hardware/address_mapped.h"
#include "hardware/regs/sio.h"
Include dependency graph for sync.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PARAM_ASSERTIONS_ENABLED_SYNC   0
 
#define PICO_SPINLOCK_ID_IRQ   9
 
#define PICO_SPINLOCK_ID_TIMER   10
 
#define PICO_SPINLOCK_ID_HARDWARE_CLAIM   11
 
#define PICO_SPINLOCK_ID_RAND   12
 
#define PICO_SPINLOCK_ID_OS1   14
 
#define PICO_SPINLOCK_ID_OS2   15
 
#define PICO_SPINLOCK_ID_STRIPED_FIRST   16
 
#define PICO_SPINLOCK_ID_STRIPED_LAST   23
 
#define PICO_SPINLOCK_ID_CLAIM_FREE_FIRST   24
 
#define PICO_SPINLOCK_ID_CLAIM_FREE_LAST   31
 
#define remove_volatile_cast(t, x)   ({__mem_fence_acquire(); (t)(x); })
 

Typedefs

typedef volatile uint32_t spin_lock_t
 A spin lock identifier.
 

Functions

static __force_inline void __sev (void)
 Insert a SEV instruction in to the code path.The SEV (send event) instruction sends an event to both cores.
 
static __force_inline void __wfe (void)
 Insert a WFE instruction in to the code path.The WFE (wait for event) instruction waits until one of a number of events occurs, including events signalled by the SEV instruction on either core.
 
static __force_inline void __wfi (void)
 Insert a WFI instruction in to the code path.The WFI (wait for interrupt) instruction waits for a interrupt to wake up the core.
 
static __force_inline void __dmb (void)
 Insert a DMB instruction in to the code path.The DMB (data memory barrier) acts as a memory barrier, all memory accesses prior to this instruction will be observed before any explicit access after the instruction.
 
static __force_inline void __dsb (void)
 Insert a DSB instruction in to the code path.The DSB (data synchronization barrier) acts as a special kind of data memory barrier (DMB). The DSB operation completes when all explicit memory accesses before this instruction complete.
 
static __force_inline void __isb (void)
 Insert a ISB instruction in to the code path.ISB acts as an instruction synchronization barrier. It flushes the pipeline of the processor, so that all instructions following the ISB are fetched from cache or memory again, after the ISB instruction has been completed.
 
static __force_inline void __mem_fence_acquire (void)
 Acquire a memory fence.
 
static __force_inline void __mem_fence_release (void)
 Release a memory fence.
 
static __force_inline uint32_t save_and_disable_interrupts (void)
 Save and disable interrupts. More...
 
static __force_inline void restore_interrupts (uint32_t status)
 Restore interrupts to a specified state. More...
 
static __force_inline spin_lock_tspin_lock_instance (uint lock_num)
 Get HW Spinlock instance from number. More...
 
static __force_inline uint spin_lock_get_num (spin_lock_t *lock)
 Get HW Spinlock number from instance. More...
 
static __force_inline void spin_lock_unsafe_blocking (spin_lock_t *lock)
 Acquire a spin lock without disabling interrupts (hence unsafe) More...
 
static __force_inline void spin_unlock_unsafe (spin_lock_t *lock)
 Release a spin lock without re-enabling interrupts. More...
 
static __force_inline uint32_t spin_lock_blocking (spin_lock_t *lock)
 Acquire a spin lock safelyThis function will disable interrupts prior to acquiring the spinlock. More...
 
static bool is_spin_locked (spin_lock_t *lock)
 Check to see if a spinlock is currently acquired elsewhere. More...
 
static __force_inline void spin_unlock (spin_lock_t *lock, uint32_t saved_irq)
 Release a spin lock safelyThis function will re-enable interrupts according to the parameters. More...
 
spin_lock_tspin_lock_init (uint lock_num)
 Initialise a spin lockThe spin lock is initially unlocked. More...
 
void spin_locks_reset (void)
 Release all spin locks.
 
uint next_striped_spin_lock_num (void)
 Return a spin lock number from the striped rangeReturns a spin lock number in the range PICO_SPINLOCK_ID_STRIPED_FIRST to PICO_SPINLOCK_ID_STRIPED_LAST in a round robin fashion. This does not grant the caller exclusive access to the spin lock, so the caller must: More...
 
void spin_lock_claim (uint lock_num)
 Mark a spin lock as usedMethod for cooperative claiming of hardware. Will cause a panic if the spin lock is already claimed. Use of this method by libraries detects accidental configurations that would fail in unpredictable ways. More...
 
void spin_lock_claim_mask (uint32_t lock_num_mask)
 Mark multiple spin locks as usedMethod for cooperative claiming of hardware. Will cause a panic if any of the spin locks are already claimed. Use of this method by libraries detects accidental configurations that would fail in unpredictable ways. More...
 
void spin_lock_unclaim (uint lock_num)
 Mark a spin lock as no longer usedMethod for cooperative claiming of hardware. More...
 
int spin_lock_claim_unused (bool required)
 Claim a free spin lock. More...
 
bool spin_lock_is_claimed (uint lock_num)
 Determine if a spin lock is claimed. More...