Infineon MOTIX™ MCU TLE987x Device Family SDK
wdt1.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  **********************************************************************************************************************/
37 /*******************************************************************************
38 ** Author(s) Identity **
39 ********************************************************************************
40 ** Initials Name **
41 ** ---------------------------------------------------------------------------**
42 ** DM Daniel Mysliwitz **
43 ** TA Thomas Albersinger **
44 ** JO Julia Ott **
45 ** BG Blandine Guillot **
46 *******************************************************************************/
47 
48 /*******************************************************************************
49 ** Revision Control History **
50 ********************************************************************************
51 ** V0.1.0: 2012-11-12, DM: Initial version **
52 ** V0.2.0: 2013-10-18, DM: Reset of bSOWactive flag in WDT1_Service() **
53 ** V0.2.1: 2014-05-16, DM: Delay_us() function added **
54 ** WD_Trig_Time calculation done as #define **
55 ** V0.2.2: 2014-06-27, TA: Changed to types from Types.h **
56 ** V0.2.3: 2014-07-24, DM: Delay_us() SysTick overrun fixed **
57 ** V0.2.4: 2015-02-10, DM: Individual header file added **
58 ** V0.2.5: 2016-11-30, DM: macros One_us and SysTickRL are moved into header**
59 ** file **
60 ** V0.2.6: 2017-04-11, DM: Delay_us() function updated **
61 ** V0.2.7: 2017-10-20, DM: MISRA 2012 compliance, the following PC-Lint **
62 ** rules are globally deactivated: **
63 ** - Info 793: ANSI/ISO limit of 6 'significant **
64 ** characters in an external identifier **
65 ** - Info 835: A zero has been given as right **
66 ** argument to operator **
67 ** - Info 845: The left argument to operator '&' **
68 ** is certain to be 0 **
69 ** V0.2.8: 2018-11-27, JO: Doxygen update **
70 ** Moved revision history from wdt1.c to wdt1.h **
71 ** Split WDT1_Init to WDT1_Init and SysTick_Init **
72 ** Changed Delay_us so that delays>=1ms are possible**
73 ** Changed __STATIC_INLINE to INLINE **
74 ** V0.2.9: 2019-03-29, JO: Changed formula for SysTickRL to use uint32 **
75 ** instead of sint32 **
76 ** CPU->SYSTICK_RL.reg initialized with macro **
77 ** SysTickRL from wdt1.h **
78 ** Added function SysTick_ReloadValue_Get **
79 ** Adapted Delay_us to use SysTick_ReloadValue_Get **
80 ** instead of register access **
81 ** Renamed Systick_Value_Get() to SysTick_Value_Get **
82 ** V0.3.0: 2020-04-15, BG: Updated revision history format **
83 ** V0.3.1: 2020-07-21, BG: EP-439: Formatted .h/.c files **
84 ** V0.3.2: 2021-04-14, JO: EP-766: Corrected function Delay_us in case the **
85 ** current systick value is 0 or the reload value **
86 ** V0.3.3: 2022-02-28, JO: EP-936: Updated copyright and branding **
87 *******************************************************************************/
88 
89 #ifndef _WDT1_H
90 #define _WDT1_H
91 
92 /*******************************************************************************
93 ** Includes **
94 *******************************************************************************/
95 #include "types.h"
96 #include "tle987x.h"
97 
98 /*******************************************************************************
99 ** External Variable Declarations **
100 *******************************************************************************/
101 extern uint32 WD_Counter;
102 
103 /*******************************************************************************
104 ** Global Macro Definitions **
105 *******************************************************************************/
106 #define One_us ((uint32)SCU_FSYS / 1000000u)
107 #define SysTickRL ((uint32)SCU_FSYS / (uint32)SysTickFreq)
108 
109 /*******************************************************************************
110 ** Global Constant Declarations **
111 *******************************************************************************/
113 #define SysTickFreq 1000u
114 
115 /*******************************************************************************
116 ** Global Function Declarations **
117 *******************************************************************************/
123 void WDT1_Init(void);
124 
130 void SysTick_Init(void);
131 
147 void WDT1_Stop(void);
148 
164 bool WDT1_Service(void);
165 
180 void WDT1_SOW_Service(uint32 NoOfSOW);
181 
202 void Delay_us(uint32 delay_time_us);
203 
204 INLINE void WDT1_Window_Count(void);
207 
208 /*******************************************************************************
209 ** Global Inline Function Definitions **
210 *******************************************************************************/
211 
225 {
226  WD_Counter++;
227 }
228 
229 
247 {
248  return CPU->SYSTICK_CUR.reg;
249 }
250 
268 {
269  return (CPU->SYSTICK_RL.reg);
270 }
271 
287 {
288  CPU->SYSTICK_RL.reg = val;
289 }
290 
291 #endif
#define CPU
Definition: tle987x.h:6089
CMSIS register HeaderFile.
General type declarations.
#define INLINE
Definition: types.h:148
uint32_t uint32
32 bit unsigned value
Definition: types.h:155
void WDT1_Init(void)
Performs the initial service of the WDT1 (closes the long open window) based on the Config Wizard for...
void WDT1_SOW_Service(uint32 NoOfSOW)
Triggers a short-window (~30ms) of the WDT1.
INLINE void SysTick_ReloadValue_Set(uint32 val)
sets the SysTick Reload value
Definition: wdt1.h:286
void WDT1_Stop(void)
Stops the service of WDT1 by stopping the SysTick timer.
INLINE void WDT1_Window_Count(void)
increments the WDT1 Window Counter
Definition: wdt1.h:224
INLINE uint32 SysTick_Value_Get(void)
returns the current SysTick timer count value
Definition: wdt1.h:246
uint32 WD_Counter
void SysTick_Init(void)
Initializes the SysTick timer to 1ms interval.
INLINE uint32 SysTick_ReloadValue_Get(void)
returns the current SysTick reload value
Definition: wdt1.h:267
bool WDT1_Service(void)
Services the WDT1 in the open window.
void Delay_us(uint32 delay_time_us)
Delays the regular program execution by a given number of Microseconds.