* 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>
		
			
				
	
	
		
			25 lines
		
	
	
		
			650 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			650 B
		
	
	
	
		
			C
		
	
	
	
	
	
#include "event.h"
 | 
						|
#include <string.h>
 | 
						|
 | 
						|
bool init_event(Event* event) {
 | 
						|
    event->semaphore_id = osSemaphoreNew(1, 0, NULL);
 | 
						|
    return event->semaphore_id != NULL;
 | 
						|
}
 | 
						|
 | 
						|
bool delete_event(Event* event) {
 | 
						|
    return osSemaphoreDelete(event->semaphore_id) == osOK;
 | 
						|
}
 | 
						|
 | 
						|
void signal_event(Event* event) {
 | 
						|
    // Ignore the result, as we do not care about repeated event signalling.
 | 
						|
    osSemaphoreRelease(event->semaphore_id);
 | 
						|
}
 | 
						|
 | 
						|
void wait_event(Event* event) {
 | 
						|
    wait_event_with_timeout(event, osWaitForever);
 | 
						|
}
 | 
						|
 | 
						|
bool wait_event_with_timeout(Event* event, uint32_t timeout_ms) {
 | 
						|
    return osSemaphoreAcquire(event->semaphore_id, timeout_ms) == osOK;
 | 
						|
}
 |