mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-14 00:37:21 +00:00
20c4121f25
* Use static mutex * Add static_assert checks * Use static semaphore * Fix formatting * Use static stream buffer * Use static timer * Use static event group * Increase allocation size for stream buffer * Remove recursive bit from the mutex before freeing * Prevent service tasks from ever returning * Use static threads * Do not realloc memory when changing stack size * Use FuriSemaphore instead of raw FreeRTOS one in rpc_test * Remove redundant includes * Abolish FreeRTOS dynamic allocation * Improve FuriMutex * Improve FuriMessageQueue * Remove redundant comments and parentheses * Clean up code more * Create service threads via a dedicated constructor * Minor code improvements * Update docs for FuriThread, FuriTimer * Fix doxygen typo * Use a bigger buffer for static StreamBuffer * Furi: remove timer control block only when timer thread have completed all operations --------- Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
62 lines
1.1 KiB
C
62 lines
1.1 KiB
C
/**
|
|
* @file mutex.h
|
|
* FuriMutex
|
|
*/
|
|
#pragma once
|
|
|
|
#include "base.h"
|
|
#include "thread.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef enum {
|
|
FuriMutexTypeNormal,
|
|
FuriMutexTypeRecursive,
|
|
} FuriMutexType;
|
|
|
|
typedef struct FuriMutex FuriMutex;
|
|
|
|
/** Allocate FuriMutex
|
|
*
|
|
* @param[in] type The mutex type
|
|
*
|
|
* @return pointer to FuriMutex instance
|
|
*/
|
|
FuriMutex* furi_mutex_alloc(FuriMutexType type);
|
|
|
|
/** Free FuriMutex
|
|
*
|
|
* @param instance The pointer to FuriMutex instance
|
|
*/
|
|
void furi_mutex_free(FuriMutex* instance);
|
|
|
|
/** Acquire mutex
|
|
*
|
|
* @param instance The pointer to FuriMutex instance
|
|
* @param[in] timeout The timeout
|
|
*
|
|
* @return The furi status.
|
|
*/
|
|
FuriStatus furi_mutex_acquire(FuriMutex* instance, uint32_t timeout);
|
|
|
|
/** Release mutex
|
|
*
|
|
* @param instance The pointer to FuriMutex instance
|
|
*
|
|
* @return The furi status.
|
|
*/
|
|
FuriStatus furi_mutex_release(FuriMutex* instance);
|
|
|
|
/** Get mutex owner thread id
|
|
*
|
|
* @param instance The pointer to FuriMutex instance
|
|
*
|
|
* @return The furi thread identifier.
|
|
*/
|
|
FuriThreadId furi_mutex_get_owner(FuriMutex* instance);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|