1 /*
2 * Copyright 2020-2023 NXP
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #ifndef ADC_SAR_IP_HW_ACCESS_H
8 #define ADC_SAR_IP_HW_ACCESS_H
9
10 /**
11 * @file
12 *
13 * @internal
14 * @addtogroup adc_sar_ip Adc Sar IPL
15 * @{
16 */
17
18 #ifdef __cplusplus
19 extern "C"{
20 #endif
21
22 /*==================================================================================================
23 * INCLUDE FILES
24 * 1) system and project includes
25 * 2) needed interfaces from external units
26 * 3) internal and external interfaces from this unit
27 ==================================================================================================*/
28 #include "StandardTypes.h"
29 #include "Adc_Sar_Ip_CfgDefines.h"
30
31 #if (ADC_SAR_IP_DEV_ERROR_DETECT == STD_ON)
32 #include "Devassert.h"
33 #endif /* (ADC_SAR_IP_DEV_ERROR_DETECT == STD_ON) */
34
35 /*==================================================================================================
36 * SOURCE FILE VERSION INFORMATION
37 ==================================================================================================*/
38 #define ADC_SAR_IP_VENDOR_ID_HWACCESS 43
39 #define ADC_SAR_IP_AR_RELEASE_MAJOR_VERSION_HWACCESS 4
40 #define ADC_SAR_IP_AR_RELEASE_MINOR_VERSION_HWACCESS 7
41 #define ADC_SAR_IP_AR_RELEASE_REVISION_VERSION_HWACCESS 0
42 #define ADC_SAR_IP_SW_MAJOR_VERSION_HWACCESS 3
43 #define ADC_SAR_IP_SW_MINOR_VERSION_HWACCESS 0
44 #define ADC_SAR_IP_SW_PATCH_VERSION_HWACCESS 0
45
46 /*==================================================================================================
47 * FILE VERSION CHECKS
48 ==================================================================================================*/
49 /* Check if Adc_Sar_Ip_HwAccess.h file and Adc_Sar_Ip_CfgDefines.h file are of the same vendor */
50 #if (ADC_SAR_IP_VENDOR_ID_HWACCESS != ADC_SAR_IP_VENDOR_ID_CFGDEFINES)
51 #error "Adc_Sar_Ip_HwAccess.h and Adc_Sar_Ip_CfgDefines.h have different vendor ids"
52 #endif
53
54 /* Check if Adc_Sar_Ip_HwAccess.h file and Adc_Sar_Ip_CfgDefines.h file are of the same Autosar version */
55 #if ((ADC_SAR_IP_AR_RELEASE_MAJOR_VERSION_HWACCESS != ADC_SAR_IP_AR_RELEASE_MAJOR_VERSION_CFGDEFINES) || \
56 (ADC_SAR_IP_AR_RELEASE_MINOR_VERSION_HWACCESS != ADC_SAR_IP_AR_RELEASE_MINOR_VERSION_CFGDEFINES) || \
57 (ADC_SAR_IP_AR_RELEASE_REVISION_VERSION_HWACCESS != ADC_SAR_IP_AR_RELEASE_REVISION_VERSION_CFGDEFINES) \
58 )
59 #error "AutoSar Version Numbers of Adc_Sar_Ip_HwAccess.h and Adc_Sar_Ip_CfgDefines.h are different"
60 #endif
61
62 /* Check if Adc_Sar_Ip_HwAccess.h file and Adc_Sar_Ip_CfgDefines.h file are of the same Software version */
63 #if ((ADC_SAR_IP_SW_MAJOR_VERSION_HWACCESS != ADC_SAR_IP_SW_MAJOR_VERSION_CFGDEFINES) || \
64 (ADC_SAR_IP_SW_MINOR_VERSION_HWACCESS != ADC_SAR_IP_SW_MINOR_VERSION_CFGDEFINES) || \
65 (ADC_SAR_IP_SW_PATCH_VERSION_HWACCESS != ADC_SAR_IP_SW_PATCH_VERSION_CFGDEFINES) \
66 )
67 #error "Software Version Numbers of Adc_Sar_Ip_HwAccess.h and Adc_Sar_Ip_CfgDefines.h are different"
68 #endif
69
70 #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
71 /* Check if Adc_Sar_Ip_HwAccess.h file and StandardTypes.h file are of the same Autosar version */
72 #if ((ADC_SAR_IP_AR_RELEASE_MAJOR_VERSION_HWACCESS != STD_AR_RELEASE_MAJOR_VERSION) || \
73 (ADC_SAR_IP_AR_RELEASE_MINOR_VERSION_HWACCESS != STD_AR_RELEASE_MINOR_VERSION) \
74 )
75 #error "AutoSar Version Numbers of Adc_Sar_Ip_HwAccess.h and StandardTypes.h are different"
76 #endif
77
78 #if (ADC_SAR_IP_DEV_ERROR_DETECT == STD_ON)
79 /* Check if Adc_Sar_Ip_HwAccess.h and Devassert.h are of the same Autosar version */
80 #if ((ADC_SAR_IP_AR_RELEASE_MAJOR_VERSION_HWACCESS != DEVASSERT_AR_RELEASE_MAJOR_VERSION) || \
81 (ADC_SAR_IP_AR_RELEASE_MINOR_VERSION_HWACCESS != DEVASSERT_AR_RELEASE_MINOR_VERSION) \
82 )
83 #error "AutoSar Version Numbers of Adc_Sar_Ip_HwAccess.h and Devassert.h are different"
84 #endif
85 #endif /* (ADC_SAR_IP_DEV_ERROR_DETECT == STD_ON) */
86 #endif /* DISABLE_MCAL_INTERMODULE_ASR_CHECK */
87
88 /*==================================================================================================
89 * EXTERN DECLARATIONS
90 ==================================================================================================*/
91 extern ADC_Type * const Adc_Sar_Ip_apxAdcBase[ADC_INSTANCE_COUNT];
92 #if FEATURE_ADC_HAS_APPLICATION_EXTENSION
93 extern SAR_ADC_AE_Type * const Adc_Sar_AE_Ip_apxAdcBase[SAR_ADC_AE_INSTANCE_COUNT];
94 #endif /* FEATURE_ADC_HAS_APPLICATION_EXTENSION */
95 /*==================================================================================================
96 * DEFINES AND MACROS
97 ==================================================================================================*/
98 /* Define the hardware register size when calculating bit positions */
99 #define ADC_SAR_IP_HW_REG_SIZE (32u)
100
101 /* Definitions to compute bit positions from channel index */
102 #define ADC_SAR_IP_CHAN_2_VECT(CHNIDX) ((CHNIDX) / ADC_SAR_IP_HW_REG_SIZE)
103 #define ADC_SAR_IP_CHAN_2_BIT(CHNIDX) ((CHNIDX) % ADC_SAR_IP_HW_REG_SIZE)
104 /*==================================================================================================
105 FUNCTION DEFINITIONS
106 ==================================================================================================*/
107 #define ADC_START_SEC_CODE
108 #include "Adc_MemMap.h"
109
110 /*FUNCTION*********************************************************************
111 *
112 * Function Name : Adc_Sar_Powerup
113 * Description : Turning on power to the analog portion of ADC
114 *
115 *END*************************************************************************/
Adc_Sar_Powerup(const uint32 Instance)116 static inline void Adc_Sar_Powerup(const uint32 Instance)
117 {
118 ADC_Type * AdcBasePtr = NULL_PTR;
119 #if FEATURE_ADC_HAS_APPLICATION_EXTENSION
120 SAR_ADC_AE_Type * AdcAEBasePtr = NULL_PTR;
121 #endif /* FEATURE_ADC_HAS_APPLICATION_EXTENSION */
122
123 #if FEATURE_ADC_HAS_APPLICATION_EXTENSION
124 if (Instance >= ADC_INSTANCE_COUNT)
125 {
126 AdcAEBasePtr = Adc_Sar_AE_Ip_apxAdcBase[Instance - ADC_INSTANCE_COUNT];
127 AdcAEBasePtr->MCR &= ~(ADC_MCR_PWDN(1u));
128 }
129 else
130 #endif /* FEATURE_ADC_HAS_APPLICATION_EXTENSION */
131 {
132 AdcBasePtr = Adc_Sar_Ip_apxAdcBase[Instance];
133 AdcBasePtr->MCR &= ~(ADC_MCR_PWDN(1u));
134 }
135 }
136
137 /*FUNCTION*********************************************************************
138 *
139 * Function Name : Adc_Sar_Powerdown
140 * Description : Turning off power to the analog portion of ADC
141 *
142 *END*************************************************************************/
Adc_Sar_Powerdown(const uint32 Instance)143 static inline void Adc_Sar_Powerdown(const uint32 Instance)
144 {
145 ADC_Type * AdcBasePtr = NULL_PTR;
146 #if FEATURE_ADC_HAS_APPLICATION_EXTENSION
147 SAR_ADC_AE_Type * AdcAEBasePtr = NULL_PTR;
148 #endif /* FEATURE_ADC_HAS_APPLICATION_EXTENSION */
149
150 #if FEATURE_ADC_HAS_APPLICATION_EXTENSION
151 if (Instance >= ADC_INSTANCE_COUNT)
152 {
153 AdcAEBasePtr = Adc_Sar_AE_Ip_apxAdcBase[Instance - ADC_INSTANCE_COUNT];
154 AdcAEBasePtr->MCR |= ADC_MCR_PWDN(1u);
155 }
156 else
157 #endif /* FEATURE_ADC_HAS_APPLICATION_EXTENSION */
158 {
159 AdcBasePtr = Adc_Sar_Ip_apxAdcBase[Instance];
160 AdcBasePtr->MCR |= ADC_MCR_PWDN(1u);
161 }
162 }
163
164 #if FEATURE_ADC_HAS_HIGH_SPEED_ENABLE
165 /*FUNCTION*********************************************************************
166 *
167 * Function Name : Adc_Sar_EnableHighSpeed
168 * Description : Enable a high-speed calibration or a high-speed conversion
169 *
170 *END*************************************************************************/
Adc_Sar_EnableHighSpeed(ADC_Type * const Base,boolean Enable)171 static inline void Adc_Sar_EnableHighSpeed(ADC_Type * const Base,
172 boolean Enable)
173 {
174 uint32 Amsio = Base->AMSIO;
175 Amsio &= ~(ADC_AMSIO_HSEN_MASK);
176 Amsio |= ADC_AMSIO_HSEN(Enable ? 3u : 0u);
177 Base->AMSIO = Amsio;
178 }
179 #endif /* FEATURE_ADC_HAS_HIGH_SPEED_ENABLE */
180
181 /*FUNCTION*********************************************************************
182 *
183 * Function Name : Adc_Sar_WriteThresholds
184 * Description : Write Watchdog low, high thresholds for a wdog register
185 *
186 *END*************************************************************************/
Adc_Sar_WriteThresholds(const uint32 Instance,const uint8 RegisterNumber,const uint16 HighThreshold,const uint16 LowThreshold)187 static inline void Adc_Sar_WriteThresholds(const uint32 Instance,
188 const uint8 RegisterNumber,
189 const uint16 HighThreshold,
190 const uint16 LowThreshold)
191 {
192 ADC_Type * AdcBasePtr = NULL_PTR;
193 #if FEATURE_ADC_HAS_APPLICATION_EXTENSION
194 SAR_ADC_AE_Type * AdcAEBasePtr = NULL_PTR;
195 #endif /* FEATURE_ADC_HAS_APPLICATION_EXTENSION */
196 #if !ADC_SAR_IP_HAS_THRHLR_ARRAY
197 volatile uint32 * THRHLR0Addr = NULL_PTR;
198 volatile uint32 * THRHLR1Addr = NULL_PTR;
199 volatile uint32 * THRHLR2Addr = NULL_PTR;
200 volatile uint32 * THRHLR3Addr = NULL_PTR;
201 volatile uint32 * THRHLR4Addr = NULL_PTR;
202 volatile uint32 * THRHLR5Addr = NULL_PTR;
203 #if ((ADC_SAR_IP_THRHLR_COUNT > 6U) || FEATURE_ADC_HAS_APPLICATION_EXTENSION)
204 volatile uint32 * THRHLR6Addr = NULL_PTR;
205 volatile uint32 * THRHLR7Addr = NULL_PTR;
206 #if ((ADC_SAR_IP_THRHLR_COUNT > 8U) || FEATURE_ADC_HAS_APPLICATION_EXTENSION)
207 volatile uint32 * THRHLR8Addr = NULL_PTR;
208 volatile uint32 * THRHLR9Addr = NULL_PTR;
209 volatile uint32 * THRHLR10Addr = NULL_PTR;
210 volatile uint32 * THRHLR11Addr = NULL_PTR;
211 #if ((ADC_SAR_IP_THRHLR_COUNT > 12U) || FEATURE_ADC_HAS_APPLICATION_EXTENSION)
212 volatile uint32 * THRHLR12Addr = NULL_PTR;
213 volatile uint32 * THRHLR13Addr = NULL_PTR;
214 volatile uint32 * THRHLR14Addr = NULL_PTR;
215 volatile uint32 * THRHLR15Addr = NULL_PTR;
216 #endif /* ((ADC_SAR_IP_THRHLR_COUNT > 12U) || ...) */
217 #endif /* ((ADC_SAR_IP_THRHLR_COUNT > 8U) || ...) */
218 #endif /* ((ADC_SAR_IP_THRHLR_COUNT > 6U) || ...) */
219 #endif /* !ADC_SAR_IP_HAS_THRHLR_ARRAY */
220
221 #if FEATURE_ADC_HAS_APPLICATION_EXTENSION
222 if (Instance >= ADC_INSTANCE_COUNT)
223 {
224 AdcAEBasePtr = Adc_Sar_AE_Ip_apxAdcBase[Instance - ADC_INSTANCE_COUNT];
225 }
226 else
227 #endif /* FEATURE_ADC_HAS_APPLICATION_EXTENSION */
228 {
229 AdcBasePtr = Adc_Sar_Ip_apxAdcBase[Instance];
230 }
231
232 #if !ADC_SAR_IP_HAS_THRHLR_ARRAY
233 #if FEATURE_ADC_HAS_APPLICATION_EXTENSION
234 if (Instance >= ADC_INSTANCE_COUNT)
235 {
236 THRHLR0Addr = &(AdcAEBasePtr->THRHLR0);
237 THRHLR1Addr = &(AdcAEBasePtr->THRHLR1);
238 THRHLR2Addr = &(AdcAEBasePtr->THRHLR2);
239 THRHLR3Addr = &(AdcAEBasePtr->THRHLR3);
240 THRHLR4Addr = &(AdcAEBasePtr->THRHLR4);
241 THRHLR5Addr = &(AdcAEBasePtr->THRHLR5);
242 THRHLR6Addr = &(AdcAEBasePtr->THRHLR6);
243 THRHLR7Addr = &(AdcAEBasePtr->THRHLR7);
244 THRHLR8Addr = &(AdcAEBasePtr->THRHLR8);
245 THRHLR9Addr = &(AdcAEBasePtr->THRHLR9);
246 THRHLR10Addr = &(AdcAEBasePtr->THRHLR10);
247 THRHLR11Addr = &(AdcAEBasePtr->THRHLR11);
248 THRHLR12Addr = &(AdcAEBasePtr->THRHLR12);
249 THRHLR13Addr = &(AdcAEBasePtr->THRHLR13);
250 THRHLR14Addr = &(AdcAEBasePtr->THRHLR14);
251 THRHLR15Addr = &(AdcAEBasePtr->THRHLR15);
252 }
253 else
254 #endif /* FEATURE_ADC_HAS_APPLICATION_EXTENSION */
255 {
256 THRHLR0Addr = &(AdcBasePtr->THRHLR0);
257 THRHLR1Addr = &(AdcBasePtr->THRHLR1);
258 THRHLR2Addr = &(AdcBasePtr->THRHLR2);
259 THRHLR3Addr = &(AdcBasePtr->THRHLR3);
260 THRHLR4Addr = &(AdcBasePtr->THRHLR4);
261 THRHLR5Addr = &(AdcBasePtr->THRHLR5);
262 #if (ADC_SAR_IP_THRHLR_COUNT > 6U)
263 THRHLR6Addr = &(AdcBasePtr->THRHLR6);
264 THRHLR7Addr = &(AdcBasePtr->THRHLR7);
265 #if (ADC_SAR_IP_THRHLR_COUNT > 8U)
266 THRHLR8Addr = &(AdcBasePtr->THRHLR8);
267 THRHLR9Addr = &(AdcBasePtr->THRHLR9);
268 THRHLR10Addr = &(AdcBasePtr->THRHLR10);
269 THRHLR11Addr = &(AdcBasePtr->THRHLR11);
270 #if (ADC_SAR_IP_THRHLR_COUNT > 12U)
271 THRHLR12Addr = &(AdcBasePtr->THRHLR12);
272 THRHLR13Addr = &(AdcBasePtr->THRHLR13);
273 THRHLR14Addr = &(AdcBasePtr->THRHLR14);
274 THRHLR15Addr = &(AdcBasePtr->THRHLR15);
275 #endif /* (ADC_SAR_IP_THRHLR_COUNT > 12U) */
276 #endif /* (ADC_SAR_IP_THRHLR_COUNT > 8U) */
277 #endif /* (ADC_SAR_IP_THRHLR_COUNT > 6U) */
278 }
279 #endif /* ADC_SAR_IP_HAS_THRHLR_ARRAY */
280
281 #if ADC_SAR_IP_HAS_THRHLR_ARRAY
282 #if (ADC_SAR_IP_DEV_ERROR_DETECT == STD_ON)
283 DevAssert(RegisterNumber < ADC_SAR_IP_THRHLR_COUNT);
284 #endif /* (ADC_SAR_IP_DEV_ERROR_DETECT == STD_ON) */
285 uint32 Value = ADC_THRHLR_THRH(HighThreshold) |
286 ADC_THRHLR_THRL(LowThreshold);
287 AdcBasePtr->THRHLR[RegisterNumber] = Value;
288
289 #else /* ADC_SAR_IP_HAS_THRHLR_ARRAY == 0 */
290
291 uint32 Value = ADC_THRHLR0_THRH(HighThreshold) |
292 ADC_THRHLR0_THRL(LowThreshold);
293 switch (RegisterNumber)
294 {
295 case 0:
296 *THRHLR0Addr = Value;
297 break;
298 case 1:
299 *THRHLR1Addr = Value;
300 break;
301 case 2:
302 *THRHLR2Addr = Value;
303 break;
304 case 3:
305 *THRHLR3Addr = Value;
306 break;
307 case 4:
308 *THRHLR4Addr = Value;
309 break;
310 case 5:
311 *THRHLR5Addr = Value;
312 break;
313 #if ((ADC_SAR_IP_THRHLR_COUNT > 6U) || FEATURE_ADC_HAS_APPLICATION_EXTENSION)
314 case 6:
315 *THRHLR6Addr = Value;
316 break;
317 case 7:
318 *THRHLR7Addr = Value;
319 break;
320 #if ((ADC_SAR_IP_THRHLR_COUNT > 8U) || FEATURE_ADC_HAS_APPLICATION_EXTENSION)
321 case 8:
322 *THRHLR8Addr = Value;
323 break;
324 case 9:
325 *THRHLR9Addr = Value;
326 break;
327 case 10:
328 *THRHLR10Addr = Value;
329 break;
330 case 11:
331 *THRHLR11Addr = Value;
332 break;
333 #if ((ADC_SAR_IP_THRHLR_COUNT > 12U) || FEATURE_ADC_HAS_APPLICATION_EXTENSION)
334 case 12:
335 *THRHLR12Addr = Value;
336 break;
337 case 13:
338 *THRHLR13Addr = Value;
339 break;
340 case 14:
341 *THRHLR14Addr = Value;
342 break;
343 case 15:
344 *THRHLR15Addr = Value;
345 break;
346 #endif /* ((ADC_SAR_IP_THRHLR_COUNT > 12U) || ...) */
347 #endif /* ((ADC_SAR_IP_THRHLR_COUNT > 8U) || ...) */
348 #endif /* ((ADC_SAR_IP_THRHLR_COUNT > 6U) || ...) */
349 default:
350 ; /* no-op */
351 break;
352 }
353 #endif /* ADC_SAR_IP_HAS_THRHLR_ARRAY */
354 }
355
356 #if (ADC_SAR_IP_HAS_CWSELR_UNROLLED == 1u)
357 /*FUNCTION*********************************************************************
358 *
359 * Function Name : Adc_Sar_GetChannelWatchdogAddress
360 * Description : Returns the address of the specified CWSELR register
361 *
362 *END*************************************************************************/
Adc_Sar_GetChannelWatchdogAddress(const uint32 Instance,const uint32 RegisterNumber)363 static inline volatile uint32 * Adc_Sar_GetChannelWatchdogAddress(const uint32 Instance,
364 const uint32 RegisterNumber)
365 {
366 ADC_Type * AdcBasePtr = NULL_PTR;
367 #if FEATURE_ADC_HAS_APPLICATION_EXTENSION
368 SAR_ADC_AE_Type * AdcAEBasePtr = NULL_PTR;
369 #endif /* FEATURE_ADC_HAS_APPLICATION_EXTENSION */
370 volatile uint32 * CwselrAddr = NULL_PTR;
371 #if (ADC_SAR_IP_HAS_CWSELR0 || FEATURE_ADC_HAS_APPLICATION_EXTENSION)
372 volatile uint32 * CWSELR0Addr = NULL_PTR;
373 #endif /* (ADC_SAR_IP_HAS_CWSELR0 || FEATURE_ADC_HAS_APPLICATION_EXTENSION) */
374 #if (ADC_SAR_IP_HAS_CWSELR1 || FEATURE_ADC_HAS_APPLICATION_EXTENSION)
375 volatile uint32 * CWSELR1Addr = NULL_PTR;
376 #endif /* (ADC_SAR_IP_HAS_CWSELR1 || FEATURE_ADC_HAS_APPLICATION_EXTENSION) */
377 #if (ADC_SAR_IP_HAS_CWSELR2 || FEATURE_ADC_HAS_APPLICATION_EXTENSION)
378 volatile uint32 * CWSELR2Addr = NULL_PTR;
379 #endif /* (ADC_SAR_IP_HAS_CWSELR2 || FEATURE_ADC_HAS_APPLICATION_EXTENSION) */
380
381 #if FEATURE_ADC_HAS_APPLICATION_EXTENSION
382 if (Instance >= ADC_INSTANCE_COUNT)
383 {
384 AdcAEBasePtr = Adc_Sar_AE_Ip_apxAdcBase[Instance - ADC_INSTANCE_COUNT];
385 CWSELR0Addr = &(AdcAEBasePtr->CWSELR0);
386 CWSELR1Addr = &(AdcAEBasePtr->CWSELR1);
387 CWSELR2Addr = &(AdcAEBasePtr->CWSELR2);
388 }
389 else
390 #endif /* FEATURE_ADC_HAS_APPLICATION_EXTENSION */
391 {
392 AdcBasePtr = Adc_Sar_Ip_apxAdcBase[Instance];
393 #if ADC_SAR_IP_HAS_CWSELR0
394 CWSELR0Addr = &(AdcBasePtr->CWSELR0);
395 #endif /* ADC_SAR_IP_HAS_CWSELR0 */
396 #if ADC_SAR_IP_HAS_CWSELR1
397 CWSELR1Addr = &(AdcBasePtr->CWSELR1);
398 #endif /* ADC_SAR_IP_HAS_CWSELR1 */
399 #if ADC_SAR_IP_HAS_CWSELR2
400 CWSELR2Addr = &(AdcBasePtr->CWSELR2);
401 #endif /* ADC_SAR_IP_HAS_CWSELR2 */
402 }
403
404 switch (RegisterNumber)
405 {
406 #if (ADC_SAR_IP_HAS_CWSELR0 || FEATURE_ADC_HAS_APPLICATION_EXTENSION)
407 case 0u:
408 CwselrAddr = CWSELR0Addr;
409 break;
410 #endif /* (ADC_SAR_IP_HAS_CWSELR0 || FEATURE_ADC_HAS_APPLICATION_EXTENSION) */
411 #if (ADC_SAR_IP_HAS_CWSELR1 || FEATURE_ADC_HAS_APPLICATION_EXTENSION)
412 case 1u:
413 CwselrAddr = CWSELR1Addr;
414 break;
415 #endif /* (ADC_SAR_IP_HAS_CWSELR1 || FEATURE_ADC_HAS_APPLICATION_EXTENSION) */
416 #if (ADC_SAR_IP_HAS_CWSELR2 || FEATURE_ADC_HAS_APPLICATION_EXTENSION)
417 case 2u:
418 CwselrAddr = CWSELR2Addr;
419 break;
420 #endif /* (ADC_SAR_IP_HAS_CWSELR2 || FEATURE_ADC_HAS_APPLICATION_EXTENSION) */
421 #if ADC_SAR_IP_HAS_CWSELR3
422 case 3u:
423 CwselrAddr = &(AdcBasePtr->CWSELR3);
424 break;
425 #endif /* ADC_SAR_IP_HAS_CWSELR3 */
426 #if ADC_SAR_IP_HAS_CWSELR4
427 case 4u:
428 CwselrAddr = &(AdcBasePtr->CWSELR4);
429 break;
430 #endif /* ADC_SAR_IP_HAS_CWSELR4 */
431 #if ADC_SAR_IP_HAS_CWSELR5
432 case 5u:
433 CwselrAddr = &(AdcBasePtr->CWSELR5);
434 break;
435 #endif /* ADC_SAR_IP_HAS_CWSELR5 */
436 #if ADC_SAR_IP_HAS_CWSELR6
437 case 6u:
438 CwselrAddr = &(AdcBasePtr->CWSELR6);
439 break;
440 #endif /* ADC_SAR_IP_HAS_CWSELR6 */
441 #if ADC_SAR_IP_HAS_CWSELR7
442 case 7u:
443 CwselrAddr = &(AdcBasePtr->CWSELR7);
444 break;
445 #endif /* ADC_SAR_IP_HAS_CWSELR7 */
446 #if ADC_SAR_IP_HAS_CWSELR8
447 case 8u:
448 CwselrAddr = &(AdcBasePtr->CWSELR8);
449 break;
450 #endif /* ADC_SAR_IP_HAS_CWSELR8 */
451 #if ADC_SAR_IP_HAS_CWSELR9
452 case 9u:
453 CwselrAddr = &(AdcBasePtr->CWSELR9);
454 break;
455 #endif /* ADC_SAR_IP_HAS_CWSELR9 */
456 #if ADC_SAR_IP_HAS_CWSELR10
457 case 10u:
458 CwselrAddr = &(AdcBasePtr->CWSELR10);
459 break;
460 #endif /* ADC_SAR_IP_HAS_CWSELR10 */
461 #if ADC_SAR_IP_HAS_CWSELR11
462 case 11u:
463 CwselrAddr = &(AdcBasePtr->CWSELR11);
464 break;
465 #endif /* ADC_SAR_IP_HAS_CWSELR11 */
466 default:
467 ; /* the RegisterNumber does not exist */
468 #if (ADC_SAR_IP_DEV_ERROR_DETECT == STD_ON)
469 DevAssert(FALSE);
470 #endif /* (ADC_SAR_IP_DEV_ERROR_DETECT == STD_ON) */
471 break;
472 }
473
474 return CwselrAddr;
475 }
476 #endif /* ADC_SAR_IP_HAS_CWSELR_UNROLLED == 1 */
477
478 #if (STD_ON == ADC_SAR_IP_WDG_ENABLED)
479 /*FUNCTION*********************************************************************
480 *
481 * Function Name : Adc_Sar_WriteChannelMapping
482 * Description :
483 *
484 *END*************************************************************************/
Adc_Sar_WriteChannelMapping(const uint32 Instance,const uint32 RegisterNumber,const uint32 FieldPosition,const uint32 Value)485 static inline void Adc_Sar_WriteChannelMapping(const uint32 Instance,
486 const uint32 RegisterNumber,
487 const uint32 FieldPosition,
488 const uint32 Value)
489 {
490 uint32 CwselrVal;
491 uint32 CwselrMask;
492 uint32 CwselrShift;
493
494 #if (ADC_SAR_IP_HAS_CWSELR_UNROLLED == 1u)
495 volatile uint32 * Cwselr = Adc_Sar_GetChannelWatchdogAddress(Instance, RegisterNumber);
496
497 /* Each CWSELR register contains 8 watchdog selections according to 8 channels
498 Each watchdog selection possibly needs maximum 4 bits for setting */
499 CwselrShift = FieldPosition * ADC_CWSELR0_WSEL_CH1_SHIFT;
500 CwselrMask = (uint32)ADC_CWSELR0_WSEL_CH0_MASK << CwselrShift;
501 CwselrVal = (*Cwselr) & (~CwselrMask);
502 CwselrVal |= ADC_CWSELR0_WSEL_CH0(Value) << CwselrShift;
503 *Cwselr = CwselrVal;
504 #else /* ADC_SAR_IP_HAS_CWSELR_UNROLLED == 0 */
505 ADC_Type * const AdcBasePtr = Adc_Sar_Ip_apxAdcBase[Instance];
506
507 CwselrShift = FieldPosition * ADC_CWSELR_WSEL_CH1_SHIFT;
508 CwselrMask = (uint32)ADC_CWSELR_WSEL_CH0_MASK << CwselrShift;
509 CwselrVal = CWSELR(AdcBasePtr, RegisterNumber) & (~CwselrMask);
510 CwselrVal |= ADC_CWSELR_WSEL_CH0(Value) << CwselrShift;
511 CWSELR(AdcBasePtr, RegisterNumber) = CwselrVal;
512 #endif /* (ADC_SAR_IP_HAS_CWSELR_UNROLLED == 1u) */
513 }
514 #endif /* (STD_ON == ADC_SAR_IP_WDG_ENABLED) */
515
Adc_Sar_ResetWdogCWSELR(const uint32 Instance,const uint8 RegisterNumber)516 static inline void Adc_Sar_ResetWdogCWSELR(const uint32 Instance, const uint8 RegisterNumber)
517 {
518 #if (ADC_SAR_IP_HAS_CWSELR_UNROLLED == 1u)
519 volatile uint32 * Cwselr = Adc_Sar_GetChannelWatchdogAddress(Instance, (uint32)RegisterNumber);
520
521 *Cwselr = 0U;
522 #else /* ADC_SAR_IP_HAS_CWSELR_UNROLLED == 0 */
523 ADC_Type * const AdcBasePtr = Adc_Sar_Ip_apxAdcBase[Instance];
524
525 CWSELR(AdcBasePtr, RegisterNumber) = 0u;
526 #endif /* (ADC_SAR_IP_HAS_CWSELR_UNROLLED == 1u) */
527 }
528
529 #define ADC_STOP_SEC_CODE
530 #include "Adc_MemMap.h"
531
532 #ifdef __cplusplus
533 }
534 #endif
535
536 /** @} */
537
538 #endif /* ADC_SAR_IP_HW_ACCESS_H */
539