1 /*
2 * Copyright 2020-2023 NXP
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 /**
8 * @file Lcu_Ip_Irq.c
9 *
10 * @version 3.0.0
11 *
12 * @brief AUTOSAR Mcl - Lcu Ip driver source file.
13 * @details
14 *
15 * @addtogroup LCU_IP_DRIVER LCU IP Driver
16 * @{
17 */
18
19 #ifdef __cplusplus
20 extern "C"{
21 #endif
22
23 #include "Lcu_Ip_Irq.h"
24 #if (STD_ON == LCU_IP_MULTICORE_IS_AVAILABLE)
25 #include "Lcu_Ip_Multicore.h"
26 #endif /* STD_ON == LCU_IP_MULTICORE_IS_AVAILABLE */
27
28
29 /*==================================================================================================
30 SOURCE FILE VERSION INFORMATION
31 ==================================================================================================*/
32 #define LCU_IP_IRQ_VENDOR_ID_C 43
33 #define LCU_IP_IRQ_AR_RELEASE_MAJOR_VERSION_C 4
34 #define LCU_IP_IRQ_AR_RELEASE_MINOR_VERSION_C 7
35 #define LCU_IP_IRQ_AR_RELEASE_REVISION_VERSION_C 0
36 #define LCU_IP_IRQ_SW_MAJOR_VERSION_C 3
37 #define LCU_IP_IRQ_SW_MINOR_VERSION_C 0
38 #define LCU_IP_IRQ_SW_PATCH_VERSION_C 0
39
40 /*==================================================================================================
41 FILE VERSION CHECKS
42 ==================================================================================================*/
43 /* Check if Lcu_Ip_Irq.c file and Lcu_Ip_Irq.h file are of the same vendor */
44 #if (LCU_IP_IRQ_VENDOR_ID_C != LCU_IP_IRQ_VENDOR_ID)
45 #error "Lcu_Ip_Irq.c and Lcu_Ip_Irq.h have different vendor ids"
46 #endif
47
48 /* Check if Lcu_Ip_Irq.c file and Lcu_Ip_Irq.h file are of the same Autosar version */
49 #if ((LCU_IP_IRQ_AR_RELEASE_MAJOR_VERSION_C != LCU_IP_IRQ_AR_RELEASE_MAJOR_VERSION) || \
50 (LCU_IP_IRQ_AR_RELEASE_MINOR_VERSION_C != LCU_IP_IRQ_AR_RELEASE_MINOR_VERSION) || \
51 (LCU_IP_IRQ_AR_RELEASE_REVISION_VERSION_C != LCU_IP_IRQ_AR_RELEASE_REVISION_VERSION) \
52 )
53 #error "AutoSar Version Numbers of Lcu_Ip_Irq.c and Lcu_Ip_Irq.h are different"
54 #endif
55
56 /* Check if Lcu_Ip_Irq.c file and Lcu_Ip_Irq.h file are of the same Software version */
57 #if ((LCU_IP_IRQ_SW_MAJOR_VERSION_C != LCU_IP_IRQ_SW_MAJOR_VERSION) || \
58 (LCU_IP_IRQ_SW_MINOR_VERSION_C != LCU_IP_IRQ_SW_MINOR_VERSION) || \
59 (LCU_IP_IRQ_SW_PATCH_VERSION_C != LCU_IP_IRQ_SW_PATCH_VERSION) \
60 )
61 #error "Software Version Numbers of Lcu_Ip_Irq.c and Lcu_Ip_Irq.h are different"
62 #endif
63
64 #if (STD_ON == LCU_IP_MULTICORE_IS_AVAILABLE)
65 /* Check if Lcu_Ip_Irq.c file and Lcu_Ip_Multicore.h file are of the same vendor */
66 #if (LCU_IP_IRQ_VENDOR_ID_C != LCU_IP_MULTICORE_VENDOR_ID)
67 #error "Lcu_Ip_Irq.c and Lcu_Ip_Multicore.h have different vendor ids"
68 #endif
69
70 /* Check if Lcu_Ip_Irq.c file and Lcu_Ip_Multicore.h file are of the same Autosar version */
71 #if ((LCU_IP_IRQ_AR_RELEASE_MAJOR_VERSION_C != LCU_IP_MULTICORE_AR_RELEASE_MAJOR_VERSION) || \
72 (LCU_IP_IRQ_AR_RELEASE_MINOR_VERSION_C != LCU_IP_MULTICORE_AR_RELEASE_MINOR_VERSION) || \
73 (LCU_IP_IRQ_AR_RELEASE_REVISION_VERSION_C != LCU_IP_MULTICORE_AR_RELEASE_REVISION_VERSION) \
74 )
75 #error "AutoSar Version Numbers of Lcu_Ip_Irq.c and Lcu_Ip_Multicore.h are different"
76 #endif
77
78 /* Check if Lcu_Ip_Irq.c file and Lcu_Ip_Multicore.h file are of the same Software version */
79 #if ((LCU_IP_IRQ_SW_MAJOR_VERSION_C != LCU_IP_MULTICORE_SW_MAJOR_VERSION) || \
80 (LCU_IP_IRQ_SW_MINOR_VERSION_C != LCU_IP_MULTICORE_SW_MINOR_VERSION) || \
81 (LCU_IP_IRQ_SW_PATCH_VERSION_C != LCU_IP_MULTICORE_SW_PATCH_VERSION) \
82 )
83 #error "Software Version Numbers of Lcu_Ip_Irq.c and Lcu_Ip_Multicore.h are different"
84 #endif
85 #endif /* STD_ON == LCU_IP_MULTICORE_IS_AVAILABLE */
86
87 #if (STD_ON == LCU_IP_IS_AVAILABLE)
88 #define MCL_START_SEC_CODE
89 #include "Mcl_MemMap.h"
90 /*==================================================================================================
91 * LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
92 ==================================================================================================*/
93
94 /*==================================================================================================
95 * LOCAL MACROS
96 ==================================================================================================*/
97
98 /*==================================================================================================
99 * LOCAL CONSTANTS
100 ==================================================================================================*/
101
102 /*==================================================================================================
103 * LOCAL VARIABLES
104 ==================================================================================================*/
105
106 /*==================================================================================================
107 * GLOBAL CONSTANTS
108 ==================================================================================================*/
109
110 /*==================================================================================================
111 * GLOBAL VARIABLES
112 ==================================================================================================*/
113
114 /*==================================================================================================
115 * LOCAL FUNCTION PROTOTYPES
116 ==================================================================================================*/
117 ISR(Lcu0_Ip_IRQHandler);
118
119 ISR(Lcu1_Ip_IRQHandler);
120
121 /*==================================================================================================
122 * LOCAL FUNCTIONS
123 ==================================================================================================*/
124
125 /*==================================================================================================
126 * GLOBAL FUNCTIONS
127 ==================================================================================================*/
128 /* LUT */
HwAcc_Lcu_GetLutIntEnable(const uint32 IntEn,uint8 HwOutput)129 static inline boolean HwAcc_Lcu_GetLutIntEnable(const uint32 IntEn, uint8 HwOutput)
130 {
131 boolean RetStatus = FALSE;
132 /* Get Lut Int Enable*/
133 if (IntEn & (LUT_INT_ENABLE_MASK << HwOutput))
134 {
135 RetStatus = TRUE;
136 }
137 return RetStatus;
138 }
139
HwAcc_Lcu_GetLutStatus(const uint32 Status,const uint8 HwOutput)140 static inline boolean HwAcc_Lcu_GetLutStatus(const uint32 Status, const uint8 HwOutput)
141 {
142 boolean RetStatus = FALSE;
143 /* Get Lut Status */
144 if (Status & (LUT_STS_EVENT_MASK << HwOutput))
145 {
146 RetStatus = TRUE;
147 }
148 return RetStatus;
149 }
150
HwAcc_Lcu_ClearLutStatus(const uint8 LcuId,const uint8 LcId,const uint8 HwOutput)151 static inline void HwAcc_Lcu_ClearLutStatus(const uint8 LcuId, const uint8 LcId, const uint8 HwOutput)
152 {
153 /* Clear Lut Status */
154 LCU_Type * PtBase = Lcu_Ip_paxBaseInst[LcuId];
155 PtBase->LC[LcId].STS = LCU_STS_LUT_STS((uint32)1U << HwOutput);
156 }
157
158
159 /* FORCE */
HwAcc_Lcu_GetForceIntEnable(const uint32 IntEn,const uint8 HwOutput)160 static inline boolean HwAcc_Lcu_GetForceIntEnable(const uint32 IntEn, const uint8 HwOutput)
161 {
162 boolean RetStatus = FALSE;
163 /* Get Force Int Enable */
164 if (IntEn & (FORCE_INT_ENABLE_MASK << HwOutput))
165 {
166 RetStatus = TRUE;
167 }
168 return RetStatus;
169 }
170
HwAcc_Lcu_GetForceStatus(const uint32 Status,const uint8 HwOutput)171 static inline boolean HwAcc_Lcu_GetForceStatus(const uint32 Status, const uint8 HwOutput)
172 {
173 boolean RetStatus = FALSE;
174 /* Get Force Status */
175 if (Status & (FORCE_STS_EVENT_MASK << HwOutput))
176 {
177 RetStatus = TRUE;
178 }
179 return RetStatus;
180 }
181
HwAcc_Lcu_ClearForceStatus(const uint8 LcuId,const uint8 HwOutput)182 static inline void HwAcc_Lcu_ClearForceStatus(const uint8 LcuId, const uint8 HwOutput)
183 {
184 /* Clear Force Status */
185 LCU_Type * PtBase = Lcu_Ip_paxBaseInst[LcuId];
186 PtBase->FORCESTS = LCU_FORCESTS_FORCESTS((uint32)1U << HwOutput);
187 }
188
Lcu_IrqHandler(const uint8 HwInstance)189 void Lcu_IrqHandler(const uint8 HwInstance)
190 {
191 uint32 RegLcIntEn = 0U;
192 uint32 RegLcStatus = 0U;
193 uint8 HwLogicCell = 0U;
194 uint8 HwOutput = 0U;
195 #if (STD_ON == LCU_IP_MULTICORE_IS_AVAILABLE)
196 Lcu_Ip_ReturnType ReturnValue;
197 #endif /* STD_ON == LCU_IP_MULTICORE_IS_AVAILABLE */
198
199 for (HwLogicCell = 0U; HwLogicCell < LCU_LC_COUNT; HwLogicCell++)
200 {
201 #if (STD_ON == LCU_IP_MULTICORE_IS_AVAILABLE)
202 ReturnValue = Lcu_Ip_ValidateCore(HwInstance, HwLogicCell);
203 if (ReturnValue == LCU_IP_STATUS_SUCCESS)
204 {
205 #endif /* STD_ON == LCU_IP_MULTICORE_IS_AVAILABLE */
206
207 RegLcIntEn = Lcu_Ip_paxBaseInst[HwInstance]->LC[HwLogicCell].INTDMAEN;
208 RegLcStatus = Lcu_Ip_paxBaseInst[HwInstance]->LC[HwLogicCell].STS;
209
210 if(RegLcStatus != 0U)
211 {
212 for(HwOutput = 0U; HwOutput < LCU_NUM_OUTPUT_PER_LC; HwOutput++)
213 {
214 /* If event flag was set by hardware */
215 if (HwAcc_Lcu_GetLutStatus(RegLcStatus, HwOutput))
216 {
217 /* If enable flag was set by user */
218 if (HwAcc_Lcu_GetLutIntEnable(RegLcIntEn, HwOutput))
219 {
220 /* Clear event flag */
221 HwAcc_Lcu_ClearLutStatus(HwInstance, HwLogicCell, HwOutput);
222 Lcu_Ip_IrqHandler(HwInstance, HwLogicCell, HwOutput, LCU_IP_LUT_EVENT);
223 }
224 }
225 /* If event flag was set by hardware */
226 if (HwAcc_Lcu_GetForceStatus(RegLcStatus, HwOutput))
227 {
228 /* If enable flag was set by user */
229 if (HwAcc_Lcu_GetForceIntEnable(RegLcIntEn, HwOutput))
230 {
231 /* Clear event flag */
232 HwAcc_Lcu_ClearForceStatus(HwInstance, HwOutput);
233 Lcu_Ip_IrqHandler(HwInstance, HwLogicCell, HwOutput, LCU_IP_FORCE_EVENT);
234 }
235 }
236 }
237 }
238 #if (STD_ON == LCU_IP_MULTICORE_IS_AVAILABLE)
239 }
240 else
241 {
242 /* Do Nothing */
243 }
244 #endif /* STD_ON == LCU_IP_MULTICORE_IS_AVAILABLE */
245 }
246 }
247
ISR(Lcu0_Ip_IRQHandler)248 ISR(Lcu0_Ip_IRQHandler)
249 {
250 /* Lcu 0 Irq Handler */
251 Lcu_IrqHandler(0U);
252 }
253
ISR(Lcu1_Ip_IRQHandler)254 ISR(Lcu1_Ip_IRQHandler)
255 {
256 /* Lcu 1 Irq Handler */
257 Lcu_IrqHandler(1U);
258 }
259
260 #define MCL_STOP_SEC_CODE
261 #include "Mcl_MemMap.h"
262
263 #endif /* #if (STD_ON == LCU_IP_IS_AVAILABLE) */
264
265 #ifdef __cplusplus
266 }
267 #endif
268
269 /** @} */
270