]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/interrupt/fsl_interrupt_manager.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / hal / TARGET_Freescale / TARGET_KPSDK_MCUS / TARGET_KPSDK_CODE / drivers / interrupt / fsl_interrupt_manager.h
1 /*
2 * Copyright (c) 2013 - 2014, 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 #if !defined(__FSL_INTERRUPT_MANAGER_H__)
31 #define __FSL_INTERRUPT_MANAGER_H__
32
33 #include <stdint.h>
34 #include <stdbool.h>
35 #include <assert.h>
36 #include "fsl_interrupt_features.h"
37 #include "device/fsl_device_registers.h"
38
39 /*! @addtogroup interrupt_manager*/
40 /*! @{*/
41
42 /*! @file*/
43
44 /*******************************************************************************
45 * Definitions
46 ******************************************************************************/
47
48 /*******************************************************************************
49 * API
50 ******************************************************************************/
51
52 #if defined(__cplusplus)
53 extern "C" {
54 #endif /* __cplusplus*/
55
56 /*! @name interrupt_manager APIs*/
57 /*@{*/
58
59 /*!
60 * @brief Installs an interrupt handler routine for a given IRQ number.
61 *
62 * This function lets the application register/replace the interrupt
63 * handler for a specified IRQ number. The IRQ number is different than the vector
64 * number. IRQ 0 starts from the vector 16 address. See a chip-specific reference
65 * manual for details and the startup_MKxxxx.s file for each chip
66 * family to find out the default interrupt handler for each device. This
67 * function converts the IRQ number to the vector number by adding 16 to
68 * it.
69 *
70 * @param irqNumber IRQ number
71 * @param handler Interrupt handler routine address pointer
72 */
73 void INT_SYS_InstallHandler(IRQn_Type irqNumber, void (*handler)(void));
74
75 /*!
76 * @brief Enables an interrupt for a given IRQ number.
77 *
78 * This function enables the individual interrupt for a specified IRQ
79 * number. It calls the system NVIC API to access the interrupt control
80 * register. The input IRQ number does not include the core interrupt, only
81 * the peripheral interrupt, from 0 to a maximum supported IRQ.
82 *
83 * @param irqNumber IRQ number
84 */
85 static inline void INT_SYS_EnableIRQ(IRQn_Type irqNumber)
86 {
87 /* check IRQ number */
88 assert(0 <= irqNumber);
89 assert(irqNumber <= FSL_FEATURE_INTERRUPT_IRQ_MAX);
90
91 /* call core API to enable the IRQ*/
92 NVIC_EnableIRQ(irqNumber);
93 }
94
95 /*!
96 * @brief Disables an interrupt for a given IRQ number.
97 *
98 * This function enables the individual interrupt for a specified IRQ
99 * number. It calls the system NVIC API to access the interrupt control
100 * register.
101 *
102 * @param irqNumber IRQ number
103 */
104 static inline void INT_SYS_DisableIRQ(IRQn_Type irqNumber)
105 {
106 /* check IRQ number */
107 assert(0 <= irqNumber);
108 assert(irqNumber <= FSL_FEATURE_INTERRUPT_IRQ_MAX);
109
110 /* call core API to disable the IRQ*/
111 NVIC_DisableIRQ(irqNumber);
112 }
113
114 /*!
115 * @brief Enables system interrupt.
116 *
117 * This function enables the global interrupt by calling the core API.
118 *
119 */
120 void INT_SYS_EnableIRQGlobal(void);
121
122 /*!
123 * @brief Disable system interrupt.
124 *
125 * This function disables the global interrupt by calling the core API.
126 *
127 */
128 void INT_SYS_DisableIRQGlobal(void);
129
130 /*@}*/
131
132 #if defined(__cplusplus)
133 }
134 #endif /* __cplusplus*/
135
136 /*! @}*/
137
138 #endif /* __FSL_INTERRUPT_MANAGER_H__*/
139 /*******************************************************************************
140 * EOF
141 ******************************************************************************/
142
Imprint / Impressum