mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-11-26 21:39:28 +03: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>
59 lines
1.2 KiB
C
59 lines
1.2 KiB
C
/**
|
|
* @file semaphore.h
|
|
* FuriSemaphore
|
|
*/
|
|
#pragma once
|
|
|
|
#include "base.h"
|
|
#include "thread.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct FuriSemaphore FuriSemaphore;
|
|
|
|
/** Allocate semaphore
|
|
*
|
|
* @param[in] max_count The maximum count
|
|
* @param[in] initial_count The initial count
|
|
*
|
|
* @return pointer to FuriSemaphore instance
|
|
*/
|
|
FuriSemaphore* furi_semaphore_alloc(uint32_t max_count, uint32_t initial_count);
|
|
|
|
/** Free semaphore
|
|
*
|
|
* @param instance The pointer to FuriSemaphore instance
|
|
*/
|
|
void furi_semaphore_free(FuriSemaphore* instance);
|
|
|
|
/** Acquire semaphore
|
|
*
|
|
* @param instance The pointer to FuriSemaphore instance
|
|
* @param[in] timeout The timeout
|
|
*
|
|
* @return The furi status.
|
|
*/
|
|
FuriStatus furi_semaphore_acquire(FuriSemaphore* instance, uint32_t timeout);
|
|
|
|
/** Release semaphore
|
|
*
|
|
* @param instance The pointer to FuriSemaphore instance
|
|
*
|
|
* @return The furi status.
|
|
*/
|
|
FuriStatus furi_semaphore_release(FuriSemaphore* instance);
|
|
|
|
/** Get semaphore count
|
|
*
|
|
* @param instance The pointer to FuriSemaphore instance
|
|
*
|
|
* @return Semaphore count
|
|
*/
|
|
uint32_t furi_semaphore_get_count(FuriSemaphore* instance);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|