Tactility/TactilityC/Source/tt_semaphore.cpp
Ken Van Hoeylandt 6c67845645
Cleanup and improvements (#194)
- Lots of changes for migrating C code to C++
- Improved `Lockable` in several ways like adding `withLock()` (+ tests)
- Improved `Semaphore` a bit for improved readability, and also added some tests
- Upgrade Linux machine in GitHub Actions so that we can compile with a newer GCC
- Simplification of WiFi connection
- Updated funding options
- (and more)
2025-01-28 17:39:58 +01:00

29 lines
726 B
C++

#include "tt_semaphore.h"
#include "Semaphore.h"
extern "C" {
#define HANDLE_AS_SEMAPHORE(handle) ((tt::Semaphore*)(handle))
SemaphoreHandle tt_semaphore_alloc(uint32_t maxCount, TickType_t initialCount) {
return new tt::Semaphore(maxCount, initialCount);
}
void tt_semaphore_free(SemaphoreHandle handle) {
delete HANDLE_AS_SEMAPHORE(handle);
}
bool tt_semaphore_acquire(SemaphoreHandle handle, TickType_t timeoutTicks) {
return HANDLE_AS_SEMAPHORE(handle)->acquire(timeoutTicks);
}
bool tt_semaphore_release(SemaphoreHandle handle) {
return HANDLE_AS_SEMAPHORE(handle)->release();
}
uint32_t tt_semaphore_get_count(SemaphoreHandle handle) {
return HANDLE_AS_SEMAPHORE(handle)->getAvailable();
}
}