Infineon MOTIX™ MCU TLE988x/9x Device Family SDK
timer2x.h
Go to the documentation of this file.
1 /*
2  ***********************************************************************************************************************
3  *
4  * Copyright (c) Infineon Technologies AG
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the
8  * following conditions are met:
9  *
10  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following
11  * disclaimer.
12  *
13  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
14  * following disclaimer in the documentation and/or other materials provided with the distribution.
15  *
16  * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote
17  * products derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  **********************************************************************************************************************/
43 /*******************************************************************************
44 ** Author(s) Identity **
45 ********************************************************************************
46 ** Initials Name **
47 ** ---------------------------------------------------------------------------**
48 ** DM Daniel Mysliwitz **
49 ** BG Blandine Guillot **
50 ** JO Julia Ott **
51 *******************************************************************************/
52 
53 /*******************************************************************************
54 ** Revision Control History **
55 ********************************************************************************
56 ** V0.1.0: 2019-10-28, DM: Initial version **
57 ** V0.2.0: 2020-04-28, BG: Updated revision history format **
58 ** V0.3.0: 2020-05-18, BG: Added first functions **
59 ** V0.4.0: 2020-07-10, BG: Added inline functions list **
60 ** V0.4.1: 2020-09-30, JO: EP-485: Fixed T2x_setIntervalTimer functions by **
61 ** removing /1000000 (fT2x is given in MHz, not Hz) **
62 ** V0.4.2: 2020-10-06, BG: EP-492: Removed MISRA 2012 errors **
63 ** V0.4.3: 2020-10-21, BG: EP-539: Considered the enable checkbox in CW in **
64 ** the initialization function **
65 ** V0.4.4: 2020-11-12, JO: EP-590: Removed \param none and \return none to **
66 ** avoid doxygen warning **
67 ** Added end of group for doxygen **
68 ** V0.4.5: 2020-11-20, BG: EP-610: Corrected MISRA 2012 errors **
69 ** The following rules are globally deactivated: **
70 ** - Info 774: Boolean within 'if' always evaluates **
71 ** to False/True **
72 ** V0.4.6: 2020-12-18, BG: EP-652: Corrected name of error code variable **
73 ** V0.4.7: 2021-01-07, BG: EP-664: Added APIs to get the reload/capture **
74 ** value and set the timer value for T20 and T21 **
75 ** V0.4.8: 2021-03-17, BG: EP-742: Renamed defines file for timer2x **
76 ** V0.4.9: 2021-04-06, BG: EP-760: Replaced if instructions to check if the **
77 ** module is enabled with preprocessor directives to**
78 ** avoid compiler warnings **
79 ** V0.5.0: 2021-11-12, JO: EP-937: Updated copyright and branding **
80 *******************************************************************************/
81 
82 #ifndef _TIMER2X_H
83 #define _TIMER2X_H
84 
85 /*******************************************************************************
86 ** Includes **
87 *******************************************************************************/
88 
89 #include "types.h"
90 #include "tle989x.h"
91 #include "tle_variants.h"
92 #include "timer2x_defines.h"
93 #include "isr_defines.h"
94 #include "scu_defines.h"
95 
96 /*******************************************************************************
97 ** Global Constant Declarations **
98 *******************************************************************************/
99 
100 /*******************************************************************************
101 ** Global Type Declarations **
102 *******************************************************************************/
103 
104 /*******************************************************************************
105 ** Global Macro Declarations **
106 *******************************************************************************/
107 
108 /*******************************************************************************
109 ** Global Function Declarations **
110 *******************************************************************************/
111 
112 sint8 T20_init(void);
113 sint8 T21_init(void);
114 sint8 T20_setIntervalTimer(uint32 u32_timeInterval_us);
115 sint8 T21_setIntervalTimer(uint32 u32_timeInterval_us);
116 INLINE void T20_start(void);
117 INLINE void T20_stop(void);
118 INLINE void T21_start(void);
119 INLINE void T21_stop(void);
124 INLINE void T20_setCntVal(uint16 u16_cntVal);
125 INLINE void T21_setCntVal(uint16 u16_cntVal);
126 INLINE void T20_setRelCaptVal(uint16 u16_relCaptVal);
127 INLINE void T21_setRelCaptVal(uint16 u16_relCaptVal);
133 INLINE void T20_clrExternalSts(void);
135 INLINE void T21_clrExternalSts(void);
136 
137 /*******************************************************************************
138 ** Global Inline Function Definitions **
139 *******************************************************************************/
140 
143 INLINE void T20_start(void)
144 {
145  T20->CON.bit.TR2 = 1u;
146 }
147 
150 INLINE void T20_stop(void)
151 {
152  T20->CON.bit.TR2 = 0u;
153 }
154 
157 INLINE void T21_start(void)
158 {
159  T21->CON.bit.TR2 = 1u;
160 }
161 
164 INLINE void T21_stop(void)
165 {
166  T21->CON.bit.TR2 = 0u;
167 }
168 
174 {
175  return (uint16)T20->CNT.reg;
176 }
177 
183 {
184  return (uint16)T21->CNT.reg;
185 }
186 
192 {
193  return (uint16)T20->RC.reg;
194 }
195 
201 {
202  return (uint16)T21->RC.reg;
203 }
204 
209 INLINE void T20_setCntVal(uint16 u16_cntVal)
210 {
211  T20->CNT.reg = u16_cntVal;
212 }
213 
218 INLINE void T21_setCntVal(uint16 u16_cntVal)
219 {
220  T21->CNT.reg = u16_cntVal;
221 }
222 
227 INLINE void T20_setRelCaptVal(uint16 u16_relCaptVal)
228 {
229  T20->RC.reg = u16_relCaptVal;
230 }
231 
236 INLINE void T21_setRelCaptVal(uint16 u16_relCaptVal)
237 {
238  T21->RC.reg = u16_relCaptVal;
239 }
240 
246 {
247  return (uint8)T20->CON.bit.TF2;
248 }
249 
255 {
256  return (uint8)T20->CON.bit.EXF2;
257 }
258 
264 {
265  return (uint8)T21->CON.bit.TF2;
266 }
267 
273 {
274  return (uint8)T21->CON.bit.EXF2;
275 }
276 
280 {
281  T20->ICLR.bit.TF2CLR = 1u;
282 }
283 
287 {
288  T20->ICLR.bit.EXF2CLR = 1u;
289 }
290 
294 {
295  T21->ICLR.bit.TF2CLR = 1u;
296 }
297 
301 {
302  T21->ICLR.bit.EXF2CLR = 1u;
303 }
304 
307 #endif /* _TIMER2X_H */
#define T20
Definition: tle989x.h:24079
#define T21
Definition: tle989x.h:24080
INLINE uint16 T20_getCapRelVal(void)
Get T20 Capture/Reload Value T20.RC.
Definition: timer2x.h:191
INLINE void T20_stop(void)
Stop T20.
Definition: timer2x.h:150
INLINE void T21_stop(void)
Stop T21.
Definition: timer2x.h:164
INLINE void T20_setRelCaptVal(uint16 u16_relCaptVal)
Set T20 Reload/Capture Value T20.RC.
Definition: timer2x.h:227
INLINE void T21_setCntVal(uint16 u16_cntVal)
Set T21 Count Value T21.CNT.
Definition: timer2x.h:218
sint8 T21_init(void)
Initialize all CW registers of the timer 21.
Definition: timer2x.c:78
sint8 T20_setIntervalTimer(uint32 u32_timeInterval_us)
Define an interval timer with the timer T20.
Definition: timer2x.c:98
INLINE uint16 T21_getCntVal(void)
Get T21 Count Value T21.CNT.
Definition: timer2x.h:182
INLINE uint8 T20_getOverUnderflowSts(void)
Get T20 Overflow/Underflow Status T20.CON.TF2.
Definition: timer2x.h:245
INLINE void T21_clrOverUnderflowSts(void)
Clear T21 Overflow/Underflow Status T21.ICLR.TF2CLR.
Definition: timer2x.h:293
sint8 T21_setIntervalTimer(uint32 u32_timeInterval_us)
Define an interval timer with the timer T21.
Definition: timer2x.c:153
INLINE void T20_clrExternalSts(void)
Clear T20 External Status T20.ICLR.EXF2CLR.
Definition: timer2x.h:286
INLINE uint8 T21_getExternalSts(void)
Get T21 External Status T21.CON.EXF2.
Definition: timer2x.h:272
INLINE void T20_clrOverUnderflowSts(void)
Clear T20 Overflow/Underflow Status T20.ICLR.TF2CLR.
Definition: timer2x.h:279
INLINE void T20_start(void)
Start T20.
Definition: timer2x.h:143
INLINE uint16 T20_getCntVal(void)
Get T20 Count Value T20.CNT.
Definition: timer2x.h:173
INLINE void T21_setRelCaptVal(uint16 u16_relCaptVal)
Set T21 Reload/Capture Value T21.RC.
Definition: timer2x.h:236
INLINE uint16 T21_getCapRelVal(void)
Get T21 Capture/Reload Value T21.RC.
Definition: timer2x.h:200
INLINE void T20_setCntVal(uint16 u16_cntVal)
Set T20 Count Value T20.CNT.
Definition: timer2x.h:209
sint8 T20_init(void)
Initialize all CW registers of the timer 20.
Definition: timer2x.c:59
INLINE uint8 T21_getOverUnderflowSts(void)
Get T21 Overflow/Underflow Status T21.CON.TF2.
Definition: timer2x.h:263
INLINE void T21_clrExternalSts(void)
Clear T21 External Status T21.ICLR.EXF2CLR.
Definition: timer2x.h:300
INLINE void T21_start(void)
Start T21.
Definition: timer2x.h:157
INLINE uint8 T20_getExternalSts(void)
Get T20 External Status T20.CON.EXF2.
Definition: timer2x.h:254
Device specific memory layout defines and features.
General type declarations.
#define INLINE
Definition: types.h:167
uint8_t uint8
8 bit unsigned value
Definition: types.h:220
int8_t sint8
8 bit signed value
Definition: types.h:225
uint16_t uint16
16 bit unsigned value
Definition: types.h:221
uint32_t uint32
32 bit unsigned value
Definition: types.h:222