2020-10-11 09:18:47 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "../freertosinc.h"
|
|
|
|
|
|
2026-01-03 21:19:24 +01:00
|
|
|
namespace concurrency {
|
2020-10-11 09:18:47 +08:00
|
|
|
|
|
|
|
|
#ifdef HAS_FREE_RTOS
|
|
|
|
|
|
2026-01-03 21:19:24 +01:00
|
|
|
class BinarySemaphoreFreeRTOS {
|
|
|
|
|
SemaphoreHandle_t semaphore;
|
2020-10-11 09:18:47 +08:00
|
|
|
|
2026-01-03 21:19:24 +01:00
|
|
|
public:
|
|
|
|
|
BinarySemaphoreFreeRTOS();
|
|
|
|
|
~BinarySemaphoreFreeRTOS();
|
2020-10-11 09:18:47 +08:00
|
|
|
|
2026-01-03 21:19:24 +01:00
|
|
|
/**
|
|
|
|
|
* Returns false if we timed out
|
|
|
|
|
*/
|
|
|
|
|
bool take(uint32_t msec);
|
2020-10-11 09:18:47 +08:00
|
|
|
|
2026-01-03 21:19:24 +01:00
|
|
|
void give();
|
2020-10-11 09:18:47 +08:00
|
|
|
|
2026-01-03 21:19:24 +01:00
|
|
|
void giveFromISR(BaseType_t *pxHigherPriorityTaskWoken);
|
2020-10-11 09:18:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-03-25 06:15:15 +08:00
|
|
|
} // namespace concurrency
|