am_hal_interrupt.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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.11 of the AmbiqSuite Development Package.
  47. //
  48. //*****************************************************************************
  49. #ifndef AM_HAL_INTERRUPT_H
  50. #define AM_HAL_INTERRUPT_H
  51. //*****************************************************************************
  52. //
  53. //! @name ISR number macros.
  54. //! @brief ISR macros.
  55. //!
  56. //! These macros are used for all ui32Interrupt arguments in this module.
  57. //! @{
  58. //
  59. //*****************************************************************************
  60. //
  61. // Hardware interrupts
  62. //
  63. #define AM_HAL_INTERRUPT_MAX (47) //AM_HAL_INTERRUPT_SOFTWARE3
  64. #define AM_HAL_INTERRUPT_RESET 1
  65. #define AM_HAL_INTERRUPT_NMI 2
  66. #define AM_HAL_INTERRUPT_HARDFAULT 3
  67. #define AM_HAL_INTERRUPT_MPUFAULT 4
  68. #define AM_HAL_INTERRUPT_BUSFAULT 5
  69. #define AM_HAL_INTERRUPT_USAGEFAULT 6
  70. #define AM_HAL_INTERRUPT_SVCALL 11
  71. #define AM_HAL_INTERRUPT_DEBUGMON 12
  72. #define AM_HAL_INTERRUPT_PENDSV 14
  73. #define AM_HAL_INTERRUPT_SYSTICK 15
  74. //
  75. // Begin IRQs
  76. //
  77. #define AM_HAL_INTERRUPT_BROWNOUT 16
  78. #define AM_HAL_INTERRUPT_WATCHDOG 17
  79. #define AM_HAL_INTERRUPT_CLKGEN 18
  80. #define AM_HAL_INTERRUPT_VCOMP 19
  81. #define AM_HAL_INTERRUPT_IOSLAVE 20
  82. #define AM_HAL_INTERRUPT_IOSACC 21
  83. #define AM_HAL_INTERRUPT_IOMASTER0 22
  84. #define AM_HAL_INTERRUPT_IOMASTER1 23
  85. #define AM_HAL_INTERRUPT_IOMASTER2 24
  86. #define AM_HAL_INTERRUPT_IOMASTER3 25
  87. #define AM_HAL_INTERRUPT_IOMASTER4 26
  88. #define AM_HAL_INTERRUPT_IOMASTER5 27
  89. #define AM_HAL_INTERRUPT_GPIO 28
  90. #define AM_HAL_INTERRUPT_CTIMER 29
  91. #define AM_HAL_INTERRUPT_UART0 30
  92. #define AM_HAL_INTERRUPT_UART1 31
  93. #define AM_HAL_INTERRUPT_UART (AM_HAL_INTERRUPT_UART0)
  94. #define AM_HAL_INTERRUPT_ADC 32
  95. #define AM_HAL_INTERRUPT_PDM 33
  96. #define AM_HAL_INTERRUPT_STIMER 34
  97. #define AM_HAL_INTERRUPT_STIMER_CMPR0 35
  98. #define AM_HAL_INTERRUPT_STIMER_CMPR1 36
  99. #define AM_HAL_INTERRUPT_STIMER_CMPR2 37
  100. #define AM_HAL_INTERRUPT_STIMER_CMPR3 38
  101. #define AM_HAL_INTERRUPT_STIMER_CMPR4 39
  102. #define AM_HAL_INTERRUPT_STIMER_CMPR5 40
  103. #define AM_HAL_INTERRUPT_STIMER_CMPR6 41
  104. #define AM_HAL_INTERRUPT_STIMER_CMPR7 42
  105. #define AM_HAL_INTERRUPT_FLASH 43
  106. #define AM_HAL_INTERRUPT_SOFTWARE0 44
  107. #define AM_HAL_INTERRUPT_SOFTWARE1 45
  108. #define AM_HAL_INTERRUPT_SOFTWARE2 46
  109. #define AM_HAL_INTERRUPT_SOFTWARE3 47
  110. //! @}
  111. //*****************************************************************************
  112. //
  113. //! @brief Interrupt priority
  114. //!
  115. //! This macro is made to be used with the \e am_hal_interrupt_priority_set()
  116. //! function. It converts a priority number to the format used by the ARM
  117. //! standard priority register, where only the top 3 bits are used.
  118. //!
  119. //! For example, AM_HAL_INTERRUPT_PRIORITY(1) yields a value of 0x20.
  120. //
  121. //*****************************************************************************
  122. #define AM_HAL_INTERRUPT_PRIORITY(n) (((uint32_t)(n) & 0x7) << 5)
  123. #ifdef __cplusplus
  124. extern "C"
  125. {
  126. #endif
  127. //*****************************************************************************
  128. //
  129. // External function definitions
  130. //
  131. //*****************************************************************************
  132. extern void am_hal_interrupt_enable(uint32_t ui32Interrupt);
  133. extern void am_hal_interrupt_disable(uint32_t ui32Interrupt);
  134. extern void am_hal_interrupt_pend_set(uint32_t ui32Interrupt);
  135. extern void am_hal_interrupt_pend_clear(uint32_t ui32Interrupt);
  136. extern void am_hal_interrupt_priority_set(uint32_t ui32Interrupt,
  137. uint32_t ui32Priority);
  138. extern uint32_t am_hal_interrupt_master_disable(void);
  139. extern uint32_t am_hal_interrupt_master_enable(void);
  140. extern void am_hal_interrupt_master_set(uint32_t ui32InterruptState);
  141. #ifdef __cplusplus
  142. }
  143. #endif
  144. #endif // AM_HAL_INTERRUPT_H
  145. //*****************************************************************************
  146. //
  147. // End Doxygen group.
  148. //! @}
  149. //
  150. //*****************************************************************************