diff --git a/include/sta/os2/signal.hpp b/include/sta/os2/signal.hpp new file mode 100644 index 0000000..ed0e815 --- /dev/null +++ b/include/sta/os2/signal.hpp @@ -0,0 +1,27 @@ +#ifndef STA_OS2_SIGNAL_HPP +#define STA_OS2_SIGNAL_HPP + +#include + +#include + + +namespace sta +{ + class Os2Signal : public Signal + { + public: + Os2Signal(osSemaphoreId_t * semaphore); + + void notify() override; + bool peek() override; + bool test() override; + void wait() override; + + private: + osSemaphoreId_t * semaphore_; + }; +} // namespace sta + + +#endif // STA_OS2_SIGNAL_HPP diff --git a/src/os2/signal.cpp b/src/os2/signal.cpp new file mode 100644 index 0000000..667b4da --- /dev/null +++ b/src/os2/signal.cpp @@ -0,0 +1,29 @@ +#include + + +namespace sta +{ + Os2Signal::Os2Signal(osSemaphoreId_t * semaphore) + : semaphore_{semaphore} + {} + + void Os2Signal::notify() + { + osSemaphoreRelease(*semaphore_); + } + + bool Os2Signal::peek() + { + return (osSemaphoreGetCount(*semaphore_) != 0); + } + + bool Os2Signal::test() + { + return (osSemaphoreAcquire(*semaphore_, 0) == osOK); + } + + void Os2Signal::wait() + { + osSemaphoreAcquire(*semaphore_, osWaitForever); + } +} // namespace sta