| ISF 2.1 Intelligent Sensing Framework for Kinetis with Processor Expert

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
fsl_pit_irq.c
Go to the documentation of this file.
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
31 #include <stdlib.h>
32 #include <assert.h>
33 #include "fsl_pit_driver.h"
34 #include "BM_pit_instance.h"
35 #include "fsl_pit_features.h"
36
37 /*!
38 * @addtogroup pit_irq
39 * @{
40 */
41
42 /*******************************************************************************
43 * Variables
44 ******************************************************************************/
45 #if defined (KL25Z4_SERIES)
46 /*!
47 * @brief Table to save PIT IRQ enum numbers defined in CMSIS files.
48 *
49 * They are used by pit_init_channel to enable or disable PIT interrupts. This table is
50 * indexed by channel number which could return PIT IRQ numbers.
51 */
52 const IRQn_Type pit_irq_ids[FSL_FEATURE_PIT_TIMER_COUNT] =
53 {
54 PIT_IRQn, PIT_IRQn
55 };
56 #elif defined (K64F12_SERIES) || defined (K70F12_SERIES) || defined (K22F51212_SERIES)
57 const IRQn_Type pit_irq_ids[FSL_FEATURE_PIT_TIMER_COUNT] =
58 {
59 PIT0_IRQn, PIT1_IRQn, PIT2_IRQn, PIT3_IRQn
60 };
61 #endif
62
63 /*!
64 * @brief Function table to save PIT isr callback function pointers.
65 *
66 * Call pit_register_isr_callback_function to install isr callback functions.
67 */
68 pit_isr_callback_t pit_isr_callback_table[FSL_FEATURE_PIT_TIMER_COUNT] = {NULL};
69
70 /*******************************************************************************
71 * Code
72 ******************************************************************************/
73 #if defined (KL25Z4_SERIES)
74 /*!
75 * @brief System default IRQ handler defined in startup code.
76 *
77 * Users can either edit this handler or define a callback function. Furthermore,
78 * interrupt manager could be used to re-map the IRQ handler to another function.
79 */
80 void PIT_IRQHandler(void)
81 {
82 uint32_t i;
83 for(i=0; i < FSL_FEATURE_PIT_TIMER_COUNT; i++)
84 {
85 /* Run callback function if it exists.*/
86 if (pit_isr_callback_table[i])
87 {
88 (*pit_isr_callback_table[i])();
89 }
90
91 /* Clear interrupt flag.*/
92 pit_hal_clear_interrupt_flag(i);
93
94 }
95 }
96
97 #elif defined (K64F12_SERIES) || defined (K70F12_SERIES) || defined (K22F51212_SERIES)
98
99 void PIT0_IRQHandler(void)
100 {
101 /* Run callback function if it exists.*/
102 if (pit_isr_callback_table[0])
103 {
104 (*pit_isr_callback_table[0])();
105 }
106
107 /* Clear interrupt flag.*/
108 pit_hal_clear_interrupt_flag(0);
109 }
110
111 void PIT1_IRQHandler(void)
112 {
113 /* Run callback function if it exists.*/
114 if (pit_isr_callback_table[1])
115 {
116 (*pit_isr_callback_table[1])();
117 }
118
119 /* Clear interrupt flag.*/
120 pit_hal_clear_interrupt_flag(1);
121 }
122
123 void PIT2_IRQHandler(void)
124 {
125 /* Run callback function if it exists.*/
126 if (pit_isr_callback_table[2])
127 {
128 (*pit_isr_callback_table[2])();
129 }
130
131 /* Clear interrupt flag.*/
132 pit_hal_clear_interrupt_flag(2);
133 }
134
135 void PIT3_IRQHandler(void)
136 {
137 /* Run callback function if it exists.*/
138 if (pit_isr_callback_table[3])
139 {
140 (*pit_isr_callback_table[3])();
141 }
142
143 /* Clear interrupt flag.*/
144 pit_hal_clear_interrupt_flag(3);
145 }
146 #endif
147
148 /*! @} */
149
150 /*FUNCTION**********************************************************************
151 *
152 * Function Name : pit_register_isr_callback_function
153 * Description : Register pit isr callback function.
154 * System default ISR interfaces are already defined in fsl_pit_irq.c. Users
155 * can either edit these ISRs or use this function to register a callback
156 * function. The default ISR will run the callback function it there is one
157 * installed here.
158
159 *END**************************************************************************/
160 void pit_register_isr_callback_function(uint32_t timer, pit_isr_callback_t function)
161 {
162 //assert(timer < FSL_FEATURE_PIT_TIMER_COUNT);
163 //assert(function != NULL);
164
165 pit_isr_callback_table[timer] = function;
166 }
167
168 /*******************************************************************************
169 * EOF
170 ******************************************************************************/
171
172
173
fsl_pit_features.h
BM_pit_instance.h
pit_hal_clear_interrupt_flag
void pit_hal_clear_interrupt_flag(uint32_t timer)
Clear timer interrupt flag.
Definition: fsl_pit_hal.c:105
pit_isr_callback_t
void(* pit_isr_callback_t)(void)
PIT ISR callback function typedef.
Definition: fsl_pit_driver.h:45
pit_register_isr_callback_function
void pit_register_isr_callback_function(uint32_t timer, pit_isr_callback_t function)
Register pit isr callback function.
Definition: fsl_pit_irq.c:160
pit_isr_callback_table
pit_isr_callback_t pit_isr_callback_table[FSL_FEATURE_PIT_TIMER_COUNT]
Function table to save PIT isr callback function pointers.
Definition: fsl_pit_irq.c:68
fsl_pit_driver.h
fsl_pit_driver.h defines structures and types for the PIT driver.
- © Freescale Semiconductor, Inc. 2015. All Rights Reserved.