iLLD_TC27xD
1.0
IfxVadc_Adc.h
Go to the documentation of this file.
1
/**
2
* \file IfxVadc_Adc.h
3
* \brief VADC ADC details
4
* \ingroup IfxLld_Vadc
5
*
6
* \version iLLD_1_0_0_11_0
7
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
8
*
9
*
10
* IMPORTANT NOTICE
11
*
12
*
13
* Infineon Technologies AG (Infineon) is supplying this file for use
14
* exclusively with Infineon's microcontroller products. This file can be freely
15
* distributed within development tools that are supporting such microcontroller
16
* products.
17
*
18
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
19
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
20
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
21
* INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
22
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
23
*
24
* \defgroup IfxLld_Vadc_Adc_Usage How to use the VADC ADC Interface driver?
25
* \ingroup IfxLld_Vadc
26
*
27
* VADC comprises of independent analog channels with Analog/Digital converters to convert analog input to discrete digital output.
28
*
29
* In the following sections it will be described, how to integrate the driver into the application framework.
30
*
31
* \section IfxLld_Vadc_Adc_Preparation Preparation
32
* \subsection IfxLld_Vadc_Adc_Include Include Files
33
*
34
* Include following header file into your C code:
35
* \code
36
*
37
* #include <Vadc/Adc/IfxVadc_Adc.h>
38
*
39
* \endcode
40
*
41
* \subsection IfxLld_Vadc_Adc_Variables Variables
42
* \code
43
*
44
* // VADC handle
45
* IfxVadc_Adc vadc;
46
* IfxVadc_Adc_Group adcGroup;
47
* \endcode
48
*
49
* \subsection IfxLld_Vadc_Adc_ModuleInitialisation Module Initialisation
50
* The module initialisation can be done in the same function:
51
* \code
52
* // create configuration
53
* IfxVadc_Adc_Config adcConfig;
54
* IfxVadc_Adc_initModuleConfig(&adcConfig, &MODULE_VADC);
55
*
56
* // initialize module
57
* // IfxVadc_Adc vadc; // declared globally
58
* IfxVadc_Adc_initModule(&vadc, &adcConfig);
59
* \endcode
60
*
61
*
62
* \subsection IfxLld_Vadc_Adc_GroupInitialisation Group Initialisation
63
* The group initialisation can be done in the same function:
64
* \code
65
* // create group config
66
* IfxVadc_Adc_GroupConfig adcGroupConfig;
67
* IfxVadc_Adc_initGroupConfig(&adcGroupConfig, &vadc);
68
*
69
* // change group (default is GroupId_0, change to GroupId_3)
70
* adcGroupConfig.groupId = IfxVadc_GroupId_3;
71
*
72
* // IMPORTANT: usually we use the same group as master!
73
* adcGroupConfig.master = adcGroupConfig.groupId;
74
*
75
* // enable all arbiter request sources
76
* adcGroupConfig.arbiter.requestSlotQueueEnabled = TRUE; // enable Queue mode
77
* adcGroupConfig.arbiter.requestSlotScanEnabled = TRUE; // enable Scan mode
78
* adcGroupConfig.arbiter.requestSlotBackgroundScanEnabled = TRUE; // enable Background scan
79
*
80
* // enable all gates in "always" mode (no edge detection)
81
* adcGroupConfig.queueRequest.triggerConfig.gatingMode = IfxVadc_GatingMode_always;
82
* adcGroupConfig.scanRequest.triggerConfig.gatingMode = IfxVadc_GatingMode_always;
83
* adcGroupConfig.backgroundScanRequest.triggerConfig.gatingMode = IfxVadc_GatingMode_always;
84
*
85
* // enable auto scan
86
* adcGroupConfig.scanRequest.autoscanEnabled = TRUE;
87
* adcGroupConfig.backgroundScanRequest.autoBackgroundScanEnabled = TRUE;
88
*
89
* // initialize the group
90
* IfxVadc_Adc_initGroup(&adcGroup, &adcGroupConfig);
91
* \endcode
92
*
93
* \subsection IfxLld_Vadc_Adc_QueuedTransfers Queued Transfers
94
* Now, VADC is initialised. Here,Three channels are used for queued transfers
95
* \code
96
* // IMPORTANT: for deterministic results we have to disable the queue gate
97
* // while filling the queue, otherwise results could be output in the wrong order
98
* IfxVadc_GatingMode savedGate = IfxVadc_getQueueSlotGatingMode(adcGroup.group);
99
* IfxVadc_GatingSource gatingSource=IfxVadc_getQueueSlotGatingSource(adcGroup.group);
100
*
101
* IfxVadc_setQueueSlotGatingConfig(adcGroup.group, gatingSource, IfxVadc_GatingMode_disabled );
102
* // create channel config
103
* IfxVadc_Adc_ChannelConfig adcChannelConfig[3];
104
* IfxVadc_Adc_Channel adcChannel[3];
105
*
106
* for(int chnIx=0; chnIx<3; ++chnIx) {
107
* IfxVadc_Adc_initChannelConfig(&adcChannelConfig[chnIx], &adcGroup);
108
*
109
* adcChannelConfig[chnIx].channelId = (IfxVadc_ChannelId)(chnIx);
110
* adcChannelConfig[chnIx].resultRegister = IfxVadc_ChannelResult_1; // use result register #1 for all channels
111
*
112
* // initialize the channel
113
* IfxVadc_Adc_initChannel(&adcChannel[chnIx], &adcChannelConfig[chnIx]);
114
*
115
* // Add channel to queue with refill enabled
116
* IfxVadc_Adc_addToQueue(&adcChannel[chnIx], IFXVADC_QUEUE_REFILL);
117
*
118
* // restore previous gate config
119
*
120
* IfxVadc_setQueueSlotGatingConfig(adcGroup.group, gatingSource, savedGate );
121
*
122
* // start the Queue
123
* IfxVadc_Adc_startQueue(&adcGroup); // just for the case that somebody copy&pastes the code - the queue has already been started in previous test
124
*
125
* // get 10 results for all 3 channels and store in temporary buffer
126
* // (the usage of a buffer is required, since the print statements used by the checks take more time than the conversions)
127
* Ifx_VADC_RES resultTrace[3*10];
128
* for(int i=0; i<3*10; ++i)
129
* {
130
* unsigned chnIx = i % 3;
131
*
132
* // wait for valid result
133
* Ifx_VADC_RES conversionResult;
134
* do {
135
* conversionResult = IfxVadc_Adc_getResult(&adcChannel[chnIx]);
136
* } while( !conversionResult.B.VF );
137
*
138
* // store result
139
* resultTrace[i] = conversionResult;
140
* }
141
*
142
* // stop the queue
143
* IfxVadc_Adc_clearQueue(&adcGroup);
144
*
145
* // check results in buffer
146
* // ...
147
* }
148
* \endcode
149
*
150
* \subsection IfxLld_Vadc_Adc_AutoScan Auto Scan
151
* Autoscan of 5 channels
152
* \code
153
* // create group config
154
* IfxVadc_Adc_GroupConfig adcGroupConfig;
155
* IfxVadc_Adc_initGroupConfig(&adcGroupConfig, &vadc);
156
*
157
* // change group (default is GroupId_0, change to GroupId_3)
158
* adcGroupConfig.groupId = IfxVadc_GroupId_3;
159
*
160
* // IMPORTANT: usually we use the same group as master!
161
* adcGroupConfig.master = adcGroupConfig.groupId;
162
*
163
* // enable gate in "always" mode (no edge detection)
164
* adcGroupConfig.scanRequest.triggerConfig.gatingMode = IfxVadc_GatingMode_always;
165
*
166
* // enable auto scan
167
* adcGroupConfig.arbiter.requestSlotScanEnabled = TRUE;
168
* adcGroupConfig.scanRequest.autoscanEnabled = TRUE;
169
*
170
* // initialize the group
171
* //IfxVadc_Adc_Group adcGroup; // no need to create a new one
172
* IfxVadc_Adc_initGroup(&adcGroup, &adcGroupConfig);
173
*
174
* {
175
* // create channel config
176
* IfxVadc_Adc_ChannelConfig adcChannelConfig[5];
177
* IfxVadc_Adc_Channel adcChannel[5];
178
*
179
* for(int chnIx=0; chnIx<5; ++chnIx) {
180
* IfxVadc_Adc_initChannelConfig(&adcChannelConfig[chnIx], &adcGroup);
181
*
182
* adcChannelConfig[chnIx].channelId = (IfxVadc_ChannelId)(chnIx);
183
* adcChannelConfig[chnIx].resultRegister = (IfxVadc_ChannelResult)(chnIx); // use dedicated result register
184
*
185
* // initialize the channel
186
* IfxVadc_Adc_initChannel(&adcChannel[chnIx], &adcChannelConfig[chnIx]);
187
*
188
* // add to scan
189
* unsigned channels = (1 << adcChannelConfig[chnIx].channelId);
190
* unsigned mask = channels;
191
* IfxVadc_Adc_setScan(&adcGroup, channels, mask);
192
* }
193
*
194
* // start scan
195
* IfxVadc_Adc_startScan(&adcGroup);
196
*
197
* // check results
198
* for(int chnIx=0; chnIx<5; ++chnIx) {
199
* unsigned group = adcChannel[chnIx].group->groupId;
200
* unsigned channel = adcChannel[chnIx].channel;
201
*
202
* // wait for valid result
203
* Ifx_VADC_RES conversionResult;
204
* do {
205
* conversionResult = IfxVadc_Adc_getResult(&adcChannel[chnIx]);
206
* } while( !conversionResult.B.VF );
207
*
208
*
209
* }
210
* }
211
* \endcode
212
*
213
* \subsection IfxLld_Vadc_Adc_BackGroundScan Background Scan
214
* Background Scan of 2 channels
215
*
216
* \code
217
* // create group config
218
* IfxVadc_Adc_GroupConfig adcGroupConfig;
219
* IfxVadc_Adc_initGroupConfig(&adcGroupConfig, &vadc);
220
*
221
* // change group (default is GroupId_0, change to GroupId_3)
222
* adcGroupConfig.groupId = IfxVadc_GroupId_3;
223
*
224
* // IMPORTANT: usually we use the same group as master!
225
* adcGroupConfig.master = adcGroupConfig.groupId;
226
*
227
* // enable background scan
228
* adcGroupConfig.arbiter.requestSlotBackgroundScanEnabled = TRUE;
229
* adcGroupConfig.backgroundScanRequest.autoBackgroundScanEnabled = TRUE;
230
*
231
* // enable gate in "always" mode (no edge detection)
232
* adcGroupConfig.backgroundScanRequest.triggerConfig.gatingMode = IfxVadc_GatingMode_always;
233
*
234
* // create channel config
235
* IfxVadc_Adc_ChannelConfig adcChannelConfig[2];
236
* IfxVadc_Adc_Channel adcChannel[2];
237
*
238
* for(int chnIx=0; chnIx<2; ++chnIx)
239
* {
240
* IfxVadc_Adc_initChannelConfig(&adcChannelConfig[chnIx], &adcGroup);
241
*
242
* adcChannelConfig[chnIx].channelId = (IfxVadc_ChannelId)(chnIx + 5);
243
* adcChannelConfig[chnIx].resultRegister = (IfxVadc_ChannelResult)(5 + chnIx); // use register #5 and 6 for results
244
* adcChannelConfig[chnIx].backgroundChannel = TRUE;
245
*
246
* // initialize the channel
247
* IfxVadc_Adc_initChannel(&adcChannel[chnIx], &adcChannelConfig[chnIx]);
248
*
249
* // add to background scan
250
* unsigned channels = (1 << adcChannelConfig[chnIx].channelId);
251
* unsigned mask = channels;
252
* IfxVadc_Adc_setBackgroundScan(&vadc, &adcGroup, channels, mask);
253
* }
254
*
255
* // start autoscan
256
* IfxVadc_Adc_startBackgroundScan(&vadc);
257
*
258
* // check results
259
* for(int chnIx=0; chnIx<2; ++chnIx)
260
* {
261
* unsigned group = adcChannel[chnIx].group->groupId;
262
* unsigned channel = adcChannel[chnIx].channel;
263
*
264
* // wait for valid result
265
* Ifx_VADC_RES conversionResult;
266
* do
267
* {
268
* conversionResult = IfxVadc_Adc_getResult(&adcChannel[chnIx]);
269
* } while( !conversionResult.B.VF );
270
*
271
* // check with expected value
272
* // ...
273
* }
274
* \endcode
275
*
276
* \subsection IfxLld_Vadc_Adc_EmuxConfiguration External Multiplexer Configuration
277
* External Configuration of 3 channels at channel 3
278
*
279
* \code
280
*
281
* IfxVadc_Adc_EmuxControl emuxConfig;
282
*
283
* IfxVadc_Adc_initExternalMultiplexerModeConfig(&emuxConfig,vadc);
284
*
285
* emuxConfig.groupId = IfxVadc_GroupId_1;
286
* emuxConfig.channels = (uint8)IfxVadc_ChannelId_3;
287
* emuxConfig.startChannel = IfxVadc_EmuxSelectValue_2; // it will take 0 to 2 external channel
288
*
289
* emuxConfig.sampleTimeControl = IfxVadc_EmuxSampleTimeControl_always;
290
* emuxConfig.mode = IfxVadc_ExternalMultiplexerMode_steady;
291
*
292
* IfxVadc_Adc_EmuxPinConfig pinsConfig ={
293
* .pins={ &IfxVadc_EMUX00_P02_6_OUT,
294
* &IfxVadc_EMUX01_P02_7_OUT,
295
* &IfxVadc_EMUX02_P02_8_OUT},
296
*
297
*
298
* .outputMode = IfxPort_OutputMode_pushPull,
299
* .padDriver = IfxPort_PadDriver_cmosAutomotiveSpeed1
300
* };
301
* emuxConfig.emuxOutPinConfig = pinsConfig;
302
*
303
* IfxVadc_Adc_initExternalMultiplexerMode(vadc, &emuxConfig);
304
*
305
* IfxVadc_setEmuxGroupResolution(&vadc->G[emuxConfig.groupId], 0, IfxVadc_ChannelResolution_12bit);
306
* IfxVadc_setEmuxGroupSampletime(&vadc->G[emuxConfig.groupId], 0, 50000, 1.0e-6);
307
*
308
* \endcode
309
*
310
* \defgroup IfxLld_Vadc_Adc Interface Driver
311
* \ingroup IfxLld_Vadc
312
* \defgroup IfxLld_Vadc_Adc_DataStructures Data Structures
313
* \ingroup IfxLld_Vadc_Adc
314
* \defgroup IfxLld_Vadc_Adc_Module Module Functions
315
* \ingroup IfxLld_Vadc_Adc
316
* \defgroup IfxLld_Vadc_Adc_Group Group Functions
317
* \ingroup IfxLld_Vadc_Adc
318
* \defgroup IfxLld_Vadc_Adc_Channel Channel Functions
319
* \ingroup IfxLld_Vadc_Adc
320
* \defgroup IfxLld_Vadc_Adc_Background_Autoscan Background Autoscan Functions
321
* \ingroup IfxLld_Vadc_Adc
322
* \defgroup IfxLld_Vadc_Adc_ChannelScan Channel Scan Functions
323
* \ingroup IfxLld_Vadc_Adc
324
* \defgroup IfxLld_Vadc_Adc_Queue Queue Functions
325
* \ingroup IfxLld_Vadc_Adc
326
* \defgroup IfxLld_Vadc_Adc_Clock Clock Functions
327
* \ingroup IfxLld_Vadc_Adc
328
* \defgroup IfxLld_Vadc_Adc_Interrupt Interrupt Functions
329
* \ingroup IfxLld_Vadc_Adc
330
* \defgroup IfxLld_Vadc_Adc_Variables Variables
331
* \ingroup IfxLld_Vadc_Adc
332
* \defgroup IfxLld_Vadc_Adc_Emux Emux Functions
333
* \ingroup IfxLld_Vadc_Adc
334
*/
335
336
#ifndef IFXVADC_ADC_H
337
#define IFXVADC_ADC_H 1
338
339
/******************************************************************************/
340
/*----------------------------------Includes----------------------------------*/
341
/******************************************************************************/
342
343
#include "
Vadc/Std/IfxVadc.h
"
344
#include "
_Utilities/Ifx_Assert.h
"
345
346
/******************************************************************************/
347
/*------------------------------Type Definitions------------------------------*/
348
/******************************************************************************/
349
350
typedef
uint8
IfxVadc_Adc_SYNCTR_STSEL
;
351
352
/******************************************************************************/
353
/*-----------------------------Data Structures--------------------------------*/
354
/******************************************************************************/
355
356
/** \addtogroup IfxLld_Vadc_Adc_DataStructures
357
* \{ */
358
/** \brief VADC handle data structure
359
*/
360
typedef
struct
361
{
362
Ifx_VADC *
vadc
;
/**< \brief Specifies the pointer to the VADC module registers */
363
}
IfxVadc_Adc
;
364
365
/** \brief Gating/Trigger configuration structure
366
*/
367
typedef
struct
368
{
369
IfxVadc_GatingSource
gatingSource
;
/**< \brief Specifies used gate input for group */
370
IfxVadc_TriggerSource
triggerSource
;
/**< \brief Specifies used Trigger input for group */
371
IfxVadc_GatingMode
gatingMode
;
/**< \brief Specifies gating mode. High level, Low Level or Gating disabled */
372
IfxVadc_TriggerMode
triggerMode
;
/**< \brief Specifies trigger mode. Rising, falling any edge leads to an trigger event */
373
}
IfxVadc_Adc_GatingTriggerConfig
;
374
375
/** \} */
376
377
/** \addtogroup IfxLld_Vadc_Adc_DataStructures
378
* \{ */
379
/** \brief Arbiter configuration structure.
380
*/
381
typedef
struct
382
{
383
IfxVadc_ArbitrationRounds
arbiterRoundLength
;
/**< \brief Specifies arbiter round length. */
384
boolean
requestSlotQueueEnabled
;
/**< \brief request queue if enabled. */
385
boolean
requestSlotScanEnabled
;
/**< \brief request scan if enabled. */
386
boolean
requestSlotBackgroundScanEnabled
;
/**< \brief request background scan if enabled. */
387
}
IfxVadc_Adc_ArbiterConfig
;
388
389
/** \brief Background scan mode configuration structure.
390
*/
391
typedef
struct
392
{
393
boolean
autoBackgroundScanEnabled
;
/**< \brief background autoscan functionality enable or disable. */
394
IfxVadc_Adc_GatingTriggerConfig
triggerConfig
;
/**< \brief trigger and gating configuration. */
395
IfxVadc_RequestSlotPriority
requestSlotPrio
;
/**< \brief priority of used background scan request slot. */
396
IfxVadc_RequestSlotStartMode
requestSlotStartMode
;
/**< \brief start mode for request background scan source. */
397
}
IfxVadc_Adc_BackgroundScanConfig
;
398
399
/** \brief Input class configuration structure
400
*/
401
typedef
struct
402
{
403
float32
sampleTime
;
/**< \brief Specifies the requested sample time for input class */
404
IfxVadc_ChannelResolution
resolution
;
/**< \brief Specifies the conversion Mode 8,10,12Bit or 10bit fast compare */
405
}
IfxVadc_Adc_ClassConfig
;
406
407
/** \brief Group handle data structure
408
*/
409
typedef
struct
410
{
411
IfxVadc_Adc
module
;
/**< \brief The VADC handle structure */
412
Ifx_VADC_G *
group
;
/**< \brief Pointer to the group registers */
413
IfxVadc_GroupId
groupId
;
/**< \brief Specifies the group index */
414
}
IfxVadc_Adc_Group
;
415
416
/** \brief Queue configuration structure
417
*/
418
typedef
struct
419
{
420
boolean
flushQueueAfterInit
;
/**< \brief Specifies if the queue is flushed after configuration */
421
IfxVadc_Adc_GatingTriggerConfig
triggerConfig
;
/**< \brief trigger and gating configuration. */
422
IfxVadc_RequestSlotPriority
requestSlotPrio
;
/**< \brief priority of used queue request slot. */
423
IfxVadc_RequestSlotStartMode
requestSlotStartMode
;
/**< \brief start mode for request queue source. */
424
}
IfxVadc_Adc_QueueConfig
;
425
426
/** \brief Scan mode configuration structure.
427
*/
428
typedef
struct
429
{
430
boolean
autoscanEnabled
;
/**< \brief Specifies autoscan functionality. */
431
IfxVadc_Adc_GatingTriggerConfig
triggerConfig
;
/**< \brief Specifies trigger and gating configuration */
432
IfxVadc_RequestSlotPriority
requestSlotPrio
;
/**< \brief priority of used scan request slot. */
433
IfxVadc_RequestSlotStartMode
requestSlotStartMode
;
/**< \brief start mode for request scan source. */
434
}
IfxVadc_Adc_ScanConfig
;
435
436
/** \} */
437
438
typedef
struct
439
{
440
IfxVadc_Emux_Out
*pins[3];
/**< \brief Emux Pins configuration */
441
IfxPort_OutputMode
outputMode
;
/**< \brief the pin output mode which should be configured */
442
IfxPort_PadDriver
padDriver
;
/**< \brief Pad driver */
443
}
IfxVadc_Adc_EmuxPinConfig
;
444
445
/** \addtogroup IfxLld_Vadc_Adc_DataStructures
446
* \{ */
447
/** \brief Channel handle data structure
448
*/
449
typedef
struct
450
{
451
IfxVadc_ChannelId
channel
;
/**< \brief Specifies the channel index */
452
IfxVadc_ChannelResult
resultreg
;
/**< \brief Specifies allocated result register */
453
const
IfxVadc_Adc_Group
*
group
;
/**< \brief Specifies the group of the channel */
454
}
IfxVadc_Adc_Channel
;
455
456
/** \brief Channel configuration structure
457
*/
458
typedef
struct
459
{
460
boolean
globalResultUsage
;
/**< \brief Specifies storage in global result register */
461
boolean
synchonize
;
/**< \brief Specifies synchronized conversion channel */
462
boolean
backgroundChannel
;
/**< \brief Specifies channel is used as background channel */
463
boolean
rightAlignedStorage
;
/**< \brief Specifies result is right aligned */
464
Ifx_Priority
resultPriority
;
/**< \brief Interrupt priority of the result trigger interrupt, if 0 the interrupt is disable */
465
Ifx_Priority
channelPriority
;
/**< \brief Interrupt priority of the channel trigger interrupt, if 0 the interrupt is disable */
466
IfxSrc_Tos
resultServProvider
;
/**< \brief Interrupt service provider for the result trigger interrupt */
467
IfxSrc_Tos
channelServProvider
;
/**< \brief Interrupt service provider for the channel trigger interrupt */
468
IfxVadc_SrcNr
resultSrcNr
;
/**< \brief Service node of the result trigger */
469
IfxVadc_SrcNr
channelSrcNr
;
/**< \brief Service node of the channel trigger */
470
IfxVadc_ChannelId
channelId
;
/**< \brief Specifies the channel index */
471
IfxVadc_InputClasses
inputClass
;
/**< \brief Specifies input class selection */
472
IfxVadc_ChannelReference
reference
;
/**< \brief Specifies Reference selection */
473
IfxVadc_ChannelResult
resultRegister
;
/**< \brief Specifies Result register selection */
474
IfxVadc_BoundarySelection
lowerBoundary
;
/**< \brief Specifies lower boundary selection */
475
IfxVadc_BoundarySelection
upperBoundary
;
/**< \brief Specifies upper boundary selection */
476
IfxVadc_BoundaryExtension
boundaryMode
;
/**< \brief Specifies Standard mode of fast compare mode */
477
IfxVadc_LimitCheck
limitCheck
;
/**< \brief Specifies boundary band selection upper/lower */
478
const
IfxVadc_Adc_Group
*
group
;
/**< \brief Specifies pointer to the IfxVadc_Adc_Group group handle */
479
}
IfxVadc_Adc_ChannelConfig
;
480
481
/** \brief VADC module configuration structure
482
*/
483
typedef
struct
484
{
485
Ifx_VADC *
vadc
;
/**< \brief Specifies the pointer to the VADC module registers */
486
IfxVadc_Adc_ClassConfig
globalInputClass[
IFXVADC_NUM_GLOBAL_INPUTCLASSES
];
/**< \brief Specifies the global conversion settings one and two */
487
float32
digitalFrequency
;
/**< \brief Specifies digital ADC Frequency */
488
float32
analogFrequency
;
/**< \brief Specifies analog ADC Frequency */
489
float32
moduleFrequency
;
/**< \brief module Frequency in Hz. */
490
boolean
startupCalibration
;
/**< \brief Can be enabled to execute a startup calibration (disabled by default).
491
* Note that this option will also enable all converter groups.
492
* If this isn't desired, don't use this option, but execute IfxVadc_Adc_startupCalibration() after all ADC groups have been initialized. */
493
IfxVadc_LowSupplyVoltageSelect
supplyVoltage
;
/**< \brief Select Low Power Supply Voltage */
494
}
IfxVadc_Adc_Config
;
495
496
/** \brief Emux Control Structure
497
*/
498
typedef
struct
499
{
500
Ifx_VADC *
vadc
;
/**< \brief pointer to Module Configuration */
501
IfxVadc_ExternalMultiplexerMode
mode
;
/**< \brief Specifies the External Multiplexer mode */
502
IfxVadc_EmuxSelectValue
startChannel
;
/**< \brief specifies the external channel start value(EMUX[x:0])
503
* x- specifies external channel number */
504
IfxVadc_EmuxCodingScheme
code
;
/**< \brief specifes binary/gray code */
505
IfxVadc_EmuxSampleTimeControl
sampleTimeControl
;
/**< \brief specifies when to use sample time control */
506
IfxVadc_GroupId
groupId
;
/**< \brief specifies groupId */
507
uint8
channels
;
/**< \brief specifies channel number */
508
IfxVadc_EmuxInterface
emuxInterface
;
/**< \brief specifies the Emux interface */
509
IfxVadc_Adc_EmuxPinConfig
emuxOutPinConfig
;
/**< \brief configure the emux output pin */
510
IfxVadc_ChannelSelectionStyle
channelSelectionStyle
;
/**< \brief External Multiplexer Channel Selection Style */
511
}
IfxVadc_Adc_EmuxControl
;
512
513
/** \brief Group configuration structure
514
*/
515
typedef
struct
516
{
517
const
IfxVadc_Adc
*
module
;
/**< \brief Specifies pointer to the IfxVadc_Adc module handle */
518
IfxVadc_GroupId
groupId
;
/**< \brief Specifies the group/kernel id */
519
IfxVadc_GroupId
master
;
/**< \brief Specifies the master group. If master is different from groupId, then the group is configured as slave. */
520
IfxVadc_Adc_ClassConfig
inputClass[
IFXVADC_NUM_INPUTCLASSES
];
/**< \brief Specifies conversion settings one and two */
521
IfxVadc_Adc_ScanConfig
scanRequest
;
/**< \brief Specifies scan mode configuration */
522
IfxVadc_Adc_QueueConfig
queueRequest
;
/**< \brief Specifies queued mode configuration */
523
IfxVadc_Adc_BackgroundScanConfig
backgroundScanRequest
;
/**< \brief Specifies back ground scan configuration */
524
boolean
disablePostCalibration
;
/**< \brief Specifies if calibration after conversion (post calibration) should be disabled */
525
IfxVadc_Adc_ArbiterConfig
arbiter
;
/**< \brief Arbiter configuration structure. */
526
}
IfxVadc_Adc_GroupConfig
;
527
528
/** \} */
529
530
/** \addtogroup IfxLld_Vadc_Adc_Module
531
* \{ */
532
533
/******************************************************************************/
534
/*-------------------------Inline Function Prototypes-------------------------*/
535
/******************************************************************************/
536
537
/** \brief Reset the VADC module
538
* \param vadc pointer to the VADC module
539
* \return None
540
*
541
* Example Usage :\ref IfxLld_Vadc_Adc_Usage
542
*
543
*/
544
IFX_INLINE
void
IfxVadc_Adc_deInitModule
(
IfxVadc_Adc
*vadc);
545
546
/** \brief Get the current VADC configuration (e.g. VADC frequency)
547
* \param vadc pointer to the VADC module
548
* \param config pointer to the VADC module configuration
549
* \return None
550
*
551
* Example Usage :\ref IfxLld_Vadc_Adc_Usage
552
*
553
*/
554
IFX_INLINE
void
IfxVadc_Adc_getModuleConfig
(
IfxVadc_Adc
*vadc,
IfxVadc_Adc_Config
*config);
555
556
/** \brief Get conversion result based on the Request Source. (Function does not care about the alignment)
557
* value = raw * gain + offset
558
* \param group pointer to the VADC group
559
* \param channel channel number
560
* \param sourceType type of request source
561
* \return scaled Conversion result
562
*
563
* \code
564
* // create configuration
565
* IfxVadc_Adc_Config adcConfig;
566
* IfxVadc_Adc_initModuleConfig(&adcConfig, &MODULE_VADC);
567
*
568
* // initialize module
569
* IfxVadc_Adc vadc;
570
* IfxVadc_Adc_initModule(&vadc, &adcConfig);
571
*
572
* // create group config
573
* IfxVadc_Adc_GroupConfig adcGroupConfig;
574
* IfxVadc_Adc_initGroupConfig(&adcGroupConfig, &vadc);
575
*
576
* // change group (default is GroupId0, change to GroupId2)
577
* adcGroupConfig.groupId = IfxVadc_GroupId2;
578
* adcGroupConfig.master = adcGroupConfig.groupId;
579
*
580
* // enable gate in "always" mode (no edge detection)
581
* adcGroupConfig.scanRequest.triggerConfig.gatingMode = IfxVadc_GatingMode_always;
582
*
583
* // enable auto scan
584
* adcGroupConfig.arbiter.requestSlotScanEnabled = TRUE;
585
* adcGroupConfig.scanRequest.autoscanEnabled = TRUE;
586
*
587
* // initialize the group
588
* IfxVadc_Adc_Group adcGroup;
589
* IfxVadc_Adc_initGroup(&adcGroup, &adcGroupConfig);
590
*
591
* // create channel config
592
* IfxVadc_Adc_ChannelConfig adcChannelConfig;
593
* IfxVadc_Adc_initChannelConfig(&adcChannelConfig, &adcGroup);
594
*
595
* // change channel (default is ChannelId0, change to ChannelId2)
596
* adcChannelConfig.channelId = IfxVadc_ChannelId2;
597
*
598
* // initialize the channel
599
* IfxVadc_Adc_Channel adcChannel;
600
* IfxVadc_Adc_initChannel(&adcChannel, &adcChannelConfig);
601
*
602
* uint32 channels = (1 << 2); // enable channel #2
603
* uint32 mask = (1 << 7) | (1 << 2); // modify the selection for channel #7 and #2; channel #7 will be disabled
604
*
605
* // configure wait for read mode
606
* IfxVadc_Adc_configureWaitForReadMode(&adcChannel, TRUE);
607
*
608
* // configure scan
609
* IfxVadc_Adc_setScan(&adcGroup, channels, mask);
610
*
611
* // start the scan
612
* IfxVadc_Adc_startScan(&adcGroup);
613
*
614
* // wait for valid result
615
* Ifx_VADC_RES resultChannel;
616
* do {
617
* resultChannel = IfxVadc_Adc_getResultBasedOnRequestSource(&adcGroup, IfxVadc_ChannelId2, IfxVadc_RequestSource_scan);
618
* } while( !resultChannel.B.VF );
619
* \endcode
620
*
621
*/
622
IFX_INLINE
Ifx_VADC_RES
IfxVadc_Adc_getResultBasedOnRequestSource
(
IfxVadc_Adc_Group
*group,
IfxVadc_ChannelId
channel,
IfxVadc_RequestSource
sourceType);
623
624
/******************************************************************************/
625
/*-------------------------Global Function Prototypes-------------------------*/
626
/******************************************************************************/
627
628
/** \brief Disable VADC Module
629
* \param vadc Pointer to VADC Module
630
* \return None
631
*/
632
IFX_EXTERN
void
IfxVadc_Adc_disableModule
(Ifx_VADC *vadc);
633
634
/** \brief Initialise the VADC to run with the expected frequency and calibration
635
* \param vadc pointer to the VADC handle
636
* \param config pointer to the VADC configuration
637
* \return IfxVadc_Status
638
*
639
* For coding example see: \ref IfxLld_Vadc_Adc_Usage
640
*
641
*/
642
IFX_EXTERN
IfxVadc_Status
IfxVadc_Adc_initModule
(
IfxVadc_Adc
*vadc,
const
IfxVadc_Adc_Config
*config);
643
644
/** \brief Initialise buffer with default VADC configuration
645
* \param config pointer to the VADC module configuration
646
* \param vadc pointer to the VADC
647
* \return None
648
*
649
* For coding example see: \ref IfxLld_Vadc_Adc_Usage
650
*
651
*/
652
IFX_EXTERN
void
IfxVadc_Adc_initModuleConfig
(
IfxVadc_Adc_Config
*config, Ifx_VADC *vadc);
653
654
/** \} */
655
656
/** \addtogroup IfxLld_Vadc_Adc_Group
657
* \{ */
658
659
/******************************************************************************/
660
/*-------------------------Inline Function Prototypes-------------------------*/
661
/******************************************************************************/
662
663
/** \brief Gets the current group register set
664
* \param group Group handle data structure
665
* \return Group register set
666
*
667
* Ifx_VADC* vadc = &MODULE_VADC;
668
* Ifx_VADC_G* group = &MODULE_VADC.G[0]; // for group 0
669
*
670
* uint32 channels = (1 << 5) | (1 << 2); // enable channel #5 and #2
671
* uint32 mask = (1 << 7) | (1 << 5) | (1 << 2); // modify the selection for channel #7, #5 and #2; channel #7 will be disabled
672
*
673
* //confiure wait for read mode for global result register
674
* IfxVadc_configureWaitForReadMode(group,IfxVadc_ChannelResult0, TRUE);
675
* IfxVadc_configureWaitForReadMode(group,IfxVadc_ChannelResult1, TRUE);
676
*
677
* // configure scan
678
* IfxVadc_setScan(group, channels, mask);
679
*
680
* // enable auto scan
681
* IfxVadc_setAutoScan(group, TRUE);
682
*
683
* // start the scan
684
* IfxVadc_startScan(group);
685
*
686
* // wait for conversion to finish
687
*
688
* // fetch the 2 results of conversion for group 0
689
* Ifx_VADC_RES results[10];
690
* result = IfxVadc_getGroupResult(group, results, 0, 2);
691
*
692
*/
693
IFX_INLINE
Ifx_VADC_G *
IfxVadc_Adc_getGroupRegsFromGroup
(
const
IfxVadc_Adc_Group
*group);
694
695
/** \brief Get conversion result for the group
696
* \param group pointer to the VADC group
697
* \param results pointer to scaled conversion results
698
* \param resultOffset offset for the first result
699
* \param numResults number of results
700
* \return None
701
*
702
* \code
703
* // create configuration
704
* IfxVadc_Adc_Config adcConfig;
705
* IfxVadc_Adc_initModuleConfig(&adcConfig, &MODULE_VADC);
706
*
707
* // initialize module
708
* IfxVadc_Adc vadc;
709
* IfxVadc_Adc_initModule(&vadc, &adcConfig);
710
*
711
* // create group config
712
* IfxVadc_Adc_GroupConfig adcGroupConfig;
713
* IfxVadc_Adc_initGroupConfig(&adcGroupConfig, &vadc);
714
*
715
* // change group (default is GroupId0, change to GroupId2)
716
* adcGroupConfig.groupId = IfxVadc_GroupId2;
717
* adcGroupConfig.master = adcGroupConfig.groupId;
718
*
719
* // enable gate in "always" mode (no edge detection)
720
* adcGroupConfig.scanRequest.triggerConfig.gatingMode = IfxVadc_GatingMode_always;
721
*
722
* // enable auto scan
723
* adcGroupConfig.arbiter.requestSlotScanEnabled = TRUE;
724
* adcGroupConfig.scanRequest.autoscanEnabled = TRUE;
725
*
726
* // initialize the group
727
* IfxVadc_Adc_Group adcGroup;
728
* IfxVadc_Adc_initGroup(&adcGroup, &adcGroupConfig);
729
*
730
* // create channel config
731
* IfxVadc_Adc_ChannelConfig adcChannelConfig2;
732
* IfxVadc_Adc_initChannelConfig(&adcChannelConfig2, &adcGroup);
733
*
734
* // change channel (default is ChannelId0, change to ChannelId2)
735
* adcChannelConfig2.channelId = IfxVadc_ChannelId2;
736
*
737
* // initialize the channel
738
* IfxVadc_Adc_Channel adcChannel2;
739
* IfxVadc_Adc_initChannel(&adcChannel2, &adcChannelConfig2);
740
*
741
* // create channel config
742
* IfxVadc_Adc_ChannelConfig adcChannelConfig5;
743
* IfxVadc_Adc_initChannelConfig(&adcChannelConfig5, &adcGroup);
744
*
745
* // change channel (default is ChannelId0, change to ChannelId5)
746
* adcChannelConfig5.channelId = IfxVadc_ChannelId5;
747
* // change channel result register (default is ChannelResult0, change to ChannelResult1)
748
* adcChannelConfig5.resultRegister = IfxVadc_ChannelResult1;
749
*
750
* // initialize the channel
751
* IfxVadc_Adc_Channel adcChannel5;
752
* IfxVadc_Adc_initChannel(&adcChannel5, &adcChannelConfig5);
753
*
754
* uint32 channels = (1 << 5) | (1 << 2); // enable channel #5 and #2
755
* uint32 mask = (1 << 7) | (1 << 5) | (1 << 2); // modify the selection for channel #7, #5 and #2; channel #7 will be disabled
756
*
757
* // configure wait for read mode
758
* IfxVadc_Adc_configureWaitForReadMode(&adcChannel2, TRUE);
759
* IfxVadc_Adc_configureWaitForReadMode(&adcChannel5, TRUE);
760
*
761
* // configure scan
762
* IfxVadc_Adc_setScan(&adcGroup, channels, mask);
763
*
764
* // start the scan
765
* IfxVadc_Adc_startScan(&adcGroup);
766
*
767
* // wait for conversion to finish
768
* IfxVadc_Status scanStatus;
769
* do
770
* {
771
* scanStatus = IfxVadc_Adc_getScanStatus(&adcGroup);
772
* } while(scanStatus==IfxVadc_Status_ChannelsStillPending);
773
*
774
* // fetch the 2 results of conversion for group 0
775
* Ifx_VADC_RES results[10];
776
* IfxVadc_Adc_getGroupResult(&adcGroup, results, 0, 2);
777
* \endcode
778
*
779
*/
780
IFX_INLINE
void
IfxVadc_Adc_getGroupResult
(
IfxVadc_Adc_Group
*group, Ifx_VADC_RES *results,
uint32
resultOffset,
uint32
numResults);
781
782
/** \brief Gets the current group module register address
783
* \param group Group handle data structure
784
* \return Group module register base address
785
*/
786
IFX_INLINE
Ifx_VADC *
IfxVadc_Adc_getVadcFromGroup
(
const
IfxVadc_Adc_Group
*group);
787
788
/******************************************************************************/
789
/*-------------------------Global Function Prototypes-------------------------*/
790
/******************************************************************************/
791
792
/** \brief Reset the VADC group
793
* \param group pointer to the VADC group
794
* \return None
795
*
796
* Example Usage :\ref IfxLld_Vadc_Adc_Usage
797
*
798
*/
799
IFX_EXTERN
void
IfxVadc_Adc_deInitGroup
(
IfxVadc_Adc_Group
*group);
800
801
/** \brief Get the current group configuration (e.g. vadc frequency)
802
* \param group pointer to the VADC group
803
* \param config pointer to the VADC group configuration
804
* \return None
805
*
806
* Example Usage :\ref IfxLld_Vadc_Adc_Usage
807
*
808
*/
809
IFX_EXTERN
void
IfxVadc_Adc_getGroupConfig
(
IfxVadc_Adc_Group
*group,
IfxVadc_Adc_GroupConfig
*config);
810
811
/** \brief Initialise the VADC group (also autoscan and queue modes) Slave Groups must initialize first.
812
* \param group pointer to the VADC group
813
* \param config pointer to the VADC group configuration
814
* \return IfxVadc_Status
815
*
816
* For coding example see: \ref IfxLld_Vadc_Adc_Usage
817
*
818
*/
819
IFX_EXTERN
IfxVadc_Status
IfxVadc_Adc_initGroup
(
IfxVadc_Adc_Group
*group,
const
IfxVadc_Adc_GroupConfig
*config);
820
821
/** \brief Initialise buffer with default VADC configuration
822
* \param config pointer to the VADC group configuration
823
* \param vadc pointer to the VADC module
824
* \return None
825
*
826
* For coding example see: \ref IfxLld_Vadc_Adc_Usage
827
*
828
*/
829
IFX_EXTERN
void
IfxVadc_Adc_initGroupConfig
(
IfxVadc_Adc_GroupConfig
*config,
IfxVadc_Adc
*vadc);
830
831
/** \} */
832
833
/** \addtogroup IfxLld_Vadc_Adc_Channel
834
* \{ */
835
836
/******************************************************************************/
837
/*-------------------------Inline Function Prototypes-------------------------*/
838
/******************************************************************************/
839
840
/** \brief pointer to the VADC channel
841
* \param channel pointer to the VADC channel
842
* \param waitForRead wait for read mode enabled/disable
843
* \return None
844
*
845
* For coding example see: \ref IfxVadc_Adc_getGroupResult
846
*
847
*/
848
IFX_INLINE
void
IfxVadc_Adc_configureWaitForReadMode
(
IfxVadc_Adc_Channel
*channel,
boolean
waitForRead);
849
850
/** \brief Get conversion result (Function does not care about the alignment)
851
* \param channel pointer to the VADC channel
852
* \return scaled Conversion result
853
*
854
* For coding example see: \ref IfxLld_Vadc_Adc_Usage
855
*
856
*/
857
IFX_INLINE
Ifx_VADC_RES
IfxVadc_Adc_getResult
(
IfxVadc_Adc_Channel
*channel);
858
859
/******************************************************************************/
860
/*-------------------------Global Function Prototypes-------------------------*/
861
/******************************************************************************/
862
863
/** \brief Get the current channel configuration (e.g. sample settings)
864
* \param channel pointer to the VADC channel
865
* \param config pointer to the VADC channel configuration
866
* \return None
867
*
868
* Example Usage :\ref IfxLld_Vadc_Adc_Usage
869
*
870
*/
871
IFX_EXTERN
void
IfxVadc_Adc_getChannelConfig
(
IfxVadc_Adc_Channel
*channel,
IfxVadc_Adc_ChannelConfig
*config);
872
873
/** \brief get the channel Conversion Time
874
* \param channel Channel
875
* \param conversionMode specifies Compatible mode(Standard Conversion mode).
876
* \return channel conversion time in sec
877
*/
878
IFX_EXTERN
float32
IfxVadc_Adc_getChannelConversionTime
(
IfxVadc_Adc_Channel
*channel,
IfxVadc_ConversionType
conversionMode);
879
880
/** \brief Initialise one channel with given configuration
881
* \param channel pointer to the VADC channel
882
* \param config pointer to the VADC channel configuration
883
* \return IfxVadc_Status
884
*
885
* For coding example see: \ref IfxLld_Vadc_Adc_Usage
886
*
887
*/
888
IFX_EXTERN
IfxVadc_Status
IfxVadc_Adc_initChannel
(
IfxVadc_Adc_Channel
*channel,
const
IfxVadc_Adc_ChannelConfig
*config);
889
890
/** \brief Initialise buffer with default channel configuration
891
* \param config pointer to the VADC channel configuration
892
* \param group pointer to the VADC group
893
* \return None
894
*
895
* For coding example see: \ref IfxLld_Vadc_Adc_Usage
896
*
897
*/
898
IFX_EXTERN
void
IfxVadc_Adc_initChannelConfig
(
IfxVadc_Adc_ChannelConfig
*config,
const
IfxVadc_Adc_Group
*group);
899
900
/** \} */
901
902
/** \addtogroup IfxLld_Vadc_Adc_Background_Autoscan
903
* \{ */
904
905
/******************************************************************************/
906
/*-------------------------Inline Function Prototypes-------------------------*/
907
/******************************************************************************/
908
909
/** \brief access function to enable/disable wait for read mode for global result register
910
* \param vadc pointer to the VADC module
911
* \param waitForRead wait for read mode enabled/disabled
912
* \return None
913
*
914
* For coding example see: \ref IfxVadc_Adc_getGlobalResult
915
*
916
*/
917
IFX_INLINE
void
IfxVadc_Adc_configureWaitForReadModeForGlobalResultRegister
(
IfxVadc_Adc
*vadc,
boolean
waitForRead);
918
919
/** \brief Gives the background scan status for a group
920
* \param vadc pointer to the VADC module
921
* \return IfxVadc_Status
922
*/
923
IFX_INLINE
IfxVadc_Status
IfxVadc_Adc_getBackgroundScanStatus
(
IfxVadc_Adc
*vadc);
924
925
/** \brief returns result stored in global result register
926
* \param vadc pointer to the VADC module
927
* \return global result register
928
*
929
* \code
930
* // create configuration
931
* IfxVadc_Adc_Config adcConfig;
932
* IfxVadc_Adc_initModuleConfig(&adcConfig, &MODULE_VADC);
933
*
934
* // initialize module
935
* IfxVadc_Adc vadc;
936
* IfxVadc_Adc_initModule(&vadc, &adcConfig);
937
*
938
* // create group config
939
* IfxVadc_Adc_GroupConfig adcGroupConfig;
940
* IfxVadc_Adc_initGroupConfig(&adcGroupConfig, &vadc);
941
*
942
* // change group (default is GroupId_0, change to GroupId_3)
943
* adcGroupConfig.groupId = IfxVadc_GroupId_3;
944
*
945
* // IMPORTANT: usually we use the same group as master!
946
* adcGroupConfig.master = adcGroupConfig.groupId;
947
*
948
* // enable background scan
949
* adcGroupConfig.arbiter.requestSlotBackgroundScanEnabled = TRUE;
950
* adcGroupConfig.backgroundScanRequest.autoBackgroundScanEnabled = TRUE;
951
*
952
* // enable gate in "always" mode (no edge detection)
953
* adcGroupConfig.backgroundScanRequest.triggerConfig.gatingMode = IfxVadc_GatingMode_always;
954
*
955
* // initialize the group
956
* IfxVadc_Adc_Group adcGroup;
957
* IfxVadc_Adc_initGroup(&adcGroup, &adcGroupConfig);
958
*
959
* // create channel config
960
* IfxVadc_Adc_ChannelConfig adcChannelConfig2;
961
* IfxVadc_Adc_initChannelConfig(&adcChannelConfig2, &adcGroup);
962
* adcChannelConfig2.backgroundChannel = TRUE;
963
* adcChannelConfig2.globalResultUsage = TRUE;
964
*
965
* // change channel (default is ChannelId0, change to ChannelId2)
966
* adcChannelConfig2.channelId = IfxVadc_ChannelId2;
967
*
968
* // initialize the channel
969
* IfxVadc_Adc_Channel adcChannel2;
970
* IfxVadc_Adc_initChannel(&adcChannel2, &adcChannelConfig2);
971
*
972
* // create channel config
973
* IfxVadc_Adc_ChannelConfig adcChannelConfig5;
974
* IfxVadc_Adc_initChannelConfig(&adcChannelConfig5, &adcGroup);
975
* adcChannelConfig5.backgroundChannel = TRUE;
976
* adcChannelConfig5.globalResultUsage = TRUE;
977
*
978
* // change channel (default is ChannelId0, change to ChannelId5)
979
* adcChannelConfig5.channelId = IfxVadc_ChannelId5;
980
*
981
*
982
* // initialize the channel
983
* IfxVadc_Adc_Channel adcChannel5;
984
* IfxVadc_Adc_initChannel(&adcChannel5, &adcChannelConfig5);
985
*
986
* uint32 channels = (1 << 5) | (1 << 2); // enable channel #5 and #2
987
* uint32 mask = (1 << 7) | (1 << 5) | (1 << 2); // modify the selection for channel #7, #5 and #2; channel #7 will be disabled
988
*
989
* //configure wait for read mode
990
* IfxVadc_Adc_configureWaitForReadModeForGlobalResultRegister(&vadc, TRUE);
991
*
992
* // configure background scan
993
* IfxVadc_Adc_setBackgroundScan(&vadc, &adcGroupConfig, channels, mask);
994
*
995
* // start the background scan
996
* IfxVadc_Adc_startBackgroundScan(&vadc);
997
*
998
* // wait for valid result for channel 2
999
* Ifx_VADC_GLOBRES resultChannel2;
1000
* do {
1001
* resultChannel2 = IfxVadc_Adc_getGlobalResult(&vadc);
1002
* } while( !resultChannel2.B.VF );
1003
*
1004
* // wait for valid result for channel 5
1005
* Ifx_VADC_GLOBRES resultChannel5;
1006
* do {
1007
* resultChannel5 = IfxVadc_Adc_getGlobalResult(&vadc);
1008
* } while( !resultChannel5.B.VF );
1009
* \endcode
1010
*
1011
*/
1012
IFX_INLINE
Ifx_VADC_GLOBRES
IfxVadc_Adc_getGlobalResult
(
IfxVadc_Adc
*vadc);
1013
1014
/** \brief configures a background scan
1015
* \param vadc pointer to the VADC module
1016
* \param group pointer to the VADC group
1017
* \param channels specifies the channels which should be enabled/disabled
1018
* \param mask specifies the channels which should be modified
1019
* \return None
1020
*
1021
* For coding example see: \ref IfxLld_Vadc_Adc_Usage
1022
*
1023
*/
1024
IFX_INLINE
void
IfxVadc_Adc_setBackgroundScan
(
IfxVadc_Adc
*vadc,
IfxVadc_Adc_Group
*group,
uint32
channels,
uint32
mask);
1025
1026
/** \brief Starts a background scan
1027
* \param vadc pointer to the VADC module
1028
* \return None
1029
*
1030
* For coding example see: \ref IfxLld_Vadc_Adc_Usage
1031
*
1032
*/
1033
IFX_INLINE
void
IfxVadc_Adc_startBackgroundScan
(
IfxVadc_Adc
*vadc);
1034
1035
/** \} */
1036
1037
/** \addtogroup IfxLld_Vadc_Adc_ChannelScan
1038
* \{ */
1039
1040
/******************************************************************************/
1041
/*-------------------------Inline Function Prototypes-------------------------*/
1042
/******************************************************************************/
1043
1044
/** \brief Gives the scan status for a group.
1045
* \param group pointer to the VADC group
1046
* \return IfxVadc_Status
1047
*
1048
* For coding example see: \ref IfxVadc_Adc_getResultBasedOnRequestSource
1049
*
1050
*/
1051
IFX_INLINE
IfxVadc_Status
IfxVadc_Adc_getScanStatus
(
IfxVadc_Adc_Group
*group);
1052
1053
/** \brief Configures an autoscan.
1054
* \param group pointer to the VADC group
1055
* \param channels specifies the channels which should be enabled/disabled
1056
* \param mask specifies the channels which should be modified
1057
* \return None
1058
*
1059
* For coding example see: \ref IfxLld_Vadc_Adc_Usage
1060
*
1061
*/
1062
IFX_INLINE
void
IfxVadc_Adc_setScan
(
IfxVadc_Adc_Group
*group,
uint32
channels,
uint32
mask);
1063
1064
/** \brief Starts an autoscan on the specified group
1065
* \param group pointer to the VADC group
1066
* \return None
1067
*
1068
* For coding example see: \ref IfxLld_Vadc_Adc_Usage
1069
*
1070
*/
1071
IFX_INLINE
void
IfxVadc_Adc_startScan
(
IfxVadc_Adc_Group
*group);
1072
1073
/** \} */
1074
1075
/** \addtogroup IfxLld_Vadc_Adc_Queue
1076
* \{ */
1077
1078
/******************************************************************************/
1079
/*-------------------------Inline Function Prototypes-------------------------*/
1080
/******************************************************************************/
1081
1082
/** \brief Add an entry to the queue of a group for the specified channel with the following options set:
1083
* refill
1084
* source interrupt enable/disable
1085
* external trigger control
1086
* \param channel pointer to the VADC channel
1087
* \param options options for channel
1088
* \return None
1089
*
1090
* For coding example see: \ref IfxVadc_Adc_getResult
1091
*
1092
*/
1093
IFX_INLINE
void
IfxVadc_Adc_addToQueue
(
IfxVadc_Adc_Channel
*channel,
uint32
options);
1094
1095
/** \brief Flush the contents of the queue of a group
1096
* \param group pointer to the VADC group
1097
* \return None
1098
*
1099
* For coding example see: \ref IfxVadc_Adc_getResult
1100
*
1101
*/
1102
IFX_INLINE
void
IfxVadc_Adc_clearQueue
(
IfxVadc_Adc_Group
*group);
1103
1104
/** \brief Gives the status of the Queue of a group by returning non zero value if the Queue is full
1105
* \param group pointer to the VADC group
1106
* \return Queue status
1107
*
1108
* For coding example see: \ref IfxVadc_Adc_getResult
1109
*
1110
*/
1111
IFX_INLINE
IfxVadc_Status
IfxVadc_Adc_getQueueStatus
(
IfxVadc_Adc_Group
*group);
1112
1113
/** \brief Starts a queue of a group by generating a trigger event through software
1114
* \param group pointer to the VADC group
1115
* \return None
1116
*
1117
* For coding example see: \ref IfxLld_Vadc_Adc_Usage
1118
*
1119
*/
1120
IFX_INLINE
void
IfxVadc_Adc_startQueue
(
IfxVadc_Adc_Group
*group);
1121
1122
/** \} */
1123
1124
/** \addtogroup IfxLld_Vadc_Adc_Emux
1125
* \{ */
1126
1127
/******************************************************************************/
1128
/*-------------------------Global Function Prototypes-------------------------*/
1129
/******************************************************************************/
1130
1131
/** \brief initialise default configuration for external multiplexer
1132
* \param emuxConfig speciifies EMUX configuration
1133
* \param vadc pointer to VADC module space
1134
* \return None
1135
*/
1136
IFX_EXTERN
void
IfxVadc_Adc_initExternalMultiplexerModeConfig
(
IfxVadc_Adc_EmuxControl
*emuxConfig, Ifx_VADC *vadc);
1137
1138
/** \brief initalise external multiplexer.
1139
* \param vadc Pointer to VADC Module space
1140
* \param emuxControl speciifies EMUX configuration
1141
* \return None
1142
*/
1143
IFX_EXTERN
void
IfxVadc_Adc_initExternalMultiplexerMode
(Ifx_VADC *vadc,
const
IfxVadc_Adc_EmuxControl
*emuxControl);
1144
1145
/** \} */
1146
1147
/******************************************************************************/
1148
/*---------------------Inline Function Implementations------------------------*/
1149
/******************************************************************************/
1150
1151
IFX_INLINE
void
IfxVadc_Adc_addToQueue
(
IfxVadc_Adc_Channel
*channel,
uint32
options)
1152
{
1153
IfxVadc_addToQueue
(channel->
group
->
group
, channel->
channel
, options);
1154
}
1155
1156
1157
IFX_INLINE
void
IfxVadc_Adc_clearQueue
(
IfxVadc_Adc_Group
*group)
1158
{
1159
IfxVadc_clearQueue
(group->
group
,
TRUE
);
1160
}
1161
1162
1163
IFX_INLINE
void
IfxVadc_Adc_configureWaitForReadMode
(
IfxVadc_Adc_Channel
*channel,
boolean
waitForRead)
1164
{
1165
IfxVadc_configureWaitForReadMode
(channel->
group
->
group
, channel->
resultreg
, waitForRead);
1166
}
1167
1168
1169
IFX_INLINE
void
IfxVadc_Adc_configureWaitForReadModeForGlobalResultRegister
(
IfxVadc_Adc
*vadc,
boolean
waitForRead)
1170
{
1171
IfxVadc_configureWaitForReadModeForGlobalResultRegister
(vadc->
vadc
, waitForRead);
1172
}
1173
1174
1175
IFX_INLINE
void
IfxVadc_Adc_deInitModule
(
IfxVadc_Adc
*vadc)
1176
{
1177
Ifx_VADC *vadcSFR = vadc->
vadc
;
1178
1179
IfxVadc_resetKernel
(vadcSFR);
1180
}
1181
1182
1183
IFX_INLINE
IfxVadc_Status
IfxVadc_Adc_getBackgroundScanStatus
(
IfxVadc_Adc
*vadc)
1184
{
1185
return
IfxVadc_getBackgroundScanStatus
(vadc->
vadc
);
1186
}
1187
1188
1189
IFX_INLINE
Ifx_VADC_GLOBRES
IfxVadc_Adc_getGlobalResult
(
IfxVadc_Adc
*vadc)
1190
{
1191
return
IfxVadc_getGlobalResult
(vadc->
vadc
);
1192
}
1193
1194
1195
IFX_INLINE
Ifx_VADC_G *
IfxVadc_Adc_getGroupRegsFromGroup
(
const
IfxVadc_Adc_Group
*group)
1196
{
1197
return
group->
group
;
1198
}
1199
1200
1201
IFX_INLINE
void
IfxVadc_Adc_getGroupResult
(
IfxVadc_Adc_Group
*group, Ifx_VADC_RES *results,
uint32
resultOffset,
uint32
numResults)
1202
{
1203
IfxVadc_getGroupResult
(group->
group
, results, resultOffset, numResults);
1204
}
1205
1206
1207
IFX_INLINE
void
IfxVadc_Adc_getModuleConfig
(
IfxVadc_Adc
*vadc,
IfxVadc_Adc_Config
*config)
1208
{
1209
config->
vadc
= vadc->
vadc
;
1210
config->
analogFrequency
=
IfxVadc_getAdcAnalogFrequency
(vadc->
vadc
);
1211
config->
digitalFrequency
=
IfxVadc_getAdcDigitalFrequency
(vadc->
vadc
);
1212
config->
globalInputClass
[0].
resolution
=
IfxVadc_getGlobalResolution
(vadc->
vadc
, 0);
1213
config->
globalInputClass
[1].
resolution
=
IfxVadc_getGlobalResolution
(vadc->
vadc
, 1);
1214
config->
globalInputClass
[0].
sampleTime
=
IfxVadc_getGlobalSampleTime
(vadc->
vadc
, 0, config->
analogFrequency
);
1215
config->
globalInputClass
[1].
sampleTime
=
IfxVadc_getGlobalSampleTime
(vadc->
vadc
, 1, config->
analogFrequency
);
1216
config->
moduleFrequency
=
IfxVadc_getAdcModuleFrequency
();
1217
config->
startupCalibration
=
IfxVadc_getStartupCalibration
(vadc->
vadc
);
1218
}
1219
1220
1221
IFX_INLINE
IfxVadc_Status
IfxVadc_Adc_getQueueStatus
(
IfxVadc_Adc_Group
*group)
1222
{
1223
return
IfxVadc_getQueueStatus
(group->
group
);
1224
}
1225
1226
1227
IFX_INLINE
Ifx_VADC_RES
IfxVadc_Adc_getResult
(
IfxVadc_Adc_Channel
*channel)
1228
{
1229
return
IfxVadc_getResult
(channel->
group
->
group
, channel->
resultreg
);
1230
}
1231
1232
1233
IFX_INLINE
Ifx_VADC_RES
IfxVadc_Adc_getResultBasedOnRequestSource
(
IfxVadc_Adc_Group
*group,
IfxVadc_ChannelId
channel,
IfxVadc_RequestSource
sourceType)
1234
{
1235
return
IfxVadc_getResultBasedOnRequestSource
(group->
module
.
vadc
, group->
group
, channel, sourceType);
1236
}
1237
1238
1239
IFX_INLINE
IfxVadc_Status
IfxVadc_Adc_getScanStatus
(
IfxVadc_Adc_Group
*group)
1240
{
1241
return
IfxVadc_getScanStatus
(group->
group
);
1242
}
1243
1244
1245
IFX_INLINE
Ifx_VADC *
IfxVadc_Adc_getVadcFromGroup
(
const
IfxVadc_Adc_Group
*group)
1246
{
1247
return
group->
module
.
vadc
;
1248
}
1249
1250
1251
IFX_INLINE
void
IfxVadc_Adc_setBackgroundScan
(
IfxVadc_Adc
*vadc,
IfxVadc_Adc_Group
*group,
uint32
channels,
uint32
mask)
1252
{
1253
IfxVadc_setBackgroundScan
(vadc->
vadc
, group->
groupId
, channels, mask);
1254
}
1255
1256
1257
IFX_INLINE
void
IfxVadc_Adc_setScan
(
IfxVadc_Adc_Group
*group,
uint32
channels,
uint32
mask)
1258
{
1259
IfxVadc_setScan
(group->
group
, channels, mask);
1260
}
1261
1262
1263
IFX_INLINE
void
IfxVadc_Adc_startBackgroundScan
(
IfxVadc_Adc
*vadc)
1264
{
1265
IfxVadc_startBackgroundScan
(vadc->
vadc
);
1266
}
1267
1268
1269
IFX_INLINE
void
IfxVadc_Adc_startQueue
(
IfxVadc_Adc_Group
*group)
1270
{
1271
IfxVadc_startQueue
(group->
group
);
1272
}
1273
1274
1275
IFX_INLINE
void
IfxVadc_Adc_startScan
(
IfxVadc_Adc_Group
*group)
1276
{
1277
IfxVadc_startScan
(group->
group
);
1278
}
1279
1280
1281
#endif
/* IFXVADC_ADC_H */
home
mclld
Libraries
release
iLLD_1_0_0_11_0
src
ifx
TC27xD
Vadc
Adc
IfxVadc_Adc.h
Generated by
1.8.4