mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
* SdCard HAL refactored (#135) - Refactor SdCard HAL - introduce Lockable * Screenshot and FatFS improvements (#136) - Fix screenshots on ESP32 - Improve Screenshot service - Convert Screenshot app to class-based instead of structs - Screenshot app now automatically updates when task is finished - Enable FatFS long filename support * Re-use common log messages (#138) For consistency and binary size reduction * Toolbar spinner should get margin to the right * More TactilityC features (#139) * Rewrote Loader - Simplified Loader by removing custom threa - Created DispatcherThread - Move auto-starting apps to Boot app - Fixed Dispatcher bug where it could get stuck not processing new messages * Hide AP settings if the AP is not saved * Missing from previous commit * Replace LV_EVENT_CLICKED with LV_EVENT_SHORT_CLICKED * Refactored files app and created InputDialog (#140) - Changed Files app so that it has a View and State - Files app now allows for long-pressing on files to perform actions - Files app now has rename and delete actions - Created InputDialog app - Improved AlertDialog app layout
96 lines
1.7 KiB
C++
96 lines
1.7 KiB
C++
/**
|
|
* @file mutex.h
|
|
* Mutex
|
|
*/
|
|
#pragma once
|
|
|
|
#include "CoreTypes.h"
|
|
#include "Thread.h"
|
|
#include "RtosCompatSemaphore.h"
|
|
#include "Check.h"
|
|
#include "Lockable.h"
|
|
#include <memory>
|
|
|
|
namespace tt {
|
|
|
|
class ScopedMutexUsage;
|
|
|
|
/**
|
|
* Wrapper for FreeRTOS xSemaphoreCreateMutex and xSemaphoreCreateRecursiveMutex
|
|
* Can be used in IRQ mode (within ISR context)
|
|
*/
|
|
class Mutex : public Lockable {
|
|
|
|
public:
|
|
|
|
enum Type {
|
|
TypeNormal,
|
|
TypeRecursive,
|
|
};
|
|
|
|
private:
|
|
|
|
SemaphoreHandle_t semaphore;
|
|
Type type;
|
|
|
|
public:
|
|
|
|
explicit Mutex(Type type = TypeNormal);
|
|
~Mutex() override;
|
|
|
|
TtStatus acquire(uint32_t timeoutTicks) const;
|
|
TtStatus release() const;
|
|
|
|
bool lock(uint32_t timeoutTicks) const override { return acquire(timeoutTicks) == TtStatusOk; }
|
|
bool unlock() const override { return release() == TtStatusOk; }
|
|
|
|
ThreadId getOwner() const;
|
|
};
|
|
|
|
/** Allocate Mutex
|
|
*
|
|
* @param[in] type The mutex type
|
|
*
|
|
* @return pointer to Mutex instance
|
|
*/
|
|
|
|
[[deprecated("use class")]]
|
|
Mutex* tt_mutex_alloc(Mutex::Type type);
|
|
|
|
/** Free Mutex
|
|
*
|
|
* @param mutex The Mutex instance
|
|
*/
|
|
[[deprecated("use class")]]
|
|
void tt_mutex_free(Mutex* mutex);
|
|
|
|
/** Acquire mutex
|
|
*
|
|
* @param mutex The Mutex instance
|
|
* @param[in] timeout The timeout
|
|
*
|
|
* @return The status.
|
|
*/
|
|
[[deprecated("use class")]]
|
|
TtStatus tt_mutex_acquire(Mutex* mutex, uint32_t timeout);
|
|
|
|
/** Release mutex
|
|
*
|
|
* @param mutex The Mutex instance
|
|
*
|
|
* @return The status.
|
|
*/
|
|
[[deprecated("use class")]]
|
|
TtStatus tt_mutex_release(Mutex* mutex);
|
|
|
|
/** Get mutex owner thread id
|
|
*
|
|
* @param mutex The Mutex instance
|
|
*
|
|
* @return The thread identifier.
|
|
*/
|
|
[[deprecated("use class")]]
|
|
ThreadId tt_mutex_get_owner(Mutex* mutex);
|
|
|
|
} // namespace
|