events_hooks.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /**
  2. * \file
  3. *
  4. * \brief SAM Event System Driver
  5. *
  6. * Copyright (C) 2014-2015 Atmel Corporation. All rights reserved.
  7. *
  8. * \asf_license_start
  9. *
  10. * \page License
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions are met:
  14. *
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. *
  18. * 2. Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. *
  22. * 3. The name of Atmel may not be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * 4. This software may only be redistributed and used in connection with an
  26. * Atmel microcontroller product.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
  29. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  30. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  31. * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
  32. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  34. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  36. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  37. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  38. * POSSIBILITY OF SUCH DAMAGE.
  39. *
  40. * \asf_license_stop
  41. *
  42. */
  43. /*
  44. * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
  45. */
  46. #include "events.h"
  47. #ifndef _EVENTS_HOOKS_H_INCLUDED_
  48. #define _EVENTS_HOOKS_H_INCLUDED_
  49. #ifdef __cplusplus
  50. extern "C" {
  51. #endif
  52. /**
  53. * \addtogroup asfdoc_sam0_events_group
  54. * @{
  55. *
  56. */
  57. /**
  58. * \brief Interrupt source enumerator.
  59. *
  60. * Interrupt source selector definitions.
  61. *
  62. */
  63. enum events_interrupt_source {
  64. /** Overrun in event channel detected interrupt */
  65. EVENTS_INTERRUPT_OVERRUN,
  66. /** Event signal propagation in event channel detected interrupt */
  67. EVENTS_INTERRUPT_DETECT,
  68. };
  69. /**
  70. * \brief Initializes an interrupt hook for insertion in the event interrupt hook queue.
  71. *
  72. * Initializes a hook structure so it is ready for insertion in the interrupt hook queue.
  73. *
  74. * \param[out] hook Pointer to an \ref events_hook struct instance
  75. * \param[in] hook_func Pointer to a function containing the interrupt hook code
  76. *
  77. * \return Status of the hook creation procedure.
  78. * \retval STATUS_OK Creation and initialization of interrupt hook went successful
  79. *
  80. */
  81. enum status_code events_create_hook(struct events_hook *hook, events_interrupt_hook hook_func);
  82. /**
  83. * \brief Insert hook into the event drivers interrupt hook queue.
  84. *
  85. * Inserts a hook into the event drivers interrupt hook queue.
  86. *
  87. * \param[in] resource Pointer to an \ref events_resource struct instance
  88. * \param[in] hook Pointer to an \ref events_hook struct instance
  89. *
  90. * \return Status of the insertion procedure.
  91. * \retval STATUS_OK Insertion of hook went successful
  92. *
  93. */
  94. enum status_code events_add_hook(struct events_resource *resource, struct events_hook *hook);
  95. /**
  96. * \brief Remove hook from the event drivers interrupt hook queue.
  97. *
  98. * Removes a hook from the event drivers interrupt hook queue.
  99. *
  100. * \param[in] resource Pointer to an \ref events_resource struct instance
  101. * \param[in] hook Pointer to an \ref events_hook struct instance
  102. *
  103. * \return Status of the removal procedure.
  104. * \retval STATUS_OK Removal of hook went successful
  105. * \retval STATUS_ERR_NO_MEMORY There are no hooks instances in the event driver interrupt hook list
  106. * \retval STATUS_ERR_NOT_FOUND Interrupt hook not found in the event drivers interrupt hook list
  107. *
  108. */
  109. enum status_code events_del_hook(struct events_resource *resource, struct events_hook *hook);
  110. /**
  111. * \brief Enable interrupt source.
  112. *
  113. * Enable an interrupt source so can trigger execution of an interrupt hook.
  114. *
  115. * \param[in] resource Pointer to an \ref events_resource struct instance
  116. * \param[in] source One of the members in the \ref events_interrupt_source enumerator
  117. *
  118. * \return Status of the interrupt source enable procedure.
  119. * \retval STATUS_OK Enabling of the interrupt source was successful
  120. * \retval STATUS_ERR_INVALID_ARG Interrupt source does not exist
  121. *
  122. */
  123. enum status_code events_enable_interrupt_source(struct events_resource *resource, enum events_interrupt_source source);
  124. /**
  125. * \brief Disable interrupt source.
  126. *
  127. * Disable an interrupt source so can trigger execution of an interrupt hook.
  128. *
  129. * \param[in] resource Pointer to an \ref events_resource struct instance
  130. * \param[in] source One of the members in the \ref events_interrupt_source enumerator
  131. *
  132. * \return Status of the interrupt source enable procedure.
  133. * \retval STATUS_OK Enabling of the interrupt source went successful
  134. * \retval STATUS_ERR_INVALID_ARG Interrupt source does not exist
  135. *
  136. */
  137. enum status_code events_disable_interrupt_source(struct events_resource *resource, enum events_interrupt_source source);
  138. /**
  139. * \brief Check if interrupt source is set.
  140. *
  141. * Check if an interrupt source is set and should be processed.
  142. *
  143. * \param[in] resource Pointer to an \ref events_resource struct instance
  144. * \param[in] source One of the members in the \ref events_interrupt_source enumerator
  145. *
  146. * \return Status of the interrupt source.
  147. * \retval true Interrupt source is set
  148. * \retval false Interrupt source is not set
  149. *
  150. */
  151. bool events_is_interrupt_set(struct events_resource *resource, enum events_interrupt_source source);
  152. /**
  153. * \brief Acknowledge an interrupt source.
  154. *
  155. * Acknowledge an interrupt source so the interrupt state is cleared in hardware.
  156. *
  157. * \param[in] resource Pointer to an \ref events_resource struct instance
  158. * \param[in] source One of the members in the \ref events_interrupt_source enumerator
  159. *
  160. * \return Status of the interrupt source.
  161. * \retval STATUS_OK Interrupt source was acknowledged successfully
  162. *
  163. */
  164. enum status_code events_ack_interrupt(struct events_resource *resource, enum events_interrupt_source source);
  165. #ifdef __cplusplus
  166. }
  167. #endif
  168. #endif