gl_sema.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef __GSL_SEMA_H__
  2. #define __GSL_SEMA_H__
  3. #include "gl_types.h"
  4. /******************************************************************************/
  5. /**
  6. * @brief Used to create a binary or counting semaphore.
  7. *
  8. * @param szName String identifier for the semaphore. Limit to 16 characters. Used wherever supported.
  9. * @param dMaxCount Maximum semaphore count. Value of 1 means binary semaphore.
  10. * @param dInitialValue Initial count of semaphore. Zero means semaphore is unavailable.
  11. * @param pSemId Semaphore object identifier returned by the API (on success)
  12. *
  13. * @return @a GL_SUCCESS on success
  14. * @return @a GL_FAILURE on failure
  15. *
  16. * @note Cannot be used from ISR/DSR.
  17. *******************************************************************************/
  18. GL_Status_t GL_SemaphoreCreate(GL_INT8 *szName, GL_UINT32 dMaxCount, GL_UINT32 dInitialValue, GL_Semaphore_t *pSemId);
  19. /******************************************************************************/
  20. /**
  21. * @brief Used to delete a semaphore. Regarding tasks waiting on a deleted semaphore, the behavior depends on the underlying OS; the GSL does not guarantee a default behavior (hence, applications should avoid this scenario). Typically, an error is returned to the waiting tasks.
  22. *
  23. * @param semId Semaphore object identifier
  24. *
  25. * @return @a GL_SUCCESS on success
  26. * @return @a GL_FAILURE on failure
  27. *
  28. * @note Cannot be used from ISR/DSR.
  29. *******************************************************************************/
  30. GL_Status_t GL_SemaphoreDelete(GL_Semaphore_t semId);
  31. /******************************************************************************/
  32. /**
  33. * @brief Used to release a semaphore.
  34. *
  35. * @param semId Semaphore object identifier
  36. *
  37. * @return @a GL_SUCCESS on success
  38. * @return @a GL_FAILURE on failure
  39. *******************************************************************************/
  40. GL_Status_t GL_SemaphoreGive(GL_Semaphore_t semId);
  41. /******************************************************************************/
  42. /**
  43. * @brief Used to take a semaphore with/without timeout.
  44. *
  45. * @param semId Semaphore object identifier
  46. * @param sdTimeout timeout period to receive message. Measured in milliseconds. Set to:
  47. * @li @a GL_INFINITE_WAIT
  48. * @li @a GL_NO_WAIT
  49. * @li Any value between 1-2147483647 for finite wait)
  50. *
  51. * @return @a GL_SUCCESS on success
  52. * @return @a GL_FAILURE on failure
  53. * @return @a GL_TIMEOUT on timeout
  54. *
  55. * @note Cannot be used from ISR/DSR.
  56. *******************************************************************************/
  57. GL_Status_t GL_SemaphoreTake(GL_Semaphore_t semId, GL_INT32 sdTimeout);
  58. #endif // __GL_SEMA_H__