12#ifndef __METAL_MUTEX__H__
13#error "Include metal/mutex.h instead of metal/freertos/mutex.h"
16#ifndef __METAL_FREERTOS_MUTEX__H__
17#define __METAL_FREERTOS_MUTEX__H__
19#include <metal/assert.h>
37#define METAL_MUTEX_INIT(m) { NULL }; \
38_Pragma("GCC warning\"static initialisation of the mutex is deprecated\"")
39#elif defined(__ICCARM__)
40#define DO_PRAGMA(x) _Pragma(#x)
41#define METAL_MUTEX_INIT(m) { NULL }; \
42DO_PRAGMA(message("Warning: static initialisation of the mutex is deprecated"))
44#define METAL_MUTEX_INIT(m) { NULL }
51#define METAL_MUTEX_DEFINE(m) metal_mutex_t m = METAL_MUTEX_INIT(m)
56 mutex->
m = xSemaphoreCreateMutex();
63 vSemaphoreDelete(mutex->
m);
70 return xSemaphoreTake(mutex->
m, (TickType_t)0);
76 xSemaphoreTake(mutex->
m, portMAX_DELAY);
82 xSemaphoreGive(mutex->
m);
88 return (!xSemaphoreGetMutexHolder(mutex->
m)) ? 0 : 1;
#define metal_assert(cond)
Assertion macro.
Definition: assert.h:21
static void __metal_mutex_release(metal_mutex_t *mutex)
Definition: mutex.h:79
static void __metal_mutex_deinit(metal_mutex_t *mutex)
Definition: mutex.h:60
static int __metal_mutex_try_acquire(metal_mutex_t *mutex)
Definition: mutex.h:67
static int __metal_mutex_is_acquired(metal_mutex_t *mutex)
Definition: mutex.h:85
static void __metal_mutex_acquire(metal_mutex_t *mutex)
Definition: mutex.h:73
static void __metal_mutex_init(metal_mutex_t *mutex)
Definition: mutex.h:53