1 /*
2  * Copyright 2020-2023 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 /* Prevention from multiple including the same header */
8 #ifndef LCU_IP_TYPES_H_
9 #define LCU_IP_TYPES_H_
10 
11 /**
12 *   @file    Lcu_Ip_Types.h
13 *
14 *   @version 3.0.0
15 *
16 *   @brief   AUTOSAR Mcl - Lcu Ip driver header file.
17 *   @details
18 *
19 *   @addtogroup LCU_IP_DRIVER LCU IP Driver
20 *   @{
21 */
22 
23 #ifdef __cplusplus
24 extern "C"{
25 #endif
26 
27 /*==================================================================================================
28 *                                          INCLUDE FILES
29 * 1) system and project includes
30 * 2) needed interfaces from external units
31 * 3) internal and external interfaces from this unit
32 ==================================================================================================*/
33 #include "Lcu_Ip_Cfg_Defines.h"
34 
35 #if (STD_ON == LCU_IP_IS_AVAILABLE)
36 
37 #include "Lcu_Ip_Regs.h"
38 #include "Lcu_Ip_Features.h"
39 
40 #endif
41 
42 /*==================================================================================================
43                                SOURCE FILE VERSION INFORMATION
44 ==================================================================================================*/
45 #define LCU_IP_TYPES_VENDOR_ID                       43
46 #define LCU_IP_TYPES_AR_RELEASE_MAJOR_VERSION        4
47 #define LCU_IP_TYPES_AR_RELEASE_MINOR_VERSION        7
48 #define LCU_IP_TYPES_AR_RELEASE_REVISION_VERSION     0
49 #define LCU_IP_TYPES_SW_MAJOR_VERSION                3
50 #define LCU_IP_TYPES_SW_MINOR_VERSION                0
51 #define LCU_IP_TYPES_SW_PATCH_VERSION                0
52 
53 /*==================================================================================================
54                                       FILE VERSION CHECKS
55 ==================================================================================================*/
56 /* Check if header file and Lcu_Ip_Cfg_Defines.h file are of the same vendor */
57 #if (LCU_IP_TYPES_VENDOR_ID != LCU_IP_CFG_DEFINES_VENDOR_ID)
58     #error "Lcu_Ip_Types.h and Lcu_Ip_Cfg_Defines.h have different vendor ids"
59 #endif
60 
61 /* Check if header file and Lcu_Ip_Cfg_Defines.h file are of the same Autosar version */
62 #if ((LCU_IP_TYPES_AR_RELEASE_MAJOR_VERSION != LCU_IP_CFG_DEFINES_AR_RELEASE_MAJOR_VERSION) || \
63      (LCU_IP_TYPES_AR_RELEASE_MINOR_VERSION != LCU_IP_CFG_DEFINES_AR_RELEASE_MINOR_VERSION) || \
64      (LCU_IP_TYPES_AR_RELEASE_REVISION_VERSION != LCU_IP_CFG_DEFINES_AR_RELEASE_REVISION_VERSION) \
65     )
66     #error "AutoSar Version Numbers of Lcu_Ip_Types.h and Lcu_Ip_Cfg_Defines.h are different"
67 #endif
68 
69 /* Check if header file and Lcu_Ip_Cfg_Defines.h file are of the same Software version */
70 #if ((LCU_IP_TYPES_SW_MAJOR_VERSION != LCU_IP_CFG_DEFINES_SW_MAJOR_VERSION) || \
71      (LCU_IP_TYPES_SW_MINOR_VERSION != LCU_IP_CFG_DEFINES_SW_MINOR_VERSION) || \
72      (LCU_IP_TYPES_SW_PATCH_VERSION != LCU_IP_CFG_DEFINES_SW_PATCH_VERSION) \
73     )
74     #error "Software Version Numbers of Lcu_Ip_Types.h and Lcu_Ip_Cfg_Defines.h are different"
75 #endif
76 
77 #if (STD_ON == LCU_IP_IS_AVAILABLE)
78 
79 /* Check if header file and Lcu_Ip_Regs.h file are of the same vendor */
80 #if (LCU_IP_TYPES_VENDOR_ID != LCU_IP_REGS_VENDOR_ID)
81     #error "Lcu_Ip_Types.h and Lcu_Ip_Regs.h have different vendor ids"
82 #endif
83 
84 /* Check if header file and Lcu_Ip_Regs.h file are of the same Autosar version */
85 #if ((LCU_IP_TYPES_AR_RELEASE_MAJOR_VERSION != LCU_IP_REGS_AR_RELEASE_MAJOR_VERSION) || \
86      (LCU_IP_TYPES_AR_RELEASE_MINOR_VERSION != LCU_IP_REGS_AR_RELEASE_MINOR_VERSION) || \
87      (LCU_IP_TYPES_AR_RELEASE_REVISION_VERSION != LCU_IP_REGS_AR_RELEASE_REVISION_VERSION) \
88     )
89     #error "AutoSar Version Numbers of Lcu_Ip_Types.h and Lcu_Ip_Regs.h are different"
90 #endif
91 
92 /* Check if header file and Lcu_Ip_Regs.h file are of the same Software version */
93 #if ((LCU_IP_TYPES_SW_MAJOR_VERSION != LCU_IP_REGS_SW_MAJOR_VERSION) || \
94      (LCU_IP_TYPES_SW_MINOR_VERSION != LCU_IP_REGS_SW_MINOR_VERSION) || \
95      (LCU_IP_TYPES_SW_PATCH_VERSION != LCU_IP_REGS_SW_PATCH_VERSION) \
96     )
97     #error "Software Version Numbers of Lcu_Ip_Types.h and Lcu_Ip_Regs.h are different"
98 #endif
99 
100 /* Check if header file and Lcu_Ip_Features.h file are of the same vendor */
101 #if (LCU_IP_TYPES_VENDOR_ID != LCU_IP_FEATURES_VENDOR_ID)
102     #error "Lcu_Ip_Types.h and Lcu_Ip_Features.h have different vendor ids"
103 #endif
104 
105 /* Check if header file and Lcu_Ip_Features.h file are of the same Autosar version */
106 #if ((LCU_IP_TYPES_AR_RELEASE_MAJOR_VERSION != LCU_IP_FEATURES_AR_RELEASE_MAJOR_VERSION) || \
107      (LCU_IP_TYPES_AR_RELEASE_MINOR_VERSION != LCU_IP_FEATURES_AR_RELEASE_MINOR_VERSION) || \
108      (LCU_IP_TYPES_AR_RELEASE_REVISION_VERSION != LCU_IP_FEATURES_AR_RELEASE_REVISION_VERSION) \
109     )
110     #error "AutoSar Version Numbers of Lcu_Ip_Types.h and Lcu_Ip_Features.h are different"
111 #endif
112 
113 /* Check if header file and Lcu_Ip_Features.h file are of the same Software version */
114 #if ((LCU_IP_TYPES_SW_MAJOR_VERSION != LCU_IP_FEATURES_SW_MAJOR_VERSION) || \
115      (LCU_IP_TYPES_SW_MINOR_VERSION != LCU_IP_FEATURES_SW_MINOR_VERSION) || \
116      (LCU_IP_TYPES_SW_PATCH_VERSION != LCU_IP_FEATURES_SW_PATCH_VERSION) \
117     )
118     #error "Software Version Numbers of Lcu_Ip_Types.h and Lcu_Ip_Features.h are different"
119 #endif
120 
121 /*==================================================================================================
122 *                                            CONSTANTS
123 ==================================================================================================*/
124 
125 /*==================================================================================================
126 *                                       DEFINES AND MACROS
127 ==================================================================================================*/
128 
129 /*==================================================================================================
130 *                                              ENUMS
131 ==================================================================================================*/
132 /**
133  * @brief This type contains the LCU IP Event.
134  * @details The Event Type give information for interrupt event is LUT or FORCE.
135  *
136  * */
137 typedef enum
138 {
139     LCU_IP_LUT_EVENT        = 0U,
140     LCU_IP_FORCE_EVENT      = 1U
141 }Lcu_Ip_Event;
142 
143 /**
144  * @brief This type contains the LCU IP Return Type.
145  * @details The Return Type give information for the execution of interfaces.
146  *
147  * */
148 typedef enum{
149     LCU_IP_STATUS_SUCCESS      = E_OK,
150     LCU_IP_STATUS_ERROR        = E_NOT_OK,
151     LCU_IP_STATUS_PROTECTED    = 2U,
152 #if (STD_ON == LCU_IP_MULTICORE_IS_AVAILABLE)
153     LCU_IP_STATUS_WRONG_CORE   = 3U,
154 #endif /* STD_ON == LCU_IP_MULTICORE_IS_AVAILABLE */
155 }Lcu_Ip_ReturnType;
156 
157 /*==================================================================================================
158 *                                  STRUCTURES AND OTHER TYPEDEFS
159 ==================================================================================================*/
160 /**
161  * @brief This type contains the LCU IP Callback interface.
162  * @details The Callback is defined by the user and installed by the driver in the corresponding IRQ.
163  *
164  * @return void
165  * */
166 typedef void(*Lcu_Ip_Callback) (Lcu_Ip_Event Event);
167 
168 /* LCU Ip Logic Input Identification */
169 typedef struct{
170     uint8 HwInstId;                              /**< @brief LCU hardware instance number. */
171     uint8 HwLcInputId;                           /**< @brief This information was created by combine hardware logic cell and hardware input number */
172 }Lcu_Ip_LogicInputIdType;
173 
174 /* LCU Ip Logic Output Identification */
175 typedef struct{
176     uint8 HwInstId;                              /**< @brief LCU hardware instance number. */
177     uint8 HwLcOutputId;                          /**< @brief This information was created by combine hardware logic cell and hardware output number. */
178     Lcu_Ip_Callback IntCallback;                 /**< @brief The channel callback is installed in
179                                                       the interrupt and is called automatically
180                                                       from the interrupt every time it is triggered.*/
181 }Lcu_Ip_LogicOutputIdType;
182 
183 /* LCU IP LC Input Configuration */
184 typedef struct{
185     uint8 MuxSel;                                /**< @brief [MUXSEL] Input MUX Select. */
186     boolean SwSynMode;                           /**< @brief [SW_MODE] Specifies the software sync mode for the inputs to this LC.When Software Override is enabled (SWEN),these bits control whether Software Override Value (SWVALUE) changes occur immediately or on the rising edge of the selected sync pulse */
187     uint8 SwValue;                               /**< @brief [SWVALUE] Software override input value */
188 }Lcu_Ip_LogicInputConfigType;
189 
190 /* LCU IP LC Output Configuration */
191 typedef struct{
192     boolean EnDebugMode;                             /**< @brief [DBGEN] Enables outputs to continue operation in Debug mode */
193     uint16 LutControl;                               /**< @brief [LUTCTRL] LUT control */
194     uint16 LutRiseFilt;                              /**< @brief [LUT_RISE_FILT] LUT Rise Filter */
195     uint16 LutFallFilt;                              /**< @brief [LUT_FALL_FILT] LUT Fall Filter */
196     boolean EnLutDma;                                /**< @brief [LUT_DMA_EN] Enables the generation of a DMA request when an LUT event occurs */
197     boolean EnForceDma;                              /**< @brief [FORCE_DMA_EN] Enables the generation of a DMA request when a force event occurs */
198     boolean EnLutInt;                                /**< @brief [LUT_INT_EN] Enables the generation of an interrupt request when an LUT event */
199     boolean EnForceInt;                              /**< @brief [FORCE_INT_EN] Enables the generation of an interrupt request when a force event occurs */
200     boolean InvertOutput;                            /**< @brief [OUTPOL] Set Output Polarity: invert or not. */
201     uint8 ForceSignalSel;                            /**< @brief [FORCE_SENSE] Select Force signal */
202     uint8 ClearForceMode;                            /**< @brief [FORCE_MODE] Force Clearing Mode */
203     uint8 ForceSyncSel;                              /**< @brief [SYNC_SEL] The Force Sync Select Parameter specifies which sync input to use for this output */
204 }Lcu_Ip_LogicOutputConfigType;
205 
206 
207 /* Logic Input Configuration  */
208 typedef struct{
209     Lcu_Ip_LogicInputIdType xLogicInputId;           /**< @brief The Logic LC ID contains configuration information and identification */
210     const Lcu_Ip_LogicInputConfigType * pxLcInputConfig;   /**< @brief The Logic Input configuration */
211 }Lcu_Ip_LogicInputType;
212 
213 /* Logic Output Configuration */
214 typedef struct{
215     Lcu_Ip_LogicOutputIdType xLogicOutputId;         /**< @brief The Logic LC ID contains configuration information and identification */
216     const Lcu_Ip_LogicOutputConfigType * pxLcOutputConfig; /**< @brief The Logic Cell input configuration for all inputs */
217 }Lcu_Ip_LogicOutputType;
218 
219 /* Logic Cell Configuration */
220 typedef struct{
221     uint8 HwLcId;                                /**< @brief LCU hardware Logic cell number. */
222     uint8 ForceFilter;                           /**< @brief [FORCE_FILT] Specifies the count, in clock cycles, that a force input must remain at a given logic state before the filtered force input switches state */
223     uint8 ForcePolarity;                         /**< @brief [FORCE_POL] Specifies the polarity of the force input */
224     uint8 CombEn;                                /**< @brief [COMB_EN] Combinational Force Path (CFP) Enable */
225     uint8 SwSyncSel;                             /**< @brief [SW_SYNC_SEL] Selects which sync input to use for software synced mode */
226 #if (STD_ON == LCU_IP_MULTICORE_IS_AVAILABLE)
227     uint8 CoreRef;                               /**< @brief Core reference */
228 #endif /* STD_ON == LCU_IP_MULTICORE_IS_AVAILABLE */
229 }Lcu_Ip_LogicCellType;
230 
231 /* Logic Instance Configuration */
232 typedef struct{
233     uint8 HwInstId;                                                  /**< @brief LCU hardware instance number. */
234     uint8 NumLogicCellConfig;                                        /**< @brief Number logic cell configuration */
235     const Lcu_Ip_LogicCellType * const * ppxLogicCellConfigArray;    /**< @brief Logic Cell configuration array */
236     uint8 OperationMode;                                             /**< @brief LCU operation mode: Interrupt/Polling Mode. */
237 }Lcu_Ip_LogicInstanceType;
238 
239 typedef struct{
240     Lcu_Ip_Callback Callback;
241 }Lcu_Ip_HwOutputStateType;
242 
243 /* LCU initialization */
244 typedef struct{
245     Lcu_Ip_HwOutputStateType ** ppxHwOutputStateArray;
246     const Lcu_Ip_LogicInstanceType * const * ppxLogicInstanceConfigArray;
247     const Lcu_Ip_LogicOutputConfigType * const pxLogicOutputResetConfigArray;
248     const Lcu_Ip_LogicInputConfigType * const pxLogicInputResetConfigArray;
249     const Lcu_Ip_LogicOutputType * const * ppxLogicOutputConfigArray;
250     const Lcu_Ip_LogicInputType * const * ppxLogicInputConfigArray;
251 #if (STD_ON == LCU_IP_MULTICORE_IS_AVAILABLE)
252     uint8 LcuCoreRef;
253 #endif /* STD_ON == LCU_IP_MULTICORE_IS_AVAILABLE */
254 }Lcu_Ip_InitType;
255 
256 /*==================================================================================================
257 *                                  GLOBAL VARIABLE DECLARATIONS
258 ==================================================================================================*/
259 
260 /*==================================================================================================
261 *                                       FUNCTION PROTOTYPES
262 ==================================================================================================*/
263 
264 #endif /* #ifdef LCU_IP_IS_AVAILABLE */
265 
266 #ifdef __cplusplus
267 }
268 #endif
269 
270 /** @} */
271 
272 #endif  /* #ifndef LCU_IP_TYPES_H_ */
273