interrupt.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright (c) 2009-2012, Freescale Semiconductor, Inc.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * o Redistributions of source code must retain the above copyright notice, this list
  9. * of conditions and the following disclaimer.
  10. *
  11. * o Redistributions in binary form must reproduce the above copyright notice, this
  12. * list of conditions and the following disclaimer in the documentation and/or
  13. * other materials provided with the distribution.
  14. *
  15. * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
  16. * contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  23. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef __INTERRUPT_H__
  31. #define __INTERRUPT_H__
  32. #include "sdk_types.h"
  33. #include "irq_numbers.h"
  34. //! @addtogroup diag_interrupt
  35. //! @{
  36. /*!
  37. * @file interrupt.h
  38. * @brief Interface for the interrupt manager.
  39. */
  40. ////////////////////////////////////////////////////////////////////////////////
  41. // Definitions
  42. ////////////////////////////////////////////////////////////////////////////////
  43. //! @brief
  44. typedef enum {
  45. CPU_0,
  46. CPU_1,
  47. CPU_2,
  48. CPU_3,
  49. } cpuid_e;
  50. //! @brief Interrupt service routine.
  51. typedef void (*irq_hdlr_t) (void);
  52. ////////////////////////////////////////////////////////////////////////////////
  53. // API
  54. ////////////////////////////////////////////////////////////////////////////////
  55. #if defined(__cplusplus)
  56. extern "C" {
  57. #endif
  58. //! @brief Enable an interrupt.
  59. //!
  60. //! Sets the interrupt priority and makes it non-secure. Then the interrupt is
  61. //! enabled on the CPU specified by @a cpu_id.
  62. //!
  63. //! @param irq_id The interrupt number to enable.
  64. //! @param cpu_id The index of the CPU for which the interrupt will be enabled.
  65. //! @param priority The interrupt priority, from 0-255. Lower numbers have higher priority.
  66. void enable_interrupt(uint32_t irq_id, uint32_t cpu_id, uint32_t priority);
  67. //! @brief Disable an interrupt on the specified CPU.
  68. //!
  69. //! @param irq_id The interrupt number to disabled.
  70. //! @param cpu_id The index of the CPU for which the interrupt will be disabled.
  71. void disable_interrupt(uint32_t irq_id, uint32_t cpu_id);
  72. //! @brief Set the interrupt service routine for the specified interrupt.
  73. //!
  74. //! @param irq_id The interrupt number.
  75. //! @param isr Function that will be called to handle the interrupt.
  76. void register_interrupt_routine(uint32_t irq_id, irq_hdlr_t isr);
  77. //! @brief Interrupt handler that simply prints a message.
  78. void default_interrupt_routine(void);
  79. #if defined(__cplusplus)
  80. }
  81. #endif
  82. //! @}
  83. #endif
  84. ////////////////////////////////////////////////////////////////////////////////
  85. // EOF
  86. ////////////////////////////////////////////////////////////////////////////////