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)
This commit is contained in:
committed by
GitHub
parent
1bb1260ea0
commit
6c67845645
@@ -4,7 +4,7 @@
|
||||
|
||||
namespace tt {
|
||||
|
||||
static inline struct QueueDefinition* createHandle(uint32_t maxCount, uint32_t initialCount) {
|
||||
static inline QueueHandle_t createHandle(uint32_t maxCount, uint32_t initialCount) {
|
||||
assert((maxCount > 0U) && (initialCount <= maxCount));
|
||||
|
||||
if (maxCount == 1U) {
|
||||
@@ -21,7 +21,7 @@ static inline struct QueueDefinition* createHandle(uint32_t maxCount, uint32_t i
|
||||
}
|
||||
}
|
||||
|
||||
Semaphore::Semaphore(uint32_t maxCount, uint32_t initialCount) : handle(createHandle(maxCount, initialCount)){
|
||||
Semaphore::Semaphore(uint32_t maxAvailable, uint32_t initialAvailable) : handle(createHandle(maxAvailable, initialAvailable)) {
|
||||
assert(!TT_IS_IRQ_MODE());
|
||||
tt_check(handle != nullptr);
|
||||
}
|
||||
@@ -30,7 +30,7 @@ Semaphore::~Semaphore() {
|
||||
assert(!TT_IS_IRQ_MODE());
|
||||
}
|
||||
|
||||
bool Semaphore::acquire(uint32_t timeout) const {
|
||||
bool Semaphore::acquire(TickType_t timeout) const {
|
||||
if (TT_IS_IRQ_MODE()) {
|
||||
if (timeout != 0U) {
|
||||
return false;
|
||||
@@ -45,7 +45,7 @@ bool Semaphore::acquire(uint32_t timeout) const {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return xSemaphoreTake(handle.get(), (TickType_t)timeout) == pdPASS;
|
||||
return xSemaphoreTake(handle.get(), timeout) == pdPASS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,13 +63,13 @@ bool Semaphore::release() const {
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t Semaphore::getCount() const {
|
||||
uint32_t Semaphore::getAvailable() const {
|
||||
if (TT_IS_IRQ_MODE()) {
|
||||
// TODO: uxSemaphoreGetCountFromISR is not supported on esp-idf 5.1.2 - perhaps later on?
|
||||
#ifdef uxSemaphoreGetCountFromISR
|
||||
return uxSemaphoreGetCountFromISR(handle.get());
|
||||
#else
|
||||
return uxQueueMessagesWaitingFromISR((QueueHandle_t)hSemaphore);
|
||||
return uxQueueMessagesWaitingFromISR(handle.get());
|
||||
#endif
|
||||
} else {
|
||||
return uxSemaphoreGetCount(handle.get());
|
||||
|
||||
Reference in New Issue
Block a user