| 63 | |
| 64 | template<ptrdiff_t LeastMaxValue> |
| 65 | void CountingSemaphoreSTM32<LeastMaxValue>::release(ptrdiff_t update) { |
| 66 | FL_ASSERT(update >= 0, "CountingSemaphoreSTM32: release update must be non-negative"); |
| 67 | FL_ASSERT(mHandle != nullptr, "CountingSemaphoreSTM32::release() called on null semaphore"); |
| 68 | |
| 69 | SemaphoreHandle_t handle = static_cast<SemaphoreHandle_t>(mHandle); |
| 70 | |
| 71 | // Release the semaphore 'update' times |
| 72 | for (ptrdiff_t i = 0; i < update; ++i) { |
| 73 | BaseType_t result = xSemaphoreGive(handle); |
| 74 | |
| 75 | // If we fail to give, it means we would exceed the max value |
| 76 | if (result != pdTRUE) { |
| 77 | FL_ASSERT(false, "CountingSemaphoreSTM32: release would exceed max value"); |
| 78 | break; |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | template<ptrdiff_t LeastMaxValue> |
| 84 | void CountingSemaphoreSTM32<LeastMaxValue>::acquire() { |
no outgoing calls
no test coverage detected