event.h 728 B

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