version_2.0
Dependents: cc3000_ping_demo_try_2
Fork of mbed by
TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/interrupt/fsl_interrupt_manager.h@83:8a40adfe8776, 2014-04-28 (annotated)
- Committer:
- bogdanm
- Date:
- Mon Apr 28 17:39:05 2014 +0100
- Revision:
- 83:8a40adfe8776
Release 83 of the mbed library
Main changes:
- updated tests
- K64F TCP/IP support
- lots of fixes in various targets
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 83:8a40adfe8776 | 1 | /* |
bogdanm | 83:8a40adfe8776 | 2 | * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. |
bogdanm | 83:8a40adfe8776 | 3 | * All rights reserved. |
bogdanm | 83:8a40adfe8776 | 4 | * |
bogdanm | 83:8a40adfe8776 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
bogdanm | 83:8a40adfe8776 | 6 | * are permitted provided that the following conditions are met: |
bogdanm | 83:8a40adfe8776 | 7 | * |
bogdanm | 83:8a40adfe8776 | 8 | * o Redistributions of source code must retain the above copyright notice, this list |
bogdanm | 83:8a40adfe8776 | 9 | * of conditions and the following disclaimer. |
bogdanm | 83:8a40adfe8776 | 10 | * |
bogdanm | 83:8a40adfe8776 | 11 | * o Redistributions in binary form must reproduce the above copyright notice, this |
bogdanm | 83:8a40adfe8776 | 12 | * list of conditions and the following disclaimer in the documentation and/or |
bogdanm | 83:8a40adfe8776 | 13 | * other materials provided with the distribution. |
bogdanm | 83:8a40adfe8776 | 14 | * |
bogdanm | 83:8a40adfe8776 | 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
bogdanm | 83:8a40adfe8776 | 16 | * contributors may be used to endorse or promote products derived from this |
bogdanm | 83:8a40adfe8776 | 17 | * software without specific prior written permission. |
bogdanm | 83:8a40adfe8776 | 18 | * |
bogdanm | 83:8a40adfe8776 | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
bogdanm | 83:8a40adfe8776 | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
bogdanm | 83:8a40adfe8776 | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
bogdanm | 83:8a40adfe8776 | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
bogdanm | 83:8a40adfe8776 | 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
bogdanm | 83:8a40adfe8776 | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
bogdanm | 83:8a40adfe8776 | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
bogdanm | 83:8a40adfe8776 | 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
bogdanm | 83:8a40adfe8776 | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
bogdanm | 83:8a40adfe8776 | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
bogdanm | 83:8a40adfe8776 | 29 | */ |
bogdanm | 83:8a40adfe8776 | 30 | #if !defined(__FSL_INTERRUPT_MANAGER_H__) |
bogdanm | 83:8a40adfe8776 | 31 | #define __FSL_INTERRUPT_MANAGER_H__ |
bogdanm | 83:8a40adfe8776 | 32 | |
bogdanm | 83:8a40adfe8776 | 33 | #include <stdint.h> |
bogdanm | 83:8a40adfe8776 | 34 | #include <stdbool.h> |
bogdanm | 83:8a40adfe8776 | 35 | #include <assert.h> |
bogdanm | 83:8a40adfe8776 | 36 | #include "fsl_interrupt_features.h" |
bogdanm | 83:8a40adfe8776 | 37 | #include "device/fsl_device_registers.h" |
bogdanm | 83:8a40adfe8776 | 38 | |
bogdanm | 83:8a40adfe8776 | 39 | /*! @addtogroup interrupt_manager*/ |
bogdanm | 83:8a40adfe8776 | 40 | /*! @{*/ |
bogdanm | 83:8a40adfe8776 | 41 | |
bogdanm | 83:8a40adfe8776 | 42 | /*! @file*/ |
bogdanm | 83:8a40adfe8776 | 43 | |
bogdanm | 83:8a40adfe8776 | 44 | /******************************************************************************* |
bogdanm | 83:8a40adfe8776 | 45 | * Definitions |
bogdanm | 83:8a40adfe8776 | 46 | ******************************************************************************/ |
bogdanm | 83:8a40adfe8776 | 47 | |
bogdanm | 83:8a40adfe8776 | 48 | /******************************************************************************* |
bogdanm | 83:8a40adfe8776 | 49 | * API |
bogdanm | 83:8a40adfe8776 | 50 | ******************************************************************************/ |
bogdanm | 83:8a40adfe8776 | 51 | |
bogdanm | 83:8a40adfe8776 | 52 | #if defined(__cplusplus) |
bogdanm | 83:8a40adfe8776 | 53 | extern "C" { |
bogdanm | 83:8a40adfe8776 | 54 | #endif /* __cplusplus*/ |
bogdanm | 83:8a40adfe8776 | 55 | |
bogdanm | 83:8a40adfe8776 | 56 | /*! @name interrupt_manager APIs*/ |
bogdanm | 83:8a40adfe8776 | 57 | /*@{*/ |
bogdanm | 83:8a40adfe8776 | 58 | |
bogdanm | 83:8a40adfe8776 | 59 | /*! |
bogdanm | 83:8a40adfe8776 | 60 | * @brief Installs an interrupt handler routine for a given IRQ number. |
bogdanm | 83:8a40adfe8776 | 61 | * |
bogdanm | 83:8a40adfe8776 | 62 | * This function lets the application register/replace the interrupt |
bogdanm | 83:8a40adfe8776 | 63 | * handler for a specified IRQ number. The IRQ number is different than the vector |
bogdanm | 83:8a40adfe8776 | 64 | * number. IRQ 0 starts from the vector 16 address. See a chip-specific reference |
bogdanm | 83:8a40adfe8776 | 65 | * manual for details and the startup_MKxxxx.s file for each chip |
bogdanm | 83:8a40adfe8776 | 66 | * family to find out the default interrupt handler for each device. This |
bogdanm | 83:8a40adfe8776 | 67 | * function converts the IRQ number to the vector number by adding 16 to |
bogdanm | 83:8a40adfe8776 | 68 | * it. |
bogdanm | 83:8a40adfe8776 | 69 | * |
bogdanm | 83:8a40adfe8776 | 70 | * @param irqNumber IRQ number |
bogdanm | 83:8a40adfe8776 | 71 | * @param handler Interrupt handler routine address pointer |
bogdanm | 83:8a40adfe8776 | 72 | */ |
bogdanm | 83:8a40adfe8776 | 73 | void interrupt_register_handler(IRQn_Type irqNumber, void (*handler)(void)); |
bogdanm | 83:8a40adfe8776 | 74 | |
bogdanm | 83:8a40adfe8776 | 75 | /*! |
bogdanm | 83:8a40adfe8776 | 76 | * @brief Enables an interrupt for a given IRQ number. |
bogdanm | 83:8a40adfe8776 | 77 | * |
bogdanm | 83:8a40adfe8776 | 78 | * This function enables the individual interrupt for a specified IRQ |
bogdanm | 83:8a40adfe8776 | 79 | * number. It calls the system NVIC API to access the interrupt control |
bogdanm | 83:8a40adfe8776 | 80 | * register. The input IRQ number does not include the core interrupt, only |
bogdanm | 83:8a40adfe8776 | 81 | * the peripheral interrupt, from 0 to a maximum supported IRQ. |
bogdanm | 83:8a40adfe8776 | 82 | * |
bogdanm | 83:8a40adfe8776 | 83 | * @param irqNumber IRQ number |
bogdanm | 83:8a40adfe8776 | 84 | */ |
bogdanm | 83:8a40adfe8776 | 85 | static inline void interrupt_enable(IRQn_Type irqNumber) |
bogdanm | 83:8a40adfe8776 | 86 | { |
bogdanm | 83:8a40adfe8776 | 87 | /* check IRQ number */ |
bogdanm | 83:8a40adfe8776 | 88 | assert(0 <= irqNumber); |
bogdanm | 83:8a40adfe8776 | 89 | assert(irqNumber <= FSL_FEATURE_INTERRUPT_IRQ_MAX); |
bogdanm | 83:8a40adfe8776 | 90 | |
bogdanm | 83:8a40adfe8776 | 91 | /* call core API to enable the IRQ*/ |
bogdanm | 83:8a40adfe8776 | 92 | NVIC_EnableIRQ(irqNumber); |
bogdanm | 83:8a40adfe8776 | 93 | } |
bogdanm | 83:8a40adfe8776 | 94 | |
bogdanm | 83:8a40adfe8776 | 95 | /*! |
bogdanm | 83:8a40adfe8776 | 96 | * @brief Disables an interrupt for a given IRQ number. |
bogdanm | 83:8a40adfe8776 | 97 | * |
bogdanm | 83:8a40adfe8776 | 98 | * This function enables the individual interrupt for a specified IRQ |
bogdanm | 83:8a40adfe8776 | 99 | * number. It calls the system NVIC API to access the interrupt control |
bogdanm | 83:8a40adfe8776 | 100 | * register. |
bogdanm | 83:8a40adfe8776 | 101 | * |
bogdanm | 83:8a40adfe8776 | 102 | * @param irqNumber IRQ number |
bogdanm | 83:8a40adfe8776 | 103 | */ |
bogdanm | 83:8a40adfe8776 | 104 | static inline void interrupt_disable(IRQn_Type irqNumber) |
bogdanm | 83:8a40adfe8776 | 105 | { |
bogdanm | 83:8a40adfe8776 | 106 | /* check IRQ number */ |
bogdanm | 83:8a40adfe8776 | 107 | assert(0 <= irqNumber); |
bogdanm | 83:8a40adfe8776 | 108 | assert(irqNumber <= FSL_FEATURE_INTERRUPT_IRQ_MAX); |
bogdanm | 83:8a40adfe8776 | 109 | |
bogdanm | 83:8a40adfe8776 | 110 | /* call core API to disable the IRQ*/ |
bogdanm | 83:8a40adfe8776 | 111 | NVIC_DisableIRQ(irqNumber); |
bogdanm | 83:8a40adfe8776 | 112 | } |
bogdanm | 83:8a40adfe8776 | 113 | |
bogdanm | 83:8a40adfe8776 | 114 | /*! |
bogdanm | 83:8a40adfe8776 | 115 | * @brief Enables system interrupt. |
bogdanm | 83:8a40adfe8776 | 116 | * |
bogdanm | 83:8a40adfe8776 | 117 | * This function enables the global interrupt by calling the core API. |
bogdanm | 83:8a40adfe8776 | 118 | * |
bogdanm | 83:8a40adfe8776 | 119 | */ |
bogdanm | 83:8a40adfe8776 | 120 | void interrupt_enable_global(void); |
bogdanm | 83:8a40adfe8776 | 121 | |
bogdanm | 83:8a40adfe8776 | 122 | /*! |
bogdanm | 83:8a40adfe8776 | 123 | * @brief Disable system interrupt. |
bogdanm | 83:8a40adfe8776 | 124 | * |
bogdanm | 83:8a40adfe8776 | 125 | * This function disables the global interrupt by calling the core API. |
bogdanm | 83:8a40adfe8776 | 126 | * |
bogdanm | 83:8a40adfe8776 | 127 | */ |
bogdanm | 83:8a40adfe8776 | 128 | void interrupt_disable_global(void); |
bogdanm | 83:8a40adfe8776 | 129 | |
bogdanm | 83:8a40adfe8776 | 130 | /*@}*/ |
bogdanm | 83:8a40adfe8776 | 131 | |
bogdanm | 83:8a40adfe8776 | 132 | #if defined(__cplusplus) |
bogdanm | 83:8a40adfe8776 | 133 | } |
bogdanm | 83:8a40adfe8776 | 134 | #endif /* __cplusplus*/ |
bogdanm | 83:8a40adfe8776 | 135 | |
bogdanm | 83:8a40adfe8776 | 136 | /*! @}*/ |
bogdanm | 83:8a40adfe8776 | 137 | |
bogdanm | 83:8a40adfe8776 | 138 | #endif /* __FSL_INTERRUPT_MANAGER_H__*/ |
bogdanm | 83:8a40adfe8776 | 139 | /******************************************************************************* |
bogdanm | 83:8a40adfe8776 | 140 | * EOF |
bogdanm | 83:8a40adfe8776 | 141 | ******************************************************************************/ |
bogdanm | 83:8a40adfe8776 | 142 |