event_flags.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #include "base.h"
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /// Attributes structure for event flags.
  7. typedef struct {
  8. const char* name; ///< name of the event flags
  9. uint32_t attr_bits; ///< attribute bits
  10. void* cb_mem; ///< memory for control block
  11. uint32_t cb_size; ///< size of provided memory for control block
  12. } osEventFlagsAttr_t;
  13. /// \details Event Flags ID identifies the event flags.
  14. typedef void* osEventFlagsId_t;
  15. /// Create and Initialize an Event Flags object.
  16. /// \param[in] attr event flags attributes; NULL: default values.
  17. /// \return event flags ID for reference by other functions or NULL in case of error.
  18. osEventFlagsId_t osEventFlagsNew(const osEventFlagsAttr_t* attr);
  19. /// Get name of an Event Flags object.
  20. /// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew.
  21. /// \return name as null-terminated string.
  22. const char* osEventFlagsGetName(osEventFlagsId_t ef_id);
  23. /// Set the specified Event Flags.
  24. /// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew.
  25. /// \param[in] flags specifies the flags that shall be set.
  26. /// \return event flags after setting or error code if highest bit set.
  27. uint32_t osEventFlagsSet(osEventFlagsId_t ef_id, uint32_t flags);
  28. /// Clear the specified Event Flags.
  29. /// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew.
  30. /// \param[in] flags specifies the flags that shall be cleared.
  31. /// \return event flags before clearing or error code if highest bit set.
  32. uint32_t osEventFlagsClear(osEventFlagsId_t ef_id, uint32_t flags);
  33. /// Get the current Event Flags.
  34. /// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew.
  35. /// \return current event flags.
  36. uint32_t osEventFlagsGet(osEventFlagsId_t ef_id);
  37. /// Wait for one or more Event Flags to become signaled.
  38. /// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew.
  39. /// \param[in] flags specifies the flags to wait for.
  40. /// \param[in] options specifies flags options (osFlagsXxxx).
  41. /// \param[in] timeout \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
  42. /// \return event flags before clearing or error code if highest bit set.
  43. uint32_t
  44. osEventFlagsWait(osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout);
  45. /// Delete an Event Flags object.
  46. /// \param[in] ef_id event flags ID obtained by \ref osEventFlagsNew.
  47. /// \return status code that indicates the execution status of the function.
  48. osStatus_t osEventFlagsDelete(osEventFlagsId_t ef_id);
  49. #ifdef __cplusplus
  50. }
  51. #endif