nrf_nvic.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /**
  2. * Copyright (c) 2014 - 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 NRF_NVIC_H__
  41. #define NRF_NVIC_H__
  42. #include <stdint.h>
  43. #include "nrf.h"
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. /**@brief Enable External Interrupt.
  48. * @note Corresponds to NVIC_EnableIRQ in CMSIS.
  49. *
  50. * @pre{IRQn is valid and not reserved by the stack}
  51. *
  52. * @param[in] IRQn See the NVIC_EnableIRQ documentation in CMSIS.
  53. *
  54. * @retval ::NRF_SUCCESS The interrupt was enabled.
  55. */
  56. uint32_t sd_nvic_EnableIRQ(IRQn_Type IRQn);
  57. /**@brief Disable External Interrupt.
  58. * @note Corresponds to NVIC_DisableIRQ in CMSIS.
  59. *
  60. * @pre{IRQn is valid and not reserved by the stack}
  61. *
  62. * @param[in] IRQn See the NVIC_DisableIRQ documentation in CMSIS
  63. *
  64. * @retval ::NRF_SUCCESS The interrupt was disabled.
  65. */
  66. uint32_t sd_nvic_DisableIRQ(IRQn_Type IRQn);
  67. /**@brief Get Pending Interrupt.
  68. * @note Corresponds to NVIC_GetPendingIRQ in CMSIS.
  69. *
  70. * @pre{IRQn is valid and not reserved by the stack}
  71. *
  72. * @param[in] IRQn See the NVIC_GetPendingIRQ documentation in CMSIS.
  73. * @param[out] p_pending_irq Return value from NVIC_GetPendingIRQ.
  74. *
  75. * @retval ::NRF_SUCCESS The interrupt is available for the application.
  76. */
  77. uint32_t sd_nvic_GetPendingIRQ(IRQn_Type IRQn, uint32_t * p_pending_irq);
  78. /**@brief Set Pending Interrupt.
  79. * @note Corresponds to NVIC_SetPendingIRQ in CMSIS.
  80. *
  81. * @pre{IRQn is valid and not reserved by the stack}
  82. *
  83. * @param[in] IRQn See the NVIC_SetPendingIRQ documentation in CMSIS.
  84. *
  85. * @retval ::NRF_SUCCESS The interrupt is set pending.
  86. */
  87. uint32_t sd_nvic_SetPendingIRQ(IRQn_Type IRQn);
  88. /**@brief Clear Pending Interrupt.
  89. * @note Corresponds to NVIC_ClearPendingIRQ in CMSIS.
  90. *
  91. * @pre{IRQn is valid and not reserved by the stack}
  92. *
  93. * @param[in] IRQn See the NVIC_ClearPendingIRQ documentation in CMSIS.
  94. *
  95. * @retval ::NRF_SUCCESS The interrupt pending flag is cleared.
  96. */
  97. uint32_t sd_nvic_ClearPendingIRQ(IRQn_Type IRQn);
  98. /**@brief Set Interrupt Priority.
  99. * @note Corresponds to NVIC_SetPriority in CMSIS.
  100. *
  101. * @pre{IRQn is valid and not reserved by the stack}
  102. * @pre{priority is valid and not reserved by the stack}
  103. *
  104. * @param[in] IRQn See the NVIC_SetPriority documentation in CMSIS.
  105. * @param[in] priority A valid IRQ priority for use by the application.
  106. *
  107. * @retval ::NRF_SUCCESS The interrupt and priority level is available for the application.
  108. */
  109. uint32_t sd_nvic_SetPriority(IRQn_Type IRQn, uint32_t priority);
  110. /**@brief Get Interrupt Priority.
  111. * @note Corresponds to NVIC_GetPriority in CMSIS.
  112. *
  113. * @pre{IRQn is valid and not reserved by the stack}
  114. *
  115. * @param[in] IRQn See the NVIC_GetPriority documentation in CMSIS.
  116. * @param[out] p_priority Return value from NVIC_GetPriority.
  117. *
  118. * @retval ::NRF_SUCCESS The interrupt priority is returned in p_priority.
  119. */
  120. uint32_t sd_nvic_GetPriority(IRQn_Type IRQn, uint32_t * p_priority);
  121. /**@brief System Reset.
  122. * @note Corresponds to NVIC_SystemReset in CMSIS.
  123. *
  124. * @retval ::NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN
  125. */
  126. uint32_t sd_nvic_SystemReset(void);
  127. /**@brief Enters critical region.
  128. *
  129. * @post Application interrupts will be disabled.
  130. * @sa sd_nvic_critical_region_exit
  131. *
  132. * @param[out] p_is_nested_critical_region 1: If in a nested critical region.
  133. * 0: Otherwise.
  134. *
  135. * @retval ::NRF_SUCCESS
  136. */
  137. uint32_t sd_nvic_critical_region_enter(uint8_t * p_is_nested_critical_region);
  138. /**@brief Exit critical region.
  139. *
  140. * @pre Application has entered a critical region using ::sd_nvic_critical_region_enter.
  141. * @post If not in a nested critical region, the application interrupts will restored to the state before ::sd_nvic_critical_region_enter was called.
  142. *
  143. * @param[in] is_nested_critical_region If this is set to 1, the critical region won't be exited. @sa sd_nvic_critical_region_enter.
  144. *
  145. * @retval ::NRF_SUCCESS
  146. */
  147. uint32_t sd_nvic_critical_region_exit(uint8_t is_nested_critical_region);
  148. #ifdef __cplusplus
  149. }
  150. #endif
  151. #endif /* NRF_NVIC_H__ */