| 109 | template<ptrdiff_t LeastMaxValue> |
| 110 | template<class Rep, class Period> |
| 111 | bool CountingSemaphoreSTM32<LeastMaxValue>::try_acquire_for( |
| 112 | const std::chrono::duration<Rep, Period>& rel_time) { // okay std namespace |
| 113 | |
| 114 | if (mHandle == nullptr) { |
| 115 | return false; |
| 116 | } |
| 117 | |
| 118 | // Convert duration to FreeRTOS ticks |
| 119 | auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(rel_time); // okay std namespace |
| 120 | TickType_t ticks = pdMS_TO_TICKS(ms.count()); |
| 121 | |
| 122 | SemaphoreHandle_t handle = static_cast<SemaphoreHandle_t>(mHandle); |
| 123 | BaseType_t result = xSemaphoreTake(handle, ticks); |
| 124 | |
| 125 | return (result == pdTRUE); |
| 126 | } |
| 127 | |
| 128 | template<ptrdiff_t LeastMaxValue> |
| 129 | template<class Clock, class Duration> |