1 /*
2  * Copyright 2021-2023 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef SIUL2_ICU_IP_H
8 #define SIUL2_ICU_IP_H
9 
10 /**
11  *     @file
12  *
13  *     @addtogroup siul2_icu_ip SIUL2 IPL
14  *     @{
15  */
16 
17 #ifdef __cplusplus
18 extern "C"{
19 #endif
20 
21 /*==================================================================================================
22 *                                          INCLUDE FILES
23 *  1) system and project includes
24 *  2) needed interfaces from external units
25 *  3) internal and external interfaces from this unit
26 ==================================================================================================*/
27 #include "Siul2_Icu_Ip_Types.h"
28 #include "Siul2_Icu_Ip_Cfg.h"
29 
30 #if (STD_ON == SIUL2_ICU_IP_USED)
31     #if (STD_ON == SIUL2_ICU_IP_ENABLE_USER_MODE_SUPPORT)
32         #include "Reg_eSys.h"
33     #endif
34 #endif /* SIUL2_ICU_IP_USED */
35 
36 /*==================================================================================================
37 *                                SOURCE FILE VERSION INFORMATION
38 ==================================================================================================*/
39 #define SIUL2_ICU_IP_VENDOR_ID                    43
40 #define SIUL2_ICU_IP_AR_RELEASE_MAJOR_VERSION     4
41 #define SIUL2_ICU_IP_AR_RELEASE_MINOR_VERSION     7
42 #define SIUL2_ICU_IP_AR_RELEASE_REVISION_VERSION  0
43 #define SIUL2_ICU_IP_SW_MAJOR_VERSION             1
44 #define SIUL2_ICU_IP_SW_MINOR_VERSION             0
45 #define SIUL2_ICU_IP_SW_PATCH_VERSION             0
46 
47 /*==================================================================================================
48 *                                       FILE VERSION CHECKS
49 ==================================================================================================*/
50 /* Check if source file and ICU header file are of the same vendor */
51 #if (SIUL2_ICU_IP_VENDOR_ID != SIUL2_ICU_IP_TYPES_VENDOR_ID)
52     #error "Siul2_Icu_Ip.h and Siul2_Icu_Ip_Types.h have different vendor IDs"
53 #endif
54 /* Check if source file and ICU header file are of the same AutoSar version */
55 #if ((SIUL2_ICU_IP_AR_RELEASE_MAJOR_VERSION  != SIUL2_ICU_IP_TYPES_AR_RELEASE_MAJOR_VERSION) || \
56      (SIUL2_ICU_IP_AR_RELEASE_MINOR_VERSION  != SIUL2_ICU_IP_TYPES_AR_RELEASE_MINOR_VERSION) || \
57      (SIUL2_ICU_IP_AR_RELEASE_REVISION_VERSION   != SIUL2_ICU_IP_TYPES_AR_RELEASE_REVISION_VERSION))
58     #error "AutoSar Version Numbers of Siul2_Icu_Ip.h and Siul2_Icu_Ip_Types.h are different"
59 #endif
60 /* Check if source file and ICU header file are of the same Software version */
61 #if ((SIUL2_ICU_IP_SW_MAJOR_VERSION  != SIUL2_ICU_IP_TYPES_SW_MAJOR_VERSION) || \
62      (SIUL2_ICU_IP_SW_MINOR_VERSION  != SIUL2_ICU_IP_TYPES_SW_MINOR_VERSION) || \
63      (SIUL2_ICU_IP_SW_PATCH_VERSION  != SIUL2_ICU_IP_TYPES_SW_PATCH_VERSION))
64 #error "Software Version Numbers of Siul2_Icu_Ip.h and Siul2_Icu_Ip_Types.h are different"
65 #endif
66 
67 /* Check if source file and ICU header file are of the same vendor */
68 #if (SIUL2_ICU_IP_VENDOR_ID != SIUL2_ICU_IP_CFG_VENDOR_ID)
69     #error "Siul2_Icu_Ip.h and Siul2_Icu_Ip_Cfg.h have different vendor IDs"
70 #endif
71 /* Check if source file and ICU header file are of the same AutoSar version */
72 #if ((SIUL2_ICU_IP_AR_RELEASE_MAJOR_VERSION  != SIUL2_ICU_IP_CFG_AR_RELEASE_MAJOR_VERSION) || \
73      (SIUL2_ICU_IP_AR_RELEASE_MINOR_VERSION  != SIUL2_ICU_IP_CFG_AR_RELEASE_MINOR_VERSION) || \
74      (SIUL2_ICU_IP_AR_RELEASE_REVISION_VERSION   != SIUL2_ICU_IP_CFG_AR_RELEASE_REVISION_VERSION))
75     #error "AutoSar Version Numbers of Siul2_Icu_Ip.h and Siul2_Icu_Ip_Cfg.h are different"
76 #endif
77 /* Check if source file and ICU header file are of the same Software version */
78 #if ((SIUL2_ICU_IP_SW_MAJOR_VERSION  != SIUL2_ICU_IP_CFG_SW_MAJOR_VERSION) || \
79      (SIUL2_ICU_IP_SW_MINOR_VERSION  != SIUL2_ICU_IP_CFG_SW_MINOR_VERSION) || \
80      (SIUL2_ICU_IP_SW_PATCH_VERSION  != SIUL2_ICU_IP_CFG_SW_PATCH_VERSION))
81 #error "Software Version Numbers of Siul2_Icu_Ip.h and Siul2_Icu_Ip_Cfg.h are different"
82 #endif
83 
84 #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
85     #if (STD_ON == SIUL2_ICU_IP_USED)
86         #if (SIUL2_ICU_IP_ENABLE_USER_MODE_SUPPORT == STD_ON)
87         /* Check if header file and Reg_eSys.h file are of the same Autosar version */
88             #if ((SIUL2_ICU_IP_AR_RELEASE_MAJOR_VERSION != REG_ESYS_AR_RELEASE_MAJOR_VERSION) || \
89                 (SIUL2_ICU_IP_AR_RELEASE_MINOR_VERSION != REG_ESYS_AR_RELEASE_MINOR_VERSION))
90                 #error "AutoSar Version Numbers of Siul2_Icu_Ip.h and Reg_eSys.h are different"
91             #endif
92         #endif
93     #endif /* SIUL2_ICU_IP_USED */
94 #endif
95 
96 
97 /*==================================================================================================
98 *                                            CONSTANTS
99 ==================================================================================================*/
100 
101 /*==================================================================================================
102 *                                        DEFINES AND MACROS
103 ==================================================================================================*/
104 #if (STD_ON == SIUL2_ICU_IP_USED)
105 
106 #if (defined SIUL2_ICU_CONFIG_EXT)
107 #define ICU_START_SEC_CONFIG_DATA_UNSPECIFIED
108 #include "Icu_MemMap.h"
109 
110 /* Macro used to import SIUL2 PB generated configurations. */
111 SIUL2_ICU_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 SIUL2_Type * const Siul2_Icu_Ip_pBase[];
131 
132 #ifdef SIUL2_ICU_AE_AVAILABLE
133 /* Table of base addresses for SUIL2 instances. */
134 extern SIUL2_AE_Type * const Siul2_Ae_Icu_Ip_pBase[];
135 #endif
136 
137 #define ICU_STOP_SEC_CONST_UNSPECIFIED
138 #include "Icu_MemMap.h"
139 
140 /*==================================================================================================
141 *                                      FUNCTION PROTOTYPES
142 ==================================================================================================*/
143 #define ICU_START_SEC_CODE
144 #include "Icu_MemMap.h"
145 
146 #if (SIUL2_ICU_IP_DEINIT_API == STD_ON)
147 /**
148  * @brief      Driver function that de-initializes SIUL hardware channel.
149  * @details    This function:
150  *              - Restore to reset values SIUL2 registers used on init.
151  *
152  * @param[in]  instance - Instance number used
153  * @return     Siul2_Icu_Ip_StatusType - The status of DeInit
154  */
155 Siul2_Icu_Ip_StatusType Siul2_Icu_Ip_DeInit(uint8 instance);
156 #endif /* SIUL2_ICU_IP_DEINIT_API == STD_ON */
157 
158 /**
159  * @brief      Driver function that initializes SIUL hardware channel.
160  * @details    This function:
161  *              - Disables interrupt.
162  *              - Sets Interrupt filter enable register
163  *              - Sets Interrupt Filter Clock Prescaler Register
164  *              - Sets Activation Condition
165  *
166  * @param[in]  instance  Hardware instance of SIUL2 used.
167  * @param[in]  userConfig    Instance configuration.
168  *
169  * @return     Siul2_Icu_Ip_StatusType - The status of Init
170  */
171 Siul2_Icu_Ip_StatusType Siul2_Icu_Ip_Init(uint8 instance, const Siul2_Icu_Ip_ConfigType* userConfig);
172 
173 /**
174  * @brief
175  * @details   This function enables the requested activation condition(rising, falling or both
176  *            edges) for corresponding SIUL2 channels.
177  *
178  * @param[in] instance  Hardware instance of SIUL2 used.
179  * @param[in] hwChannel Hardware channel of SIUL2 used.
180  * @param[in] edge      Edge activation type used.
181  */
182 void Siul2_Icu_Ip_SetActivationCondition(uint8 instance, uint8 hwChannel, Siul2_Icu_Ip_EdgeType edge);
183 
184 #if (SIUL2_ICU_IP_GET_INPUT_STATE_API == STD_ON)
185 /**
186  * @brief ICU driver function that sets activation condition of SIUL2 channel.
187  *
188  * @param[in]      instance  Hardware instance of SIUL2 used.
189  * @param[in]      hwChannel Hardware channel of SIUL2 used.
190  * @return boolean Input state.
191  */
192 boolean Siul2_Icu_Ip_GetInputState(uint8 instance, uint8 hwChannel);
193 #endif  /* SIUL2_ICU_IP_GET_INPUT_STATE_API */
194 
195 /**
196  * @brief      ICU driver function that enables the interrupt of SIUL2 channel.
197  * @details    This function enables SIUL2 Channel Interrupt.
198  *
199  * @param[in]  instance  Hardware instance of SIUL2 used.
200  * @param[in]  hwChannel Hardware channel of SIUL2 used.
201  * @return     void
202  */
203 void Siul2_Icu_Ip_EnableInterrupt(uint8 instance, uint8 hwChannel);
204 
205 /**
206  * @brief      ICU driver function that disables the interrupt of SIUL2 channel.
207  * @details    This function disables SIUL2 Channel Interrupt.
208  *
209  * @param[in]  instance  Hardware instance of SIUL2 used.
210  * @param[in]  hwChannel Hardware channel of SIUL2 used.
211  * @return     void
212  */
213 void Siul2_Icu_Ip_DisableInterrupt(uint8 instance, uint8 hwChannel);
214 
215 #if (SIUL2_ICU_IP_SET_MODE_API == STD_ON)
216 /**
217  * @brief      Driver function sets SIUL2 hardware channel into SLEEP mode.
218  * @details    This function enables the interrupt if wakeup is enabled for corresponding SIUL2 channel.
219  *
220  * @param[in]  instance  Hardware instance of SIUL2 used.
221  * @param[in]  hwChannel Hardware channel of SIUL2 used.
222  * @return     void
223  */
224 void Siul2_Icu_Ip_SetSleepMode(uint8 instance, uint8 hwChannel);
225 
226 /**
227  * @brief      Driver function that sets SIUL2 hardware channel into NORMAL mode.
228  * @details    This function enables the interrupt if Notification is enabled for corresponding
229  *             SIUL2 channel.
230  *
231  * @param[in]  instance  Hardware instance of SIUL2 used.
232  * @param[in]  hwChannel Hardware channel of SIUL2 used.
233  * @return     void
234  */
235 void Siul2_Icu_Ip_SetNormalMode(uint8 instance, uint8 HwChannel);
236 #endif  /* SIUL2_ICU_IP_SET_MODE_API  */
237 
238 #if (SIUL2_ICU_IP_DUAL_CLOCK_MODE_API == STD_ON)
239 /**
240  * @brief      Icu driver function used to set the global prescaler of a SIUL2 module.
241  * @details    This function:
242  *             - Sets IFCPR register with a prescaler value
243  *
244  * @param[in]  instance  Hardware instance of SIUL2 used.
245  * @param[in]  mode Global prescaler for the SIUL2 module.
246  * @return     void
247  */
248 void Siul2_Icu_Ip_SetClockMode(uint8 instance, Siul2_Icu_Ip_ClockModeType mode);
249 #endif  /* SIUL2_ICU_IP_DUAL_CLOCK_MODE_API */
250 
251 /**
252  * @brief      Driver function Enable Notification for timestamp.
253  *
254  * @param[in]  instance  Hardware instance of FTM used.
255  * @param[in]  hwChannel Hardware channel of FTM used.
256  * @return     void
257  */
258 void Siul2_Icu_Ip_EnableNotification(uint8 instance, uint8 hwChannel);
259 
260 /**
261  * @brief      Driver function Disable Notification for timestamp.
262  *
263  * @param[in]  instance  Hardware instance of FTM used.
264  * @param[in]  hwChannel Hardware channel of FTM used.
265  * @return     void
266  */
267 void Siul2_Icu_Ip_DisableNotification(uint8 instance, uint8 hwChannel);
268 
269 #define ICU_STOP_SEC_CODE
270 #include "Icu_MemMap.h"
271 
272 #endif /* SIUL2_ICU_IP_USED */
273 
274 #ifdef __cplusplus
275 }
276 #endif
277 
278 /** @} */
279 
280 #endif  /* SIUL2_ICU_IP_H */
281