mutex.h File Reference
#include "pico/lock_core.h"
Include dependency graph for mutex.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  __packed_aligned
 recursive mutex instance More...
 
struct  mutex
 regular (non recursive) mutex instance More...
 

Macros

#define auto_init_mutex(name)   static __attribute__((section(".mutex_array"))) mutex_t name
 Helper macro for static definition of mutexes. More...
 
#define auto_init_recursive_mutex(name)   static __attribute__((section(".mutex_array"))) recursive_mutex_t name = { .core = { .spin_lock = (spin_lock_t *)1 /* marker for runtime_init */ }, .owner = 0, .enter_count = 0 }
 Helper macro for static definition of recursive mutexes. More...
 

Typedefs

typedef struct __packed_aligned recursive_mutex_t
 recursive mutex instance
 
typedef struct __packed_aligned mutex mutex_t
 regular (non recursive) mutex instance
 

Functions

void mutex_init (mutex_t *mtx)
 Initialise a mutex structure. More...
 
void recursive_mutex_init (recursive_mutex_t *mtx)
 Initialise a recursive mutex structure. More...
 
void mutex_enter_blocking (mutex_t *mtx)
 Take ownership of a mutex. More...
 
void recursive_mutex_enter_blocking (recursive_mutex_t *mtx)
 Take ownership of a recursive mutex. More...
 
bool mutex_try_enter (mutex_t *mtx, uint32_t *owner_out)
 Attempt to take ownership of a mutex. More...
 
bool mutex_try_enter_block_until (mutex_t *mtx, absolute_time_t until)
 Attempt to take ownership of a mutex until the specified time. More...
 
bool recursive_mutex_try_enter (recursive_mutex_t *mtx, uint32_t *owner_out)
 Attempt to take ownership of a recursive mutex. More...
 
bool mutex_enter_timeout_ms (mutex_t *mtx, uint32_t timeout_ms)
 Wait for mutex with timeout. More...
 
bool recursive_mutex_enter_timeout_ms (recursive_mutex_t *mtx, uint32_t timeout_ms)
 Wait for recursive mutex with timeout. More...
 
bool mutex_enter_timeout_us (mutex_t *mtx, uint32_t timeout_us)
 Wait for mutex with timeout. More...
 
bool recursive_mutex_enter_timeout_us (recursive_mutex_t *mtx, uint32_t timeout_us)
 Wait for recursive mutex with timeout. More...
 
bool mutex_enter_block_until (mutex_t *mtx, absolute_time_t until)
 Wait for mutex until a specific time. More...
 
bool recursive_mutex_enter_block_until (recursive_mutex_t *mtx, absolute_time_t until)
 Wait for mutex until a specific time. More...
 
void mutex_exit (mutex_t *mtx)
 Release ownership of a mutex. More...
 
void recursive_mutex_exit (recursive_mutex_t *mtx)
 Release ownership of a recursive mutex. More...
 
static bool mutex_is_initialized (mutex_t *mtx)
 Test for mutex initialized state. More...
 
static bool recursive_mutex_is_initialized (recursive_mutex_t *mtx)
 Test for recursive mutex initialized state. More...