- WiFi Connect app is now hidden by default, but accessible at the bottom of the WiFi Manage app when WiFi is turned on. - WiFi service now turns on WiFi when calling connect() and WiFi is not on. - Removed `blocking` option for `service::loader::startApp()`. This feature was unused and complex. - Various apps: Moved private headers into Private/ folder. - Various apps: created start() function for easy starting. - Added documentation to all TactilityC APIs - Refactored various `enum` into `class enum` - Refactor M5Stack `initBoot()` (but VBus is still 0V for some reason)
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 class Type {
|
|
Normal,
|
|
Recursive,
|
|
};
|
|
|
|
private:
|
|
|
|
SemaphoreHandle_t semaphore;
|
|
Type type;
|
|
|
|
public:
|
|
|
|
explicit Mutex(Type type = Type::Normal);
|
|
~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
|