hv_vos_Queue.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * @file hv_vos_Queue.h
  3. * @brief Header file of queue.
  4. *
  5. * @verbatim
  6. * ==============================================================================
  7. * ##### How to use #####
  8. * ==============================================================================
  9. * (+) Use ()
  10. *
  11. * @endverbatim
  12. * @author HiView SoC Software Team
  13. * @version 1.0.0
  14. * @date 2023-03-01
  15. */
  16. #ifndef _HV_VOS_QUEUE_H
  17. #define _HV_VOS_QUEUE_H
  18. VOS_EXTERN_C_BEGIN
  19. typedef struct _HV_VOS_QUEUE_INIT_PARAMS{
  20. UINT32 queueLen;
  21. UINT32 itemSize;
  22. } Hv_Vos_QUEUE_INIT_PARAMS;
  23. /** @defgroup VOS_QUEUE VOS_QUEUE
  24. * VOS queue functions
  25. * @{
  26. */
  27. /** @brief queue forward declaration */
  28. typedef struct _HV_VOS_QUEUE_S HV_VOS_QUEUE_S;
  29. /** @brief Create queue
  30. *
  31. * @return queue pointer, return NULL if create fail
  32. */
  33. HV_VOS_QUEUE_S *Hv_Vos_QueueInit(Hv_Vos_QUEUE_INIT_PARAMS *param);
  34. /** @brief Destroy queue
  35. *
  36. * @param self queue pointer
  37. * @return result
  38. */
  39. void Hv_Vos_QueueCleanup(HV_VOS_QUEUE_S *self);
  40. /** @brief Enqueue
  41. *
  42. * @param self queue pointer
  43. * @param buffer pointer to buffer
  44. * @param waitTicks wait ticks
  45. */
  46. BOOL Hv_Vos_QueueSend(HV_VOS_QUEUE_S *self, const void *buffer);
  47. BOOL Hv_Vos_QueueTimedSend(HV_VOS_QUEUE_S *self, const void *buffer, UINT32 waitMs);
  48. /** @brief Enqueue in ISR
  49. *
  50. * @param self semaphore pointer
  51. * @param buffer pointer to buffer
  52. */
  53. BOOL Hv_Vos_QueueSendFromISR(HV_VOS_QUEUE_S *self, const void *buffer);
  54. BOOL Hv_Vos_QueueSendFromISR_unYield(HV_VOS_QUEUE_S *self, const void *buffer);
  55. /** @brief Dequeu
  56. *
  57. * @param self queue pointer
  58. * @param buffer pointer to buffer
  59. * @param waitTicks wait ticks
  60. */
  61. BOOL Hv_Vos_QueueRecv(HV_VOS_QUEUE_S *self, void *buffer);
  62. BOOL Hv_Vos_QueueTimedRecv(HV_VOS_QUEUE_S *self, void *buffer, UINT32 waitMs);
  63. BOOL Hv_Vos_QueueReceiveFromISR(HV_VOS_QUEUE_S *self, void *buffer);
  64. /**
  65. * @brief Dequeu Return the number of messages stored in a queue.
  66. *
  67. * @param self A handle to the queue being queried.
  68. * @return The number of messages available in the queue.
  69. */
  70. ULONG32 Hv_Vos_QueueMessagesWaiting(const HV_VOS_QUEUE_S *self);
  71. /**
  72. * @brief Dequeu Return the number of messages stored in a queue. can use in isr.
  73. *
  74. * @param self A handle to the queue being queried.
  75. * @return The number of messages available in the queue.
  76. */
  77. ULONG32 Hv_Vos_QueueMessagesWaitingFromISR(const HV_VOS_QUEUE_S *self);
  78. /** @} */ //end of group VOS_QUEUE
  79. VOS_EXTERN_C_END
  80. #endif