event.h 658 B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include "cmsis_os.h"
  5. typedef struct {
  6. osSemaphoreId_t semaphore_id;
  7. } Event;
  8. /*
  9. Creates Event.
  10. */
  11. bool init_event(Event* event);
  12. /*
  13. Free resources allocated by `init_event`.
  14. This function doesn't free the memory occupied by `Event` itself.
  15. */
  16. bool delete_event(Event* event);
  17. /*
  18. Signals the event.
  19. If the event is already in "signalled" state, nothing happens.
  20. */
  21. void signal_event(Event* event);
  22. /*
  23. Waits until the event is signalled.
  24. */
  25. void wait_event(Event* event);
  26. /*
  27. Waits with a timeout until the event is signalled.
  28. */
  29. bool wait_event_with_timeout(Event* event, uint32_t timeout_ms);