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_timer.h 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 - timer support
  27. =============================================================================*/
  28. #ifndef VCOS_TIMER_H
  29. #define VCOS_TIMER_H
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. #include "vcos_types.h"
  34. #ifndef VCOS_PLATFORM_H
  35. #include "pthreads/vcos_platform.h"
  36. #endif
  37. /** \file vcos_timer.h
  38. *
  39. * Timers are single shot.
  40. *
  41. * Timer times are in milliseconds.
  42. *
  43. * \note that timer callback functions are called from an arbitrary thread
  44. * context. The expiration function should do its work as quickly as possible;
  45. * blocking should be avoided.
  46. *
  47. * \note On Windows, the separate function vcos_timer_init() must be called
  48. * as timer initialization from DllMain is not possible.
  49. */
  50. /** Perform timer subsystem initialization. This function is not needed
  51. * on non-Windows platforms but is still present so that it can be
  52. * called. On Windows it is needed because vcos_init() gets called
  53. * from DLL initialization where it is not possible to create a
  54. * time queue (deadlock occurs if you try).
  55. *
  56. * @return VCOS_SUCCESS on success. VCOS_EEXIST if this has already been called
  57. * once. VCOS_ENOMEM if resource allocation failed.
  58. */
  59. VCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_timer_init(void);
  60. /** Create a timer in a disabled state.
  61. *
  62. * The timer is initially disabled.
  63. *
  64. * @param timer timer handle
  65. * @param name name for timer
  66. * @param expiration_routine function to call when timer expires
  67. * @param context context passed to expiration routine
  68. *
  69. */
  70. VCOS_INLINE_DECL
  71. VCOS_STATUS_T vcos_timer_create(VCOS_TIMER_T *timer,
  72. const char *name,
  73. void (*expiration_routine)(void *context),
  74. void *context);
  75. /** Start a timer running.
  76. *
  77. * Timer must be stopped.
  78. *
  79. * @param timer timer handle
  80. * @param delay Delay to wait for, in ms
  81. */
  82. VCOS_INLINE_DECL
  83. void vcos_timer_set(VCOS_TIMER_T *timer, VCOS_UNSIGNED delay);
  84. /** Stop an already running timer.
  85. *
  86. * @param timer timer handle
  87. */
  88. VCOS_INLINE_DECL
  89. void vcos_timer_cancel(VCOS_TIMER_T *timer);
  90. /** Stop a timer and restart it.
  91. * @param timer timer handle
  92. * @param delay delay in ms
  93. */
  94. VCOS_INLINE_DECL
  95. void vcos_timer_reset(VCOS_TIMER_T *timer, VCOS_UNSIGNED delay);
  96. VCOS_INLINE_DECL
  97. void vcos_timer_delete(VCOS_TIMER_T *timer);
  98. #ifdef __cplusplus
  99. }
  100. #endif
  101. #endif