2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
8 * o Redistributions of source code must retain the above copyright notice, this list
9 * of conditions and the following disclaimer.
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.
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.
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.
33 #include "fsl_pit_common.h"
34 #include "fsl_pit_driver.h"
41 /*******************************************************************************
43 ******************************************************************************/
46 * @brief Function table to save PIT isr callback function pointers.
48 * Call PIT_DRV_InstallCallback to install isr callback functions.
50 static pit_isr_callback_t pitIsrCallbackTable[HW_PIT_INSTANCE_COUNT][FSL_FEATURE_PIT_TIMER_COUNT] = {{NULL}};
52 /*******************************************************************************
54 ******************************************************************************/
55 #if defined (KL25Z4_SERIES)
57 * @brief System default IRQ handler defined in startup code.
59 * Users can either edit this handler or define a callback function. Furthermore,
60 * interrupt manager could be used to re-map the IRQ handler to another function.
62 void PIT_IRQHandler(void)
65 for(i=0; i < FSL_FEATURE_PIT_TIMER_COUNT; i++)
67 /* Clear interrupt flag.*/
68 PIT_HAL_ClearIntFlag(g_pitBaseAddr[0], i);
70 /* Run callback function if it exists.*/
71 if (pitIsrCallbackTable[0][i])
73 (*pitIsrCallbackTable[0][i])();
78 #elif defined (K64F12_SERIES) || defined (K24F12_SERIES) || defined (K63F12_SERIES) || \
79 defined (K22F12810_SERIES) || defined (K22F25612_SERIES) || defined (K22F51212_SERIES) || \
80 defined (KV31F12810_SERIES) || defined (KV31F25612_SERIES) || defined (KV31F51212_SERIES) || \
81 defined (K70F12_SERIES)
82 void PIT0_IRQHandler(void)
84 /* Clear interrupt flag.*/
85 PIT_HAL_ClearIntFlag(g_pitBaseAddr[0], 0U);
87 /* Run callback function if it exists.*/
88 if (pitIsrCallbackTable[0][0])
90 (*pitIsrCallbackTable[0][0])();
94 void PIT1_IRQHandler(void)
96 /* Clear interrupt flag.*/
97 PIT_HAL_ClearIntFlag(g_pitBaseAddr[0], 1U);
99 /* Run callback function if it exists.*/
100 if (pitIsrCallbackTable[0][1])
102 (*pitIsrCallbackTable[0][1])();
106 void PIT2_IRQHandler(void)
108 /* Clear interrupt flag.*/
109 PIT_HAL_ClearIntFlag(g_pitBaseAddr[0], 2U);
111 /* Run callback function if it exists.*/
112 if (pitIsrCallbackTable[0][2])
114 (*pitIsrCallbackTable[0][2])();
118 void PIT3_IRQHandler(void)
120 /* Clear interrupt flag.*/
121 PIT_HAL_ClearIntFlag(g_pitBaseAddr[0], 3U);
123 /* Run callback function if it exists.*/
124 if (pitIsrCallbackTable[0][3])
126 (*pitIsrCallbackTable[0][3])();
133 /*FUNCTION**********************************************************************
135 * Function Name : PIT_DRV_InstallCallback
136 * Description : Register pit isr callback function.
137 * System default ISR interfaces are already defined in fsl_pit_irq.c. Users
138 * can either edit these ISRs or use this function to register a callback
139 * function. The default ISR will run the callback function it there is one
142 *END**************************************************************************/
143 void PIT_DRV_InstallCallback(uint32_t instance, uint32_t channel, pit_isr_callback_t function)
145 assert(channel < FSL_FEATURE_PIT_TIMER_COUNT);
146 assert(function != NULL);
148 pitIsrCallbackTable[instance][channel] = function;
151 /*******************************************************************************
153 ******************************************************************************/