2024-05-01 13:56:38 +02:00

58 lines
1.0 KiB
C++

/**
* @file
* @brief RTOS mutex implementation.
*/
#ifndef STA_RTOS_MUTEX_HPP
#define STA_RTOS_MUTEX_HPP
#include <sta/mutex.hpp>
#include <cmsis_os2.h>
namespace sta
{
/**
* @brief Implementation of Mutex interface using CMSIS RTOS2.
* @ingroup STA_RTOS_SYNC
*/
class RtosMutex : public Mutex
{
public:
/**
* @param handle CMSIS RTOS2 mutex
*/
RtosMutex(osMutexId_t handle);
/**
* @brief Construct a new Rtos Mutex object
*
* @param name The name of the mutex.
*/
RtosMutex(const char* name);
/**
* @brief Method for checking mutex ownership.
*
* @return Returns true if the currently running thread is the owner of the mutex.
*/
bool isCurrentThreadOwner() override;
/**
* @brief Acquire the mutex.
*/
void acquire(uint32_t timeout = osWaitForever) override;
/**
* @brief Release the mutex.
*/
void release() override;
private:
osMutexId_t handle_; /**< CMSIS RTOS2 mutex */
};
} // namespace sta
#endif // STA_RTOS_MUTEX_HPP