gl_queue.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #ifndef __GSL_QUEUE_H__
  2. #define __GSL_QUEUE_H__
  3. #include "gl_types.h"
  4. /******************************************************************************/
  5. /*!
  6. * @brief Used to create a message queue. Space is separately reserved in the queue for normal and urgent messages. Urgent messages should be used sparingly during emergencies only - urgent messages cannot be written into the normal message space. However, if an urgent message is available, it will always be read before a normal message.
  7. *
  8. * @param szName String identifier for the message queue. Limit to 16 characters. Used wherever supported.
  9. * @param dElementSize size of each element in the message queue.
  10. * @param dMaxElements maximum numbers of elements in the message queue.
  11. * @param dMaxUrgentElements maximum number of urgent elements in the message queue. Use 0 if urgent messages are not required.
  12. * @param pQueueId Queue object identifier returned by the API (on success)
  13. *
  14. * @return @a GL_SUCCESS on success
  15. * @return @a GL_FAILURE on failure
  16. *
  17. * @note Cannot be used from ISR/DSR.
  18. *******************************************************************************/
  19. GL_Status_t GL_QueueCreate(char *szName, GL_UINT32 dElementSize, GL_UINT32 dMaxElements,
  20. GL_UINT32 dMaxUrgentElements, GL_Queue_t *pQueueId);
  21. /******************************************************************************/
  22. /*!
  23. * @brief Used to delete a message queue. Regarding tasks waiting on a deleted message queue, 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.
  24. *
  25. * @param queueId Queue object identifier
  26. *
  27. * @return @a GL_SUCCESS on success
  28. * @return @a GL_FAILURE on failure
  29. *
  30. * @note Cannot be used from ISR/DSR.
  31. *******************************************************************************/
  32. GL_Status_t GL_QueueDelete(GL_Queue_t queueId);
  33. /******************************************************************************/
  34. /*!
  35. * @brief Used to send a message. The size of the message buffer must match that specified during creation.
  36. *
  37. * @param queueId Queue object identifierpBuffer: Pointer to message buffer
  38. *
  39. * @return @a GL_SUCCESS on success
  40. * @return @a GL_FAILURE on failure
  41. * @return @a GL_QUEUE_FULL if queue has no free space
  42. *
  43. * @note Cannot be used from ISR/DSR.
  44. *******************************************************************************/
  45. GL_Status_t GL_QueueSend(GL_Queue_t queueId, void *pBuffer, GL_UINT32 dSize);
  46. /******************************************************************************/
  47. /*!
  48. * @brief Used to send an urgent message. The size of the message buffer must match that specified during creation.
  49. *
  50. * @param queueId Queue object identifierpBuffer: Pointer to message buffer
  51. *
  52. * @return @a GL_SUCCESS on success
  53. * @return @a GL_FAILURE on failure
  54. * @return @a GL_QUEUE_FULL if queue has no free space
  55. *
  56. * @note Cannot be used from ISR/DSR.
  57. *******************************************************************************/
  58. GL_Status_t GL_QueueSendUrgent(GL_Queue_t queueId, void *pBuffer, GL_UINT32 dSize);
  59. /******************************************************************************/
  60. /*!
  61. * @brief Used to send an urgent message. The size of the message buffer must match that specified during creation.
  62. *
  63. * @param queueId Queue object identifierpBuffer: Pointer to message buffer
  64. * @param sdTimeout timeout period to receive message. Measured in milliseconds. Set to:
  65. * @li @a GL_INFINITE_WAIT
  66. * @li @a GL_NO_WAIT (Any value between 1-2147483647 for finite wait)
  67. *
  68. * @return @a GL_SUCCESS on success
  69. * @return @a GL_FAILURE on failure
  70. * @return @a GL_TIMEOUT on timeout
  71. * @return @a GL_QUEUE_EMPTY if queue has no message and timeout=GL_NO_WAIT
  72. *
  73. * @note Cannot be used from ISR/DSR.
  74. *******************************************************************************/
  75. GL_Status_t GL_QueueReceive(GL_Queue_t queueId, void *pBuffer, GL_UINT32 dSize, GL_INT32 sdTimeout);
  76. /******************************************************************************/
  77. /*!
  78. * @brief Drop normal messages in a queue
  79. *
  80. * @param queueId Queue object identifier
  81. *
  82. * @return @a GL_SUCCESS on success
  83. * @return @a GL_FAILURE on failure
  84. *
  85. * @note Cannot be used from ISR/DSR.
  86. *******************************************************************************/
  87. GL_Status_t GL_QueueFlushNormal(GL_Queue_t queueId);
  88. /******************************************************************************/
  89. /*!
  90. * @brief Drop urgent messages in a queue
  91. *
  92. * @param queueId Queue object identifier
  93. *
  94. * @return @a GL_SUCCESS on success
  95. * @return @a GL_FAILURE on failure
  96. *
  97. * @note Cannot be used from ISR/DSR.
  98. *******************************************************************************/
  99. GL_Status_t GL_QueueFlushUrgent(GL_Queue_t queueId);
  100. /******************************************************************************/
  101. /*!
  102. * @brief The queue will be reinitialized without caring inside messages.
  103. *
  104. * @param queueId Queue object identifier
  105. *
  106. * @return @a GL_SUCCESS on success
  107. * @return @a GL_FAILURE on failure
  108. *
  109. * @note Cannot be used from ISR/DSR.
  110. *******************************************************************************/
  111. GL_Status_t GL_QueueFlush(GL_Queue_t queueId);
  112. /******************************************************************************/
  113. /*!
  114. * @brief This returns the current number of FREE URGENT messages in the queue.
  115. *
  116. * @param queueId Queue object identifier
  117. * @param value container of the value of free urgent messages peek from GL_Queue_t
  118. *
  119. * @return @a GL_SUCCESS on success
  120. * @return @a GL_FAILURE on failure
  121. *
  122. * @note None
  123. *******************************************************************************/
  124. GL_Status_t GL_QueuePeekUrgent(GL_Queue_t queueId, UINT32 *value);
  125. GL_Status_t GL_QueuePeek(GL_Queue_t queueId, GL_UINT32 *value);
  126. #endif