am_hal_interrupt.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. //*****************************************************************************
  2. //
  3. // am_hal_interrupt.h
  4. //! @file
  5. //!
  6. //! @brief Helper functions supporting interrupts and NVIC operation.
  7. //!
  8. //! These functions may be used for NVIC-level interrupt configuration.
  9. //!
  10. //! @addtogroup interrupt2 Interrupt (ARM NVIC support functions)
  11. //! @ingroup apollo2hal
  12. //! @{
  13. //
  14. //*****************************************************************************
  15. //*****************************************************************************
  16. //
  17. // Copyright (c) 2017, Ambiq Micro
  18. // All rights reserved.
  19. //
  20. // Redistribution and use in source and binary forms, with or without
  21. // modification, are permitted provided that the following conditions are met:
  22. //
  23. // 1. Redistributions of source code must retain the above copyright notice,
  24. // this list of conditions and the following disclaimer.
  25. //
  26. // 2. Redistributions in binary form must reproduce the above copyright
  27. // notice, this list of conditions and the following disclaimer in the
  28. // documentation and/or other materials provided with the distribution.
  29. //
  30. // 3. Neither the name of the copyright holder nor the names of its
  31. // contributors may be used to endorse or promote products derived from this
  32. // software without specific prior written permission.
  33. //
  34. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  35. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  36. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  37. // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  38. // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  39. // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  40. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  41. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  42. // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  43. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  44. // POSSIBILITY OF SUCH DAMAGE.
  45. //
  46. // This is part of revision 1.2.9 of the AmbiqSuite Development Package.
  47. //
  48. //*****************************************************************************
  49. #ifndef AM_HAL_INTERRUPT_H
  50. #define AM_HAL_INTERRUPT_H
  51. #ifdef __cplusplus
  52. extern "C"
  53. {
  54. #endif
  55. //*****************************************************************************
  56. //
  57. //! @name ISR number macros.
  58. //! @brief ISR macros.
  59. //!
  60. //! These macros are used for all ui32Interrupt arguments in this module.
  61. //! @{
  62. //
  63. //*****************************************************************************
  64. //
  65. // Hardware interrupts
  66. //
  67. #define AM_HAL_INTERRUPT_RESET 1
  68. #define AM_HAL_INTERRUPT_NMI 2
  69. #define AM_HAL_INTERRUPT_HARDFAULT 3
  70. #define AM_HAL_INTERRUPT_MPUFAULT 4
  71. #define AM_HAL_INTERRUPT_BUSFAULT 5
  72. #define AM_HAL_INTERRUPT_USAGEFAULT 6
  73. #define AM_HAL_INTERRUPT_SVCALL 11
  74. #define AM_HAL_INTERRUPT_DEBUGMON 12
  75. #define AM_HAL_INTERRUPT_PENDSV 14
  76. #define AM_HAL_INTERRUPT_SYSTICK 15
  77. //
  78. // Begin IRQs
  79. //
  80. #define AM_HAL_INTERRUPT_BROWNOUT 16
  81. #define AM_HAL_INTERRUPT_WATCHDOG 17
  82. #define AM_HAL_INTERRUPT_CLKGEN 18
  83. #define AM_HAL_INTERRUPT_VCOMP 19
  84. #define AM_HAL_INTERRUPT_IOSLAVE 20
  85. #define AM_HAL_INTERRUPT_IOSACC 21
  86. #define AM_HAL_INTERRUPT_IOMASTER0 22
  87. #define AM_HAL_INTERRUPT_IOMASTER1 23
  88. #define AM_HAL_INTERRUPT_IOMASTER2 24
  89. #define AM_HAL_INTERRUPT_IOMASTER3 25
  90. #define AM_HAL_INTERRUPT_IOMASTER4 26
  91. #define AM_HAL_INTERRUPT_IOMASTER5 27
  92. #define AM_HAL_INTERRUPT_GPIO 28
  93. #define AM_HAL_INTERRUPT_CTIMER 29
  94. #define AM_HAL_INTERRUPT_UART0 30
  95. #define AM_HAL_INTERRUPT_UART1 31
  96. #define AM_HAL_INTERRUPT_UART (AM_HAL_INTERRUPT_UART0)
  97. #define AM_HAL_INTERRUPT_ADC 32
  98. #define AM_HAL_INTERRUPT_PDM 33
  99. #define AM_HAL_INTERRUPT_STIMER 34
  100. #define AM_HAL_INTERRUPT_STIMER_CMPR0 35
  101. #define AM_HAL_INTERRUPT_STIMER_CMPR1 36
  102. #define AM_HAL_INTERRUPT_STIMER_CMPR2 37
  103. #define AM_HAL_INTERRUPT_STIMER_CMPR3 38
  104. #define AM_HAL_INTERRUPT_STIMER_CMPR4 39
  105. #define AM_HAL_INTERRUPT_STIMER_CMPR5 40
  106. #define AM_HAL_INTERRUPT_STIMER_CMPR6 41
  107. #define AM_HAL_INTERRUPT_STIMER_CMPR7 42
  108. #define AM_HAL_INTERRUPT_FLASH 43
  109. #define AM_HAL_INTERRUPT_SOFTWARE0 44
  110. #define AM_HAL_INTERRUPT_SOFTWARE1 45
  111. #define AM_HAL_INTERRUPT_SOFTWARE2 46
  112. #define AM_HAL_INTERRUPT_SOFTWARE3 47
  113. //! @}
  114. //*****************************************************************************
  115. //
  116. //! @brief Interrupt priority
  117. //!
  118. //! This macro is made to be used with the \e am_hal_interrupt_priority_set()
  119. //! function. It converts a priority number to the format used by the ARM
  120. //! standard priority register, where only the top 3 bits are used.
  121. //!
  122. //! For example, AM_HAL_INTERRUPT_PRIORITY(1) yields a value of 0x20.
  123. //
  124. //*****************************************************************************
  125. #define AM_HAL_INTERRUPT_PRIORITY(n) (((uint32_t)(n) & 0x7) << 5)
  126. //*****************************************************************************
  127. //
  128. // External function definitions
  129. //
  130. //*****************************************************************************
  131. extern void am_hal_interrupt_enable(uint32_t ui32Interrupt);
  132. extern void am_hal_interrupt_disable(uint32_t ui32Interrupt);
  133. extern void am_hal_interrupt_pend_set(uint32_t ui32Interrupt);
  134. extern void am_hal_interrupt_pend_clear(uint32_t ui32Interrupt);
  135. extern void am_hal_interrupt_priority_set(uint32_t ui32Interrupt,
  136. uint32_t ui32Priority);
  137. extern uint32_t am_hal_interrupt_master_disable(void);
  138. extern uint32_t am_hal_interrupt_master_enable(void);
  139. extern void am_hal_interrupt_master_set(uint32_t ui32InterruptState);
  140. #ifdef __cplusplus
  141. }
  142. #endif
  143. #endif // AM_HAL_INTERRUPT_H
  144. //*****************************************************************************
  145. //
  146. // End Doxygen group.
  147. //! @}
  148. //
  149. //*****************************************************************************