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  * The applicable license agreement can be found at this pack's installation directory in the file
8  * license/IFX_SW_Licence_MOTIX_LITIX.txt
9  *
10  **********************************************************************************************************************/
26 /*******************************************************************************
27 ** Author(s) Identity **
28 ********************************************************************************
29 ** Initials Name **
30 ** ---------------------------------------------------------------------------**
31 ** DM Daniel Mysliwitz **
32 ** BG Blandine Guillot **
33 ** JO Julia Ott **
34 *******************************************************************************/
35 
36 /*******************************************************************************
37 ** Revision Control History **
38 ********************************************************************************
39 ** V0.1.0: 2019-10-28, DM: Initial version **
40 ** V0.2.0: 2020-04-28, BG: Updated revision history format **
41 ** V0.3.0: 2020-05-18, BG: Added first functions **
42 ** V0.4.0: 2020-07-10, BG: Added inline functions list **
43 ** V0.4.1: 2020-09-30, JO: EP-485: Fixed T2x_setIntervalTimer functions by **
44 ** removing /1000000 (fT2x is given in MHz, not Hz) **
45 ** V0.4.2: 2020-10-06, BG: EP-492: Removed MISRA 2012 errors **
46 ** V0.4.3: 2020-10-21, BG: EP-539: Considered the enable checkbox in CW in **
47 ** the initialization function **
48 ** V0.4.4: 2020-11-12, JO: EP-590: Removed \param none and \return none to **
49 ** avoid doxygen warning **
50 ** Added end of group for doxygen **
51 ** V0.4.5: 2020-11-20, BG: EP-610: Corrected MISRA 2012 errors **
52 ** The following rules are globally deactivated: **
53 ** - Info 774: Boolean within 'if' always evaluates **
54 ** to False/True **
55 ** V0.4.6: 2020-12-18, BG: EP-652: Corrected name of error code variable **
56 ** V0.4.7: 2021-01-07, BG: EP-664: Added APIs to get the reload/capture **
57 ** value and set the timer value for T20 and T21 **
58 ** V0.4.8: 2021-03-17, BG: EP-742: Renamed defines file for timer2x **
59 ** V0.4.9: 2021-04-06, BG: EP-760: Replaced if instructions to check if the **
60 ** module is enabled with preprocessor directives to**
61 ** avoid compiler warnings **
62 ** V0.5.0: 2021-11-12, JO: EP-937: Updated copyright and branding **
63 ** V0.5.1: 2024-11-05, JO: EP-1494: Updated license **
64 *******************************************************************************/
65 
66 #ifndef _TIMER2X_H
67 #define _TIMER2X_H
68 
69 /*******************************************************************************
70 ** Includes **
71 *******************************************************************************/
72 
73 #include "types.h"
74 #include "tle989x.h"
75 #include "tle_variants.h"
76 #include "timer2x_defines.h"
77 #include "isr_defines.h"
78 #include "scu_defines.h"
79 
80 /*******************************************************************************
81 ** Global Constant Declarations **
82 *******************************************************************************/
83 
84 /*******************************************************************************
85 ** Global Type Declarations **
86 *******************************************************************************/
87 
88 /*******************************************************************************
89 ** Global Macro Declarations **
90 *******************************************************************************/
91 
92 /*******************************************************************************
93 ** Global Function Declarations **
94 *******************************************************************************/
95 
96 sint8 T20_init(void);
97 sint8 T21_init(void);
98 sint8 T20_setIntervalTimer(uint32 u32_timeInterval_us);
99 sint8 T21_setIntervalTimer(uint32 u32_timeInterval_us);
100 INLINE void T20_start(void);
101 INLINE void T20_stop(void);
102 INLINE void T21_start(void);
103 INLINE void T21_stop(void);
108 INLINE void T20_setCntVal(uint16 u16_cntVal);
109 INLINE void T21_setCntVal(uint16 u16_cntVal);
110 INLINE void T20_setRelCaptVal(uint16 u16_relCaptVal);
111 INLINE void T21_setRelCaptVal(uint16 u16_relCaptVal);
117 INLINE void T20_clrExternalSts(void);
119 INLINE void T21_clrExternalSts(void);
120 
121 /*******************************************************************************
122 ** Global Inline Function Definitions **
123 *******************************************************************************/
124 
127 INLINE void T20_start(void)
128 {
129  T20->CON.bit.TR2 = 1u;
130 }
131 
134 INLINE void T20_stop(void)
135 {
136  T20->CON.bit.TR2 = 0u;
137 }
138 
141 INLINE void T21_start(void)
142 {
143  T21->CON.bit.TR2 = 1u;
144 }
145 
148 INLINE void T21_stop(void)
149 {
150  T21->CON.bit.TR2 = 0u;
151 }
152 
158 {
159  return (uint16)T20->CNT.reg;
160 }
161 
167 {
168  return (uint16)T21->CNT.reg;
169 }
170 
176 {
177  return (uint16)T20->RC.reg;
178 }
179 
185 {
186  return (uint16)T21->RC.reg;
187 }
188 
193 INLINE void T20_setCntVal(uint16 u16_cntVal)
194 {
195  T20->CNT.reg = u16_cntVal;
196 }
197 
202 INLINE void T21_setCntVal(uint16 u16_cntVal)
203 {
204  T21->CNT.reg = u16_cntVal;
205 }
206 
211 INLINE void T20_setRelCaptVal(uint16 u16_relCaptVal)
212 {
213  T20->RC.reg = u16_relCaptVal;
214 }
215 
220 INLINE void T21_setRelCaptVal(uint16 u16_relCaptVal)
221 {
222  T21->RC.reg = u16_relCaptVal;
223 }
224 
230 {
231  return (uint8)T20->CON.bit.TF2;
232 }
233 
239 {
240  return (uint8)T20->CON.bit.EXF2;
241 }
242 
248 {
249  return (uint8)T21->CON.bit.TF2;
250 }
251 
257 {
258  return (uint8)T21->CON.bit.EXF2;
259 }
260 
264 {
265  T20->ICLR.bit.TF2CLR = 1u;
266 }
267 
271 {
272  T20->ICLR.bit.EXF2CLR = 1u;
273 }
274 
278 {
279  T21->ICLR.bit.TF2CLR = 1u;
280 }
281 
285 {
286  T21->ICLR.bit.EXF2CLR = 1u;
287 }
288 
291 #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:175
INLINE void T20_stop(void)
Stop T20.
Definition: timer2x.h:134
INLINE void T21_stop(void)
Stop T21.
Definition: timer2x.h:148
INLINE void T20_setRelCaptVal(uint16 u16_relCaptVal)
Set T20 Reload/Capture Value T20.RC.
Definition: timer2x.h:211
INLINE void T21_setCntVal(uint16 u16_cntVal)
Set T21 Count Value T21.CNT.
Definition: timer2x.h:202
sint8 T21_init(void)
Initialize all CW registers of the timer 21.
Definition: timer2x.c:61
sint8 T20_setIntervalTimer(uint32 u32_timeInterval_us)
Define an interval timer with the timer T20.
Definition: timer2x.c:81
INLINE uint16 T21_getCntVal(void)
Get T21 Count Value T21.CNT.
Definition: timer2x.h:166
INLINE uint8 T20_getOverUnderflowSts(void)
Get T20 Overflow/Underflow Status T20.CON.TF2.
Definition: timer2x.h:229
INLINE void T21_clrOverUnderflowSts(void)
Clear T21 Overflow/Underflow Status T21.ICLR.TF2CLR.
Definition: timer2x.h:277
sint8 T21_setIntervalTimer(uint32 u32_timeInterval_us)
Define an interval timer with the timer T21.
Definition: timer2x.c:136
INLINE void T20_clrExternalSts(void)
Clear T20 External Status T20.ICLR.EXF2CLR.
Definition: timer2x.h:270
INLINE uint8 T21_getExternalSts(void)
Get T21 External Status T21.CON.EXF2.
Definition: timer2x.h:256
INLINE void T20_clrOverUnderflowSts(void)
Clear T20 Overflow/Underflow Status T20.ICLR.TF2CLR.
Definition: timer2x.h:263
INLINE void T20_start(void)
Start T20.
Definition: timer2x.h:127
INLINE uint16 T20_getCntVal(void)
Get T20 Count Value T20.CNT.
Definition: timer2x.h:157
INLINE void T21_setRelCaptVal(uint16 u16_relCaptVal)
Set T21 Reload/Capture Value T21.RC.
Definition: timer2x.h:220
INLINE uint16 T21_getCapRelVal(void)
Get T21 Capture/Reload Value T21.RC.
Definition: timer2x.h:184
INLINE void T20_setCntVal(uint16 u16_cntVal)
Set T20 Count Value T20.CNT.
Definition: timer2x.h:193
sint8 T20_init(void)
Initialize all CW registers of the timer 20.
Definition: timer2x.c:42
INLINE uint8 T21_getOverUnderflowSts(void)
Get T21 Overflow/Underflow Status T21.CON.TF2.
Definition: timer2x.h:247
INLINE void T21_clrExternalSts(void)
Clear T21 External Status T21.ICLR.EXF2CLR.
Definition: timer2x.h:284
INLINE void T21_start(void)
Start T21.
Definition: timer2x.h:141
INLINE uint8 T20_getExternalSts(void)
Get T20 External Status T20.CON.EXF2.
Definition: timer2x.h:238
Device specific memory layout defines and features.
General type declarations.
#define INLINE
Definition: types.h:151
uint8_t uint8
8 bit unsigned value
Definition: types.h:204
int8_t sint8
8 bit signed value
Definition: types.h:209
uint16_t uint16
16 bit unsigned value
Definition: types.h:205
uint32_t uint32
32 bit unsigned value
Definition: types.h:206