2024-02-07 18:50:13 +01:00

61 lines
1.0 KiB
C++

/**
* @file
* @brief RTOS signal implementation.
*/
#ifndef STA_RTOS_SIGNAL_HPP
#define STA_RTOS_SIGNAL_HPP
#include <sta/signal.hpp>
#include <cmsis_os2.h>
namespace sta
{
/**
* @brief Implementation of Signal interface using CMSIS RTOS2.
*
* @ingroup STA_RTOS_SYNC
*
*/
class RtosSignal : public Signal
{
public:
/**
* @param semaphore CMSIS RTOS2 semaphore
*/
RtosSignal(osSemaphoreId_t semaphore);
RtosSignal(uint32_t max, uint32_t initial = 0);
/**
* @brief Notify the signal.
*/
void notify() override;
/**
* @brief Check if the signal is set.
*
* @return true if the signal is set.
*/
bool peek() override;
/**
* @brief Check if the signal is set and clear it.
*
* @return true if the signal was set.
*/
bool test() override;
/**
* @brief Wait for the signal to be set.
*/
void wait() override;
private:
osSemaphoreId_t semaphore_; /**< CMSIS RTOS2 semaphore */
};
} // namespace sta
#endif // STA_RTOS_SIGNAL_HPP