Projektarbeit Line Following Robot bei Prof. Chowanetz im WS22/23
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vcos_queue.h 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. Copyright (c) 2012, Broadcom Europe Ltd
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * Neither the name of the copyright holder nor the
  12. names of its contributors may be used to endorse or promote products
  13. derived from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
  18. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. /*=============================================================================
  26. VideoCore OS Abstraction Layer - Queue public header file
  27. =============================================================================*/
  28. #ifndef VCOS_QUEUE_H
  29. #define VCOS_QUEUE_H
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. #include "vcos_types.h"
  34. #include "pthreads/vcos_platform.h"
  35. /** \file vcos_queue.h
  36. *
  37. * API for accessing a fixed length queue.
  38. *
  39. * Nucleus offers variable length items, but this feature is not used
  40. * in the current code base, so is withdrawn to simplify the API.
  41. */
  42. /** Create a fixed length queue.
  43. *
  44. * @param queue Pointer to queue control block
  45. * @param name Name of queue
  46. * @param message_size Size of each queue message item in words (words are sizeof VCOS_UNSIGNED).
  47. * @param queue_start Start address of queue area
  48. * @param queue_size Size in words (words are sizeof VCOS_UNSIGNED) of queue
  49. *
  50. */
  51. VCOS_INLINE_DECL
  52. VCOS_STATUS_T vcos_queue_create(VCOS_QUEUE_T *queue,
  53. const char *name,
  54. VCOS_UNSIGNED message_size,
  55. void *queue_start,
  56. VCOS_UNSIGNED queue_size);
  57. /** Delete a queue.
  58. * @param queue The queue to delete
  59. */
  60. VCOS_INLINE_DECL
  61. void vcos_queue_delete(VCOS_QUEUE_T *queue);
  62. /** Send an item to a queue. If there is no space, the call with
  63. * either block waiting for space, or return an error, depending
  64. * on the value of the wait parameter.
  65. *
  66. * @param queue The queue to send to
  67. * @param src The data to send (length set when queue was created)
  68. * @param wait Whether to wait for space (VCOS_SUSPEND) or fail if
  69. * no space (VCOS_NO_SUSPEND).
  70. *
  71. * @return If space available, returns VCOS_SUCCESS. Otherwise returns
  72. * VCOS_EAGAIN if no space available before timeout expires.
  73. *
  74. */
  75. VCOS_INLINE_DECL
  76. VCOS_STATUS_T vcos_queue_send(VCOS_QUEUE_T *queue, const void *src, VCOS_UNSIGNED wait);
  77. /** Receive an item from a queue.
  78. * @param queue The queue to receive from
  79. * @param dst Where to write the data to
  80. * @param wait Whether to wait (VCOS_SUSPEND) or fail if
  81. * empty (VCOS_NO_SUSPEND).
  82. *
  83. * @return If an item is available, returns VCOS_SUCCESS. Otherwise returns
  84. * VCOS_EAGAIN if no item available before timeout expires.
  85. */
  86. VCOS_INLINE_DECL
  87. VCOS_STATUS_T vcos_queue_receive(VCOS_QUEUE_T *queue, void *dst, VCOS_UNSIGNED wait);
  88. #ifdef __cplusplus
  89. }
  90. #endif
  91. #endif