From 341f36ef9d0585e52a87a6c0ebb7498bec55e63e Mon Sep 17 00:00:00 2001 From: dario Date: Wed, 7 Feb 2024 18:50:13 +0100 Subject: [PATCH] Additional constructor for rtos signal --- include/sta/rtos/signal.hpp | 2 ++ src/signal.cpp | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/sta/rtos/signal.hpp b/include/sta/rtos/signal.hpp index b7b0ee9..f39f3da 100644 --- a/include/sta/rtos/signal.hpp +++ b/include/sta/rtos/signal.hpp @@ -25,6 +25,8 @@ namespace sta */ RtosSignal(osSemaphoreId_t semaphore); + RtosSignal(uint32_t max, uint32_t initial = 0); + /** * @brief Notify the signal. */ diff --git a/src/signal.cpp b/src/signal.cpp index 6047088..594396c 100644 --- a/src/signal.cpp +++ b/src/signal.cpp @@ -1,11 +1,21 @@ #include +#include + namespace sta { RtosSignal::RtosSignal(osSemaphoreId_t semaphore) : semaphore_{semaphore} - {} + { + STA_ASSERT(semaphore != NULL); + } + + RtosSignal::RtosSignal(uint32_t max, uint32_t initial /* = 0 */) + : semaphore_{osSemaphoreNew(max, initial, NULL)} + { + STA_ASSERT(semaphore_ != NULL); + } void RtosSignal::notify() {