1 /*
2  * Copyright 2021-2022 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef SWT_IP_H
8 #define SWT_IP_H
9 
10 /**
11 *   @file
12 *
13 *   @addtogroup Swt
14 *   @{
15 */
16 
17 #ifdef __cplusplus
18 extern "C"{
19 #endif
20 
21 
22 /*==================================================================================================
23 *                                        INCLUDE FILES
24 * 1) system and project includes
25 * 2) needed interfaces from external units
26 * 3) internal and external interfaces from this unit
27 ==================================================================================================*/
28 
29 #include "Swt_Ip_Types.h"
30 #include "Swt_Ip_DeviceRegisters.h"
31 
32 /*==================================================================================================
33 *                                 SOURCE FILE VERSION INFORMATION
34 ==================================================================================================*/
35 #define SWT_IP_VENDOR_ID                    43
36 #define SWT_IP_MODULE_ID                    102
37 #define SWT_IP_AR_RELEASE_MAJOR_VERSION     4
38 #define SWT_IP_AR_RELEASE_MINOR_VERSION     7
39 #define SWT_IP_AR_RELEASE_REVISION_VERSION  0
40 #define SWT_IP_SW_MAJOR_VERSION             0
41 #define SWT_IP_SW_MINOR_VERSION             9
42 #define SWT_IP_SW_PATCH_VERSION             0
43 
44 /*==================================================================================================
45 *                                       FILE VERSION CHECKS
46 ==================================================================================================*/
47 
48 /* Check if current file and Swt_Ip_Types header file are of the same vendor */
49 #if (SWT_IP_VENDOR_ID != SWT_IP_TYPES_VENDOR_ID)
50 #error "Swt_Ip.h and Swt_Ip_Types.h have different vendor ids"
51 #endif
52 
53 #if ((SWT_IP_AR_RELEASE_MAJOR_VERSION    != SWT_IP_TYPES_AR_RELEASE_MAJOR_VERSION) || \
54      (SWT_IP_AR_RELEASE_MINOR_VERSION    != SWT_IP_TYPES_AR_RELEASE_MINOR_VERSION) || \
55      (SWT_IP_AR_RELEASE_REVISION_VERSION != SWT_IP_TYPES_AR_RELEASE_REVISION_VERSION))
56 #error "AutoSar Version Numbers of Swt_Ip.h and Swt_Ip_Types.h are different"
57 #endif
58 
59 #if ((SWT_IP_SW_MAJOR_VERSION != SWT_IP_TYPES_SW_MAJOR_VERSION) || \
60      (SWT_IP_SW_MINOR_VERSION != SWT_IP_TYPES_SW_MINOR_VERSION) || \
61      (SWT_IP_SW_PATCH_VERSION != SWT_IP_TYPES_SW_PATCH_VERSION))
62 #error "Software Version Numbers of Swt_Ip.h and Swt_Ip_Types.h are different"
63 #endif
64 
65 /* Check if current file and Swt_Ip_DeviceRegisters header file are of the same vendor */
66 #if (SWT_IP_VENDOR_ID != SWT_IP_DEVICE_REGISTERS_VENDOR_ID)
67 #error "Swt_Ip.h and Swt_Ip_DeviceRegisters.h have different vendor ids"
68 #endif
69 
70 #if ((SWT_IP_AR_RELEASE_MAJOR_VERSION    != SWT_IP_DEVICE_REGISTERS_AR_RELEASE_MAJOR_VERSION) || \
71      (SWT_IP_AR_RELEASE_MINOR_VERSION    != SWT_IP_DEVICE_REGISTERS_AR_RELEASE_MINOR_VERSION) || \
72      (SWT_IP_AR_RELEASE_REVISION_VERSION != SWT_IP_DEVICE_REGISTERS_AR_RELEASE_REVISION_VERSION))
73 #error "AutoSar Version Numbers of Swt_Ip.h and Swt_Ip_DeviceRegisters.h are different"
74 #endif
75 
76 #if ((SWT_IP_SW_MAJOR_VERSION != SWT_IP_DEVICE_REGISTERS_SW_MAJOR_VERSION) || \
77      (SWT_IP_SW_MINOR_VERSION != SWT_IP_DEVICE_REGISTERS_SW_MINOR_VERSION) || \
78      (SWT_IP_SW_PATCH_VERSION != SWT_IP_DEVICE_REGISTERS_SW_PATCH_VERSION))
79 #error "Software Version Numbers of Swt_Ip.h and Swt_Ip_DeviceRegisters.h are different"
80 #endif
81 
82 /*==================================================================================================
83 *                                            CONSTANTS
84 ==================================================================================================*/
85 
86 /*==================================================================================================
87 *                                       DEFINES AND MACROS
88 ==================================================================================================*/
89 
90 /*==================================================================================================
91 *                                              ENUMS
92 ==================================================================================================*/
93 
94 /*==================================================================================================
95 *                                  STRUCTURES AND OTHER TYPEDEFS
96 ==================================================================================================*/
97 
98 /*==================================================================================================
99 *                                  GLOBAL VARIABLE DECLARATIONS
100 ==================================================================================================*/
101 
102 /*==================================================================================================
103 *                                       FUNCTION PROTOTYPES
104 ==================================================================================================*/
105 
106 #ifdef WDG_ROM
107     #if (WDG_ROM == 1U)
108         #define WDG_START_SEC_CODE
109     #endif
110 #else
111     #if (WDG_RAM == 0U)
112         #define WDG_START_SEC_RAMCODE
113     #endif
114 #endif
115 
116 #include "Wdg_MemMap.h"
117 
118 /*!
119  * @brief       Initialize SWT instance.
120  * @details     This Initializes SWT instance with the configuration passed via
121  *              ConfigPtr pointer.
122  *
123  * @param[in]   Instance     SWT Instance number.
124  * @param[in]   ConfigPtr  Pointer to the configuration structure
125  *                              which will be used to configure the SWT driver
126  *
127  * @return      An error code or SWT_IP_STATUS_SUCCESS
128  */
129 Swt_Ip_StatusType Swt_Ip_Init(const uint32 Instance,
130                         const Swt_Ip_ConfigType * const ConfigPtr);
131 
132 #if (SWT_IP_DEINIT == STD_ON)
133 /*!
134  * @brief       De-Initializes SWT instance.
135  * @details     This function De-Initializes SWT instance.
136  *
137  * @param[in]   Instance     SWT Instance number
138  *
139  * @return      An error code or SWT_IP_STATUS_SUCCESS
140  */
141     Swt_Ip_StatusType Swt_Ip_Deinit(const uint32 Instance);
142 #endif
143 
144 
145 /*!
146  * @brief       Services the SWT instance.
147  * @details     This function services SWT instance.
148  *
149  * @param[in]   Instance     SWT Instance number
150  *
151  * @return      void
152  */
153  void Swt_Ip_Service(const uint32 Instance);
154 
155 
156 /*!
157  * @brief       Configure SWT instance.
158  * @details     This function configure SWT instance.
159  *
160  * @param[in]   Instance     SWT Instance number
161  * @param[in]   ConfigPtr  Pointer to the configuration structure
162  *                              which will be used to configure the SWT driver
163  *
164  * @return      An error code or SWT_IP_STATUS_SUCCESS
165  */
166 Swt_Ip_StatusType Swt_Ip_Config(const uint32 Instance,
167                             const Swt_Ip_ConfigType * const ConfigPtr);
168 
169 /*!
170  * @brief       Sets the timeout value for SWT instance.
171  * @details     This function sets the timeout value for SWT instance.
172  *
173  * @param[in]   Instance     SWT Instance number
174  * @param[in]   TimeoutValue SWT timeout value
175  * @param[in]   WindowValue  SWT window value
176  *
177  * @return      An error code or SWT_IP_STATUS_SUCCESS
178  */
179 Swt_Ip_StatusType Swt_Ip_SetTimeout(const uint32 Instance,
180                                 const uint32 TimeoutValue, const uint32 WindowValue);
181 
182 /*!
183  * @brief       Starts the timer of SWT instance.
184  * @details     This function starts the timer of the SWT instance.
185  *
186  * @param[in]   Instance     SWT Instance number
187  *
188  * @return      An error code or SWT_IP_STATUS_SUCCESS
189  */
190 Swt_Ip_StatusType Swt_Ip_StartTimer(const uint32 Instance);
191 
192 /*!
193  * @brief       Stops the timer of SWT instance.
194  * @details     This function stops the timer of the SWT instance.
195  *
196  * @param[in]   Instance     SWT Instance number
197  *
198  * @return      An error code or SWT_IP_STATUS_SUCCESS
199  */
200 Swt_Ip_StatusType Swt_Ip_StopTimer(const uint32 Instance);
201 
202 #if (SWT_IP_DEINIT == STD_ON)
203 #if (SWT_IP_CLEAR_RESET_REQUEST == STD_ON)
204 /*!
205  * @brief       Clear reset request.
206  * @details     This function clear the reset request for SWT instance.
207  *
208  * @param[in]   Instance     SWT Instance number
209  *
210  * @return                             Swt_Ip_StatusType.
211  * @retval  SWT_IP_STATUS_SUCCESS      Clear reset request successfully.
212  * @retval  SWT_IP_STATUS_ERROR        Clear reset request encountered error
213  *                                     caused by unlock sequence failed.
214  */
215     Swt_Ip_StatusType Swt_Ip_ClearResetRequest(const uint32 Instance);
216 #endif
217 #endif
218 
219 
220 #ifdef WDG_ROM
221     #if (WDG_ROM == 1U)
222         #define WDG_STOP_SEC_CODE
223     #endif
224 #else
225     #if (WDG_RAM == 0U)
226         #define WDG_STOP_SEC_RAMCODE
227     #endif
228 #endif
229 
230 
231 #include "Wdg_MemMap.h"
232 
233 #ifdef __cplusplus
234 }
235 #endif
236 
237 /** @} */
238 
239 #endif /*SWT_IP_H */
240 
241