mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 10:53:17 +00:00
- Update `Configuration` to use C++ vector instead of C arrays - Rename `Desktop` app to `Launcher` - Fix for hard-coded app start of `Launcher` and `CrashDiagnostics` apps. - Ensure `Launcher` icons are clickable, even if they're not loading. - Don't show error scenario for SD card in statusbar when SD card status is unknown (this happens during Mutex timeout due to LVGL rendering delays) - Cleanup deprecated `Mutex` methods. - `hal::getConfiguration()` now returns a pointer instead of a reference, just like `tt:getConfiguration()`
66 lines
1.3 KiB
C++
66 lines
1.3 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 {
|
|
|
|
/**
|
|
* 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;
|
|
|
|
/** Attempt to lock the mutex. Blocks until timeout passes or lock is acquired.
|
|
* @param[in] timeout
|
|
* @return status result
|
|
*/
|
|
TtStatus acquire(TickType_t timeout) const;
|
|
|
|
/** Attempt to unlock the mutex.
|
|
* @return status result
|
|
*/
|
|
TtStatus release() const;
|
|
|
|
/** Attempt to lock the mutex. Blocks until timeout passes or lock is acquired.
|
|
* @param[in] timeout
|
|
* @return success result
|
|
*/
|
|
bool lock(TickType_t timeout) const override { return acquire(timeout) == TtStatusOk; }
|
|
|
|
/** Attempt to unlock the mutex.
|
|
* @return success result
|
|
*/
|
|
bool unlock() const override { return release() == TtStatusOk; }
|
|
|
|
/** @return the owner of the thread */
|
|
ThreadId getOwner() const;
|
|
};
|
|
|
|
} // namespace
|