1 /* 2 * Copyright 2021-2024 NXP 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef EMIOS_ICU_IRQ_H 8 #define EMIOS_ICU_IRQ_H 9 10 /** 11 * @file Emios_Icu_Ip_Irq.h 12 * 13 * @addtogroup emios_icu_ip EMIOS 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 "OsIf.h" 28 #include "Emios_Icu_Ip_Cfg.h" 29 30 #if (STD_ON == EMIOS_ICU_IP_USED) 31 #if ((STD_ON == EMIOS_ICU_IP_SIGNALMEASUREMENT_USES_DMA_IPL) || (STD_ON == EMIOS_ICU_IP_TIMESTAMP_USES_DMA_IPL)) 32 #include "Dma_Ip.h" 33 #endif 34 #endif 35 /*================================================================================================== 36 * SOURCE FILE VERSION INFORMATION 37 ==================================================================================================*/ 38 #define EMIOS_ICU_IP_IRQ_VENDOR_ID 43 39 #define EMIOS_ICU_IP_IRQ_AR_RELEASE_MAJOR_VERSION 4 40 #define EMIOS_ICU_IP_IRQ_AR_RELEASE_MINOR_VERSION 7 41 #define EMIOS_ICU_IP_IRQ_AR_RELEASE_REVISION_VERSION 0 42 #define EMIOS_ICU_IP_IRQ_SW_MAJOR_VERSION 2 43 #define EMIOS_ICU_IP_IRQ_SW_MINOR_VERSION 0 44 #define EMIOS_ICU_IP_IRQ_SW_PATCH_VERSION 0 45 46 /*================================================================================================== 47 * FILE VERSION CHECKS 48 ==================================================================================================*/ 49 #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK 50 #if (STD_ON == EMIOS_ICU_IP_USED) 51 #if ((STD_ON == EMIOS_ICU_IP_SIGNALMEASUREMENT_USES_DMA_IPL) || (STD_ON == EMIOS_ICU_IP_TIMESTAMP_USES_DMA_IPL)) 52 /* Check if header file and Dma_Ip.h file are of the same Autosar version */ 53 #if ((EMIOS_ICU_IP_IRQ_AR_RELEASE_MAJOR_VERSION != DMA_IP_AR_RELEASE_MAJOR_VERSION) || \ 54 (EMIOS_ICU_IP_IRQ_AR_RELEASE_MINOR_VERSION != DMA_IP_AR_RELEASE_MINOR_VERSION)) 55 #error "AutoSar Version Numbers of Emios_Icu_Ip_Irq.h and Dma_Ip.h are different" 56 #endif 57 #endif 58 #endif 59 #endif 60 61 #if (EMIOS_ICU_IP_IRQ_VENDOR_ID != EMIOS_ICU_IP_CFG_VENDOR_ID) 62 #error "Emios_Icu_Ip_Irq.h and Emios_Icu_Ip_Cfg.h have different vendor ids" 63 #endif 64 65 /* Check if header file and Emios_Icu_Ip_Cfg.h file are of the same Autosar version */ 66 #if ((EMIOS_ICU_IP_IRQ_AR_RELEASE_MAJOR_VERSION != EMIOS_ICU_IP_CFG_AR_RELEASE_MAJOR_VERSION) || \ 67 (EMIOS_ICU_IP_IRQ_AR_RELEASE_MINOR_VERSION != EMIOS_ICU_IP_CFG_AR_RELEASE_MINOR_VERSION) || \ 68 (EMIOS_ICU_IP_IRQ_AR_RELEASE_REVISION_VERSION != EMIOS_ICU_IP_CFG_AR_RELEASE_REVISION_VERSION)) 69 #error "AutoSar Version Numbers of Emios_Icu_Ip_Irq.h and Emios_Icu_Ip_Cfg.h are different" 70 #endif 71 72 /* Check if header file and Emios_Icu_Ip_Cfg.h file are of the same Software version */ 73 #if ((EMIOS_ICU_IP_IRQ_SW_MAJOR_VERSION != EMIOS_ICU_IP_CFG_SW_MAJOR_VERSION) || \ 74 (EMIOS_ICU_IP_IRQ_SW_MINOR_VERSION != EMIOS_ICU_IP_CFG_SW_MINOR_VERSION) || \ 75 (EMIOS_ICU_IP_IRQ_SW_PATCH_VERSION != EMIOS_ICU_IP_CFG_SW_PATCH_VERSION)) 76 #error "Software Version Numbers of Emios_Icu_Ip_Irq.h and Emios_Icu_Ip_Cfg.h are different" 77 #endif 78 79 #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK 80 /* Check if this header file and OsIf.h file are of the same Autosar version */ 81 #if ((EMIOS_ICU_IP_IRQ_AR_RELEASE_MAJOR_VERSION != OSIF_AR_RELEASE_MAJOR_VERSION) || \ 82 (EMIOS_ICU_IP_IRQ_AR_RELEASE_MINOR_VERSION != OSIF_AR_RELEASE_MINOR_VERSION)) 83 #error "AutoSar Version Numbers of Emios_Icu_Ip_Irq.h and OsIf.h are different" 84 #endif 85 #endif 86 87 /*================================================================================================== 88 * CONSTANTS 89 ==================================================================================================*/ 90 91 /*================================================================================================== 92 * DEFINES AND MACROS 93 ==================================================================================================*/ 94 95 /*================================================================================================== 96 * GLOBAL VARIABLES 97 ==================================================================================================*/ 98 99 /*================================================================================================== 100 * ENUMS 101 ==================================================================================================*/ 102 103 /*================================================================================================== 104 * STRUCTURES AND OTHER TYPEDEFS 105 ==================================================================================================*/ 106 107 /*================================================================================================== 108 * GLOBAL VARIABLE DECLARATIONS 109 ==================================================================================================*/ 110 111 /*================================================================================================== 112 * FUNCTION PROTOTYPES 113 ==================================================================================================*/ 114 #if (STD_ON == EMIOS_ICU_IP_USED) 115 116 #define ICU_START_SEC_CODE 117 #include "Icu_MemMap.h" 118 119 /** 120 * @brief Icu driver function that handles the interrupt of eMIOS channel. 121 * @details This function: 122 * - Reads the status register 123 * - Clears the pending interrupt 124 * - Processes interrupt for corresponding eMIOS channel 125 * 126 * @param[in] channel - eMIOS hardware channel 127 * 128 * 129 */ 130 void Emios_Icu_Ip_IrqHandler(uint8 instance, uint8 channel); 131 132 #if (EMIOS_ICU_IP_SIGNAL_MEASUREMENT_API == STD_ON) 133 /** 134 * @brief Icu driver function that handles the signal measurement type interrupt. 135 * @details This service is called when an interrupt is recognized as a Signal Measurement 136 * type. There are two branch depending on the sub-function selected: Duty Cycle or 137 * OTHER. Duty Cycle requires an extra variable, because three values are required: 138 * two flanks for active signal time and another flank for the end of the pulse. For 139 * calculating high, low and period is enough with the HW registers. 140 * 141 * @param[in] instance - eMIOS module index 142 * @param[in] hwChannel - eMIOS Channel index 143 * @param[in] bOverflow Parameter that indicates the source of report is an overflow 144 */ 145 void Emios_Icu_Ip_SignalMeasurementHandler(const uint8 instance, const uint8 hwChannel, boolean bOverflow); 146 #endif /* EMIOS_ICU_IP_SIGNAL_MEASUREMENT_API == STD_ON */ 147 148 #if (STD_ON == EMIOS_ICU_IP_TIMESTAMP_USES_DMA_IPL) 149 /** 150 * @brief This function saves the value of timestamps in the internal buffer 151 * @details This function saves the value of timestamps in the internal buffer 152 * 153 * @param[in] Channel Logical number of the ICU channel 154 * 155 * @return void 156 * @pre Emios_Icu_Ip_Init must be called before. 157 * implements Emios_Icu_Ip_TimestampDmaProcessing 158 **/ 159 void Emios_Icu_Ip_TimestampDmaProcessing(uint8 instance, uint8 hwChannel); 160 #endif /* (STD_ON == EMIOS_ICU_IP_TIMESTAMP_USES_DMA_IPL) */ 161 162 #if (STD_ON == EMIOS_ICU_IP_SIGNALMEASUREMENT_USES_DMA_IPL) 163 /** 164 * @brief This function saves the value of signal measurement in the internal buffer 165 * @details This function saves the value of signal measurement in the internal buffer 166 * 167 * @param[in] Channel Logical number of the ICU channel 168 * @return void 169 * @pre Emios_Icu_Ip_Init must be called before. 170 * 171 * implements Emios_Icu_Ip_SignalMeasurementDmaProcessing 172 **/ 173 void Emios_Icu_Ip_SignalMeasurementDmaProcessing(uint8 instance, uint8 hwChannel); 174 #endif 175 176 #define ICU_STOP_SEC_CODE 177 #include "Icu_MemMap.h" 178 179 #endif /* EMIOS_ICU_IP_USED */ 180 181 #ifdef __cplusplus 182 } 183 #endif 184 185 /** @} */ 186 187 #endif /* EMIOS_ICU_IP_IRQ_H */ 188