nrfx_dppi.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /**
  2. * Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form, except as embedded into a Nordic
  13. * Semiconductor ASA integrated circuit in a product or a software update for
  14. * such product, must reproduce the above copyright notice, this list of
  15. * conditions and the following disclaimer in the documentation and/or other
  16. * materials provided with the distribution.
  17. *
  18. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * 4. This software, with or without modification, must only be used with a
  23. * Nordic Semiconductor ASA integrated circuit.
  24. *
  25. * 5. Any software provided in binary form under this license must not be reverse
  26. * engineered, decompiled, modified and/or disassembled.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  29. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  31. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  32. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. */
  40. #ifndef NRFX_DPPI_H__
  41. #define NRFX_DPPI_H__
  42. #include <nrfx.h>
  43. #include <hal/nrf_dppi.h>
  44. /**
  45. * @defgroup nrfx_dppi DPPI allocator
  46. * @{
  47. * @ingroup nrf_dppi
  48. * @brief Distributed Programmable Peripheral Interconnect (DPPI) allocator.
  49. */
  50. #ifdef __cplusplus
  51. extern "C" {
  52. #endif
  53. /** @brief Function for freeing all allocated channels and groups. */
  54. void nrfx_dppi_free(void);
  55. /**
  56. * @brief Function for allocating a DPPI channel.
  57. * @details This function allocates the first unused DPPI channel.
  58. *
  59. * @param[out] p_channel Pointer to the DPPI channel number that has been allocated.
  60. *
  61. * @retval NRFX_SUCCESS The channel was successfully allocated.
  62. * @retval NRFX_ERROR_NO_MEM There is no available channel to be used.
  63. */
  64. nrfx_err_t nrfx_dppi_channel_alloc(uint8_t * p_channel);
  65. /**
  66. * @brief Function for freeing a DPPI channel.
  67. * @details This function also disables the chosen channel.
  68. *
  69. * @param[in] channel DPPI channel to be freed.
  70. *
  71. * @retval NRFX_SUCCESS The channel was successfully freed.
  72. * @retval NRFX_ERROR_INVALID_PARAM The specified channel is not allocated.
  73. */
  74. nrfx_err_t nrfx_dppi_channel_free(uint8_t channel);
  75. /**
  76. * @brief Function for enabling a DPPI channel.
  77. *
  78. * @param[in] channel DPPI channel to be enabled.
  79. *
  80. * @retval NRFX_SUCCESS The channel was successfully enabled.
  81. * @retval NRFX_ERROR_INVALID_PARAM The specified channel is not allocated.
  82. */
  83. nrfx_err_t nrfx_dppi_channel_enable(uint8_t channel);
  84. /**
  85. * @brief Function for disabling a DPPI channel.
  86. *
  87. * @param[in] channel DPPI channel to be disabled.
  88. *
  89. * @retval NRFX_SUCCESS The channel was successfully disabled.
  90. * @retval NRFX_ERROR_INVALID_PARAM The specified channel is not allocated.
  91. */
  92. nrfx_err_t nrfx_dppi_channel_disable(uint8_t channel);
  93. /**
  94. * @brief Function for allocating a DPPI channel group.
  95. * @details This function allocates the first unused DPPI group.
  96. *
  97. * @param[out] p_group Pointer to the DPPI channel group that has been allocated.
  98. *
  99. * @retval NRFX_SUCCESS The channel group was successfully allocated.
  100. * @retval NRFX_ERROR_NO_MEM There is no available channel group to be used.
  101. */
  102. nrfx_err_t nrfx_dppi_group_alloc(nrf_dppi_channel_group_t * p_group);
  103. /**
  104. * @brief Function for freeing a DPPI channel group.
  105. * @details This function also disables the chosen group.
  106. *
  107. * @param[in] group DPPI channel group to be freed.
  108. *
  109. * @retval NRFX_SUCCESS The channel group was successfully freed.
  110. * @retval NRFX_ERROR_INVALID_PARAM The specified group is not allocated.
  111. */
  112. nrfx_err_t nrfx_dppi_group_free(nrf_dppi_channel_group_t group);
  113. /**
  114. * @brief Function for including a DPPI channel in a channel group.
  115. *
  116. * @param[in] channel DPPI channel to be added.
  117. * @param[in] group Channel group in which to include the channel.
  118. *
  119. * @retval NRFX_SUCCESS The channel was successfully included.
  120. * @retval NRFX_ERROR_INVALID_PARAM The specified group or channel is not allocated.
  121. */
  122. nrfx_err_t nrfx_dppi_channel_include_in_group(uint8_t channel,
  123. nrf_dppi_channel_group_t group);
  124. /**
  125. * @brief Function for removing a DPPI channel from a channel group.
  126. *
  127. * @param[in] channel DPPI channel to be removed.
  128. * @param[in] group Channel group from which to remove the channel.
  129. *
  130. * @retval NRFX_SUCCESS The channel was successfully removed.
  131. * @retval NRFX_ERROR_INVALID_PARAM The specified group or channel is not allocated.
  132. */
  133. nrfx_err_t nrfx_dppi_channel_remove_from_group(uint8_t channel,
  134. nrf_dppi_channel_group_t group);
  135. /**
  136. * @brief Function for clearing a DPPI channel group.
  137. *
  138. * @param[in] group Channel group to be cleared.
  139. *
  140. * @retval NRFX_SUCCESS The group was successfully cleared.
  141. * @retval NRFX_ERROR_INVALID_PARAM The specified group is not allocated.
  142. */
  143. nrfx_err_t nrfx_dppi_group_clear(nrf_dppi_channel_group_t group);
  144. /**
  145. * @brief Function for enabling a DPPI channel group.
  146. *
  147. * @param[in] group Channel group to be enabled.
  148. *
  149. * @retval NRFX_SUCCESS The group was successfully enabled.
  150. * @retval NRFX_ERROR_INVALID_PARAM The specified group is not allocated.
  151. */
  152. nrfx_err_t nrfx_dppi_group_enable(nrf_dppi_channel_group_t group);
  153. /**
  154. * @brief Function for disabling a DPPI channel group.
  155. *
  156. * @param[in] group Channel group to be disabled.
  157. *
  158. * @retval NRFX_SUCCESS The group was successfully disabled.
  159. * @retval NRFX_ERROR_INVALID_PARAM The specified group is not allocated.
  160. */
  161. nrfx_err_t nrfx_dppi_group_disable(nrf_dppi_channel_group_t group);
  162. /** @} */
  163. #ifdef __cplusplus
  164. }
  165. #endif
  166. #endif // NRFX_DPPI_H__