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