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