ISF  2.1
Intelligent Sensing Framework for Kinetis with Processor Expert
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
fsl_pit_hal.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 "fsl_pit_hal.h"
32 #include "BM_pit_instance.h"
33 #include "fsl_pit_features.h"
34 #include "isf_fsl_TU_PEx.h"
35 #include "PIT_PDD.h"
36 
37 /*******************************************************************************
38  * Code
39  ******************************************************************************/
40 
41 void pit_hal_enable(void)
42 {
43 // BW_PIT_MCR_MDIS(0U);
44 }
45 
46 void pit_hal_disable(void)
47 {
48 // BW_PIT_MCR_MDIS(1U);
49 }
50 
52 {
53 // BW_PIT_MCR_FRZ(!timerRun);
54 }
55 
56 void pit_hal_timer_start(uint32_t timer)
57 {
58  TU_instance_tbl[timer].fnTULDDEnable(NULL);
59 }
60 
61 void pit_hal_timer_stop(uint32_t timer)
62 {
63  TU_instance_tbl[timer].fnTULDDDisable(NULL);
64 }
65 
66 void pit_hal_timer_reset(uint32_t timer)
67 {
69 }
70 
71 void pit_hal_set_timer_period_count(uint32_t timer, uint32_t count)
72 {
73  TU_instance_tbl[timer].fnTULDDSetPeriod(NULL,count);
74 }
75 
76 uint32_t pit_hal_read_timer_period_count(uint32_t timer)
77 {
78  uint32_t count;
79  TU_instance_tbl[timer].fnTULDDGetPeriod(NULL,&count);
80  return count;
81 }
82 
83 uint32_t pit_hal_read_timer_count(uint32_t timer)
84 {
85  uint32_t LDVal, CNTVal;
86 
87  TU_instance_tbl[timer].fnTULDDGetPeriod(NULL,&LDVal);
88  CNTVal = TU_instance_tbl[timer].fnTULDDGetCounter(NULL);
89  return (LDVal - CNTVal);
90 }
91 
92 void pit_hal_configure_interrupt(uint32_t timer, bool enable)
93 {
94 // BW_PIT_TCTRLn_TIE(timer, enable);
95  if (enable)
96  {
97  PIT_PDD_EnableInterrupt(PIT_BASE_PTR,timer);
98  }
99  else
100  {
101  PIT_PDD_DisableInterrupt(PIT_BASE_PTR,timer);
102  }
103 }
104 
105 void pit_hal_clear_interrupt_flag(uint32_t timer)
106 {
107  /* Write 1 will clear the flag. */
108  // HW_PIT_TFLGn_WR(timer, 1U);
109  PIT_PDD_ClearInterruptFlag(PIT_BASE_PTR,timer);
110 }
111 
112 bool pit_hal_is_timeout_occurred(uint32_t timer)
113 {
114  return 0;
115 }
116 
117 /*******************************************************************************
118  * EOF
119  ******************************************************************************/
120 
121 
122 
void pit_hal_configure_interrupt(uint32_t timer, bool enable)
Enable or disable timer interrupt.
Definition: fsl_pit_hal.c:92
void pit_hal_timer_stop(uint32_t timer)
Stop timer counting.
Definition: fsl_pit_hal.c:61
fnTUDisable_t fnTULDDDisable
void pit_hal_configure_timer_run_in_debug(bool timerRun)
Configure timers to continue to run or stop in debug mode.
Definition: fsl_pit_hal.c:51
void pit_hal_set_timer_period_count(uint32_t timer, uint32_t count)
Set timer period in units of count.
Definition: fsl_pit_hal.c:71
fnTUResetCounter_t fnTULDDResetCounter
uint32_t pit_hal_read_timer_count(uint32_t timer)
Read current timer counting value.
Definition: fsl_pit_hal.c:83
bool pit_hal_is_timeout_occurred(uint32_t timer)
Read current timer timeout flag.
Definition: fsl_pit_hal.c:112
fnTUGetCounterValue_t fnTULDDGetCounter
void pit_hal_clear_interrupt_flag(uint32_t timer)
Clear timer interrupt flag.
Definition: fsl_pit_hal.c:105
fnTUSetPeriodTicks_t fnTULDDSetPeriod
void pit_hal_timer_start(uint32_t timer)
Start timer counting.
Definition: fsl_pit_hal.c:56
void pit_hal_timer_reset(uint32_t timer)
Start timer counting.
Definition: fsl_pit_hal.c:66
void pit_hal_enable(void)
Enable PIT module.
Definition: fsl_pit_hal.c:41
fnTUEnable_t fnTULDDEnable
const TU_instance_PEx_t TU_instance_tbl[]
uint32_t pit_hal_read_timer_period_count(uint32_t timer)
Return current timer period in units of count.
Definition: fsl_pit_hal.c:76
fnTUGetPeriodTicks_t fnTULDDGetPeriod
void pit_hal_disable(void)
Disable PIT module.
Definition: fsl_pit_hal.c:46