1 /*
2 * Copyright 2021-2023 NXP
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7
8 /**
9 * @file Siul2_Dio_Ip.c
10 *
11 * @addtogroup DIO_IPL
12 * @{
13 */
14
15 #ifdef __cplusplus
16 extern "C"{
17 #endif
18
19
20 /*==================================================================================================
21 * INCLUDE FILES
22 * 1) system and project includes
23 * 2) needed interfaces from external units
24 * 3) internal and external interfaces from this unit
25 ==================================================================================================*/
26 #include "Siul2_Dio_Ip.h"
27 #include "SchM_Dio.h"
28 #if (STD_ON == SIUL2_DIO_IP_DEV_ERROR_DETECT)
29 #include "Devassert.h"
30 #endif /* (STD_ON == SIUL2_DIO_IP_DEV_ERROR_DETECT) */
31 #if (defined(MCAL_ENABLE_USER_MODE_SUPPORT) && defined(DIO_ENABLE_USER_MODE_SUPPORT) && (STD_ON == DIO_ENABLE_USER_MODE_SUPPORT))
32 #include "OsIf_Internal.h"
33 #endif /* (defined(MCAL_ENABLE_USER_MODE_SUPPORT) && defined(DIO_ENABLE_USER_MODE_SUPPORT) && (STD_ON == DIO_ENABLE_USER_MODE_SUPPORT)) */
34
35 /*==================================================================================================
36 * SOURCE FILE VERSION INFORMATION
37 ==================================================================================================*/
38 /*
39 * @brief Parameters that shall be published within the driver header file and also in the
40 * module's description file
41 */
42 #define SIUL2_DIO_IP_VENDOR_ID_C 43
43 #define SIUL2_DIO_IP_AR_RELEASE_MAJOR_VERSION_C 4
44 #define SIUL2_DIO_IP_AR_RELEASE_MINOR_VERSION_C 7
45 #define SIUL2_DIO_IP_AR_RELEASE_REVISION_VERSION_C 0
46 #define SIUL2_DIO_IP_SW_MAJOR_VERSION_C 1
47 #define SIUL2_DIO_IP_SW_MINOR_VERSION_C 0
48 #define SIUL2_DIO_IP_SW_PATCH_VERSION_C 0
49
50 /*==================================================================================================
51 * FILE VERSION CHECKS
52 ==================================================================================================*/
53 /* Check if Siul2_Dio_Ip source file and Siul2_Dio_Ip header file are of the same vendor */
54 #if (SIUL2_DIO_IP_VENDOR_ID_C != SIUL2_DIO_IP_VENDOR_ID_H)
55 #error "Siul2_Dio_Ip.c and Siul2_Dio_Ip.h have different vendor ids"
56 #endif
57
58 /* Check if Siul2_Dio_Ip source file and Siul2_Dio_Ip header file are of the same Autosar version */
59 #if ((SIUL2_DIO_IP_AR_RELEASE_MAJOR_VERSION_C != SIUL2_DIO_IP_AR_RELEASE_MAJOR_VERSION_H) || \
60 (SIUL2_DIO_IP_AR_RELEASE_MINOR_VERSION_C != SIUL2_DIO_IP_AR_RELEASE_MINOR_VERSION_H) || \
61 (SIUL2_DIO_IP_AR_RELEASE_REVISION_VERSION_C != SIUL2_DIO_IP_AR_RELEASE_REVISION_VERSION_H) \
62 )
63 #error "AutoSar Version Numbers of Siul2_Dio_Ip.c and Siul2_Dio_Ip.h are different"
64 #endif
65
66 /* Check if Siul2_Dio_Ip source file and Siul2_Dio_Ip header file are of the same Software version */
67 #if ((SIUL2_DIO_IP_SW_MAJOR_VERSION_C != SIUL2_DIO_IP_SW_MAJOR_VERSION_H) || \
68 (SIUL2_DIO_IP_SW_MINOR_VERSION_C != SIUL2_DIO_IP_SW_MINOR_VERSION_H) || \
69 (SIUL2_DIO_IP_SW_PATCH_VERSION_C != SIUL2_DIO_IP_SW_PATCH_VERSION_H) \
70 )
71 #error "Software Version Numbers of Siul2_Dio_Ip.c and Siul2_Dio_Ip.h are different"
72 #endif
73
74 #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
75 /* Check if Siul2_Dio_Ip source file and Devassert.h header file are of the same release version */
76 #if (STD_ON == SIUL2_DIO_IP_DEV_ERROR_DETECT)
77 #if ((SIUL2_DIO_IP_AR_RELEASE_MAJOR_VERSION_C != DEVASSERT_AR_RELEASE_MAJOR_VERSION) || \
78 (SIUL2_DIO_IP_AR_RELEASE_MINOR_VERSION_C != DEVASSERT_AR_RELEASE_MINOR_VERSION) \
79 )
80 #error "AutoSar Version Numbers of Siul2_Dio_Ip.c and Devassert.h are different"
81 #endif
82 #endif /* (STD_ON == SIUL2_DIO_IP_DEV_ERROR_DETECT) */
83 /* Check if Siul2_Dio_Ip source file and OsIf_Internal.h header file are of the same release version */
84 #if (defined(MCAL_ENABLE_USER_MODE_SUPPORT) && defined(DIO_ENABLE_USER_MODE_SUPPORT) && (STD_ON == DIO_ENABLE_USER_MODE_SUPPORT))
85 #if ((SIUL2_DIO_IP_AR_RELEASE_MAJOR_VERSION_C != OSIF_INTERNAL_AR_RELEASE_MAJOR_VERSION) || \
86 (SIUL2_DIO_IP_AR_RELEASE_MINOR_VERSION_C != OSIF_INTERNAL_AR_RELEASE_MINOR_VERSION) \
87 )
88 #error "AutoSar Version Numbers of Siul2_Dio_Ip.c and OsIf_Internal.h are different"
89 #endif
90 #endif /* (defined(MCAL_ENABLE_USER_MODE_SUPPORT) && defined(DIO_ENABLE_USER_MODE_SUPPORT) && (STD_ON == DIO_ENABLE_USER_MODE_SUPPORT)) */
91 /* SchM_Dio.h version check start */
92 #if ((SIUL2_DIO_IP_AR_RELEASE_MAJOR_VERSION_C != SCHM_DIO_AR_RELEASE_MAJOR_VERSION) || \
93 (SIUL2_DIO_IP_AR_RELEASE_MINOR_VERSION_C != SCHM_DIO_AR_RELEASE_MINOR_VERSION) \
94 )
95 #error "AUTOSAR Version Numbers of Siul2_Dio_Ip.c and SchM_Dio.h are different"
96 #endif
97 /* SchM_Dio.h version check end */
98 #endif /* DISABLE_MCAL_INTERMODULE_ASR_CHECK */
99 /*==================================================================================================
100 * LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
101 ==================================================================================================*/
102
103 /*==================================================================================================
104 * LOCAL MACROS
105 ==================================================================================================*/
106 #define SIUL2_DIO_IP_NUM_OF_PIN_PORT 16u
107
108 #if (defined(MCAL_ENABLE_USER_MODE_SUPPORT) && defined(DIO_ENABLE_USER_MODE_SUPPORT) && (STD_ON == DIO_ENABLE_USER_MODE_SUPPORT))
109 #define Call_Siul2_Dio_Ip_WritePinRunTime(base, pin, value) OsIf_Trusted_Call3params(Siul2_Dio_Ip_WritePinRunTime, (base), (pin), (value))
110 #define Call_Siul2_Dio_Ip_WritePinsRunTime(base, pins) OsIf_Trusted_Call2params(Siul2_Dio_Ip_WritePinsRunTime, (base), (pins))
111 #define Call_Siul2_Dio_Ip_GetPinsOutputRunTime(base) OsIf_Trusted_Call_Return1param(Siul2_Dio_Ip_GetPinsOutputRunTime, (base))
112 #define Call_Siul2_Dio_Ip_SetPinsRunTime(base, pins) OsIf_Trusted_Call2params(Siul2_Dio_Ip_SetPinsRunTime, (base), (pins))
113 #define Call_Siul2_Dio_Ip_ClearPinsRunTime(base, pins) OsIf_Trusted_Call2params(Siul2_Dio_Ip_ClearPinsRunTime, (base), (pins))
114 #define Call_Siul2_Dio_Ip_TogglePinsRunTime(base, pins) OsIf_Trusted_Call2params(Siul2_Dio_Ip_TogglePinsRunTime, (base), (pins))
115 #define Call_Siul2_Dio_Ip_ReadPinsRunTime(base) OsIf_Trusted_Call_Return1param(Siul2_Dio_Ip_ReadPinsRunTime, (base))
116 #if (STD_OFF == DIO_VIRTWRAPPER_SUPPORT)
117 #define Call_Siul2_Dio_Ip_MaskedWritePinsRunTime(u8Siul2Instance, u8PortId, pins, mask) OsIf_Trusted_Call4params(Siul2_Dio_Ip_MaskedWritePinsRunTime, (u8Siul2Instance), (u8PortId), (pins), (mask))
118 #endif /* (STD_OFF == DIO_VIRTWRAPPER_SUPPORT) */
119 #define Call_Siul2_Dio_Ip_ReadPinRunTime(base, pin) OsIf_Trusted_Call_Return2param(Siul2_Dio_Ip_ReadPinRunTime, (base), (pin))
120 #else
121 #define Call_Siul2_Dio_Ip_WritePinRunTime(base, pin, value) Siul2_Dio_Ip_WritePinRunTime(base, pin, value)
122 #define Call_Siul2_Dio_Ip_WritePinsRunTime(base, pins) Siul2_Dio_Ip_WritePinsRunTime(base, pins)
123 #define Call_Siul2_Dio_Ip_GetPinsOutputRunTime(base) Siul2_Dio_Ip_GetPinsOutputRunTime(base)
124 #define Call_Siul2_Dio_Ip_SetPinsRunTime(base, pins) Siul2_Dio_Ip_SetPinsRunTime(base, pins)
125 #define Call_Siul2_Dio_Ip_ClearPinsRunTime(base, pins) Siul2_Dio_Ip_ClearPinsRunTime(base, pins)
126 #define Call_Siul2_Dio_Ip_TogglePinsRunTime(base, pins) Siul2_Dio_Ip_TogglePinsRunTime(base, pins)
127 #define Call_Siul2_Dio_Ip_ReadPinsRunTime(base) Siul2_Dio_Ip_ReadPinsRunTime(base)
128 #if (STD_OFF == DIO_VIRTWRAPPER_SUPPORT)
129 #define Call_Siul2_Dio_Ip_MaskedWritePinsRunTime(u8Siul2Instance, u8PortId, pins, mask) Siul2_Dio_Ip_MaskedWritePinsRunTime(u8Siul2Instance, u8PortId, pins, mask)
130 #endif /* (STD_OFF == DIO_VIRTWRAPPER_SUPPORT) */
131 #define Call_Siul2_Dio_Ip_ReadPinRunTime(base, pin) Siul2_Dio_Ip_ReadPinRunTime(base, pin)
132 #endif
133 /*==================================================================================================
134 * LOCAL CONSTANTS
135 ==================================================================================================*/
136
137 /*==================================================================================================
138 * LOCAL VARIABLES
139 ==================================================================================================*/
140
141 /*==================================================================================================
142 * GLOBAL CONSTANTS
143 ==================================================================================================*/
144
145 /*==================================================================================================
146 * GLOBAL VARIABLES
147 ==================================================================================================*/
148 #define DIO_START_SEC_VAR_INIT_32
149 #include "Dio_MemMap.h"
150
151 #if (STD_ON == DIO_VIRTWRAPPER_SUPPORT)
152 #ifdef SIUL2_VIRTWRAPPER_MULTIINSTANCE
153 Siul2_Dio_Ip_CoreType Siul2_Dio_Ip_au32BaseAdresses[SIUL2_INSTANCE_COUNT] = IP_SIUL2_BASE_ADDRS;
154 #else
155 Siul2_Dio_Ip_CoreType Siul2_Dio_Ip_au32BaseAdresses[6] =
156 {
157 DIO_SIUL2_VIRTWRAPPER_PDAC0,
158 DIO_SIUL2_VIRTWRAPPER_PDAC1,
159 DIO_SIUL2_VIRTWRAPPER_PDAC2,
160 DIO_SIUL2_VIRTWRAPPER_PDAC3,
161 DIO_SIUL2_VIRTWRAPPER_PDAC4,
162 DIO_SIUL2_VIRTWRAPPER_PDAC5
163 };
164 #endif
165 #else
166 #ifdef IP_SIUL2_AE_BASE
167 Siul2_Dio_Ip_CoreType Siul2_Dio_Ip_au32BaseAdresses[SIUL2_INSTANCE_COUNT + SIUL2_AE_INSTANCE_COUNT] = { IP_SIUL2_0_BASE, IP_SIUL2_1_BASE, IP_SIUL2_3_BASE, IP_SIUL2_4_BASE, IP_SIUL2_5_BASE, IP_SIUL2_AE_BASE };
168 #else
169 Siul2_Dio_Ip_CoreType Siul2_Dio_Ip_au32BaseAdresses[SIUL2_INSTANCE_COUNT] = IP_SIUL2_BASE_ADDRS;
170 #endif /* IP_SIUL2_AE_BASE */
171 #endif
172 #define DIO_STOP_SEC_VAR_INIT_32
173 #include "Dio_MemMap.h"
174 /*==================================================================================================
175 * LOCAL FUNCTION PROTOTYPES
176 ==================================================================================================*/
177 #define DIO_START_SEC_CODE
178 #include "Dio_MemMap.h"
179
180 static inline uint16 Siul2_Dio_Ip_Rev_Bit_16(uint16 value);
181
182 void Siul2_Dio_Ip_WritePinsRunTime(Siul2_Dio_Ip_GpioType * const base,
183 Siul2_Dio_Ip_PinsChannelType pins
184 );
185
186 void Siul2_Dio_Ip_ClearPinsRunTime(Siul2_Dio_Ip_GpioType * const base,
187 Siul2_Dio_Ip_PinsChannelType pins
188 );
189
190 void Siul2_Dio_Ip_WritePinRunTime(Siul2_Dio_Ip_GpioType * const base,
191 Siul2_Dio_Ip_PinsChannelType pin,
192 Siul2_Dio_Ip_PinsLevelType value
193 );
194
195 Siul2_Dio_Ip_PinsChannelType Siul2_Dio_Ip_GetPinsOutputRunTime(const Siul2_Dio_Ip_GpioType * const base);
196
197 void Siul2_Dio_Ip_SetPinsRunTime(Siul2_Dio_Ip_GpioType * const base,
198 Siul2_Dio_Ip_PinsChannelType pins
199 );
200
201 #if (STD_OFF == DIO_VIRTWRAPPER_SUPPORT)
202 void Siul2_Dio_Ip_MaskedWritePinsRunTime(uint8 u8Siul2Instance,
203 uint8 u8PortId,
204 Siul2_Dio_Ip_PinsChannelType pins,
205 Siul2_Dio_Ip_PinsChannelType mask
206 );
207 #endif /* (STD_OFF == DIO_VIRTWRAPPER_SUPPORT) */
208
209 void Siul2_Dio_Ip_TogglePinsRunTime(Siul2_Dio_Ip_GpioType * const base,
210 Siul2_Dio_Ip_PinsChannelType pins
211 );
212
213 Siul2_Dio_Ip_PinsLevelType Siul2_Dio_Ip_ReadPinRunTime(const Siul2_Dio_Ip_GpioType * const base,
214 Siul2_Dio_Ip_PinsChannelType pin
215 );
216
217 Siul2_Dio_Ip_PinsChannelType Siul2_Dio_Ip_ReadPinsRunTime(const Siul2_Dio_Ip_GpioType * const base);
218
219 /*==================================================================================================
220 * LOCAL FUNCTIONS
221 ==================================================================================================*/
222
223 /* Reverse bit order in each halfword independently */
Siul2_Dio_Ip_Rev_Bit_16(uint16 value)224 static inline uint16 Siul2_Dio_Ip_Rev_Bit_16(uint16 value)
225 {
226 uint8 i;
227 uint16 ret = 0U;
228
229 for (i = 0U; i < 8U; i++)
230 {
231 ret |= (uint16)((((value >> i) & 1U) << (15U - i)) | (((value << i) & 0x8000U) >> (15U - i)));
232 }
233
234 return ret;
235 }
236
237 /*==================================================================================================
238 * GLOBAL FUNCTIONS
239 ==================================================================================================*/
240
Siul2_Dio_Ip_WritePinRunTime(Siul2_Dio_Ip_GpioType * const base,Siul2_Dio_Ip_PinsChannelType pin,Siul2_Dio_Ip_PinsLevelType value)241 void Siul2_Dio_Ip_WritePinRunTime(Siul2_Dio_Ip_GpioType * const base,
242 Siul2_Dio_Ip_PinsChannelType pin,
243 Siul2_Dio_Ip_PinsLevelType value
244 )
245 {
246 /* Enter critical region */
247 SchM_Enter_Dio_DIO_EXCLUSIVE_AREA_01();
248
249 Siul2_Dio_Ip_PinsChannelType pinsValues = (Siul2_Dio_Ip_PinsChannelType)base->PGPDO;
250 pinsValues &= (Siul2_Dio_Ip_PinsChannelType)(~((Siul2_Dio_Ip_PinsChannelType)1U << (15U - pin)));
251 pinsValues |= (Siul2_Dio_Ip_PinsChannelType)(((Siul2_Dio_Ip_PinsChannelType)value & 1U) << (15U - pin));
252 base->PGPDO = pinsValues;
253
254 /* Exit critical region */
255 SchM_Exit_Dio_DIO_EXCLUSIVE_AREA_01();
256 }
257 /**
258 *Function Name : Siul2_Dio_Ip_WritePin
259 * Description : This function writes the given pin from a port, with the given value
260 * ('0' represents LOW, '1' represents HIGH).
261 *
262 * @implements Siul2_Dio_Ip_WritePin_Activity
263 */
Siul2_Dio_Ip_WritePin(Siul2_Dio_Ip_GpioType * const base,Siul2_Dio_Ip_PinsChannelType pin,Siul2_Dio_Ip_PinsLevelType value)264 void Siul2_Dio_Ip_WritePin(Siul2_Dio_Ip_GpioType * const base,
265 Siul2_Dio_Ip_PinsChannelType pin,
266 Siul2_Dio_Ip_PinsLevelType value
267 )
268 {
269 SIUL2_DIO_IP_DEV_ASSERT(NULL_PTR != base);
270 SIUL2_DIO_IP_DEV_ASSERT((boolean)(pin < SIUL2_DIO_IP_NUM_OF_PIN_PORT));
271 SIUL2_DIO_IP_DEV_ASSERT((boolean)(value <= 1U));
272
273 Call_Siul2_Dio_Ip_WritePinRunTime(base, pin, value);
274 }
275
276 /**
277 * Function Name : Siul2_Dio_Ip_WritePinsRunTime
278 * Description : This function writes all pins configured as output with the values given in
279 * the parameter pins. '0' represents LOW, '1' represents HIGH.
280 *
281 */
Siul2_Dio_Ip_WritePinsRunTime(Siul2_Dio_Ip_GpioType * const base,Siul2_Dio_Ip_PinsChannelType pins)282 void Siul2_Dio_Ip_WritePinsRunTime(Siul2_Dio_Ip_GpioType * const base,
283 Siul2_Dio_Ip_PinsChannelType pins
284 )
285 {
286 base->PGPDO = Siul2_Dio_Ip_Rev_Bit_16(pins);
287 }
288
289 /**
290 * Function Name : Siul2_Dio_Ip_WritePins
291 * Description : This function writes all pins configured as output with the values given in
292 * the parameter pins. '0' represents LOW, '1' represents HIGH.
293 *
294 * @implements Siul2_Dio_Ip_WritePins_Activity
295 */
Siul2_Dio_Ip_WritePins(Siul2_Dio_Ip_GpioType * const base,Siul2_Dio_Ip_PinsChannelType pins)296 void Siul2_Dio_Ip_WritePins(Siul2_Dio_Ip_GpioType * const base,
297 Siul2_Dio_Ip_PinsChannelType pins
298 )
299 {
300 SIUL2_DIO_IP_DEV_ASSERT(NULL_PTR != base);
301 Call_Siul2_Dio_Ip_WritePinsRunTime(base, pins);
302 }
303
304 /**
305 * Function Name : Siul2_Dio_Ip_GetPinsOutputRunTime
306 * Description : This function returns the current output that is written to a port. Only pins
307 * that are configured as output will have meaningful values.
308 *
309 */
Siul2_Dio_Ip_GetPinsOutputRunTime(const Siul2_Dio_Ip_GpioType * const base)310 Siul2_Dio_Ip_PinsChannelType Siul2_Dio_Ip_GetPinsOutputRunTime(const Siul2_Dio_Ip_GpioType * const base)
311 {
312 Siul2_Dio_Ip_PinsChannelType returnValue = 0U;
313 returnValue = (Siul2_Dio_Ip_PinsChannelType)Siul2_Dio_Ip_Rev_Bit_16(base->PGPDO);
314 return returnValue;
315 }
316
317 /**
318 * Function Name : Siul2_Dio_Ip_GetPinsOutput
319 * Description : This function returns the current output that is written to a port. Only pins
320 * that are configured as output will have meaningful values.
321 *
322 * @implements Siul2_Dio_Ip_GetPinsOutput_Activity
323 */
Siul2_Dio_Ip_GetPinsOutput(const Siul2_Dio_Ip_GpioType * const base)324 Siul2_Dio_Ip_PinsChannelType Siul2_Dio_Ip_GetPinsOutput(const Siul2_Dio_Ip_GpioType * const base)
325 {
326 SIUL2_DIO_IP_DEV_ASSERT(NULL_PTR != base);
327 Siul2_Dio_Ip_PinsChannelType returnValue = 0U;
328 returnValue = Call_Siul2_Dio_Ip_GetPinsOutputRunTime(base);
329 return returnValue;
330 }
331
332 /**
333 * Function Name : Siul2_Dio_Ip_SetPinsRunTime
334 * Description : This function configures output pins listed in parameter pins (bits that are
335 * '1') to have a value of 'set' (HIGH). Pins corresponding to '0' will be
336 * unaffected.
337 *
338 */
Siul2_Dio_Ip_SetPinsRunTime(Siul2_Dio_Ip_GpioType * const base,Siul2_Dio_Ip_PinsChannelType pins)339 void Siul2_Dio_Ip_SetPinsRunTime(Siul2_Dio_Ip_GpioType * const base,
340 Siul2_Dio_Ip_PinsChannelType pins
341 )
342 {
343 base->PGPDO |= Siul2_Dio_Ip_Rev_Bit_16(pins);
344 }
345
346 /**
347 * Function Name : Siul2_Dio_Ip_SetPins
348 * Description : This function configures output pins listed in parameter pins (bits that are
349 * '1') to have a value of 'set' (HIGH). Pins corresponding to '0' will be
350 * unaffected.
351 *
352 * @implements Siul2_Dio_Ip_SetPins_Activity
353 */
Siul2_Dio_Ip_SetPins(Siul2_Dio_Ip_GpioType * const base,Siul2_Dio_Ip_PinsChannelType pins)354 void Siul2_Dio_Ip_SetPins(Siul2_Dio_Ip_GpioType * const base,
355 Siul2_Dio_Ip_PinsChannelType pins
356 )
357 {
358 SIUL2_DIO_IP_DEV_ASSERT(NULL_PTR != base);
359 Call_Siul2_Dio_Ip_SetPinsRunTime(base, pins);
360 }
361
362 /**
363 * Function Name : Siul2_Dio_Ip_ClearPinsRunTime
364 * Description : This function configures output pins listed in parameter pins (bits that are
365 * '1') to have a 'cleared' value (LOW). Pins corresponding to '0' will be
366 * unaffected.
367 *
368 */
Siul2_Dio_Ip_ClearPinsRunTime(Siul2_Dio_Ip_GpioType * const base,Siul2_Dio_Ip_PinsChannelType pins)369 void Siul2_Dio_Ip_ClearPinsRunTime(Siul2_Dio_Ip_GpioType * const base,
370 Siul2_Dio_Ip_PinsChannelType pins
371 )
372 {
373 base->PGPDO &= (Siul2_Dio_Ip_PinsChannelType)(~Siul2_Dio_Ip_Rev_Bit_16(pins));
374 }
375
376 /**
377 * Function Name : Siul2_Dio_Ip_ClearPins
378 * Description : This function configures output pins listed in parameter pins (bits that are
379 * '1') to have a 'cleared' value (LOW). Pins corresponding to '0' will be
380 * unaffected.
381 *
382 * @implements Siul2_Dio_Ip_ClearPins_Activity
383 */
Siul2_Dio_Ip_ClearPins(Siul2_Dio_Ip_GpioType * const base,Siul2_Dio_Ip_PinsChannelType pins)384 void Siul2_Dio_Ip_ClearPins(Siul2_Dio_Ip_GpioType * const base,
385 Siul2_Dio_Ip_PinsChannelType pins
386 )
387 {
388 SIUL2_DIO_IP_DEV_ASSERT(NULL_PTR != base);
389 Call_Siul2_Dio_Ip_ClearPinsRunTime(base, pins);
390 }
391
392 /**
393 * Function Name : Siul2_Dio_Ip_TogglePinsRunTime
394 * Description : This function toggles output pins listed in parameter pins (bits that are
395 * '1'). Pins corresponding to '0' will be unaffected.
396 *
397 */
Siul2_Dio_Ip_TogglePinsRunTime(Siul2_Dio_Ip_GpioType * const base,Siul2_Dio_Ip_PinsChannelType pins)398 void Siul2_Dio_Ip_TogglePinsRunTime(Siul2_Dio_Ip_GpioType * const base,
399 Siul2_Dio_Ip_PinsChannelType pins
400 )
401 {
402 base->PGPDO ^= Siul2_Dio_Ip_Rev_Bit_16(pins);
403 }
404
405 /**
406 * Function Name : Siul2_Dio_Ip_TogglePins
407 * Description : This function toggles output pins listed in parameter pins (bits that are
408 * '1'). Pins corresponding to '0' will be unaffected.
409 *
410 * @implements Siul2_Dio_Ip_TogglePins_Activity
411 */
Siul2_Dio_Ip_TogglePins(Siul2_Dio_Ip_GpioType * const base,Siul2_Dio_Ip_PinsChannelType pins)412 void Siul2_Dio_Ip_TogglePins(Siul2_Dio_Ip_GpioType * const base,
413 Siul2_Dio_Ip_PinsChannelType pins
414 )
415 {
416 SIUL2_DIO_IP_DEV_ASSERT(NULL_PTR != base);
417 Call_Siul2_Dio_Ip_TogglePinsRunTime(base, pins);
418 }
419
420 /**
421 * Function Name : Siul2_Dio_Ip_ReadPinsRunTime
422 * Description : This function returns the current input values from a port. Only pins
423 * configured as input will have meaningful values.
424 *
425 */
Siul2_Dio_Ip_ReadPinsRunTime(const Siul2_Dio_Ip_GpioType * const base)426 Siul2_Dio_Ip_PinsChannelType Siul2_Dio_Ip_ReadPinsRunTime(const Siul2_Dio_Ip_GpioType * const base)
427 {
428 Siul2_Dio_Ip_PinsChannelType returnValue = 0U;
429 returnValue = (Siul2_Dio_Ip_PinsChannelType)Siul2_Dio_Ip_Rev_Bit_16(base->PGPDI);
430 return returnValue;
431 }
432
433 /**
434 * Function Name : Siul2_Dio_Ip_ReadPins
435 * Description : This function returns the current input values from a port. Only pins
436 * configured as input will have meaningful values.
437 *
438 * @implements Siul2_Dio_Ip_ReadPins_Activity
439 */
Siul2_Dio_Ip_ReadPins(const Siul2_Dio_Ip_GpioType * const base)440 Siul2_Dio_Ip_PinsChannelType Siul2_Dio_Ip_ReadPins(const Siul2_Dio_Ip_GpioType * const base)
441 {
442 SIUL2_DIO_IP_DEV_ASSERT(NULL_PTR != base);
443 Siul2_Dio_Ip_PinsChannelType returnValue = 0U;
444 returnValue = Call_Siul2_Dio_Ip_ReadPinsRunTime(base);
445 return returnValue;
446 }
447
448 /**
449 * Function Name : Siul2_Dio_Ip_ReadPinRunTime
450 * Description : This function returns the current input value of the given pin from port. Only pin
451 * configured as input will have meaningful value.
452 *
453 */
Siul2_Dio_Ip_ReadPinRunTime(const Siul2_Dio_Ip_GpioType * const base,Siul2_Dio_Ip_PinsChannelType pin)454 Siul2_Dio_Ip_PinsLevelType Siul2_Dio_Ip_ReadPinRunTime(const Siul2_Dio_Ip_GpioType * const base,
455 Siul2_Dio_Ip_PinsChannelType pin
456 )
457 {
458 Siul2_Dio_Ip_PinsLevelType returnValue = 0U;
459 returnValue = (Siul2_Dio_Ip_PinsLevelType)((Siul2_Dio_Ip_Rev_Bit_16(base->PGPDI) & ((Siul2_Dio_Ip_PinsChannelType)1U << pin)) >> pin);
460 return returnValue;
461 }
462
463 /**
464 * Function Name : Siul2_Dio_Ip_ReadPin
465 * Description : This function returns the current input value of the given pin from port. Only pin
466 * configured as input will have meaningful value.
467 *
468 * @implements Siul2_Dio_Ip_ReadPin_Activity
469 */
Siul2_Dio_Ip_ReadPin(const Siul2_Dio_Ip_GpioType * const base,Siul2_Dio_Ip_PinsChannelType pin)470 Siul2_Dio_Ip_PinsLevelType Siul2_Dio_Ip_ReadPin(const Siul2_Dio_Ip_GpioType * const base,
471 Siul2_Dio_Ip_PinsChannelType pin
472 )
473 {
474 SIUL2_DIO_IP_DEV_ASSERT(NULL_PTR != base);
475 SIUL2_DIO_IP_DEV_ASSERT((boolean)(pin < SIUL2_DIO_IP_NUM_OF_PIN_PORT));
476 Siul2_Dio_Ip_PinsLevelType returnValue = 0U;
477 returnValue = Call_Siul2_Dio_Ip_ReadPinRunTime(base, pin);
478 return returnValue;
479 }
480
481 #if (STD_OFF == DIO_VIRTWRAPPER_SUPPORT)
482 /**
483 * Function Name : Siul2_Dio_Ip_MaskedWritePinsRunTime
484 * Description : This function writes the masked pins configured as output with the values given
485 * in the parameter pins. '0' represents LOW, '1' represents HIGH.
486 *
487 */
Siul2_Dio_Ip_MaskedWritePinsRunTime(uint8 u8Siul2Instance,uint8 u8PortId,Siul2_Dio_Ip_PinsChannelType pins,Siul2_Dio_Ip_PinsChannelType mask)488 void Siul2_Dio_Ip_MaskedWritePinsRunTime(uint8 u8Siul2Instance,
489 uint8 u8PortId,
490 Siul2_Dio_Ip_PinsChannelType pins,
491 Siul2_Dio_Ip_PinsChannelType mask
492 )
493 {
494 uint32 maskRev;
495 uint32 pinsRev;
496
497 maskRev = (uint32)(Siul2_Dio_Ip_Rev_Bit_16(mask));
498 pinsRev = (uint32)(Siul2_Dio_Ip_Rev_Bit_16(pins));
499 *(Siul2_Dio_Ip_CoreType *)(SIUL2_DIO_IP_MPGPDO_ADDR32(u8Siul2Instance, u8PortId)) = (maskRev << (uint32)16U) | pinsRev;
500 }
501 #endif /* (STD_OFF == DIO_VIRTWRAPPER_SUPPORT) */
502
503 #if (STD_OFF == DIO_VIRTWRAPPER_SUPPORT)
504 /**
505 * Function Name : Siul2_Dio_Ip_MaskedWritePins
506 * Description : This function writes the masked pins configured as output with the values given
507 * in the parameter pins. '0' represents LOW, '1' represents HIGH.
508 *
509 * @implements Siul2_Dio_Ip_MaskedWritePins_Activity
510 */
Siul2_Dio_Ip_MaskedWritePins(uint8 u8Siul2Instance,uint8 u8PortId,Siul2_Dio_Ip_PinsChannelType pins,Siul2_Dio_Ip_PinsChannelType mask)511 void Siul2_Dio_Ip_MaskedWritePins(uint8 u8Siul2Instance,
512 uint8 u8PortId,
513 Siul2_Dio_Ip_PinsChannelType pins,
514 Siul2_Dio_Ip_PinsChannelType mask
515 )
516 {
517 Call_Siul2_Dio_Ip_MaskedWritePinsRunTime(u8Siul2Instance, u8PortId, pins, mask);
518 }
519 #endif /* (STD_OFF == DIO_VIRTWRAPPER_SUPPORT) */
520
521 #define DIO_STOP_SEC_CODE
522 #include "Dio_MemMap.h"
523
524 #ifdef __cplusplus
525 }
526 #endif
527
528 /** @} */
529
530 /******************************************************************************
531 * EOF
532 *****************************************************************************/
533