1 /* 2 * Copyright 2021-2024 NXP 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 /** 8 * @file Emios_Mcl_Ip.h 9 * 10 * @version 2.0.0 11 * 12 * @brief AUTOSAR Mcl - Emios Common driver header file. 13 * 14 * @addtogroup EMIOS_IP_DRIVER EMIOS IP Driver 15 * @{ 16 */ 17 18 #ifndef EMIOS_MCL_IP_H 19 #define EMIOS_MCL_IP_H 20 21 #ifdef __cplusplus 22 extern "C"{ 23 #endif 24 25 /*================================================================================================== 26 * INCLUDE FILES 27 * 1) system and project includes 28 * 2) needed interfaces from external units 29 * 3) internal and external interfaces from this unit 30 ==================================================================================================*/ 31 #include "OsIf.h" 32 33 #include "Std_Types.h" 34 #include "Emios_Mcl_Ip_Cfg.h" 35 36 #if (STD_ON == EMIOS_MCL_IP_DEV_ERROR_DETECT) 37 #include "Devassert.h" 38 #endif 39 40 /*================================================================================================== 41 * HEADER FILE VERSION INFORMATION 42 ==================================================================================================*/ 43 #define EMIOS_MCL_IP_VENDOR_ID 43 44 #define EMIOS_MCL_IP_AR_RELEASE_MAJOR_VERSION 4 45 #define EMIOS_MCL_IP_AR_RELEASE_MINOR_VERSION 7 46 #define EMIOS_MCL_IP_AR_RELEASE_REVISION_VERSION 0 47 #define EMIOS_MCL_IP_SW_MAJOR_VERSION 2 48 #define EMIOS_MCL_IP_SW_MINOR_VERSION 0 49 #define EMIOS_MCL_IP_SW_PATCH_VERSION 0 50 51 /*================================================================================================== 52 * FILE VERSION CHECKS 53 ==================================================================================================*/ 54 #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK 55 /* Check if header file and Std_Types.h are of the same AUTOSAR version */ 56 #if ((EMIOS_MCL_IP_AR_RELEASE_MAJOR_VERSION != STD_AR_RELEASE_MAJOR_VERSION) || \ 57 (EMIOS_MCL_IP_AR_RELEASE_MINOR_VERSION != STD_AR_RELEASE_MINOR_VERSION)) 58 #error "AUTOSAR Version Numbers of Emios_Mcl_Ip.h and Std_Types.h are different" 59 #endif 60 61 /* Check if header file and OsIf.h are of the same AUTOSAR version */ 62 #if ((EMIOS_MCL_IP_AR_RELEASE_MAJOR_VERSION != OSIF_AR_RELEASE_MAJOR_VERSION) || \ 63 (EMIOS_MCL_IP_AR_RELEASE_MINOR_VERSION != OSIF_AR_RELEASE_MINOR_VERSION)) 64 #error "AUTOSAR Version Numbers of Emios_Mcl_Ip.h and OsIf.h are different" 65 #endif 66 67 #if (STD_ON == EMIOS_MCL_IP_DEV_ERROR_DETECT) 68 /* Check if header file and Devassert.h are of the same AUTOSAR version */ 69 #if ((EMIOS_MCL_IP_AR_RELEASE_MAJOR_VERSION != DEVASSERT_AR_RELEASE_MAJOR_VERSION) || \ 70 (EMIOS_MCL_IP_AR_RELEASE_MINOR_VERSION != DEVASSERT_AR_RELEASE_MINOR_VERSION)) 71 #error "AUTOSAR Version Numbers of Emios_Mcl_Ip.h and Devassert.h are different" 72 #endif 73 #endif /*(STD_ON == EMIOS_MCL_IP_DEV_ERROR_DETECT)*/ 74 #endif /*DISABLE_MCAL_INTERMODULE_ASR_CHECK*/ 75 76 /* Check if header file and Emios_Mcl_Ip_Cfg header file are of the same vendor. */ 77 #if (EMIOS_MCL_IP_VENDOR_ID != EMIOS_MCL_IP_CFG_VENDOR_ID) 78 #error "Vendor IDs of Emios_Mcl_Ip.h and Emios_Mcl_Ip_Cfg.h are different." 79 #endif 80 81 /* Check if header file and Emios_Mcl_Ip_Cfg header file are of the same AUTOSAR version. */ 82 #if ((EMIOS_MCL_IP_AR_RELEASE_MAJOR_VERSION != EMIOS_MCL_IP_CFG_AR_RELEASE_MAJOR_VERSION) || \ 83 (EMIOS_MCL_IP_AR_RELEASE_MINOR_VERSION != EMIOS_MCL_IP_CFG_AR_RELEASE_MINOR_VERSION) || \ 84 (EMIOS_MCL_IP_AR_RELEASE_REVISION_VERSION != EMIOS_MCL_IP_CFG_AR_RELEASE_REVISION_VERSION)) 85 #error "AUTOSAR version numbers of Emios_Mcl_Ip.h and Emios_Mcl_Ip_Cfg.h are different." 86 #endif 87 88 /* Check if header file and Emios_Pwm_Ip_Cfg header file are of the same software version */ 89 #if ((EMIOS_MCL_IP_SW_MAJOR_VERSION != EMIOS_MCL_IP_CFG_SW_MAJOR_VERSION) || \ 90 (EMIOS_MCL_IP_SW_MINOR_VERSION != EMIOS_MCL_IP_CFG_SW_MINOR_VERSION) || \ 91 (EMIOS_MCL_IP_SW_PATCH_VERSION != EMIOS_MCL_IP_CFG_SW_PATCH_VERSION)) 92 #error "Software version numbers of Emios_Mcl_Ip.h and Emios_Mcl_Ip_Cfg.h are different." 93 #endif 94 95 /*================================================================================================== 96 * CONSTANTS 97 ==================================================================================================*/ 98 extern eMIOS_Type *const Emios_Ip_paxBase[eMIOS_INSTANCE_COUNT]; 99 100 /*================================================================================================== 101 * DEFINES AND MACROS 102 ==================================================================================================*/ 103 104 /*================================================================================================== 105 * ENUMS 106 ==================================================================================================*/ 107 108 /*================================================================================================== 109 * STRUCTURES AND OTHER TYPEDEFS 110 ==================================================================================================*/ 111 112 /*================================================================================================== 113 * GLOBAL VARIABLE DECLARATIONS 114 ==================================================================================================*/ 115 116 /*================================================================================================== 117 * FUNCTION PROTOTYPES 118 ==================================================================================================*/ 119 #define MCL_START_SEC_CODE 120 #include "Mcl_MemMap.h" 121 122 /** 123 * @brief The function shall enable the output update for the corresponding channel. 124 * 125 * @param[in] Instance Instance of EMIOS used. 126 * @param[in] ChannelMask EMIOS channel mask used to enable the output update. 127 * This mask should be on 32 bits. 128 * 0x00000001U <- First channel will be affected 129 * ^ ^ 130 * | | 131 * MSB LSB 132 * 0x00FFFFFFU <- All channels will be affected 133 * (EMIOS instance has only 24 channels) 134 */ 135 void Emios_Mcl_Ip_ComparatorTransferEnable(uint8 Instance, uint32 ChannelMask); 136 137 /** 138 * @brief The function shall disable the output update for the corresponding channel. 139 * 140 * @param[in] Instance Instance of EMIOS used. 141 * @param[in] ChannelMask EMIOS channel mask used to disable the output update. 142 * This mask should be on 32 bits. 143 * 0x00000001U <- First channel will be affected 144 * ^ ^ 145 * | | 146 * MSB LSB 147 * 0x00FFFFFFU <- All channels will be affected 148 * (EMIOS instance has only 24 channels) 149 */ 150 void Emios_Mcl_Ip_ComparatorTransferDisable(uint8 Instance, uint32 ChannelMask); 151 152 /** 153 * @brief This function shall reset all the register used to initialize a channel as a masterbus. The 154 * API should reset to POR values all registers used for configuring the common part of EMIOS IP. 155 * 156 * @param[in] Instance Instance of EMIOS used. 157 * @return Emios_Ip_CommonStatusType 158 */ 159 Emios_Ip_CommonStatusType Emios_Mcl_Ip_Deinit(uint8 Instance); 160 161 /** 162 * @brief The API should configure the common part of EMIOS IP to be used by any driver implementation 163 * with EMIOS support (ex: ICU, PWM, GPT, OCU) 164 * 165 * @param[in] Instance Instance of EMIOS used. 166 * @param[in] ConfigPtr EMIOS instance specific configuration. 167 * @return Emios_Ip_CommonStatusType 168 */ 169 Emios_Ip_CommonStatusType Emios_Mcl_Ip_Init(uint8 Instance, const Emios_Mcl_Ip_ConfigType *const ConfigPtr); 170 171 /** 172 * @brief Allow the user to specify the number of bus reload events skipped. 173 * 174 * @details Reload Signal Output Delay Interval 175 * Specifies the delay interval, in counter bus reload events, between each assertion of AS1-BS1 reload in 176 * MC and MCB modes. 177 * 00000b - Every event 178 * 00001b - Every 2nd event 179 * 00010b - Every 3rd event 180 * . . . 181 * 11111b - Every 32nd event 182 * 183 * @param HwInstance Instance of EMIOS used. 184 * @param HwChannel EMIOS hardware channel used. 185 * @param Interval 186 */ 187 void Emios_Mcl_Ip_SetReloadInterval(uint8 HwInstance, uint8 HwChannel, uint8 Interval); 188 189 /** 190 * @brief Change the period on active/intialized EMIOS counter(master) bus. 191 * 192 * @param HwInstance Instance of EMIOS used. 193 * @param HwChannel EMIOS hardware channel used. 194 * 195 * @return boolean Status of operation. 196 */ 197 boolean Emios_Mcl_Ip_ValidateChannel(uint8 HwInstance, uint8 HwChannel); 198 199 /** 200 * @brief 201 * 202 * @param HwInstance Instance of EMIOS used. 203 * @param HwChannel EMIOS hardware channel used. 204 * @param Period Period 205 * @return Emios_Ip_CommonStatusType 206 */ 207 Emios_Ip_CommonStatusType Emios_Mcl_Ip_SetCounterBusPeriod(uint8 HwInstance, uint8 HwChannel, uint32 Period); 208 209 /** 210 * @brief Get period of counter bus channels 211 * 212 * @param Instance Instance of EMIOS used. 213 * @param Channel EMIOS hardware channel used. 214 * @return The period value of Counter Bus channels 215 */ 216 #if (STD_ON == EMIOS_MCL_IP_24BITS_TIMER_WIDTH) 217 uint32 Emios_Mcl_Ip_GetCounterBusPeriod(uint8 Instance, uint8 Channel); 218 #else 219 uint16 Emios_Mcl_Ip_GetCounterBusPeriod(uint8 Instance, uint8 Channel); 220 #endif 221 222 #if (STD_ON == EMIOS_IP_MULTICORE_IS_AVAILABLE) 223 /** 224 * @brief 225 * 226 * @param HwInstance 227 * @return boolean 228 */ 229 boolean Emios_Mcl_Ip_ValidateMultiCoreInit(uint8 HwInstance); 230 #endif /* STD_ON == EMIOS_IP_MULTICORE_IS_AVAILABLE */ 231 232 /** 233 * @brief Configure Global Timebase 234 * @details This function enables or disables the GTBE bit of the EMIOS->MCR register of an addressed eMIOS instance. 235 * 236 * @param[in] Instance Instance of EMIOS used. 237 * @param[in] Value STD_ON to set bit and STD_OFF to reset bit. 238 * @return void 239 */ 240 void Emios_Mcl_Ip_ConfigureGlobalTimebase(uint8 Instance, uint8 Value); 241 242 /** 243 * @brief Set Clock Mode 244 * @details This function set the clock mode. 245 * 246 * @param[in] Instance Instance of EMIOS used. 247 * @param[in] ConfigPtr Configuration pointer 248 * @param[in] Prescaler Clock mode 249 * @return void 250 */ 251 void Emios_Mcl_Ip_SetClockMode(uint8 Instance, const Emios_Mcl_Ip_ConfigType* const ConfigPtr, Emios_Ip_SelectPrescalerType Prescaler); 252 253 #define MCL_STOP_SEC_CODE 254 #include "Mcl_MemMap.h" 255 256 #ifdef __cplusplus 257 } 258 #endif 259 260 /** @} */ 261 262 #endif /* EMIOS_MCL_IP_H */ 263