iLLD_TC29x  1.0
IfxStm.h
Go to the documentation of this file.
1 /**
2  * \file IfxStm.h
3  * \brief STM basic functionality
4  * \ingroup IfxLld_Stm
5  *
6  * \version iLLD_1_0_0_11_0
7  * \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
8  *
9  *
10  * IMPORTANT NOTICE
11  *
12  *
13  * Infineon Technologies AG (Infineon) is supplying this file for use
14  * exclusively with Infineon's microcontroller products. This file can be freely
15  * distributed within development tools that are supporting such microcontroller
16  * products.
17  *
18  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
19  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
20  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
21  * INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
22  * OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
23  *
24  * \defgroup IfxLld_Stm_Usage How to use the Stm driver?
25  * \ingroup IfxLld_Stm
26  *
27  * The Stm Standard driver provides APIs to initialize, configure and control the Stm.
28  *
29  * In the following sections it will be described, how to integrate the driver into the application framework.
30  *
31  * \section IfxLld_Stm_Preparation Preparation
32  * \subsection IfxLld_Stm_Include Include Files
33  *
34  * Include following header file into your C code:
35  * \code
36  * #include <Stm/Std/IfxStm.h>
37  * \endcode
38  *
39  * \subsection IfxLld_Stm_Variables Variables
40  *
41  * Declare STM variables :
42  * \code
43  * Ifx_STM *stmSfr;
44  * IfxStm_CompareConfig stmConfig;
45  * \endcode
46  *
47  * \subsection IfxLld_Stm_Interrupt Interrupt Handler Installation
48  *
49  * See also \ref IfxLld_Cpu_Irq_Usage
50  *
51  * Define priorities for the Interrrupt handlers. This is normally done in the Ifx_IntPrioDef.h file:
52  * \code
53  * // priorities are normally defined in Ifx_IntPrioDef.h
54  * #define IFX_INTPRIO_STM0_SR0 10
55  * \endcode
56  *
57  * Add the interrupt service routines to your C code. They have to call the Stm interrupt handlers:
58  * please take care in choosing number of ticks, the below example code will raise an interrupt
59  * evry time the specified number of ticks have been elapsed.
60  * \code
61  * IFX_INTERRUPT(stm0Sr0ISR, 0, IFX_INTPRIO_STM0_SR0)
62  * {
63  * IfxStm_clearCompareFlag(stmSfr, stmConfig.comparator);
64  * IfxStm_increaseCompare(stmSfr, stmConfig.comparator, stmConfig.ticks);
65  * }
66  * \endcode
67  *
68  * Finally install the interrupt handlers in your initialisation function:
69  * \code
70  * // install interrupt handlers
71  * IfxCpu_Irq_installInterruptHandler(&stm0Sr0ISR, IFX_INTPRIO_STM0_SR0);
72  * IfxCpu_enableInterrupts();
73  * \endcode
74  *
75  * \subsection IfxLld_Stm_Init Module Initialisation
76  *
77  * The STM module can be configured to generate an interrupt at every compare match of the selected comaparator with the desired compare value, the interrupt can further be routed to other comparator.
78  *
79  * The module initialisation can be done as followed.
80  *
81  * \code
82  * stmSfr = &MODULE_STM0;
83  *
84  * IfxStm_initCompareConfig(&stmConfig);
85  *
86  * // configure to generate interrupt every 10 us
87  * sint32 ticks = IfxStm_getTicksFromMicroseconds(10);
88  *
89  * stmConfig.ticks = ticks;
90  *
91  * stmConfig.triggerPriority = IFX_INTPRIO_STM0_SR0;
92  * stmConfig.typeOfService = IfxSrc_Tos_cpu0;
93  *
94  * IfxStm_initCompare(stmSfr, &stmConfig);
95  *
96  * \endcode
97  *
98  * Now the Stm shall generate interrupts regularly based on the configured time !
99  *
100  * \defgroup IfxLld_Stm_Std_Enumerations Enumerations
101  * \ingroup IfxLld_Stm_Std
102  * \defgroup IfxLld_Stm_Std_Structures Data Structures
103  * \ingroup IfxLld_Stm_Std
104  * \defgroup IfxLld_Stm_Std_Module Module Functions
105  * \ingroup IfxLld_Stm_Std
106  * \defgroup IfxLld_Stm_Std_Timer Timer Functions
107  * \ingroup IfxLld_Stm_Std
108  * \defgroup IfxLld_Stm_Std_Comparator Comparator Functions
109  * \ingroup IfxLld_Stm_Std
110  */
111 
112 #ifndef IFXSTM_H
113 #define IFXSTM_H 1
114 
115 /******************************************************************************/
116 /*----------------------------------Includes----------------------------------*/
117 /******************************************************************************/
118 
119 #include "_Impl/IfxStm_cfg.h"
120 #include "Scu/Std/IfxScuCcu.h"
121 #include "Src/Std/IfxSrc.h"
122 
123 /******************************************************************************/
124 /*--------------------------------Enumerations--------------------------------*/
125 /******************************************************************************/
126 
127 /** \addtogroup IfxLld_Stm_Std_Enumerations
128  * \{ */
129 /** \brief Comparator Id defined in MODULE_STMx.ISCR.B.CMP0IRR(x = 0, 1, 2)
130  */
131 typedef enum
132 {
133  IfxStm_Comparator_0 = 0, /**< \brief Comparator Id 0 */
134  IfxStm_Comparator_1 /**< \brief Comparator Id 1 */
136 
137 /** \brief Comparator Interrupt request source defined in MODULE_SRC.STM.STM[index].SRx (x =0, 1)
138  */
139 typedef enum
140 {
141  IfxStm_ComparatorInterrupt_ir0 = 0, /**< \brief Select STMIR0 */
142  IfxStm_ComparatorInterrupt_ir1 = 1 /**< \brief Select STMIR1 */
144 
145 /** \brief Comparator start bit position defined in MODULE_STMx.CMCON.B.MSTART0(x = 0,1,2)
146  */
147 typedef enum
148 {
149  IfxStm_ComparatorOffset_0 = 0, /**< \brief Comparator start bit position 0 with 64 bit timer */
150  IfxStm_ComparatorOffset_1, /**< \brief Comparator start bit position 1 with 64 bit timer */
151  IfxStm_ComparatorOffset_2, /**< \brief Comparator start bit position 2 with 64 bit timer */
152  IfxStm_ComparatorOffset_3, /**< \brief Comparator start bit position 3 with 64 bit timer */
153  IfxStm_ComparatorOffset_4, /**< \brief Comparator start bit position 4 with 64 bit timer */
154  IfxStm_ComparatorOffset_5, /**< \brief Comparator start bit position 5 with 64 bit timer */
155  IfxStm_ComparatorOffset_6, /**< \brief Comparator start bit position 6 with 64 bit timer */
156  IfxStm_ComparatorOffset_7, /**< \brief Comparator start bit position 7 with 64 bit timer */
157  IfxStm_ComparatorOffset_8, /**< \brief Comparator start bit position 8 with 64 bit timer */
158  IfxStm_ComparatorOffset_9, /**< \brief Comparator start bit position 9 with 64 bit timer */
159  IfxStm_ComparatorOffset_10, /**< \brief Comparator start bit position 10 with 64 bit timer */
160  IfxStm_ComparatorOffset_11, /**< \brief Comparator start bit position 11 with 64 bit timer */
161  IfxStm_ComparatorOffset_12, /**< \brief Comparator start bit position 12 with 64 bit timer */
162  IfxStm_ComparatorOffset_13, /**< \brief Comparator start bit position 13 with 64 bit timer */
163  IfxStm_ComparatorOffset_14, /**< \brief Comparator start bit position 14 with 64 bit timer */
164  IfxStm_ComparatorOffset_15, /**< \brief Comparator start bit position 15 with 64 bit timer */
165  IfxStm_ComparatorOffset_16, /**< \brief Comparator start bit position 16 with 64 bit timer */
166  IfxStm_ComparatorOffset_17, /**< \brief Comparator start bit position 17 with 64 bit timer */
167  IfxStm_ComparatorOffset_18, /**< \brief Comparator start bit position 18 with 64 bit timer */
168  IfxStm_ComparatorOffset_19, /**< \brief Comparator start bit position 19 with 64 bit timer */
169  IfxStm_ComparatorOffset_20, /**< \brief Comparator start bit position 20 with 64 bit timer */
170  IfxStm_ComparatorOffset_21, /**< \brief Comparator start bit position 21 with 64 bit timer */
171  IfxStm_ComparatorOffset_22, /**< \brief Comparator start bit position 22 with 64 bit timer */
172  IfxStm_ComparatorOffset_23, /**< \brief Comparator start bit position 23 with 64 bit timer */
173  IfxStm_ComparatorOffset_24, /**< \brief Comparator start bit position 24 with 64 bit timer */
174  IfxStm_ComparatorOffset_25, /**< \brief Comparator start bit position 25 with 64 bit timer */
175  IfxStm_ComparatorOffset_26, /**< \brief Comparator start bit position 26 with 64 bit timer */
176  IfxStm_ComparatorOffset_27, /**< \brief Comparator start bit position 27 with 64 bit timer */
177  IfxStm_ComparatorOffset_28, /**< \brief Comparator start bit position 28 with 64 bit timer */
178  IfxStm_ComparatorOffset_29, /**< \brief Comparator start bit position 29 with 64 bit timer */
179  IfxStm_ComparatorOffset_30, /**< \brief Comparator start bit position 30 with 64 bit timer */
180  IfxStm_ComparatorOffset_31 /**< \brief Comparator start bit position 31 with 64 bit timer */
182 
183 /** \brief Size of compare value to compare with timer defined in MODULE_STMx.CMCON.B.MSIZE0(x = 0,1,2)
184  */
185 typedef enum
186 {
187  IfxStm_ComparatorSize_1Bit = 0, /**< \brief Size of compare value to compare with timer: 1 bit */
188  IfxStm_ComparatorSize_2Bits = 1, /**< \brief Size of compare value to compare with timer: 2 bits */
189  IfxStm_ComparatorSize_3Bits = 2, /**< \brief Size of compare value to compare with timer: 3 bits */
190  IfxStm_ComparatorSize_4Bits = 3, /**< \brief Size of compare value to compare with timer: 4 bits */
191  IfxStm_ComparatorSize_5Bits = 4, /**< \brief Size of compare value to compare with timer: 5 bits */
192  IfxStm_ComparatorSize_6Bits = 5, /**< \brief Size of compare value to compare with timer: 6 bits */
193  IfxStm_ComparatorSize_7Bits = 6, /**< \brief Size of compare value to compare with timer: 7 bits */
194  IfxStm_ComparatorSize_8Bits = 7, /**< \brief Size of compare value to compare with timer: 8 bits */
195  IfxStm_ComparatorSize_9Bits = 8, /**< \brief Size of compare value to compare with timer: 9 bits */
196  IfxStm_ComparatorSize_10Bits = 9, /**< \brief Size of compare value to compare with timer: 10 bits */
197  IfxStm_ComparatorSize_11Bits = 10, /**< \brief Size of compare value to compare with timer: 11 bits */
198  IfxStm_ComparatorSize_12Bits = 11, /**< \brief Size of compare value to compare with timer: 12 bits */
199  IfxStm_ComparatorSize_13Bits = 12, /**< \brief Size of compare value to compare with timer: 13 bits */
200  IfxStm_ComparatorSize_14Bits = 13, /**< \brief Size of compare value to compare with timer: 14 bits */
201  IfxStm_ComparatorSize_15Bits = 14, /**< \brief Size of compare value to compare with timer: 15 bits */
202  IfxStm_ComparatorSize_16Bits = 15, /**< \brief Size of compare value to compare with timer: 16 bits */
203  IfxStm_ComparatorSize_17Bits = 16, /**< \brief Size of compare value to compare with timer: 17 bits */
204  IfxStm_ComparatorSize_18Bits = 17, /**< \brief Size of compare value to compare with timer: 18 bits */
205  IfxStm_ComparatorSize_19Bits = 18, /**< \brief Size of compare value to compare with timer: 19 bits */
206  IfxStm_ComparatorSize_20Bits = 19, /**< \brief Size of compare value to compare with timer: 20 bits */
207  IfxStm_ComparatorSize_21Bits = 20, /**< \brief Size of compare value to compare with timer: 21 bits */
208  IfxStm_ComparatorSize_22Bits = 21, /**< \brief Size of compare value to compare with timer: 22 bits */
209  IfxStm_ComparatorSize_23Bits = 22, /**< \brief Size of compare value to compare with timer: 23 bits */
210  IfxStm_ComparatorSize_24Bits = 23, /**< \brief Size of compare value to compare with timer: 24 bits */
211  IfxStm_ComparatorSize_25Bits = 24, /**< \brief Size of compare value to compare with timer: 25 bits */
212  IfxStm_ComparatorSize_26Bits = 25, /**< \brief Size of compare value to compare with timer: 26 bits */
213  IfxStm_ComparatorSize_27Bits = 26, /**< \brief Size of compare value to compare with timer: 27 bits */
214  IfxStm_ComparatorSize_28Bits = 27, /**< \brief Size of compare value to compare with timer: 28 bits */
215  IfxStm_ComparatorSize_29Bits = 28, /**< \brief Size of compare value to compare with timer: 29 bits */
216  IfxStm_ComparatorSize_30Bits = 29, /**< \brief Size of compare value to compare with timer: 30 bits */
217  IfxStm_ComparatorSize_31Bits = 30, /**< \brief Size of compare value to compare with timer: 31 bits */
218  IfxStm_ComparatorSize_32Bits = 31 /**< \brief Size of compare value to compare with timer: 32 bits */
220 
221 /** \brief Enable/disable the sensitivity of the module to sleep signal\n
222  * Definition in Ifx_STM.CLC.B.EDIS
223  */
224 typedef enum
225 {
226  IfxStm_SleepMode_enable = 0, /**< \brief enables sleep mode */
227  IfxStm_SleepMode_disable = 1 /**< \brief disables sleep mode */
229 
230 /** \} */
231 
232 /******************************************************************************/
233 /*-----------------------------Data Structures--------------------------------*/
234 /******************************************************************************/
235 
236 /** \addtogroup IfxLld_Stm_Std_Structures
237  * \{ */
238 /** \brief Comparator Configuration Structure
239  */
240 typedef struct
241 {
242  IfxStm_Comparator comparator; /**< \brief Comparator Id defined in MODULE_STMx.ISCR.B.CMP0IRR(x = 0, 1, 2). */
243  IfxStm_ComparatorInterrupt comparatorInterrupt; /**< \brief Comparator Interrupt request source defined in MODULE_SRC.STM.STM[index].SRx (x =0, 1). */
244  IfxStm_ComparatorOffset compareOffset; /**< \brief Comparator start bit position defined in MODULE_STMx.CMCON.B.MSTART0(x = 0,1,2). */
245  IfxStm_ComparatorSize compareSize; /**< \brief Size of compare value to compare with timer defined in MODULE_STMx.CMCON.B.MSIZE0(x = 0,1,2). */
246  uint32 ticks; /**< \brief count for next comparison from current timer count. */
247  Ifx_Priority triggerPriority; /**< \brief Interrupt priority. Range = 0 .. 255. 0 = interrupt is disabled. */
248  IfxSrc_Tos typeOfService; /**< \brief Type of service. */
250 
251 /** \} */
252 
253 /** \addtogroup IfxLld_Stm_Std_Module
254  * \{ */
255 
256 /******************************************************************************/
257 /*-------------------------Inline Function Prototypes-------------------------*/
258 /******************************************************************************/
259 
260 /** \brief Returns system timer value.
261  * \param stm pointer to System timer module registers.
262  * \return system timer value.
263  */
264 IFX_INLINE uint64 IfxStm_get(Ifx_STM *stm);
265 
266 /** \brief Returns the system timer frequency.
267  * \param stm pointer to System timer module registers.
268  * \return the system timer frequency in Hz.
269  */
271 
272 /******************************************************************************/
273 /*-------------------------Global Function Prototypes-------------------------*/
274 /******************************************************************************/
275 
276 /** \brief enable suspend by debugger.
277  * \param stm pointer to System timer module registers.
278  * \return None
279  */
280 IFX_EXTERN void IfxStm_enableOcdsSuspend(Ifx_STM *stm);
281 
282 /** \brief API to get the resource index of the STM specified.
283  * \param stm pointer to System timer module registers.
284  * \return system timer resource index.
285  */
287 
288 /** \} */
289 
290 /** \addtogroup IfxLld_Stm_Std_Timer
291  * \{ */
292 
293 /******************************************************************************/
294 /*-------------------------Inline Function Prototypes-------------------------*/
295 /******************************************************************************/
296 
297 /** \brief Returns the lower system timer value.
298  * \param stm pointer to System timer module registers.
299  * \return the lower system timer value.
300  */
301 IFX_INLINE uint32 IfxStm_getLower(Ifx_STM *stm);
302 
303 /** \brief Gets the TIM3 couter value.
304  * \param stm pointer to System timer module registers.
305  * \return TIM3 counter value.
306  */
308 
309 /** \brief Gets the TIM4 couter value.
310  * \param stm pointer to System timer module registers.
311  * \return TIM4 counter value.
312  */
314 
315 /** \brief Gets the TIM5 couter value.
316  * \param stm pointer to System timer module registers.
317  * \return TIM5 counter value.
318  */
320 
321 /** \brief Gets the TIM6 couter value.
322  * \param stm pointer to System timer module registers.
323  * \return TIM6 counter value.
324  */
326 
327 /** \brief Gets the TIM1 couter value.
328  * \param stm pointer to System timer module registers.
329  * \return TIM1 counter value.
330  */
332 
333 /** \brief Gets the TIM2 couter value.
334  * \param stm pointer to System timer module registers.
335  * \return TIM2 counter value.
336  */
338 
339 /** \brief Returns the timer value shifted right by offset.
340  * \param stm pointer to System timer module registers.
341  * \param offset offset value.
342  * \return the lower system timer value shifted by offset.
343  */
344 IFX_INLINE uint32 IfxStm_getOffsetTimer(Ifx_STM *stm, uint8 offset);
345 
346 /** \brief Wait for requested time.
347  * The macro waits in while loop for the specified time in system timer ticks.
348  * \param stm pointer to System timer module registers.
349  * \param ticks ticks Wait time in system timer ticks.
350  * \return None
351  */
352 IFX_INLINE void IfxStm_waitTicks(Ifx_STM *stm, uint32 ticks);
353 
354 /** \} */
355 
356 /** \addtogroup IfxLld_Stm_Std_Comparator
357  * \{ */
358 
359 /******************************************************************************/
360 /*-------------------------Inline Function Prototypes-------------------------*/
361 /******************************************************************************/
362 
363 /** \brief Returns the updated compare register value.
364  * \param stm pointer to System timer module registers.
365  * \param comparator comparator selection comparator.
366  * \return The compare value
367  */
368 IFX_INLINE uint32 IfxStm_getCompare(Ifx_STM *stm, IfxStm_Comparator comparator);
369 
370 /** \brief Returns the number of ticks for the selected micro seconds based on the STM frequency.
371  * \param stm pointer to System timer module registers.
372  * \param microSeconds Number of micro seconds that need to be converted to ticks
373  * \return ticks
374  */
375 IFX_INLINE sint32 IfxStm_getTicksFromMicroseconds(Ifx_STM *stm, uint32 microSeconds);
376 
377 /** \brief Returns the number of ticks for the selected milli seconds based on the STM frequency.
378  * \param stm pointer to System timer module registers.
379  * \param milliSeconds Number of micro seconds that need to be converted to ticks
380  * \return ticks
381  */
382 IFX_INLINE sint32 IfxStm_getTicksFromMilliseconds(Ifx_STM *stm, uint32 milliSeconds);
383 
384 /** \brief Update the compare register value increased with given ticks.
385  * \param stm pointer to System timer module registers.
386  * \param comparator comparator selection comparator.
387  * \param ticks count for next comparison from current timer count.
388  * \return None
389  */
390 IFX_INLINE void IfxStm_increaseCompare(Ifx_STM *stm, IfxStm_Comparator comparator, uint32 ticks);
391 
392 /** \brief Update the compare register value.
393  * \param stm pointer to System timer module registers.
394  * \param comparator comparator selection comparator.
395  * \param ticks count for next comparison.
396  * \return None
397  */
398 IFX_INLINE void IfxStm_updateCompare(Ifx_STM *stm, IfxStm_Comparator comparator, uint32 ticks);
399 
400 /******************************************************************************/
401 /*-------------------------Global Function Prototypes-------------------------*/
402 /******************************************************************************/
403 
404 /** \brief Clear the compare interrupt flag.
405  * \param stm pointer to System timer module registers.
406  * \param comparator comparator selection comparator.
407  * \return None
408  */
409 IFX_EXTERN void IfxStm_clearCompareFlag(Ifx_STM *stm, IfxStm_Comparator comparator);
410 
411 /** \brief Initialise stm compare register.
412  * \param stm pointer to System timer module registers.
413  * \param config pointer to configuration structure.
414  * \return TRUE if Comparator successful otherwise FLASE.
415  */
416 IFX_EXTERN boolean IfxStm_initCompare(Ifx_STM *stm, const IfxStm_CompareConfig *config);
417 
418 /** \brief Initialise compare configuration with default values.
419  * \param config pointer to configuration structure.
420  * \return None
421  */
423 
424 /** \brief Enables the compare interrupt .
425  * \param stm pointer to System timer module registers.
426  * \param comparator comparator selection comparator.
427  * \return None
428  */
429 IFX_EXTERN void IfxStm_enableComparatorInterrupt(Ifx_STM *stm, IfxStm_Comparator comparator);
430 
431 /** \} */
432 
433 /******************************************************************************/
434 /*-------------------------Inline Function Prototypes-------------------------*/
435 /******************************************************************************/
436 
437 /**
438  * \param stm pointer STM registers
439  * \param mode mode selection (enable/ disable)
440  * \return None
441  */
442 IFX_INLINE void IfxStm_setSleepMode(Ifx_STM *stm, IfxStm_SleepMode mode);
443 
444 /******************************************************************************/
445 /*-------------------------Global Function Prototypes-------------------------*/
446 /******************************************************************************/
447 
448 /**
449  * \param stm pointer to STM registers
450  * \return None
451  */
452 IFX_EXTERN void IfxStm_resetModule(Ifx_STM *stm);
453 
454 /******************************************************************************/
455 /*---------------------Inline Function Implementations------------------------*/
456 /******************************************************************************/
457 
459 {
460  uint64 result;
461 
462  result = stm->TIM0.U;
463  result |= ((uint64)stm->CAP.U) << 32;
464 
465  return result;
466 }
467 
468 
470 {
471  return stm->CMP[comparator].B.CMPVAL;
472 }
473 
474 
476 {
477  float32 result;
478 
479  result = IfxScuCcu_getStmFrequency();
480 
481  return result;
482 }
483 
484 
486 {
487  return stm->TIM0.U;
488 }
489 
490 
492 {
493  return stm->TIM3.U;
494 }
495 
496 
498 {
499  return stm->TIM4.U;
500 }
501 
502 
504 {
505  return stm->TIM5.U;
506 }
507 
508 
510 {
511  return stm->TIM6.U;
512 }
513 
514 
516 {
517  return stm->TIM1.U;
518 }
519 
520 
522 {
523  return stm->TIM2.U;
524 }
525 
526 
528 {
529  uint64 now;
530 
531  now = IfxStm_get(stm);
532 
533  return (uint32)(now >> offset);
534 }
535 
536 
538 {
539  sint32 freq = (sint32)IfxStm_getFrequency(stm);
540  return (freq / (1000000)) * microSeconds;
541 }
542 
543 
545 {
546  sint32 freq = (sint32)IfxStm_getFrequency(stm);
547  return (freq / (1000)) * milliSeconds;
548 }
549 
550 
551 IFX_INLINE void IfxStm_increaseCompare(Ifx_STM *stm, IfxStm_Comparator comparator, uint32 ticks)
552 {
553  stm->CMP[comparator].B.CMPVAL = stm->CMP[comparator].B.CMPVAL + ticks;
554 }
555 
556 
558 {
561  stm->CLC.B.EDIS = mode;
562  IfxScuWdt_setCpuEndinit(passwd);
563 }
564 
565 
566 IFX_INLINE void IfxStm_updateCompare(Ifx_STM *stm, IfxStm_Comparator comparator, uint32 ticks)
567 {
568  stm->CMP[comparator].B.CMPVAL = ticks;
569 }
570 
571 
572 IFX_INLINE void IfxStm_waitTicks(Ifx_STM *stm, uint32 ticks)
573 {
574  uint32 beginTime;
575 
576  beginTime = IfxStm_getLower(stm);
577 
578  /*below code will work because of unsigned 32 bit calculation even at timer wrapping condition
579  * As an example if beginTime = 0xFFFFFFFE and current time = 2 (after overflow), unsigned calculation
580  * 2 - 0xFFFFFFFE will be 4*/
581  while ((IfxStm_getLower(stm) - beginTime) < ticks)
582  {}
583 }
584 
585 
586 #endif /* IFXSTM_H */