Implement ValueManager and ValueComposer (#183)
* Fix ValueManager implementation * Implement ValueComposer * Add constructor for ValueManager * Add value-expanders.h to flipper_v2.h set * Move COPY_COMPOSE body into a .c file * Add test for ValueManager * Add destructors for ValueMutex, ValueManager and ValueComposer * Use destructors in tests * Move composition logic into perform_compose() * Add docs for perform_compose() * Add test for ValueComposer * Replace atomic_bool with bool as g++ compiler doesn't support C11 atomics * Add Event type * Add semaphore support to the local target * Add test for Event * Update input records and relevant examples * Rename Event to AppEvent in the cc1101-workaround example * Rename Event to AppEvent in the irda example * Use Event in ValueComposer to wait for update request * Add perform_compose_internal() function * fix Event/AppEvent Co-authored-by: aanper <mail@s3f.ru>
This commit is contained in:
@@ -265,3 +265,55 @@ osStatus_t osMutexDelete (osMutexId_t mutex_id) {
|
||||
return osError;
|
||||
}
|
||||
}
|
||||
|
||||
osSemaphoreId_t osSemaphoreNew(uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr) {
|
||||
if(max_count != 1) {
|
||||
// Non-binary semaphors are not supported at the moment
|
||||
return osErrorParameter;
|
||||
}
|
||||
if(attr != NULL) {
|
||||
// Attributes are not supported at the moment
|
||||
return osErrorParameter;
|
||||
}
|
||||
|
||||
SemaphoreHandle_t handle = osMutexNew(NULL);
|
||||
if(handle == NULL) return NULL;
|
||||
|
||||
if(initial_count == 0) {
|
||||
xSemaphoreTake(handle, 0);
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
osStatus_t osSemaphoreAcquire(osSemaphoreId_t semaphore_id, uint32_t timeout) {
|
||||
if(semaphore_id == NULL) {
|
||||
return osErrorParameter;
|
||||
}
|
||||
|
||||
if(xSemaphoreTake(semaphore_id, timeout) == pdTRUE) {
|
||||
return osOK;
|
||||
} else {
|
||||
return osErrorTimeout;
|
||||
}
|
||||
}
|
||||
|
||||
osStatus_t osSemaphoreRelease(osSemaphoreId_t semaphore_id) {
|
||||
if(semaphore_id == NULL) {
|
||||
return osErrorParameter;
|
||||
}
|
||||
|
||||
if(xSemaphoreGive(semaphore_id) == pdTRUE) {
|
||||
return osOK;
|
||||
} else {
|
||||
return osErrorTimeout;
|
||||
}
|
||||
}
|
||||
|
||||
osStatus_t osSemaphoreDelete(osSemaphoreId_t semaphore_id) {
|
||||
if(semaphore_id == NULL) {
|
||||
return osErrorParameter;
|
||||
}
|
||||
|
||||
return osMutexDelete(semaphore_id);
|
||||
}
|
||||
|
Reference in New Issue
Block a user