Kinetis Bootloader  2.0.0
Common bootloader for Kinetis devices
fsl_intmux.h
1 /*
2  * Copyright (c) 2015, 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 
31 #ifndef _FSL_INTMUX_H_
32 #define _FSL_INTMUX_H_
33 
34 #include "fsl_common.h"
35 
41 /*******************************************************************************
42  * Definitions
43  ******************************************************************************/
44 
46 #define FSL_INTMUX_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
47 
49 typedef enum _intmux_channel_logic_mode
50 {
54 
55 /*******************************************************************************
56  * API
57  ******************************************************************************/
58 
59 #if defined(__cplusplus)
60 extern "C" {
61 #endif
62 
65 
75 void INTMUX_Init(INTMUX_Type *base);
76 
84 void INTMUX_Deinit(INTMUX_Type *base);
85 
95 static inline void INTMUX_ResetChannel(INTMUX_Type *base, uint32_t channel)
96 {
97  assert(channel < FSL_FEATURE_INTMUX_CHANNEL_COUNT);
98 
99  base->CHANNEL[channel].CHn_CSR |= INTMUX_CHn_CSR_RST_MASK;
100 }
101 
115 static inline void INTMUX_SetChannelMode(INTMUX_Type *base, uint32_t channel, intmux_channel_logic_mode_t logic)
116 {
117  assert(channel < FSL_FEATURE_INTMUX_CHANNEL_COUNT);
118 
119  base->CHANNEL[channel].CHn_CSR = INTMUX_CHn_CSR_AND(logic);
120 }
121 
125 
133 static inline void INTMUX_EnableInterrupt(INTMUX_Type *base, uint32_t channel, IRQn_Type irq)
134 {
135  assert(channel < FSL_FEATURE_INTMUX_CHANNEL_COUNT);
136  assert(irq >= FSL_FEATURE_INTMUX_IRQ_START_INDEX);
137 
138  base->CHANNEL[channel].CHn_IER_31_0 |= (1U << ((uint32_t)irq - FSL_FEATURE_INTMUX_IRQ_START_INDEX));
139 }
140 
148 static inline void INTMUX_DisableInterrupt(INTMUX_Type *base, uint32_t channel, IRQn_Type irq)
149 {
150  assert(channel < FSL_FEATURE_INTMUX_CHANNEL_COUNT);
151  assert(irq >= FSL_FEATURE_INTMUX_IRQ_START_INDEX);
152 
153  base->CHANNEL[channel].CHn_IER_31_0 &= ~(1U << ((uint32_t)irq - FSL_FEATURE_INTMUX_IRQ_START_INDEX));
154 }
155 
159 
167 static inline uint32_t INTMUX_GetChannelPendingSources(INTMUX_Type *base, uint32_t channel)
168 {
169  assert(channel < FSL_FEATURE_INTMUX_CHANNEL_COUNT);
170 
171  return base->CHANNEL[channel].CHn_IPR_31_0;
172 }
173 
176 #if defined(__cplusplus)
177 }
178 #endif
179 
182 #endif /* _FSL_INTMUX_H_ */
Definition: fsl_intmux.h:52
static void INTMUX_DisableInterrupt(INTMUX_Type *base, uint32_t channel, IRQn_Type irq)
Disable an interrupt source on an INTMUX channel.
Definition: fsl_intmux.h:148
Definition: fsl_intmux.h:51
static uint32_t INTMUX_GetChannelPendingSources(INTMUX_Type *base, uint32_t channel)
Get INTMUX pending interrupt sources for specific channel.
Definition: fsl_intmux.h:167
void INTMUX_Init(INTMUX_Type *base)
Initializes INTMUX module.
Definition: fsl_intmux.c:110
intmux_channel_logic_mode_t
INTMUX channel logic mode.
Definition: fsl_intmux.h:49
void INTMUX_Deinit(INTMUX_Type *base)
Deinitializes an INTMUX instance for operation.
Definition: fsl_intmux.c:124
static void INTMUX_SetChannelMode(INTMUX_Type *base, uint32_t channel, intmux_channel_logic_mode_t logic)
Set the logic mode for an INTMUX channel.
Definition: fsl_intmux.h:115
static void INTMUX_EnableInterrupt(INTMUX_Type *base, uint32_t channel, IRQn_Type irq)
Enable an interrupt source on an INTMUX channel.
Definition: fsl_intmux.h:133
static void INTMUX_ResetChannel(INTMUX_Type *base, uint32_t channel)
Reset an INTMUX channel.
Definition: fsl_intmux.h:95