1 /*
2  * Copyright 2020-2023 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef WKPU_IP_H
8 #define WKPU_IP_H
9 
10 /**
11  *     @file
12  *
13  *     @addtogroup wkpu_icu_ip WKPU IPL
14  *     @{
15  */
16 
17 #ifdef __cplusplus
18 extern "C"{
19 #endif
20 
21 
22 /*==================================================================================================
23 *                                          INCLUDE FILES
24 ==================================================================================================*/
25 #include "Wkpu_Ip_Types.h"
26 #include "Wkpu_Ip_Cfg.h"
27 
28 #if (STD_ON == WKPU_IP_USED)
29     #if (defined (WKPU_IP_ENABLE_USER_MODE_SUPPORT))
30         #if (STD_ON == WKPU_IP_ENABLE_USER_MODE_SUPPORT)
31             #include "Reg_eSys.h"
32         #endif
33     #endif
34 #endif /* WKPU_IP_USED */
35 /*==================================================================================================
36 *                                SOURCE FILE VERSION INFORMATION
37 ==================================================================================================*/
38 #define WKPU_IP_VENDOR_ID                      43
39 #define WKPU_IP_AR_RELEASE_MAJOR_VERSION       4
40 #define WKPU_IP_AR_RELEASE_MINOR_VERSION       7
41 #define WKPU_IP_AR_RELEASE_REVISION_VERSION    0
42 #define WKPU_IP_SW_MAJOR_VERSION               3
43 #define WKPU_IP_SW_MINOR_VERSION               0
44 #define WKPU_IP_SW_PATCH_VERSION               0
45 
46 /*==================================================================================================
47 *                                       FILE VERSION CHECKS
48 ==================================================================================================*/
49 /* Check if source file and ICU header file are of the same vendor */
50 #if (WKPU_IP_VENDOR_ID != WKPU_IP_TYPES_VENDOR_ID)
51     #error "Wkpu_Ip.h and Wkpu_Ip_Types.h have different vendor IDs"
52 #endif
53 /* Check if source file and ICU header file are of the same AutoSar version */
54 #if ((WKPU_IP_AR_RELEASE_MAJOR_VERSION  != WKPU_IP_TYPES_AR_RELEASE_MAJOR_VERSION) || \
55      (WKPU_IP_AR_RELEASE_MINOR_VERSION  != WKPU_IP_TYPES_AR_RELEASE_MINOR_VERSION) || \
56      (WKPU_IP_AR_RELEASE_REVISION_VERSION   != WKPU_IP_TYPES_AR_RELEASE_REVISION_VERSION))
57     #error "AutoSar Version Numbers of Wkpu_Ip.h and Wkpu_Ip_Types.h are different"
58 #endif
59 /* Check if source file and ICU header file are of the same Software version */
60 #if ((WKPU_IP_SW_MAJOR_VERSION  != WKPU_IP_TYPES_SW_MAJOR_VERSION) || \
61      (WKPU_IP_SW_MINOR_VERSION  != WKPU_IP_TYPES_SW_MINOR_VERSION) || \
62      (WKPU_IP_SW_PATCH_VERSION  != WKPU_IP_TYPES_SW_PATCH_VERSION))
63 #error "Software Version Numbers of Wkpu_Ip.h and Wkpu_Ip_Types.h are different"
64 #endif
65 
66 /* Check if source file and ICU header file are of the same vendor */
67 #if (WKPU_IP_VENDOR_ID != WKPU_IP_CFG_VENDOR_ID)
68     #error "Wkpu_Ip.h and Wkpu_Ip_Cfg.h have different vendor IDs"
69 #endif
70 /* Check if source file and ICU header file are of the same AutoSar version */
71 #if ((WKPU_IP_AR_RELEASE_MAJOR_VERSION  != WKPU_IP_CFG_AR_RELEASE_MAJOR_VERSION) || \
72      (WKPU_IP_AR_RELEASE_MINOR_VERSION  != WKPU_IP_CFG_AR_RELEASE_MINOR_VERSION) || \
73      (WKPU_IP_AR_RELEASE_REVISION_VERSION   != WKPU_IP_CFG_AR_RELEASE_REVISION_VERSION))
74     #error "AutoSar Version Numbers of Wkpu_Ip.h and Wkpu_Ip_Cfg.h are different"
75 #endif
76 /* Check if source file and ICU header file are of the same Software version */
77 #if ((WKPU_IP_SW_MAJOR_VERSION  != WKPU_IP_CFG_SW_MAJOR_VERSION) || \
78      (WKPU_IP_SW_MINOR_VERSION  != WKPU_IP_CFG_SW_MINOR_VERSION) || \
79      (WKPU_IP_SW_PATCH_VERSION  != WKPU_IP_CFG_SW_PATCH_VERSION))
80 #error "Software Version Numbers of Wkpu_Ip.h and Wkpu_Ip_Cfg.h are different"
81 #endif
82 
83 #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
84     #if (STD_ON == WKPU_IP_USED)
85         #if (defined (WKPU_IP_ENABLE_USER_MODE_SUPPORT))
86             #if (STD_ON == WKPU_IP_ENABLE_USER_MODE_SUPPORT)
87             /* Check if header file and Reg_eSys.h file are of the same Autosar version */
88                 #if ((WKPU_IP_AR_RELEASE_MAJOR_VERSION != REG_ESYS_AR_RELEASE_MAJOR_VERSION) || \
89                     (WKPU_IP_AR_RELEASE_MINOR_VERSION != REG_ESYS_AR_RELEASE_MINOR_VERSION))
90                     #error "AutoSar Version Numbers of Ftm_Icu_Ip.h and Reg_eSys.h are different"
91                 #endif
92             #endif
93         #endif
94     #endif /* WKPU_IP_USED */
95 #endif
96 
97 /*==================================================================================================
98 *                                            CONSTANTS
99 ==================================================================================================*/
100 
101 /*==================================================================================================
102 *                                        DEFINES AND MACROS
103 ==================================================================================================*/
104 #if (STD_ON == WKPU_IP_USED)
105 
106 #if (defined WKPU_CONFIG_EXT)
107 #define ICU_START_SEC_CONFIG_DATA_UNSPECIFIED
108 #include "Icu_MemMap.h"
109 
110 /* Macro used to import WKPU generated configurations. */
111 WKPU_CONFIG_EXT
112 
113 #define ICU_STOP_SEC_CONFIG_DATA_UNSPECIFIED
114 #include "Icu_MemMap.h"
115 #endif
116 /*==================================================================================================
117 *                                              ENUMS
118 ==================================================================================================*/
119 
120 /*==================================================================================================
121 *                                  STRUCTURES AND OTHER TYPEDEFS
122 ==================================================================================================*/
123 
124 /*==================================================================================================
125 *                                  GLOBAL VARIABLE DECLARATIONS
126 ==================================================================================================*/
127 #define ICU_START_SEC_CONST_UNSPECIFIED
128 #include "Icu_MemMap.h"
129 
130 extern WKPU_Type * const Wkpu_Ip_pBase[];
131 
132 #define ICU_STOP_SEC_CONST_UNSPECIFIED
133 #include "Icu_MemMap.h"
134 /*==================================================================================================
135 *                                      FUNCTION PROTOTYPES
136 ==================================================================================================*/
137 #define ICU_START_SEC_CODE
138 #include "Icu_MemMap.h"
139 
140 #if !defined(WKPU_DERIVATIVE_SUPPORT_ONLY_NMI)
141 
142 #ifdef WKPU_IP_SUPPORT_INTERRUPT_REQUEST
143 
144 #if (WKPU_IP_SET_MODE_API == STD_ON)
145 /**
146  * @brief      ICU driver function that sets WKPU channel to SLEEP mode.
147  * @details    This function enables the interrupt for WKPU channel if wakeup is enabled for
148  *             the channel.
149  *
150  * @param[in]  instance  Hardware instance of WKPU used.
151  * @param[in]  hwChannel Hardware channel of WKPU used.
152  * @return     void
153  */
154 void Wkpu_Ip_SetSleepMode(uint8 instance, uint8 hwChannel);
155 
156 /**
157  * @brief      Icu driver function that sets WKPU channel to NORMAL mode.
158  * @details    This function enables the interrupt for WKPU channel if Notifcation is enabled
159  *             for the channel.
160  *
161  * @param[in]  instance  Hardware instance of WKPU used.
162  * @param[in]  hwChannel Hardware channel of WKPU used.
163  * @return     void
164  */
165 void Wkpu_Ip_SetNormalMode(uint8 instance, uint8 hwChannel);
166 #endif  /* WKPU_IP_SET_MODE_API  */
167 
168 /**
169  * @brief      Enable the interrupt request and wakeup generation.
170  * @details    This function setup generation of interrupt and wakeup generation.
171  *
172  * @param[in]  instance  Hardware instance of WKPU used.
173  * @param[in]  hwChannel Hardware channel of WKPU used.
174  * @return     void
175  */
176 void Wkpu_Ip_EnableInterrupt(uint8 instance, uint8 hwChannel);
177 
178 /**
179  * @brief      ICU driver function that disables the interrupt of a WKPU channel.
180  * @details    This function disables WKPU Channel Interrupt.
181  *
182  * @param[in]  instance  Hardware instance of WKPU used.
183  * @param[in]  hwChannel Hardware channel of WKPU used.
184  * @return     void
185  */
186 void Wkpu_Ip_DisableInterrupt(uint8 instance, uint8 hwChannel);
187 
188 /**
189  * @brief      Icu driver function that initializes WKPU channels.
190  * @details    This function:
191  *              - Sets Interrupt Filter Enable Register
192  *              - Sets Wakeup/Interrupt Pull-up Enable Register
193  *              - Sets Activation Condition
194  *
195  * @param[in]  instance  Hardware instance of WKPU used.
196  * @param[in]  userConfig - Pointer to array of with channels configuration.
197  * @return     void
198  */
199 Wkpu_Ip_StatusType Wkpu_Ip_Init(uint8 instance, const Wkpu_Ip_IrqConfigType* userConfig);
200 
201 /**
202  * @brief      ICU driver function that resets WKPU configuration.
203  * @details    This function:
204  *              - Disables IRQ Interrupt
205  *              - Clears Wakeup/Interrupt Filter Enable Register
206  *              - Clears Wakeup/Interrupt Pull-up Enable Register
207  *              - Clears edge event enable registers
208  *              - Clear Interrupt Filter Enable Register
209  *
210  * @param[in]  instance Hardware instance of WKPU used.
211  * @return     void
212  */
213 Wkpu_Ip_StatusType Wkpu_Ip_DeInit(uint8 instance);
214 
215 /**
216  * @brief      ICU driver function that sets activation condition of WKPU channel.
217  * @details    This function enables the requested activation condition(rising, falling or both edges)
218  *             for corresponding WKPU channels.
219  *
220  * @param[in]  instance  Hardware instance of WKPU used.
221  * @param[in]  hwChannel Hardware channel of WKPU used.
222  * @param[in]  edge      Edge type for activation.
223  * @return     void
224  */
225 void Wkpu_Ip_SetActivationCondition(uint8 instance, uint8 hwChannel, Wkpu_Ip_EdgeType edge);
226 
227 /**
228  * @brief      ICU driver function that gets the input state of WKPU channel.
229  * @details    This function:
230  *             - Checks if interrupt flags for corresponding WKPU channel is set then
231  *             it clears the interrupt flag and returns the value as TRUE.
232  *
233  * @param[in]  instance  Hardware instance of WKPU used.
234  * @param[in]  hwChannel Hardware channel of WKPU used.
235  * @return     boolean
236  *              - TRUE - if channel is active
237  *              - FALSE - If channel is in idle
238  */
239 boolean Wkpu_Ip_GetInputState(uint8 instance, uint8 hwChannel);
240 
241 /**
242  * @brief      Driver function Enable Notification for timestamp.
243  */
244 void Wkpu_Ip_EnableNotification(uint8 hwChannel);
245 
246 /**
247  * @brief      Driver function Disable Notification for timestamp.
248  */
249 void Wkpu_Ip_DisableNotification(uint8 hwChannel);
250 
251 #endif /* WKPU_IP_SUPPORT_INTERRUPT_REQUEST */
252 
253 #endif /* WKPU_DERIVATIVE_SUPPORT_ONLY_NMI */
254 
255 #if (defined (WKPU_IP_NMI_API) && (STD_ON == WKPU_IP_NMI_API))
256 Wkpu_Ip_StatusType Wkpu_Ip_InitNMI(uint8 instance, const Wkpu_Ip_IrqConfigType* userConfig);
257 Wkpu_Ip_StatusType Wkpu_Ip_DeinitNMI(uint8 instance);
258 #endif
259 
260 #define ICU_STOP_SEC_CODE
261 #include "Icu_MemMap.h"
262 
263 #endif /* WKPU_IP_USED */
264 
265 #ifdef __cplusplus
266 }
267 #endif
268 
269 /** @} */
270 
271 #endif  /* WKPU_IP_H */
272