1 /* 2 * Copyright 2020-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 3 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 #define ICU_STOP_SEC_CONST_UNSPECIFIED 133 #include "Icu_MemMap.h" 134 135 /*================================================================================================== 136 * FUNCTION PROTOTYPES 137 ==================================================================================================*/ 138 #define ICU_START_SEC_CODE 139 #include "Icu_MemMap.h" 140 141 #if (SIUL2_ICU_IP_DEINIT_API == STD_ON) 142 /** 143 * @brief Driver function that de-initializes SIUL hardware channel. 144 * @details This function: 145 * - Restore to reset values SIUL2 registers used on init. 146 * 147 * @param[in] instance - Instance number used 148 * @return Siul2_Icu_Ip_StatusType - The status of DeInit 149 */ 150 Siul2_Icu_Ip_StatusType Siul2_Icu_Ip_DeInit(uint8 instance); 151 #endif /* SIUL2_ICU_IP_DEINIT_API == STD_ON */ 152 153 /** 154 * @brief Driver function that initializes SIUL hardware channel. 155 * @details This function: 156 * - Disables interrupt. 157 * - Sets Interrupt filter enable register 158 * - Sets Interrupt Filter Clock Prescaler Register 159 * - Sets Activation Condition 160 * 161 * @param[in] instance Hardware instance of SIUL2 used. 162 * @param[in] userConfig Instance configuration. 163 * 164 * @return Siul2_Icu_Ip_StatusType - The status of Init 165 */ 166 Siul2_Icu_Ip_StatusType Siul2_Icu_Ip_Init(uint8 instance, const Siul2_Icu_Ip_ConfigType* userConfig); 167 168 /** 169 * @brief 170 * @details This function enables the requested activation condition(rising, falling or both 171 * edges) for corresponding SIUL2 channels. 172 * 173 * @param[in] instance Hardware instance of SIUL2 used. 174 * @param[in] hwChannel Hardware channel of SIUL2 used. 175 * @param[in] edge Edge activation type used. 176 */ 177 void Siul2_Icu_Ip_SetActivationCondition(uint8 instance, uint8 hwChannel, Siul2_Icu_Ip_EdgeType edge); 178 179 #if (SIUL2_ICU_IP_GET_INPUT_STATE_API == STD_ON) 180 /** 181 * @brief ICU driver function that sets activation condition of SIUL2 channel. 182 * 183 * @param[in] instance Hardware instance of SIUL2 used. 184 * @param[in] hwChannel Hardware channel of SIUL2 used. 185 * @return boolean Input state. 186 */ 187 boolean Siul2_Icu_Ip_GetInputState(uint8 instance, uint8 hwChannel); 188 #endif /* SIUL2_ICU_IP_GET_INPUT_STATE_API */ 189 190 /** 191 * @brief ICU driver function that enables the interrupt of SIUL2 channel. 192 * @details This function enables SIUL2 Channel Interrupt. 193 * 194 * @param[in] instance Hardware instance of SIUL2 used. 195 * @param[in] hwChannel Hardware channel of SIUL2 used. 196 * @return void 197 */ 198 void Siul2_Icu_Ip_EnableInterrupt(uint8 instance, uint8 hwChannel); 199 200 /** 201 * @brief ICU driver function that disables the interrupt of SIUL2 channel. 202 * @details This function disables SIUL2 Channel Interrupt. 203 * 204 * @param[in] instance Hardware instance of SIUL2 used. 205 * @param[in] hwChannel Hardware channel of SIUL2 used. 206 * @return void 207 */ 208 void Siul2_Icu_Ip_DisableInterrupt(uint8 instance, uint8 hwChannel); 209 210 #if (SIUL2_ICU_IP_SET_MODE_API == STD_ON) 211 /** 212 * @brief Driver function sets SIUL2 hardware channel into SLEEP mode. 213 * @details This function enables the interrupt if wakeup is enabled for corresponding SIUL2 channel. 214 * 215 * @param[in] instance Hardware instance of SIUL2 used. 216 * @param[in] hwChannel Hardware channel of SIUL2 used. 217 * @return void 218 */ 219 void Siul2_Icu_Ip_SetSleepMode(uint8 instance, uint8 hwChannel); 220 221 /** 222 * @brief Driver function that sets SIUL2 hardware channel into NORMAL mode. 223 * @details This function enables the interrupt if Notification is enabled for corresponding 224 * SIUL2 channel. 225 * 226 * @param[in] instance Hardware instance of SIUL2 used. 227 * @param[in] hwChannel Hardware channel of SIUL2 used. 228 * @return void 229 */ 230 void Siul2_Icu_Ip_SetNormalMode(uint8 instance, uint8 HwChannel); 231 #endif /* SIUL2_ICU_IP_SET_MODE_API */ 232 233 #if (SIUL2_ICU_IP_DUAL_CLOCK_MODE_API == STD_ON) 234 /** 235 * @brief Icu driver function used to set the global prescaler of a SIUL2 module. 236 * @details This function: 237 * - Sets IFCPR register with a prescaler value 238 * 239 * @param[in] instance Hardware instance of SIUL2 used. 240 * @param[in] mode Global prescaler for the SIUL2 module. 241 * @return void 242 */ 243 void Siul2_Icu_Ip_SetClockMode(uint8 instance, Siul2_Icu_Ip_ClockModeType mode); 244 #endif /* SIUL2_ICU_IP_DUAL_CLOCK_MODE_API */ 245 246 /** 247 * @brief Driver function Enable Notification for timestamp. 248 * 249 * @param[in] instance Hardware instance of FTM used. 250 * @param[in] hwChannel Hardware channel of FTM used. 251 * @return void 252 */ 253 void Siul2_Icu_Ip_EnableNotification(uint8 instance, uint8 hwChannel); 254 255 /** 256 * @brief Driver function Disable Notification for timestamp. 257 * 258 * @param[in] instance Hardware instance of FTM used. 259 * @param[in] hwChannel Hardware channel of FTM used. 260 * @return void 261 */ 262 void Siul2_Icu_Ip_DisableNotification(uint8 instance, uint8 hwChannel); 263 264 #define ICU_STOP_SEC_CODE 265 #include "Icu_MemMap.h" 266 267 #endif /* SIUL2_ICU_IP_USED */ 268 269 #ifdef __cplusplus 270 } 271 #endif 272 273 /** @} */ 274 275 #endif /* SIUL2_ICU_IP_H */ 276