XMC Vadc
XMC Vadc
2 * @file xmc_vadc.h
3 * @date 2015-06-25
4 *
5 * @cond
6 **************************************************************************************
*******************************
7 * XMClib v2.0.0 - XMC Peripheral Driver Library
8 *
9 * Copyright (c) 2015, Infineon Technologies AG
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
modification,are permitted provided that the
13 * following conditions are met:
14 *
15 * Redistributions of source code must retain the above copyright notice, this list
of conditions and the following
16 * disclaimer.
17 *
18 * Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following
19 * disclaimer in the documentation and/or other materials provided with the
distribution.
20 *
21 * Neither the name of the copyright holders nor the names of its contributors may be
used to endorse or promote
22 * products derived from this software without specific prior written
permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES,
25 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
31 *
32 * To improve the quality of the software, users are encouraged to share
modifications, enhancements or bug fixes with
33 * Infineon Technologies AG
dave@infineon.com).
34
*************************************************************************************
********************************
35 *
36 * Change History
37 * --------------
38 *
39 * 2015-02-15:
40 * - Initial <br>
41 *
42 * 2015-02-20:
43 * - Revised for XMC1201 device.<br>
44 *
45 * 2015-04-27:
46 * - Added new APIs for SHS.<br>
47 * - Added New APIs for trigger edge selection.<BR>
48 * - Added new APIs for Queue flush entries, boundary selection, Boundary node
pointer.<BR>
49 * - Revised GatingMode APIs and EMUX Control Init API.<BR>
50 *
51 * 2015-06-20:
52 * - Removed version macros and declaration of GetDriverVersion API
53 *
54 * 2015-06-25:
55 * - BFL configuration in channel initialization fixed.
56 *
57 * @endcond
58 *
59 */
60
61 #ifndef XMC_VADC_H
62 #define XMC_VADC_H
63
64 /*************************************************************************************
********************************
65 * HEADER FILES
66
*************************************************************************************
*******************************/
67 #include <xmc_common.h>
68 #include <xmc_scu.h>
69 #include <xmc_vadc_map.h>
70
71 /**
72 * @addtogroup XMClib XMC Peripheral Library
73 * @{
74 */
75
76 /**
77 * @addtogroup VADC
78 * @brief Versatile Analog to Digital Converter (VADC) driver for XMC microcontroller
family.
79 *
80 * The XMC microcontroller provides a series of analog input channels connected to a
cluster of Analog/Digital
81 * Converters using the Successive Approximation Register (SAR) principle to convert
analog input values (voltages)
82 * to discrete digital values.
83 * \if XMC1
84 * The XMC1x is based on Sample & Hold converters, where a cluster contains 2
Sample&Hold units which share a common
85 * converter.
86 * \endif
87 *
88 * Each converter of the ADC cluster can operate independent of the others,
controlled by a dedicated set of
89 * registers and triggered by a dedicated group request source. The results of each
channel can be stored in a
90 * dedicated channel-specific result register or in a group-specific result register.<
BR>
91 *
92 * The Versatile Analog to Digital Converter module (VADC) of the XMC comprises a set
of converter blocks that
93 * can be operated either independently or via a common request source that emulates
a background converter.
94 * Each converter block is equipped with a dedicated input multiplexer and dedicated
request sources,
95 * which together build separate groups.
96 *
97 * \if XMC4
98 * @image html vadc_overview_xmc4x.png
99 * @image latex ../images/vadc_overview_xmc4x.png
100 * \else
101 * @image html vadc_overview_xmc1x.png
102 * @image latex ../images/vadc_overview_xmc1x.png
103 * \endif
104 *
105 * The VADC LLD is split into GLOBAL and GROUP related APIs.<BR>
106 * <B>GLOBAL: </B><BR>
107 * <UL>
108 * <LI>Global APIs act on the entire ADC module. Configures global configuration
registers</LI>
109 * <LI>Allows configuration of the background request source of the VADC.</LI>
110 * <LI>The clock related configurations for the VADC module are configured in the
Global APIs/</LI>
111 * <LI>The Global API names are prefixed by the \b XMC_VADC_GLOBAL_ and they accept
::XMC_VADC_GLOBAL_t as
112 * one of its arguments.</LI>
113 * <LI>Configures the background request source of the VADC. The APIs which act on
the background related registers
114 * are prefixed by \b XMC_VADC_GLOBAL_Background</LI>
115 * <LI>Configures the sample and hold unit of the VADC. The APIs which act on the SHS
related registers
116 * are prefixed by \b XMC_VADC_GLOBAL_SHS_</LI>
117 * </UL><BR>
118 *
119 * <B>GROUP: </B><BR>
120 * <UL>
121 * <LI>Group APIs act on a VADC group. Configures the group configuration registers</
LI>
122 * <LI>Configures the queue request source of the VADC. The APIs which act on the
queue related registers
123 * are prefixed by \b XMC_VADC_GROUP_Queue</LI>
124 * <LI>Configures the scan request source of the VADC. The APIs which act on the scan
related registers
125 * are prefixed by \b XMC_VADC_GROUP_Scan</LI>
126 * <LI>Configuration of the channels of each group are done by the API which have a
prefix as
127 * \b XMC_VADC_GROUP_Channel.</LI>
128 * <LI>The Group API names are prefixed by the \b XMC_VADC_GROUP_ and they accept
::XMC_VADC_GROUP_t as
129 * one of its arguments.</LI>
130 * </UL><BR>
131 * @{
132 */
133
134 /*************************************************************************************
********************************
135 * MACROS
136
*************************************************************************************
*******************************/
137
138 #if ((UC_SERIES == XMC42)||(UC_SERIES == XMC41))
139 #define XMC_VADC_GROUP_AVAILABLE (1U) /* Defines the availability of group
resource in a device*/
140 #define XMC_VADC_GSCAN_AVAILABLE (1U) /* Defines the availability of scan
request resource in a device*/
141 #define XMC_VADC_QUEUE_AVAILABLE (1U) /* Defines the availability of queue
request resource in a device*/
142 #define XMC_VADC_EMUX_AVAILABLE (1U) /* Defines the availability of
external multiplexer support in a
143 device*/
144 #define XMC_VADC_BOUNDARY_AVAILABLE (1U) /* Defines the availability of
boundary check support in a device*/
145 #define XMC_VADC_MULTIPLE_SLAVEGROUPS (1U) /* Defines the availability of
synchronous request source in device*/
146 #define XMC_VADC_MAXIMUM_NUM_GROUPS (2U) /* Defines the maximum number of
groups available in a device*/
147 #define XMC_VADC_BOUNDARY_FLAG_SELECT (1U) /* Defines the availability of
boundary flags in a device*/
148 #define XMC_VADC_DEASSERT_RESET_NEEDED (1U) /* Defines the need to de-assert the
reset to enable the peripheral */
149 #define XMC_VADC_CLOCK_UNGATING_NEEDED (1U) /* Defines the need to un-gate of
clock for peripheral enable*/
150 #define XMC_VADC_EMUX_CH_SEL_STYLE (1U) /* Defines the external multiplexer
channel selection mode of
151 operation for a particular
device*/
152 #define XMC_VADC_SHS_AVAILABLE (0U) /* Defines the availability of sample
and hold module*/
153 #define XMC_VADC_GROUP_SRCREG_AVAILABLE (1U) /* Define the availability of a source
specific result register */
154 #endif
155
156 #if (UC_SERIES == XMC44)
157 #define XMC_VADC_GROUP_AVAILABLE (1U) /* Defines the availability of group
resource in a device*/
158 #define XMC_VADC_GSCAN_AVAILABLE (1U) /* Defines the availability of scan
request resource in a device*/
159 #define XMC_VADC_QUEUE_AVAILABLE (1U) /* Defines the availability of queue
request resource in a device*/
160 #define XMC_VADC_EMUX_AVAILABLE (1U) /* Defines the availability of
external multiplexer support in a
161 device*/
162 #define XMC_VADC_BOUNDARY_AVAILABLE (1U) /* Defines the availability of
boundary check support in a device*/
163 #define XMC_VADC_MULTIPLE_SLAVEGROUPS (1U) /* Defines the availability of
synchronous request source in device*/
164 #define XMC_VADC_MAXIMUM_NUM_GROUPS (4U) /* Defines the maximum number of
groups available in a device*/
165 #define XMC_VADC_BOUNDARY_FLAG_SELECT (1U) /* Defines the availability of
boundary flags in a device*/
166 #define XMC_VADC_DEASSERT_RESET_NEEDED (1U) /* Defines the need to de-assert the
reset to enable the peripheral */
167 #define XMC_VADC_CLOCK_UNGATING_NEEDED (1U) /* Defines the need to un-gate of
clock for peripheral enable*/
168 #define XMC_VADC_EMUX_CH_SEL_STYLE (1U) /* Defines the external multiplexer
channel selection mode of
169 operation for a particular
device*/
170 #define XMC_VADC_SHS_AVAILABLE (0U) /* Defines the availability of sample
and hold module*/
171 #define XMC_VADC_GROUP_SRCREG_AVAILABLE (1U) /* Define the availability of a source
specific result register */
172 #endif
173
174 #if (UC_SERIES == XMC45)
175 #define XMC_VADC_GROUP_AVAILABLE (1U) /* Defines the availability of group
resource in a device*/
176 #define XMC_VADC_GSCAN_AVAILABLE (1U) /* Defines the availability of scan
request resource in a device*/
177 #define XMC_VADC_QUEUE_AVAILABLE (1U) /* Defines the availability of queue
request resource in a device*/
178 #define XMC_VADC_EMUX_AVAILABLE (1U) /* Defines the availability of
external multiplexer support in a
179 device*/
180 #define XMC_VADC_BOUNDARY_AVAILABLE (1U) /* Defines the availability of
boundary check support in a device*/
181 #define XMC_VADC_MULTIPLE_SLAVEGROUPS (1U) /* Defines the availability of
synchronous request source in device*/
182 #define XMC_VADC_MAXIMUM_NUM_GROUPS (4U) /* Defines the maximum number of
groups available in a device*/
183 #define XMC_VADC_BOUNDARY_FLAG_SELECT (0U) /* Defines the availability of
boundary flags in a device*/
184 #define XMC_VADC_DEASSERT_RESET_NEEDED (1U) /* Defines the need to de-assert the
reset to enable the peripheral */
185 #define XMC_VADC_CLOCK_UNGATING_NEEDED (0U) /* Defines the need to un-gate of
clock for peripheral enable*/
186 #define XMC_VADC_EMUX_CH_SEL_STYLE (0U) /* Defines the external multiplexer
channel selection mode of
187 operation for a particular
device*/
188 #define XMC_VADC_SHS_AVAILABLE (0U) /* Defines the availability of sample
and hold module*/
189 #define XMC_VADC_GROUP_SRCREG_AVAILABLE (0U) /* Define the availability of a source
specific result register */
190 #endif
191
192 #if (UC_SERIES == XMC13)
193 #define XMC_VADC_GROUP_AVAILABLE (1U) /* Defines the availability of group
resource in a device*/
194 #define XMC_VADC_GSCAN_AVAILABLE (1U) /* Defines the availability of scan
request resource in a device*/
195 #define XMC_VADC_QUEUE_AVAILABLE (1U) /* Defines the availability of queue
request resource in a device*/
196 #define XMC_VADC_EMUX_AVAILABLE (1U) /* Defines the availability of
external multiplexer support in a
197 device*/
198 #define XMC_VADC_BOUNDARY_AVAILABLE (1U) /* Defines the availability of
boundary check support in a device*/
199 #define XMC_VADC_MULTIPLE_SLAVEGROUPS (1U) /* Defines the availability of
synchronous request source in device*/
200 #define XMC_VADC_MAXIMUM_NUM_GROUPS (2U) /* Defines the maximum number of
groups available in a device*/
201 #define XMC_VADC_BOUNDARY_FLAG_SELECT (1U) /* Defines the availability of
boundary flags in a device*/
202 #define XMC_VADC_DEASSERT_RESET_NEEDED (0U) /* Defines the need to de-assert the
reset to enable the peripheral */
203 #define XMC_VADC_CLOCK_UNGATING_NEEDED (1U) /* Defines the need to un-gate of
clock for peripheral enable*/
204 #define XMC_VADC_EMUX_CH_SEL_STYLE (1U) /* Defines the external multiplexer
channel selection mode of
205 operation for a particular
device*/
206 #define XMC_VADC_SHS_AVAILABLE (1U) /* Defines the availability of sample
and hold module*/
207 #define XMC_VADC_GROUP_SRCREG_AVAILABLE (1U) /* Define the availability of a source
specific result register */
208 #endif
209
210 #if (UC_SERIES == XMC12)
211 #define XMC_VADC_GROUP_AVAILABLE (1U) /* Defines the availability of group
resource in a device*/
212 #define XMC_VADC_GSCAN_AVAILABLE (1U) /* Defines the availability of scan
request resource in a device*/
213 #define XMC_VADC_QUEUE_AVAILABLE (1U) /* Defines the availability of queue
request resource in a device*/
214 #define XMC_VADC_EMUX_AVAILABLE (1U) /* Defines the availability of
external multiplexer support in a
215 device*/
216 #define XMC_VADC_BOUNDARY_AVAILABLE (1U) /* Defines the availability of
boundary check support in a device*/
217 #define XMC_VADC_MULTIPLE_SLAVEGROUPS (1U) /* Defines the availability of
synchronous request source in device*/
218 #define XMC_VADC_MAXIMUM_NUM_GROUPS (2U) /* Defines the maximum number of
groups available in a device*/
219 #define XMC_VADC_BOUNDARY_FLAG_SELECT (1U) /* Defines the availability of
boundary flags in a device*/
220 #define XMC_VADC_DEASSERT_RESET_NEEDED (0U) /* Defines the need to de-assert the
reset to enable the peripheral */
221 #define XMC_VADC_CLOCK_UNGATING_NEEDED (1U) /* Defines the need to un-gate of
clock for peripheral enable*/
222 #define XMC_VADC_EMUX_CH_SEL_STYLE (1U) /* Defines the external multiplexer
channel selection mode of
223 operation for a particular
device*/
224 #define XMC_VADC_SHS_AVAILABLE (1U) /* Defines the availability of sample
and hold module*/
225 #define XMC_VADC_GROUP_SRCREG_AVAILABLE (1U) /* Define the availability of a source
specific result register */
226 #endif
227
228 #if (UC_SERIES == XMC11)
229 #define XMC_VADC_GROUP_AVAILABLE (0U) /* Defines the availability of group
resource in a device*/
230 #define XMC_VADC_GSCAN_AVAILABLE (0U) /* Defines the availability of scan
request resource in a device*/
231 #define XMC_VADC_QUEUE_AVAILABLE (0U) /* Defines the availability of queue
request resource in a device*/
232 #define XMC_VADC_EMUX_AVAILABLE (0U) /* Defines the availability of
external multiplexer support in a
233 device*/
234 #define XMC_VADC_BOUNDARY_AVAILABLE (0U) /* Defines the availability of
boundary check support in a device*/
235 #define XMC_VADC_MULTIPLE_SLAVEGROUPS (0U) /* Defines the availability of
synchronous request source in device*/
236 #define XMC_VADC_MAXIMUM_NUM_GROUPS (2U) /* Defines the maximum number of
groups available in a device*/
237 #define XMC_VADC_BOUNDARY_FLAG_SELECT (0U) /* Defines the availability of
boundary flags in a device*/
238 #define XMC_VADC_SHS_START_UP_CAL_ACTIVE (3U) /* Defines the need for SHS startup
calibration activation for
239 XMC1100 devices */
240 #define XMC_VADC_DEASSERT_RESET_NEEDED (0U) /* Defines the need to de-assert the
reset to enable the peripheral */
241 #define XMC_VADC_CLOCK_UNGATING_NEEDED (1U) /* Defines the need to un-gate of
clock for peripheral enable*/
242 #define XMC_VADC_CONV_ENABLE_FOR_XMC11 (*(uint32_t*) 0x40010500UL) /* Defines the
additional errata setting for
243 XMC1100 device for effective
working*/
244 #define XMC_VADC_EMUX_CH_SEL_STYLE (0U) /* Defines the external multiplexer
channel selection mode of
245 operation for a particular
device*/
246 #define XMC_VADC_SHS_AVAILABLE (0U) /* Defines the availability of sample
and hold module*/
247 #define XMC_VADC_GROUP_SRCREG_AVAILABLE (0U) /* Define the availability of a source
specific result register */
248 #endif
249
250 #define XMC_VADC_NUM_PORTS (16U) /* Defines the number of hardware
ports that can be configured
251 as triggers and gating signals */
252
253 #define XMC_VADC_NUM_RESULT_REGISTERS (16U) /* Defines the number of result
holding registers per ADC group */
254
255 #define XMC_VADC_NUM_CHANNELS_PER_GROUP (8U) /**< Defines the number of ADC
channels per group */
256
257 /*************************************************************************************
********************************
258 * ENUMS
259
*************************************************************************************
*******************************/
260 typedef uint16_t XMC_VADC_RESULT_SIZE_t; /**< Type defined the converted result size
to unsigned 16 bit integer */
261 typedef VADC_GLOBAL_TypeDef XMC_VADC_GLOBAL_t; /**< Type defined the device header
file vadc global register structure
262 type to VADC type*/
263
264 #if(XMC_VADC_GROUP_AVAILABLE == 1U)
265 typedef VADC_G_TypeDef XMC_VADC_GROUP_t; /**< Type defined the device header file
vadc group register structure
266 type to VADC Group type*/
267 #endif
268
269 #if(XMC_VADC_SHS_AVAILABLE == 1U)
270 typedef SHS_Type XMC_VADC_GLOBAL_SHS_t; /**< Type defined the sample and hold
register structure*/
271 #endif
272 /**
273 * Defines the return status after execution of VADC specific API's. Use @ref
XMC_VADC_STATUS_t for this enumeration.
274 */
275 typedef enum XMC_VADC_STATUS
276 {
277 XMC_VADC_STATUS_SUCCESS = 0, /**< Returned when the API has been able to fulfill
the callers request */
278 XMC_VADC_STATUS_ERROR /**< Returned when the API cannot fulfill the
request */
279 } XMC_VADC_STATUS_t;
280
281 /**
282 * Defines the various service requests lines. Each group can raise up to 4 service
requests independently. While
283 * all groups together have the possibility of raising 4 module wide service
requests. Use @ref XMC_VADC_SR_t for this
284 * enumeration.
285 */
286 typedef enum XMC_VADC_SR
287 {
288 XMC_VADC_SR_GROUP_SR0 = 0, /**< Group specific Service Request-0 */
289 XMC_VADC_SR_GROUP_SR1, /**< Group specific Service Request-1 */
290 XMC_VADC_SR_GROUP_SR2, /**< Group specific Service Request-2 */
291 XMC_VADC_SR_GROUP_SR3, /**< Group specific Service Request-3 */
292 XMC_VADC_SR_SHARED_SR0, /**< Module Wide Common Service Request-0 */
293 XMC_VADC_SR_SHARED_SR1, /**< Module Wide Common Service Request-1 */
294 XMC_VADC_SR_SHARED_SR2, /**< Module Wide Common Service Request-2 */
295 XMC_VADC_SR_SHARED_SR3 /**< Module Wide Common Service Request-3 */
296 } XMC_VADC_SR_t;
297
298 /**
299 * Defines the mode of operation of a channel, when an ongoing conversion gets
interrupted in between.
300 * Use @ref XMC_VADC_STARTMODE_t for this enumeration.
301 */
302 typedef enum XMC_VADC_STARTMODE
303 {
304 XMC_VADC_STARTMODE_WFS = 0, /**< An ongoing conversion completes without
interruption */
305 XMC_VADC_STARTMODE_CIR, /**< An ongoing conversion can be interrupted and
resumed later*/
306 XMC_VADC_STARTMODE_CNR /**< An ongoing conversion can be interrupted and never
resumed */
307 } XMC_VADC_STARTMODE_t;
308
309 /**
310 * Defines the edge sensitivity of the trigger signal which can assert a conversion.
311 * Use @ref XMC_VADC_TRIGGER_EDGE_t for this enumeration.
312 */
313 typedef enum XMC_VADC_TRIGGER_EDGE
314 {
315 XMC_VADC_TRIGGER_EDGE_NONE = 0, /**< No external trigger. Conversion request can be
asserted by software */
316 XMC_VADC_TRIGGER_EDGE_FALLING, /**< The falling edge of the external trigger can
assert conversion request */
317 XMC_VADC_TRIGGER_EDGE_RISING, /**< The rising edge of the external trigger can
assert conversion request */
318 XMC_VADC_TRIGGER_EDGE_ANY /**< Both the edges can assert conversion request */
319 } XMC_VADC_TRIGGER_EDGE_t;
320
321 /**
322 * Defines the external trigger input selection possibilities, to assert a
conversion. Refer the VADC interconnects
323 * section of the reference manual for details of peripherals which can be used.
Also refer xmc_vadc_map.h file for
324 * detailed definitions of the peripherals which can take the control of these
enumeration items.
325 * Use @ref XMC_VADC_TRIGGER_INPUT_SELECT_t for this enumeration.
326 */
327 typedef enum XMC_VADC_TRIGGER_INPUT_SELECT
328 {
329 XMC_VADC_REQ_TR_A = 0, /**< Trigger select signal A */
330 XMC_VADC_REQ_TR_B, /**< Trigger select signal B */
331 XMC_VADC_REQ_TR_C, /**< Trigger select signal C */
332 XMC_VADC_REQ_TR_D, /**< Trigger select signal D */
333 XMC_VADC_REQ_TR_E, /**< Trigger select signal E */
334 XMC_VADC_REQ_TR_F, /**< Trigger select signal F */
335 XMC_VADC_REQ_TR_G, /**< Trigger select signal G */
336 XMC_VADC_REQ_TR_H, /**< Trigger select signal H */
337 XMC_VADC_REQ_TR_I, /**< Trigger select signal I */
338 XMC_VADC_REQ_TR_J, /**< Trigger select signal J */
339 XMC_VADC_REQ_TR_K, /**< Trigger select signal K */
340 XMC_VADC_REQ_TR_L, /**< Trigger select signal L */
341 XMC_VADC_REQ_TR_M, /**< Trigger select signal M */
342 XMC_VADC_REQ_TR_N, /**< Trigger select signal N */
343 XMC_VADC_REQ_TR_O, /**< Trigger select signal O */
344 XMC_VADC_REQ_TR_P /**< Trigger select signal P */
345
346 } XMC_VADC_TRIGGER_INPUT_SELECT_t;
347
348 /**
349 * Defines the external gating input selection possibilities, to gate the conversion
requests. Refer the VADC
350 * interconnects section of the reference manual for details of peripherals which
can be used. Also refer
351 * xmc_vadc_map.h file for detailed definitions of the peripherals which can take
the control of these enumeration
352 * items. Use @ref XMC_VADC_GATE_INPUT_SELECT_t for this enumeration.
353 */
354 typedef enum XMC_VADC_GATE_INPUT_SELECT
355 {
356 XMC_VADC_REQ_GT_A = 0, /**< Gating select signal A */
357 XMC_VADC_REQ_GT_B, /**< Gating select signal B */
358 XMC_VADC_REQ_GT_C, /**< Gating select signal C */
359 XMC_VADC_REQ_GT_D, /**< Gating select signal D */
360 XMC_VADC_REQ_GT_E, /**< Gating select signal E */
361 XMC_VADC_REQ_GT_F, /**< Gating select signal F */
362 XMC_VADC_REQ_GT_G, /**< Gating select signal G */
363 XMC_VADC_REQ_GT_H, /**< Gating select signal H */
364 XMC_VADC_REQ_GT_I, /**< Gating select signal I */
365 XMC_VADC_REQ_GT_J, /**< Gating select signal J */
366 XMC_VADC_REQ_GT_K, /**< Gating select signal K */
367 XMC_VADC_REQ_GT_L, /**< Gating select signal L */
368 XMC_VADC_REQ_GT_M, /**< Gating select signal M */
369 XMC_VADC_REQ_GT_N, /**< Gating select signal N */
370 XMC_VADC_REQ_GT_O, /**< Gating select signal O */
371 XMC_VADC_REQ_GT_P /**< Gating select signal P */
372
373 } XMC_VADC_GATE_INPUT_SELECT_t;
374
375 /**
376 * Defines the condition for gating the conversion requests. It can be used to set
the ENGT field
377 * of ASMR/BSMR/QMR register respectively for auto_scan/background_scan/queue request
sources.
378 * Use @ref XMC_VADC_GATEMODE_t for this enumeration.
379 */
380 typedef enum XMC_VADC_GATEMODE
381 {
382 XMC_VADC_GATEMODE_BLOCK = 0, /**< External triggers are permanently blocked */
383 XMC_VADC_GATEMODE_IGNORE, /**< External triggers are unconditionally passed */
384 XMC_VADC_GATEMODE_ACTIVEHIGH, /**< External trigger is passed only if the gate
signal is high */
385 XMC_VADC_GATEMODE_ACTIVELOW /**< External trigger is passed only if the gate
signal is low */
386 } XMC_VADC_GATEMODE_t;
387
388 /**
389 * Defines the conversion result handling mode. Use @ref XMC_VADC_DMM_t for this
enumeration.
390 */
391 typedef enum XMC_VADC_DMM
392 {
393 XMC_VADC_DMM_REDUCTION_MODE = 0, /**< Standard Data reduction mode*/
394 XMC_VADC_DMM_FILTERING_MODE, /**< Provide option to select Finite Impulse
Response Filter (FIR) or
395 Infinite Impulse Response Filter (IIR)*/
396 XMC_VADC_DMM_DIFFERENCE_MODE, /**< Difference mode is selected*/
397 } XMC_VADC_DMM_t;
398
399 /**
400 * Defines the conversion mode. It defines the resolution of conversion. Use
XMC_VADC_CONVMODE_t for this enumeration.
401 */
402 typedef enum XMC_VADC_CONVMODE
403 {
404 XMC_VADC_CONVMODE_12BIT = 0, /**< Results of conversion are 12bits wide */
405 XMC_VADC_CONVMODE_10BIT = 1, /**< Results of conversion are 10bits wide */
406 XMC_VADC_CONVMODE_8BIT = 2, /**< Results of conversion are 8bits wide */
407 XMC_VADC_CONVMODE_FASTCOMPARE = 5 /**< Input signal compared with a preset range */
408 } XMC_VADC_CONVMODE_t;
409
410 /**
411 * Defines the output of a fast compare mode. Use @ref XMC_VADC_FAST_COMPARE_t for
412 * this enumeration.
413 */
414 typedef enum XMC_VADC_FAST_COMPARE
415 {
416 XMC_VADC_FAST_COMPARE_LOW = 0, /**< Input lower than than programmed reference */
417 XMC_VADC_FAST_COMPARE_HIGH , /**< Input higher than than programmed reference */
418 XMC_VADC_FAST_COMPARE_UNKNOWN /**< Unknown, Conversion probably still ongoing */
419 } XMC_VADC_FAST_COMPARE_t;
420
421 /**
422 * Defines the type of scan request source to be used. It can choose between auto
scan and background scan request
423 * source methods. Use @ref XMC_VADC_SCAN_TYPE_t for this enumeration.
424 */
425 typedef enum XMC_VADC_SCAN_TYPE
426 {
427 XMC_VADC_SCAN_TYPE_GROUPSCAN = 0, /**< Auto scan mode of operation selected. Also
called as Group scan*/
428 XMC_VADC_SCAN_TYPE_BACKGROUND /**< Background scan mode of operation selected.
Also called as Global scan*/
429 } XMC_VADC_SCAN_TYPE_t;
430
431 /**
432 * Defines the behavior of load event for the scan request source. Use @ref
XMC_VADC_SCAN_LOAD_t for this enumeration.
433 */
434 typedef enum XMC_VADC_SCAN_LOAD
435 {
436 XMC_VADC_SCAN_LOAD_OVERWRITE = 0, /**< The old set of channels is discarded in
favor of the new set
437 awaiting conversion */
438 XMC_VADC_SCAN_LOAD_COMBINE /**< The new set of channels are combined with the
pending channels from
439 previous set */
440 } XMC_VADC_SCAN_LOAD_t;
441
442 /**
443 * Defines the conversion classes that can be selected for each channel. The
enumeration members holds the group or
444 * global classes. The conversion classes decides the properties of conversion, like
resolution, sampling time etc
445 * Use @ref XMC_VADC_CHANNEL_CONV_t for this enumeration.
446 */
447
448 typedef enum XMC_VADC_CHANNEL_CONV
449 {
450 XMC_VADC_CHANNEL_CONV_GROUP_CLASS0 = 0, /**< Conversion property set-0 specific to
the group */
451 XMC_VADC_CHANNEL_CONV_GROUP_CLASS1, /**< Conversion property set-1 specific to
the group */
452 XMC_VADC_CHANNEL_CONV_GLOBAL_CLASS0, /**< Conversion property set-0, Module wide
*/
453 XMC_VADC_CHANNEL_CONV_GLOBAL_CLASS1 /**< Conversion property set-1, Module wide
*/
454 } XMC_VADC_CHANNEL_CONV_t;
455
456 /**
457 * Defines the references to boundary values used for limit checking feature. Each of
these can be assigned as
458 * either an upper bound or a lower bound. Use @ref XMC_VADC_CHANNEL_BOUNDARY_t for
this enumeration.
459 */
460
461 typedef enum XMC_VADC_CHANNEL_BOUNDARY
462 {
463 XMC_VADC_CHANNEL_BOUNDARY_GROUP_BOUND0 = 0, /**< Group specific Boundary-0 value */
464 XMC_VADC_CHANNEL_BOUNDARY_GROUP_BOUND1, /**< Group specific Boundary-1 value */
465 XMC_VADC_CHANNEL_BOUNDARY_GLOBAL_BOUND0, /**< Module wide Boundary-0 value */
466 XMC_VADC_CHANNEL_BOUNDARY_GLOBAL_BOUND1 /**< Module wide Boundary-1 value */
467 } XMC_VADC_CHANNEL_BOUNDARY_t;
468
469 /**
470 * Defines the voltage which the capacitor is charged to. Used in Broken wire
detection feature. Use
471 * @ref XMC_VADC_CHANNEL_BWDCH_t for this enumeration.
472 */
473 typedef enum XMC_VADC_CHANNEL_BWDCH
474 {
475 XMC_VADC_CHANNEL_BWDCH_VAGND = 0, /**< Capacitor pre-charged to ground*/
476 XMC_VADC_CHANNEL_BWDCH_VAREF /**< Capacitor pre-charged to reference voltage*/
477 } XMC_VADC_CHANNEL_BWDCH_t;
478
479 /**
480 * Defines the criteria for event generation by the channel. Use @ref
XMC_VADC_CHANNEL_EVGEN_t for this enumeration.
481 */
482 typedef enum XMC_VADC_CHANNEL_EVGEN
483 {
484 XMC_VADC_CHANNEL_EVGEN_NEVER = 0, /**< No event generated */
485 XMC_VADC_CHANNEL_EVGEN_INBOUND = 1U, /**< Event generated when the result is
within the normal range */
486 XMC_VADC_CHANNEL_EVGEN_COMPHIGH = 1U, /**< Event generated when the result of fast
compare operation is high */
487 XMC_VADC_CHANNEL_EVGEN_OUTBOUND = 2U, /**< Event generated when the result is
outside the normal range */
488 XMC_VADC_CHANNEL_EVGEN_COMPLOW = 2U, /**< Event generated when the result result
of fast compare operation is low */
489 XMC_VADC_CHANNEL_EVGEN_ALWAYS = 3U /**< Event generated always after conversion
- unconditionally */
490 } XMC_VADC_CHANNEL_EVGEN_t;
491
492 /**
493 * Defines the reference voltage selection for conversion. Use @ref
XMC_VADC_CHANNEL_REF_t for this enumeration.
494 */
495 typedef enum XMC_VADC_CHANNEL_REF
496 {
497 XMC_VADC_CHANNEL_REF_INTREF = 0, /**< Internal VARef */
498 XMC_VADC_CHANNEL_REF_ALT_CH0 /**< External voltage available on Channel-0 of the
perticular group */
499 } XMC_VADC_CHANNEL_REF_t;
500
501 /**
502 * Defines the criteria for boundary flag assertion. Use @ref
XMC_VADC_CHANNEL_BOUNDARY_CONDITION_t for this
503 * enumeration.
504 */
505 typedef enum XMC_VADC_CHANNEL_BOUNDARY_CONDITION
506 {
507 XMC_VADC_CHANNEL_BOUNDARY_CONDITION_ABOVE_BAND = 0, /**< Set Boundary condition
criteria to assert above the band */
508 XMC_VADC_CHANNEL_BOUNDARY_CONDITION_BELOW_BAND /**< Set Boundary condition
criteria to assert below the band */
509 } XMC_VADC_CHANNEL_BOUNDARY_CONDITION_t;
510
511 /**
512 * Defines the event which can lead to a global service request assertion. Use @ref
XMC_VADC_GLOBAL_EVENT_t for this
513 * enumeration.
514 */
515 typedef enum XMC_VADC_GLOBAL_EVENT
516 {
517 XMC_VADC_GLOBAL_EVENT_BKGNDSOURCE = VADC_GLOBEFLAG_SEVGLB_Msk, /**< Background scan
request source event */
518 XMC_VADC_GLOBAL_EVENT_RESULT = VADC_GLOBEFLAG_REVGLB_Msk /**< Global result
event */
519 } XMC_VADC_GLOBAL_EVENT_t;
520
521 /**
522 * Defines the power modes of a VADC Group. Use @ref XMC_VADC_GROUP_POWERMODE_t for
this enumeration.
523 */
524 typedef enum XMC_VADC_GROUP_POWERMODE
525 {
526 XMC_VADC_GROUP_POWERMODE_OFF = 0, /**< Group is powered down */
527 XMC_VADC_GROUP_POWERMODE_RESERVED1, /**< Reserved */
528 XMC_VADC_GROUP_POWERMODE_RESERVED2, /**< Reserved */
529 XMC_VADC_GROUP_POWERMODE_NORMAL /**< Group is powered up */
530 } XMC_VADC_GROUP_POWERMODE_t;
531
532 /**
533 * Defines the status of a VADC group (also known as kernel). Use @ref
XMC_VADC_GROUP_STATE_t for this enumeration.
534 */
535 typedef enum XMC_VADC_GROUP_STATE
536 {
537 XMC_VADC_GROUP_STATE_IDLE = 0, /**< Idle and can convert if requested */
538 XMC_VADC_GROUP_STATE_BUSY /**< Busy with an ongoing conversion */
539 } XMC_VADC_GROUP_STATE_t;
540
541 /**
542 * Defines the reference to sample time and conversion mode settings. Use @ref
XMC_VADC_GROUP_CONV_t for this
543 * enumeration.
544 */
545 typedef enum XMC_VADC_GROUP_CONV
546 {
547 XMC_VADC_GROUP_CONV_STD = 0, /**< Settings pertaining to channels directly attached
to VADC module */
548 XMC_VADC_GROUP_CONV_EMUX /**< Settings pertaining to channels connected to VADC
via EMUX */
549 } XMC_VADC_GROUP_CONV_t;
550
551 /**
552 * Defines the request source arbiter behavior. Use @ref XMC_VADC_GROUP_ARBMODE_t
for this enumeration.
553 */
554 typedef enum XMC_VADC_GROUP_ARBMODE
555 {
556 XMC_VADC_GROUP_ARBMODE_ALWAYS = 0, /**< Arbiter runs all the time */
557 XMC_VADC_GROUP_ARBMODE_ONDEMAND /**< Arbiter runs only if a conversion request
is asserted by any of the
558 request sources */
559 } XMC_VADC_GROUP_ARBMODE_t;
560
561 /**
562 * Defines the EMUX mode of operation. Use @ref XMC_VADC_GROUP_EMUXMODE_t for this
enumeration.
563 */
564 typedef enum XMC_VADC_GROUP_EMUXMODE
565 {
566 XMC_VADC_GROUP_EMUXMODE_SWCTRL = 0, /**< Perform EMUX in Software control mode*/
567 XMC_VADC_GROUP_EMUXMODE_STEADYMODE, /**< Perform EMUX in Steady mode (Use EMUX
set value)*/
568 XMC_VADC_GROUP_EMUXMODE_SINGLEMODE, /**< Perform EMUX in Single step mode*/
569 XMC_VADC_GROUP_EMUXMODE_SEQUENCEMODE, /**< Perform EMUX in Sequence mode*/
570 } XMC_VADC_GROUP_EMUXMODE_t;
571
572 /**
573 * Defines the EMUX channel selection encoding scheme. Use @ref
XMC_VADC_GROUP_EMUXCODE_t for this enumeration.
574 */
575 typedef enum XMC_VADC_GROUP_EMUXCODE
576 {
577 XMC_VADC_GROUP_EMUXCODE_BINARY = 0, /**< A linearly incrementing code serves are
MUX-SEL */
578 XMC_VADC_GROUP_EMUXCODE_GRAY /**< The MUX-SEL is gray encoded */
579 } XMC_VADC_GROUP_EMUXCODE_t;
580
581 /**
582 * Defines the service request set used. Use @ref XMC_VADC_GROUP_IRQ_t for this
enumeration.
583 */
584 typedef enum XMC_VADC_GROUP_IRQ
585 {
586 XMC_VADC_GROUP_IRQ_KERNEL = 0, /**< Refers to Group specific service request */
587 XMC_VADC_GROUP_IRQ_SHARED /**< Refers to Module wide service request */
588 } XMC_VADC_GROUP_IRQ_t;
589
590 /**
591 * Defines the alignment of the converted result. Use @ref XMC_VADC_RESULT_ALIGN_t
for this enumeration.
592 */
593 typedef enum XMC_VADC_RESULT_ALIGN
594 {
595 XMC_VADC_RESULT_ALIGN_LEFT = 0, /**< Always align result to left */
596 XMC_VADC_RESULT_ALIGN_RIGHT /**< Always align result to right */
597 } XMC_VADC_RESULT_ALIGN_t;
598
599 /**
600 * Defines the request source arbitration priority. Use @ref
XMC_VADC_GROUP_RS_PRIORITY_t for this enumeration.
601 */
602 typedef enum XMC_VADC_GROUP_RS_PRIORITY
603 {
604 XMC_VADC_GROUP_RS_PRIORITY_0 = 0, /**< Lowest priority for the request source*/
605 XMC_VADC_GROUP_RS_PRIORITY_1, /**< Second lowest priority for the request
source*/
606 XMC_VADC_GROUP_RS_PRIORITY_2, /**< Second highest priority for the request
source*/
607 XMC_VADC_GROUP_RS_PRIORITY_3, /**< Highest priority for the request source*/
608 }XMC_VADC_GROUP_RS_PRIORITY_t;
609
610 /**
611 * Defines the various modes for the boundary flag. Use @ref
XMC_VADC_GROUP_BOUNDARY_FLAG_MODE_t for this enumeration.
612 */
613 typedef enum XMC_VADC_GROUP_BOUNDARY_FLAG_MODE
614 {
615 XMC_VADC_GROUP_BOUNDARY_FLAG_MODE_DISABLED = 0, /**< Disable boundary flag*/
616 XMC_VADC_GROUP_BOUNDARY_FLAG_MODE_ENABLED, /**< Always enable
boundary*/
617 XMC_VADC_GROUP_BOUNDARY_FLAG_MODE_ENABLED_ACTIVE_LOW, /**< Enable boundary flag
when gate level is 0*/
618 XMC_VADC_GROUP_BOUNDARY_FLAG_MODE_ENABLED_ACTIVE_HIGH /**< Enable boundary flag
when gate level is 1*/
619 }XMC_VADC_GROUP_BOUNDARY_FLAG_MODE_t;
620
621
622 /**
623 * Defines the boundary select for Channel. Use @ref
XMC_VADC_GROUP_BOUNDARY_FLAG_MODE_t for this enumeration.
624 */
625 typedef enum XMC_VADC_BOUNDARY_SELECT
626 {
627 XMC_VADC_BOUNDARY_SELECT_LOWER_BOUND = 0U, /**< Select the lower boundary*/
628 XMC_VADC_BOUNDARY_SELECT_UPPER_BOUND = 2U /**< Selects the upper boundary*/
629 }XMC_VADC_BOUNDARY_SELECT_t;
630
631
632 /**
633 * Defines the group indices. Use @ref XMC_VADC_GROUP_INDEX_t for this enumeration.
634 */
635 typedef enum XMC_VADC_GROUP_INDEX
636 {
637 XMC_VADC_GROUP_INDEX_0 = 0,
638 XMC_VADC_GROUP_INDEX_1,
639 #if (XMC_VADC_MAXIMUM_NUM_GROUPS > 2)
640 XMC_VADC_GROUP_INDEX_2,
641 XMC_VADC_GROUP_INDEX_3
642 #endif
643 }XMC_VADC_GROUP_INDEX_t;
644
645 /**
646 * Defines channel alias.
647 * All enum items are available for channels 0 and 1. Other Channels can accept only
XMC_VADC_CHANNEL_ALIAS_DISABLED.
648 */
649 typedef enum XMC_VADC_CHANNEL_ALIAS
650 {
651 XMC_VADC_CHANNEL_ALIAS_DISABLED = -1,
652 XMC_VADC_CHANNEL_ALIAS_CH0 = 0,
653 XMC_VADC_CHANNEL_ALIAS_CH1 = 1,
654 XMC_VADC_CHANNEL_ALIAS_CH2 = 2,
655 XMC_VADC_CHANNEL_ALIAS_CH3 = 3,
656 XMC_VADC_CHANNEL_ALIAS_CH4 = 4,
657 XMC_VADC_CHANNEL_ALIAS_CH5 = 5,
658 XMC_VADC_CHANNEL_ALIAS_CH6 = 6,
659 XMC_VADC_CHANNEL_ALIAS_CH7 = 7
660 } XMC_VADC_CHANNEL_ALIAS_t;
661
662 #if(XMC_VADC_SHS_AVAILABLE == 1U)
663 /**
664 * Defines the gain calibration selection.
665 */
666 typedef enum XMC_VADC_SHS_GAIN_LEVEL
667 {
668 XMC_VADC_SHS_GAIN_LEVEL_0 = SHS_CALOC0_CALOFFVAL0_Pos, /**< Select the calibration
value for gain level 0 */
669 XMC_VADC_SHS_GAIN_LEVEL_1 = SHS_CALOC0_CALOFFVAL1_Pos, /**< Select the calibration
value for gain level 1 */
670 XMC_VADC_SHS_GAIN_LEVEL_2 = SHS_CALOC0_CALOFFVAL2_Pos, /**< Select the calibration
value for gain level 2 */
671 XMC_VADC_SHS_GAIN_LEVEL_3 = SHS_CALOC0_CALOFFVAL3_Pos /**< Select the calibration
value for gain level 3 */
672 }XMC_VADC_SHS_GAIN_LEVEL_t;
673
674 /**
675 * Defines the Delta sigma loop.
676 */
677 typedef enum XMC_VADC_SHS_LOOP_CH
678 {
679 XMC_VADC_SHS_LOOP_CH_0 = SHS_LOOP_LPCH0_Pos, /**< Select Delta-sigma loop 0*/
680 XMC_VADC_SHS_LOOP_CH_1 = SHS_LOOP_LPCH1_Pos /**< Select Delta-sigma loop 1*/
681 }XMC_VADC_SHS_LOOP_CH_t;
682
683 /**
684 * Provides the order in which the SHS should do the calibration
685 */
686 typedef enum XMC_VADC_GLOBAL_SHS_CALIBRATION_ORDER
687 {
688 XMC_VADC_GLOBAL_SHS_CALIBRATION_ORDER_POST_CONV = 0, /**< Calibration occur after
conversion takes place */
689 XMC_VADC_GLOBAL_SHS_CALIBRATION_ORDER_PRE_CONV /**< Calibration occur before
conversion takes place */
690 }XMC_VADC_GLOBAL_SHS_CALIBRATION_ORDER_t;
691 #endif
692
693 #if (XMC_VADC_BOUNDARY_FLAG_SELECT == 1U)
694 /**
695 * Provides possible routing values for the boundary flag.
696 */
697 typedef enum XMC_VADC_BOUNDARY_NODE
698 {
699 XMC_VADC_BOUNDARY_NODE_COMMON_BOUNDARY_FLAG_0 = 0U, /**<Route the Group boundary
flag to Common boundary flag 0 */
700 XMC_VADC_BOUNDARY_NODE_COMMON_BOUNDARY_FLAG_1, /**<Route the Group boundary
flag to Common boundary flag 1 */
701 XMC_VADC_BOUNDARY_NODE_COMMON_BOUNDARY_FLAG_2, /**<Route the Group boundary
flag to Common boundary flag 2 */
702 XMC_VADC_BOUNDARY_NODE_COMMON_BOUNDARY_FLAG_3, /**<Route the Group boundary
flag to Common boundary flag 3 */
703 XMC_VADC_BOUNDARY_NODE_COMMON_SR_LINE_0, /**<Route the Group boundary flag to
Common Service Request line 0 */
704 XMC_VADC_BOUNDARY_NODE_COMMON_SR_LINE_1, /**<Route the Group boundary flag to
Common Service Request line 1 */
705 XMC_VADC_BOUNDARY_NODE_COMMON_SR_LINE_2, /**<Route the Group boundary flag to
Common Service Request line 2 */
706 XMC_VADC_BOUNDARY_NODE_COMMON_SR_LINE_3 /**<Route the Group boundary flag to
Common Service Request line 3 */
707 }XMC_VADC_BOUNDARY_NODE_t;
708 #endif
709 /*************************************************************************************
********************************
710 * DATA STRUCTURES
711
*************************************************************************************
*******************************/
712 /*Anonymous structure/union guard start*/
713 #if defined(__CC_ARM)
714 #pragma push
715 #pragma anon_unions
716 #elif defined(__TASKING__)
717 #pragma warning 586
718 #endif
719
720 /**
721 * Structure initializing the VADC scan request source. Use type @ref
XMC_VADC_SCAN_CONFIG_t for this structure.
722 */
723 typedef struct XMC_VADC_SCAN_CONFIG
724 {
725 uint32_t conv_start_mode : 2; /**< One converter is shared between the queue
and scan request sources of the same
726 group. This field determines how scan
request source would request for
727 conversion. Uses @ref XMC_VADC_STARTMODE_t */
728 uint32_t req_src_priority : 2; /**< Request source priority for the arbiter. If
the Conversion start mode has been
729 selected as Cancel inject repeat/Never mode
then this field would determine the
730 priority of scan request source. Uses @ref
XMC_VADC_GROUP_RS_PRIORITY_t */
731 union
732 {
733 struct
734 {
735 #if(XMC_VADC_GROUP_SRCREG_AVAILABLE == (1U))
736 uint32_t src_specific_result_reg : 4; /**< Use any one Group related
result register as the destination
737 for all conversions results. To
use the individual result
register
738 from each channel configuration,
configure this field with 0x0 */
739 #else
740 uint32_t : 4;
741 #endif
742 uint32_t : 4;
743 uint32_t trigger_signal : 4; /**< Select one of the 16
possibilities for trigger. Uses @ref
744 XMC_VADC_TRIGGER_INPUT_SELECT_t
enumeration*/
745 uint32_t : 1;
746 uint32_t trigger_edge : 2; /**< Edge selection for trigger
signal. Uses @ref
747 XMC_VADC_TRIGGER_EDGE_t */
748 uint32_t : 1;
749 uint32_t gate_signal : 4; /**< Select one of the 16
possibilities for gating. Uses @ref
750 XMC_VADC_GATE_INPUT_SELECT_t */
751 uint32_t : 8;
752 uint32_t timer_mode : 1; /**< Decides whether timer mode for
equi-distant sampling shall be
753 activated or not.*/
754 uint32_t : 3;
755 };
756 uint32_t asctrl;
757 };
758 union
759 {
760 struct
761 {
762 uint32_t : 2;
763 uint32_t external_trigger : 1; /**< Conversions be initiated by external
hardware trigger */
764 uint32_t req_src_interrupt : 1; /**< Request source event can be
generated after a conversion sequence*/
765 uint32_t enable_auto_scan : 1; /**< Enables the continuous conversion
mode. Conversion completion
766 of the last channel in a scan
sequence will cause a load event. */
767 uint32_t load_mode : 1; /**< Selects load event mode. Uses @ref
XMC_VADC_SCAN_LOAD_t */
768 uint32_t : 26;
769 };
770 uint32_t asmr;
771 };
772 } XMC_VADC_SCAN_CONFIG_t;
773
774
775 typedef XMC_VADC_SCAN_CONFIG_t XMC_VADC_BACKGROUND_CONFIG_t; /**< Type defined the
scan configuration
776 structure for
background Request
Source*/
777
778 /**
779 * Structure initializing the VADC channel. Use type XMC_VADC_CHANNEL_CONFIG_t for
this enumeration.
780 */
781 typedef struct XMC_VADC_CHANNEL_CONFIG
782 {
783 union
784 {
785 struct
786 {
787 uint32_t input_class : 2; /**< Input conversion class
selection.
788 Uses @ref
XMC_VADC_CHANNEL_CONV_t */
789 uint32_t : 2;
790 uint32_t lower_boundary_select : 2; /**< Which boundary register
serves as lower bound?
791 Accepts enum @ref
XMC_VADC_CHANNEL_BOUNDARY_t
*/
792 uint32_t upper_boundary_select : 2; /**< Which boundary register
serves as upper bound?
793 Accepts enum @ref
XMC_VADC_CHANNEL_BOUNDARY_t
*/
794 uint32_t event_gen_criteria : 2; /**< When should an event be
generated?
795 Uses @ref
XMC_VADC_CHANNEL_EVGEN_t */
796 uint32_t sync_conversion : 1; /**< Enables synchronous
conversion for the configured channel*/
797 uint32_t alternate_reference : 1; /**< Input reference voltage
selection either VARef or CH-0.
798 Uses @ref
XMC_VADC_CHANNEL_REF_t*/
799 uint32_t : 4;
800 uint32_t result_reg_number : 4; /**< Group result register number
*/
801 uint32_t use_global_result : 1; /**< Use global result register
for background request source channels */
802 uint32_t result_alignment : 1; /**< Alignment of the results
read in the result register.
803 Uses @ref
XMC_VADC_RESULT_ALIGN_t */
804 uint32_t : 6;
805 uint32_t broken_wire_detect_channel : 2; /**< Source to be used to charge
the capacitor for BWD feature.
806 Uses @ref
XMC_VADC_CHANNEL_BWDCH_t. */
807 uint32_t broken_wire_detect : 1; /**< Configures extra phase
before the capacitor is sampled. */
808 };
809 uint32_t chctr;
810 };
811 union
812 {
813 struct
814 {
815 uint32_t : 8;
816 #if (XMC_VADC_BOUNDARY_FLAG_SELECT == 1U)
817 uint32_t flag_output_condition_ch0 : 1; /**< Condition for which the
boundary flag should change.
818 Uses @ref
XMC_VADC_CHANNEL_BOUNDARY_CONDI
TION_t */
819 uint32_t flag_output_condition_ch1 : 1; /**< Condition for which the
boundary flag should change.
820 Uses @ref
XMC_VADC_CHANNEL_BOUNDARY_CON
DITION_t */
821 uint32_t flag_output_condition_ch2 : 1; /**< Condition for which the
boundary flag should change.
822 Uses @ref
XMC_VADC_CHANNEL_BOUNDARY_CON
DITION_t */
823 uint32_t flag_output_condition_ch3 : 1; /**< Condition for which the
boundary flag should change.
824 Uses @ref
XMC_VADC_CHANNEL_BOUNDARY_CON
DITION_t */
825 #else
826 uint32_t : 4;
827 #endif
828 uint32_t : 4;
829 #if (XMC_VADC_BOUNDARY_FLAG_SELECT == 1U)
830 uint32_t invert_boundary_flag_ch0 : 1; /**< Inverts boundary flag output.*/
831 uint32_t invert_boundary_flag_ch1 : 1; /**< Inverts boundary flag output.*/
832 uint32_t invert_boundary_flag_ch2 : 1; /**< Inverts boundary flag output.*/
833 uint32_t invert_boundary_flag_ch3 : 1; /**< Inverts boundary flag output.*/
834
835 #else
836 uint32_t boundary_flag_output_ch0 : 1; /**< Enable the boundary flag
output on the specific channel.*/
837 uint32_t boundary_flag_output_ch1 : 1; /**< Enable the boundary flag
output on the specific channel.*/
838 uint32_t boundary_flag_output_ch2 : 1; /**< Enable the boundary flag
output on the specific channel.*/
839 uint32_t boundary_flag_output_ch3 : 1; /**< Enable the boundary flag
output on the specific channel.*/
840 #endif
841 uint32_t : 12;
842 };
843 uint32_t bfl;
844 };
845 #if (XMC_VADC_BOUNDARY_FLAG_SELECT == 1U)
846 union
847 {
848 struct
849 {
850 uint32_t boundary_flag_mode_ch0 : 4; /**< Specify the basic operation of
boundary flag 0
851 Uses @ref
XMC_VADC_GROUP_BOUNDARY_FLAG_MOD
E_t*/
852 uint32_t boundary_flag_mode_ch1 : 4; /**< Specify the basic operation of
boundary flag 1
853 Uses @ref
XMC_VADC_GROUP_BOUNDARY_FLAG_MOD
E_t*/
854 uint32_t boundary_flag_mode_ch2 : 4; /**< Specify the basic operation of
boundary flag 2
855 Uses @ref
XMC_VADC_GROUP_BOUNDARY_FLAG_MOD
E_t*/
856 uint32_t boundary_flag_mode_ch3 : 4; /**< Specify the basic operation of
boundary flag 3
857 Uses @ref
XMC_VADC_GROUP_BOUNDARY_FLAG_MOD
E_t*/
858 uint32_t : 16;
859 };
860 uint32_t bflc;
861 };
862 #endif
863 bool channel_priority; /**< Only non priority channels can be converted by
Background Request Source */
864 int8_t alias_channel; /**< Specifies the channel which has to be aliased
with CH0/CH1 (which ever is applicable).
865 Force the value to \b(int8_t)-1 to bypass alias
feature.
866 Uses @ref XMC_VADC_CHANNEL_ALIAS_t for
configuration.*/
867 } XMC_VADC_CHANNEL_CONFIG_t;
868
869 /**
870 * Structure to initialize a queue entry. Use type @ref XMC_VADC_QUEUE_ENTRY_t.
871 */
872 typedef struct XMC_VADC_QUEUE_ENTRY
873 {
874 union
875 {
876 struct
877 {
878 uint32_t channel_num : 5; /**< Channel number associated with this
queue entry.<BR>Range:[0x0 to 0x7] */
879 uint32_t refill_needed : 1; /**< Conversion completed channel gets
inserted back into the queue */
880 uint32_t generate_interrupt : 1; /**< Generates a queue request source
event */
881 uint32_t external_trigger : 1; /**< Conversion requests are raised on an
external trigger. */
882 uint32_t : 24;
883
884 };
885 uint32_t qinr0;
886 };
887 } XMC_VADC_QUEUE_ENTRY_t;
888
889 /**
890 * Structure initializing a VADC queue request source. Use type @ref
XMC_VADC_QUEUE_CONFIG_t.
891 */
892 typedef struct XMC_VADC_QUEUE_CONFIG
893 {
894 uint32_t conv_start_mode : 2; /**< One converter is shared between the queue
and scan request sources of the same
895 group. This field determines how queue
request source would request for
896 conversion. Uses @ref XMC_VADC_STARTMODE_t */
897 uint32_t req_src_priority : 2; /**< Request source priority for the arbiter.Uses
@ref XMC_VADC_GROUP_RS_PRIORITY_t */
898 union
899 {
900 struct
901 {
902 #if(XMC_VADC_GROUP_SRCREG_AVAILABLE == (1U))
903 uint32_t src_specific_result_reg : 4; /**< Uses any one Group related
result register as the destination
904 for all conversions results. To
use the individual result
register
905 from each channel configuration,
configure this field with 0x0 */
906 #else
907 uint32_t : 4;
908 #endif
909 uint32_t : 4;
910 uint32_t trigger_signal : 4; /**< Select one of the 16
possibilities for trigger.
911 Uses @ref
XMC_VADC_TRIGGER_INPUT_SELECT_t
*/
912 uint32_t : 1;
913 uint32_t trigger_edge : 2; /**< Edge selection for trigger
signal.
914 Uses @ref
XMC_VADC_TRIGGER_EDGE_t */
915 uint32_t : 1;
916 uint32_t gate_signal : 4; /**< Select one of the 16
possibilities for gating.
917 Uses @ref
XMC_VADC_GATE_INPUT_SELECT_t */
918 uint32_t : 8;
919 uint32_t timer_mode : 1; /**< Timer mode for equi-distant
sampling shall be activated or not? */
920 uint32_t : 3;
921 };
922 uint32_t qctrl0;
923 };
924 union
925 {
926 struct
927 {
928 uint32_t : 2;
929 uint32_t external_trigger : 1; /**< Are external triggers supported? */
930 uint32_t : 29;
931 };
932 uint32_t qmr0;
933 };
934 } XMC_VADC_QUEUE_CONFIG_t;
935
936
937 /**
938 * Structure to initialize the global input class configuration. Configured
parameters are sample time and
939 * conversion Mode.
940 */
941 typedef struct XMC_VADC_GLOBAL_CLASS
942 {
943 union
944 {
945 struct
946 {
947 uint32_t sample_time_std_conv : 5; /**< Sample time for
channels directly connected to VADC
948 <BR>Range: [0x0 to
0x1F] */
949 uint32_t : 3;
950 uint32_t conversion_mode_standard : 3; /**< Conversion mode for
channels directly connected to VADC.
951 Uses @ref
XMC_VADC_CONVMODE_t */
952 uint32_t : 5;
953 #if(XMC_VADC_EMUX_AVAILABLE == 1U)
954 uint32_t sampling_phase_emux_channel : 5; /**< Sample time for
channels connected via EMUX
955 <BR>Range: [0x0 to
0x1F] */
956 uint32_t : 3;
957 uint32_t conversion_mode_emux : 3; /**< Conversion mode for
channels connected via EMUX to VADC.
958 Uses @ref
XMC_VADC_CONVMODE_t */
959 uint32_t : 5;
960 #else
961 uint32_t : 16;
962 #endif
963 };
964 uint32_t globiclass;
965 };
966 } XMC_VADC_GLOBAL_CLASS_t;
967
968 #if (XMC_VADC_GROUP_AVAILABLE != 0U)
969 /**
970 * Structure to initialize converter and arbiter clock configuration
971 */
972 typedef struct XMC_VADC_GLOBAL_CLOCK
973 {
974 union
975 {
976 struct
977 {
978
979 uint32_t analog_clock_divider : 5; /**< Clock for the converter. <BR
>Range: [0x0 to 0x1F] */
980 uint32_t : 2;
981 uint32_t msb_conversion_clock : 1; /**< Additional clock cycle for
analog converter */
982 uint32_t arbiter_clock_divider : 2; /**< Request source arbiter clock
divider. <BR>Range: [0x0 to 0x3] */
983 uint32_t : 5;
984 uint32_t : 17;
985 };
986 uint32_t globcfg;
987 };
988 } XMC_VADC_GLOBAL_CLOCK_t;
989 #endif
990
991
992 /**
993 * Structure to initialize the VADC Global functions
994 */
995 typedef struct XMC_VADC_GLOBAL_CONFIG
996 {
997 union
998 {
999 struct
1000 {
1001 uint32_t boundary0 : 12; /**< Boundary value for results comparison*/
1002 uint32_t : 4;
1003 uint32_t boundary1 : 12; /**< Boundary value for results comparison*/
1004 uint32_t : 4;
1005 };
1006 uint32_t globbound;
1007 };
1008 #if (XMC_VADC_GROUP_AVAILABLE != 0U)
1009 XMC_VADC_GLOBAL_CLOCK_t clock_config; /**< ADC clock configurations*/
1010 #endif
1011 XMC_VADC_GLOBAL_CLASS_t class0; /**< ADC input conversion configurations
for GLOBICLASS[0]*/
1012 XMC_VADC_GLOBAL_CLASS_t class1; /**< ADC input conversion configurations
for GLOBICLASS[1]*/
1013 union
1014 {
1015 struct
1016 {
1017 uint32_t : 16;
1018 uint32_t data_reduction_control : 4; /**< Data reduction stages */
1019 uint32_t : 4;
1020 uint32_t wait_for_read_mode : 1; /**< Results of the next conversion
will not be overwritten in the
1021 result register until the
previous value is read*/
1022 uint32_t : 6;
1023 uint32_t event_gen_enable : 1; /**< Generates an event on
availability of new result. */
1024 };
1025 uint32_t globrcr;
1026 };
1027 union
1028 {
1029 struct
1030 {
1031 uint32_t module_disable : 1; /**< Disables the module clock.*/
1032 uint32_t : 2;
1033 uint32_t disable_sleep_mode_control : 1; /**< Set it to true in order to
disable the Sleep mode */
1034 uint32_t : 28;
1035 };
1036 uint32_t clc;
1037 };
1038 } XMC_VADC_GLOBAL_CONFIG_t;
1039
1040
1041 /**
1042 * Structure to initialize the group input class configuration. Configured
parameters are sample time and
1043 * conversion Mode.
1044 */
1045 typedef struct XMC_VADC_GROUP_CLASS
1046 {
1047 union
1048 {
1049 struct
1050 {
1051 uint32_t sample_time_std_conv : 5; /**< Sample time for
channels directly connected to VADC
1052 <BR>Range: [0x0 to
0x1F] */
1053 uint32_t : 3;
1054 uint32_t conversion_mode_standard : 3; /**< Conversion mode for
channels directly connected to VADC.
1055 Uses @ref
XMC_VADC_CONVMODE_t */
1056 uint32_t : 5;
1057 uint32_t sampling_phase_emux_channel : 5; /**< Sample time for
channels connected via EMUX
1058 <BR>Range: [0x0 to
0x1F] */
1059 uint32_t : 3;
1060 uint32_t conversion_mode_emux : 3; /**< Conversion mode for
channels connected via EMUX to VADC.
1061 Uses @ref
XMC_VADC_CONVMODE_t */
1062 uint32_t : 5;
1063 };
1064 uint32_t g_iclass0;
1065 };
1066 } XMC_VADC_GROUP_CLASS_t;
1067
1068
1069 /**
1070 * EMUX related configuration structure.
1071 */
1072 typedef struct XMC_VADC_GROUP_EMUXCFG
1073 {
1074 union
1075 {
1076 struct
1077 {
1078 uint32_t starting_external_channel : 3; /**< External channel number to
which the VADC will
1079 generate a control signal
(needed to select the analog
input in
1080 the analog multiplexer)*/
1081 uint32_t : 13;
1082 #if (XMC_VADC_EMUX_CH_SEL_STYLE == 1U)
1083 uint32_t connected_channel : 10; /**< The Channel to which the EMUX
is connected. */
1084 #else
1085 uint32_t connected_channel : 5; /**< The Channel to which the EMUX
is connected. */
1086 uint32_t : 5;
1087 #endif
1088 uint32_t emux_mode : 2; /**< Selects the external
multiplexer modes: Steady, Single Mode, step etc
1089 Uses @ref
XMC_VADC_GROUP_EMUXMODE_t*/
1090 uint32_t emux_coding : 1; /**< Select Binary or Gray coding.
Uses @ref XMC_VADC_GROUP_EMUXCODE_t*/
1091 uint32_t stce_usage : 1; /**< Use STCE for each conversion
of an external channel */
1092 #if (XMC_VADC_EMUX_CH_SEL_STYLE == 1U)
1093 uint32_t emux_channel_select_style : 1; /**< Selects the style of
configuring the \b connected_channel
1094 (Each bit represents the
channel or entire field
represents the channel number
) */
1095 uint32_t : 1;
1096 #else
1097 uint32_t : 2;
1098 #endif
1099 };
1100 uint32_t g_emuxctr;
1101 };
1102 } XMC_VADC_GROUP_EMUXCFG_t;
1103
1104
1105 /**
1106 * Group Configuration Data Structures
1107 */
1108
1109 typedef struct XMC_VADC_GROUP_CONFIG
1110 {
1111 XMC_VADC_GROUP_EMUXCFG_t emux_config; /**< External multiplexer related
configurations */
1112 XMC_VADC_GROUP_CLASS_t class0; /**< ADC input conversion configurations
for GxICLASS[0]*/
1113 XMC_VADC_GROUP_CLASS_t class1; /**< ADC input conversion configurations
for GxICLASS[1]*/
1114 union
1115 {
1116 struct
1117 {
1118 uint32_t boundary0 : 12; /**< Boundary value for results comparison*/
1119 uint32_t : 4;
1120 uint32_t boundary1 : 12; /**< Boundary value for results comparison*/
1121 uint32_t : 4;
1122 };
1123 uint32_t g_bound;
1124 };
1125 union
1126 {
1127 struct
1128 {
1129 uint32_t : 4;
1130 uint32_t arbitration_round_length : 2; /**< Number of arbiter slots to be
considered */
1131 uint32_t : 1;
1132 uint32_t arbiter_mode : 1; /**< Arbiter mode - Select either
Continuous mode or Demand based.
1133 Uses @ref
XMC_VADC_GROUP_ARBMODE_t */
1134 uint32_t : 24;
1135 };
1136 uint32_t g_arbcfg;
1137 };
1138 } XMC_VADC_GROUP_CONFIG_t;
1139
1140 /**
1141 * Structure to initialize VADC Group result register.
1142 */
1143
1144 typedef struct XMC_VADC_RESULT_CONFIG
1145 {
1146 union
1147 {
1148 struct
1149 {
1150 uint32_t : 16;
1151 uint32_t data_reduction_control : 4; /**< Configures the data reduction
stages */
1152 uint32_t post_processing_mode : 2; /**< Result data processing mode.
Uses @ref XMC_VADC_DMM_t
1153 For normal operation select
1154
XMC_VADC_DMM_t::XMC_VADC_DMM_RED
UCTION_MODE
1155 and data_reduction_control as
0*/
1156 uint32_t : 2;
1157 uint32_t wait_for_read_mode : 1; /**< Allow the conversion only after
previous results are read*/
1158 uint32_t part_of_fifo : 2; /**< Make the result register a part
of Result FIFO? */
1159 uint32_t : 4;
1160 uint32_t event_gen_enable : 1; /**< Generates an event on
availability of new result. */
1161 };
1162 uint32_t g_rcr;
1163 };
1164 } XMC_VADC_RESULT_CONFIG_t;
1165
1166 #if(XMC_VADC_SHS_AVAILABLE == 1U)
1167 /**
1168 * Structure to initialize the Stepper configurations
1169 */
1170 typedef struct XMC_VADC_GLOBAL_SHS_STEP_CONFIG
1171 {
1172 union
1173 {
1174 struct
1175 {
1176 uint32_t sh_unit_step0 :3; /**< Select a Sample and hold unit for
the stepper's step number 0.
1177 Uses @ref
XMC_VADC_GROUP_INDEX_t*/
1178 uint32_t enable_step0 :1; /**< Should the step be added to the
sequence */
1179 uint32_t sh_unit_step1 :3; /**< Select a Sample and hold unit for
the stepper's step number 1.
1180 Uses @ref
XMC_VADC_GROUP_INDEX_t*/
1181 uint32_t enable_step1 :1; /**< Should the step be added to the
sequence */
1182 uint32_t sh_unit_step2 :3; /**< Select a Sample and hold unit for
the stepper's step number 2.
1183 Uses @ref
XMC_VADC_GROUP_INDEX_t*/
1184 uint32_t enable_step2 :1; /**< Should the step be added to the
sequence */
1185 uint32_t sh_unit_step3 :3; /**< Select a Sample and hold unit for
the stepper's step number 3.
1186 Uses @ref
XMC_VADC_GROUP_INDEX_t*/
1187 uint32_t enable_step3 :1; /**< Should the step be added to the
sequence */
1188 uint32_t sh_unit_step4 :3; /**< Select a Sample and hold unit for
the stepper's step number 4.
1189 Uses @ref
XMC_VADC_GROUP_INDEX_t*/
1190 uint32_t enable_step4 :1; /**< Should the step be added to the
sequence */
1191 uint32_t sh_unit_step5 :3; /**< Select a Sample and hold unit for
the stepper's step number 5.
1192 Uses @ref
XMC_VADC_GROUP_INDEX_t*/
1193 uint32_t enable_step5 :1; /**< Should the step be added to the
sequence */
1194 uint32_t sh_unit_step6 :3; /**< Select a Sample and hold unit for
the stepper's step number 6.
1195 Uses @ref
XMC_VADC_GROUP_INDEX_t*/
1196 uint32_t enable_step6 :1; /**< Should the step be added to the
sequence */
1197 uint32_t sh_unit_step7 :3; /**< Select a Sample and hold unit for
the stepper's step number 7.
1198 Uses @ref
XMC_VADC_GROUP_INDEX_t*/
1199 uint32_t enable_step7 :1; /**< Should the step be added to the
sequence */
1200
1201 };
1202 uint32_t stepcfg;
1203 };
1204 }XMC_VADC_GLOBAL_SHS_STEP_CONFIG_t;
1205
1206 /**
1207 * Sample and hold Initialization structure
1208 */
1209 typedef struct XMC_VADC_GLOBAL_SHS_CONFIG
1210 {
1211 union
1212 {
1213 struct
1214 {
1215 uint32_t shs_clock_divider :4; /**< The divider value for the SHS clock.
Range: [0x0 to 0xF]*/
1216 uint32_t :6;
1217 uint32_t analog_reference_select :2; /**< It is possible to different
reference voltage for the SHS module
1218 Accepts ::XMC_VADC_GLOBAL_SHS_AREF_t
*/
1219 uint32_t :20;
1220 };
1221 uint32_t shscfg;
1222 };
1223
1224 XMC_VADC_GLOBAL_SHS_CALIBRATION_ORDER_t calibration_order; /**< order in which the
calibration should be taken up*/
1225
1226 }XMC_VADC_GLOBAL_SHS_CONFIG_t;
1227
1228 #endif
1229 /*Anonymous structure/union guard end*/
1230 #if defined(__CC_ARM)
1231 #pragma pop
1232 #elif defined(__TASKING__)
1233 #pragma warning restore
1234 #endif
1235 /*************************************************************************************
********************************
1236 * static inline functions
1237
*************************************************************************************
*******************************/
1238
1239 #if (XMC_VADC_GROUP_AVAILABLE == 1U)
1240 __STATIC_INLINE bool XMC_VADC_CHECK_GROUP_PTR(XMC_VADC_GROUP_t *const group_ptr)
1241 {
1242 #if (XMC_VADC_MAXIMUM_NUM_GROUPS == 4U)
1243 return((group_ptr == VADC_G0) || (group_ptr == VADC_G1) || (group_ptr == VADC_G2) ||
(group_ptr == VADC_G3));
1244 #else
1245 return((group_ptr == VADC_G0) || (group_ptr == VADC_G1));
1246 #endif
1247 }
1248 #endif
1249 /*************************************************************************************
********************************
1250 * API Prototypes
1251
*************************************************************************************
*******************************/
1252
1253 #ifdef __cplusplus
1254 extern "C" {
1255 #endif
1256
1257 /**
1258 * @param None
1259 *
1260 * @return None
1261 *
1262 * \par<b>Description:</b><br>
1263 * Enables the VADC module.<BR>\n
1264 * This API would ungate the clock to the VADC module (if applicable). Also this API
would bring
1265 * the VADC module out of reset state(if applicable), by asserting the appropriate
registers.
1266 * This API would invoke XMC_SCU_CLOCK_UngatePeripheralClock() and
XMC_SCU_RESET_DeassertPeripheralReset()
1267 * if needed. Directly accessed register is COMPARATOR.ORCCTRL (Refer to the errata
for XMC1100).
1268 *
1269 * \par<b>Related APIs:</b><BR>
1270 * XMC_VADC_GLOBAL_DisableModule().
1271 */
1272 void XMC_VADC_GLOBAL_EnableModule(void);
1273
1274 /**
1275 * @param None
1276 *
1277 * @return None
1278 *
1279 * \par<b>Description:</b><br>
1280 * Disables the VADC module.<BR>\n
1281 * This API would gate the clock to the VADC module (if applicable). Also this API
would put
1282 * the VADC module into the reset state(if applicable) by asserting the appropriate
registers.
1283 * This API would invoke XMC_SCU_CLOCK_GatePeripheralClock() and
XMC_SCU_RESET_AssertPeripheralReset() if needed.
1284 *
1285 * \par<b>Related APIs:</b><BR>
1286 * XMC_VADC_GLOBAL_EnableModule().
1287 */
1288 void XMC_VADC_GLOBAL_DisableModule(void);
1289
1290 /**
1291 *
1292 * @param global_ptr Constant pointer to the VADC module.
1293 * @param config Pointer to initialization data structure
1294 *
1295 * @return None
1296 *
1297 * \par<b>Description:</b><br>
1298 * Initializes the VADC global module with the associated configuration structure
pointed by \a config.\n\n It
1299 * enables the global access to registers by configuring reset and clock un-gating
for selected devices. It
1300 * initializes global class, boundary , result resources by setting
GLOBICLASS,GLOBBOUND,GLOBRCR registers. It also
1301 * configures the global analog and digital clock dividers by setting GLOBCFG
register. Refer related API's to change
1302 * the configurations later in the program.
1303 *
1304 * \par<b>Related APIs:</b><BR>
1305 * XMC_VADC_GLOBAL_ClockInit()<BR>
1306 */
1307 void XMC_VADC_GLOBAL_Init(XMC_VADC_GLOBAL_t *const global_ptr, const
XMC_VADC_GLOBAL_CONFIG_t *config);
1308
1309 /**
1310 *
1311 * @param global_ptr Constant pointer to the VADC module.
1312 *
1313 * @return None
1314 *
1315 * \par<b>Description:</b><br>
1316 * Enables the VADC module clock.\n\n Call this API before any further configuration
of VADC. It sets the DISR bit of CLC
1317 * register to enable.
1318 *
1319 * \par<b>Related APIs:</b><BR>
1320 * XMC_VADC_GLOBAL_Init()
1321 *
1322 */
1323 __STATIC_INLINE void XMC_VADC_GLOBAL_EnableModuleClock(XMC_VADC_GLOBAL_t *const
global_ptr)
1324 {
1325 XMC_ASSERT("XMC_VADC_GLOBAL_Enable:Wrong Module Pointer", (global_ptr == VADC))
1326 global_ptr->CLC &= ~((uint32_t)VADC_CLC_DISR_Msk);
1327 }
1328
1329 /**
1330 *
1331 * @param global_ptr Constant pointer to the VADC module.
1332 *
1333 * @return None
1334 *
1335 * \par<b>Description:</b><br>
1336 * Disables the VADC module clock.\n\n After this API call, no conversion will occur.
Call
1337 * XMC_VADC_GLOBAL_EnableModuleClock() to enable the VADC module later in the program.
1338 *
1339 * \par<b>Related APIs:</b><BR>
1340 * XMC_VADC_GLOBAL_Init()
1341 *
1342 */
1343 __STATIC_INLINE void XMC_VADC_GLOBAL_DisableModuleClock(XMC_VADC_GLOBAL_t *const
global_ptr)
1344 {
1345 XMC_ASSERT("XMC_VADC_GLOBAL_Disable:Wrong Module Pointer", (global_ptr == VADC))
1346 global_ptr->CLC |= (uint32_t) ((uint32_t)1 << VADC_CLC_DISR_Pos);
1347 }
1348
1349 /**
1350 *
1351 * @param global_ptr Constant pointer to the VADC module.
1352 *
1353 * @return None
1354 *
1355 * \par<b>Description:</b><br>
1356 * Enables VADC module to sleep if a sleep request comes.\n\n
1357 * It resets the EDIS bit of CLC register for enabling the sleep mode.
1358 *
1359 * \par<b>Related APIs:</b><BR>
1360 * XMC_VADC_GLOBAL_DisableSleepMode().
1361 */
1362 __STATIC_INLINE void XMC_VADC_GLOBAL_EnableSleepMode(XMC_VADC_GLOBAL_t *const
global_ptr)
1363 {
1364 XMC_ASSERT("XMC_VADC_GLOBAL_EnableSleepMode:Wrong Module Pointer", (global_ptr ==
VADC))
1365 global_ptr->CLC &= ~((uint32_t)VADC_CLC_EDIS_Msk);
1366 }
1367
1368 /**
1369 *
1370 * @param global_ptr Constant pointer to the VADC module.
1371 *
1372 * @return None
1373 *
1374 * \par<b>Description:</b><br>
1375 * Ignores the sleep mode request for the VADC.\n\n
1376 * With the sleep feature enabled, the module will respond to sleep
1377 * requests by going into a low power mode. It resets the EDIS bit of CLC register
for enabling the sleep mode.
1378 *
1379 * \par<b>Related APIs:</b><BR>
1380 * XMC_VADC_GLOBAL_EnableSleepMode().
1381 */
1382 __STATIC_INLINE void XMC_VADC_GLOBAL_DisableSleepMode(XMC_VADC_GLOBAL_t *const
global_ptr)
1383 {
1384 XMC_ASSERT("XMC_VADC_GLOBAL_DisableSleepMode:Wrong Module Pointer", (global_ptr ==
VADC))
1385 global_ptr->CLC |= (uint32_t) ((uint32_t)1 << VADC_CLC_EDIS_Pos);
1386 }
1387
1388 #if (XMC_VADC_GROUP_AVAILABLE == 1U)
1389 /**
1390 *
1391 * @param global_ptr Constant pointer to the VADC module.
1392 * @param config Pointer to the data structure containing clock configuration data
1393 *
1394 * @return None
1395 *
1396 * \par<b>Description:</b><br>
1397 * Configures the VADC clock.<BR>\n
1398 * Sets up the clock configuration of the VADC module using the config structure
pointed by \a config.
1399 * The clock to the analog converter and to the request source arbiter is configured
by setting the GLOBCFG register.
1400 *
1401 * \par<b>Related APIs:</b><BR>
1402 * None
1403 *
1404 */
1405 __STATIC_INLINE void XMC_VADC_GLOBAL_ClockInit(XMC_VADC_GLOBAL_t *const global_ptr,
const XMC_VADC_GLOBAL_CLOCK_t *config)
1406 {
1407 XMC_ASSERT("XMC_VADC_GLOBAL_ClockInit:Wrong Module Pointer", (global_ptr == VADC))
1408
1409 /* Write the Clock configuration into the GLOBCFG register */
1410 global_ptr->GLOBCFG = (uint32_t)(config->globcfg | (VADC_GLOBCFG_DIVWC_Msk));
1411 }
1412 #endif
1413
1414 /**
1415 *
1416 * @param global_ptr Constant pointer to the VADC module.
1417 * @param config Conversion class parameter structure
1418 * @param conv_type configure the input call for either standard conversion or EMUX
related conversion.
1419 * @param set_num Conversion class set<BR>
1420 * Range: [0x0, 0x1]
1421 *
1422 * \par<b>Description:</b><br>
1423 * Configures the ADC conversion settings like sample time and resolution.<BR>\n
1424 * Sets up the conversion settings for vadc global resource associated with \a config
structure. It configures the
1425 * conversion class properties like sampling time and resolution for selected \a
conv_type channels. It initializes
1426 * the GLOBALICLASS register specified by \a set_num with the required settings.
1427 *
1428 *
1429 * \par<b>Related APIs:</b><BR>
1430 * None
1431 *
1432 */
1433
1434 void XMC_VADC_GLOBAL_InputClassInit(XMC_VADC_GLOBAL_t *const global_ptr, const
XMC_VADC_GLOBAL_CLASS_t config,
1435 const XMC_VADC_GROUP_CONV_t conv_type, const
uint32_t set_num);
1436
1437 /**
1438 *
1439 * @param global_ptr Constant pointer to the VADC global module
1440 * @param config Pointer to result configuration data structure
1441 *
1442 * @return None
1443 *
1444 * \par<b>Description:</b><br>
1445 * Initializes global result register.<BR>\n
1446 * Initializes Global Result Register with specified settings configured in the \a
config structure.\n\n This API
1447 * results in configuration of GLOBRCR register. This helps in configuring the Data
reduction mode, global result event
1448 * , wait for read mode on the GLOBRES register.
1449 *
1450 *
1451 * \par<b>Related APIs:</b><BR>
1452 * None
1453 *
1454 */
1455
1456 __STATIC_INLINE void XMC_VADC_GLOBAL_ResultInit(XMC_VADC_GLOBAL_t *const global_ptr,
const XMC_VADC_RESULT_CONFIG_t *config)
1457 {
1458 XMC_ASSERT("XMC_VADC_GLOBAL_ResultInit:Wrong Module Pointer", (global_ptr == VADC))
1459
1460 /* Configure GLOBRCR*/
1461 global_ptr->GLOBRCR = config->g_rcr;
1462 }
1463
1464 /**
1465 *
1466 * @param global_ptr Constant pointer to the VADC module.
1467 *
1468 * @return None
1469 *
1470 * \par<b>Description:</b><br>
1471 * Enables the startup calibration feature of the VADC module.\n\n It configures the
SUCAL bit of GLOBCFG register to
1472 * enable the startup calibration feature. After turning it on, it loops until all
active groups finish calibration.
1473 * Call XMC_VADC_GLOBAL_Enable() and XMC_VADC_GLOBAL_ClockInit() before calling this
API in sequence. Calling the API
1474 * XMC_VADC_GLOBAL_DisableStartupCalibration() can disable the calibration feature at
runtime.
1475 *
1476 * \par<b>Related APIs:</b><BR>
1477 * XMC_VADC_GLOBAL_Enable()<BR>
1478 * XMC_VADC_GLOBAL_ClockInit()<BR>
1479 * None
1480 */
1481 void XMC_VADC_GLOBAL_StartupCalibration(XMC_VADC_GLOBAL_t *const global_ptr);
1482
1483
1484 /**
1485 *
1486 * @param global_ptr Constant pointer to the VADC module.
1487 *
1488 * @return None
1489 *
1490 * \par<b>Description:</b><br>
1491 * Disables the startup calibration feature of the VADC module.\n\n It configures the
SUCAL bit of GLOBCFG register to
1492 * disable the startup calibration feature. Calling the API
XMC_VADC_GLOBAL_EnsableStartupCalibration() can enable the
1493 * calibration feature at runtime.
1494 *
1495 * \par<b>Related APIs:</b><BR>
1496 * None
1497 */
1498
1499 __STATIC_INLINE void XMC_VADC_GLOBAL_DisableStartupCalibration(XMC_VADC_GLOBAL_t *
const global_ptr)
1500 {
1501 XMC_ASSERT("XMC_VADC_GLOBAL_DisableStartupCalibration:Wrong Module Pointer", (
global_ptr == VADC))
1502 global_ptr->GLOBCFG &= ~((uint32_t)VADC_GLOBCFG_SUCAL_Msk);
1503 }
1504
1505 #if (XMC_VADC_GROUP_AVAILABLE == 1U)
1506 /**
1507 *
1508 * @param global_ptr Constant pointer to the VADC module
1509 * @param group_number group number whose post calibration feature is to be
disabled. <BR>
1510 * Range[0x0 to 0x3] Accepts the enum ::XMC_VADC_GROUP_INDEX_t
1511 *
1512 * @return None
1513 *
1514 * \par<b>Description:</b><br>
1515 * Disables the post calibration for a particular group specified as \a
group_number.\n\n It configures the DPCAL0 bit
1516 * of GLOBCFG register to disable the post calibration feature. Call
XMC_VADC_GLOBAL_Enable() and
1517 * XMC_VADC_GLOBAL_ClockInit() before calling this API in sequence. Calling the API
1518 * XMC_VADC_GLOBAL_EnablePostCalibration() can enable back the calibration feature at
runtime.
1519 *
1520 * \par<b>Related APIs:</b><BR>
1521 * XMC_VADC_GLOBAL_Enable()<BR>
1522 * XMC_VADC_GLOBAL_ClockInit()<BR>
1523 * XMC_VADC_GLOBAL_DisablePostCalibration()<BR>
1524 * None
1525 */
1526
1527 __STATIC_INLINE void XMC_VADC_GLOBAL_DisablePostCalibration(XMC_VADC_GLOBAL_t *const
global_ptr, uint32_t group_number)
1528 {
1529 XMC_ASSERT("XMC_VADC_GLOBAL_DisablePostCalibration:Wrong Module Pointer", (
global_ptr == VADC))
1530
1531 global_ptr->GLOBCFG |= (uint32_t)((uint32_t)1 << ((uint32_t)VADC_GLOBCFG_DPCAL0_Pos
+ group_number));
1532 }
1533
1534 /**
1535 *
1536 * @param global_ptr Constant pointer to the VADC module
1537 * @param group_number group number whose post calibration feature is to be enabled.
<BR>
1538 * Range[0x0 to 0x3] Accepts the enum ::XMC_VADC_GROUP_INDEX_t
1539 *
1540 * @return None
1541 *
1542 * \par<b>Description:</b><br>
1543 * Enables the post calibration for a particular group specified as \a
group_number.\n\n It configures the DPCAL0 bit
1544 * of GLOBCFG register to enable the post calibration feature. Calling the API
XMC_VADC_GLOBAL_DisablePostCalibration()
1545 * can disable the calibration feature at runtime.
1546 *
1547 * \par<b>Related APIs:</b><BR>
1548 * XMC_VADC_GLOBAL_DisablePostCalibration()<BR>
1549 * None
1550 */
1551 __STATIC_INLINE void XMC_VADC_GLOBAL_EnablePostCalibration(XMC_VADC_GLOBAL_t *const
global_ptr, uint32_t group_number)
1552 {
1553 XMC_ASSERT("XMC_VADC_GLOBAL_EnablePostCalibration:Wrong Module Pointer", (global_ptr
== VADC))
1554
1555 global_ptr->GLOBCFG &= (~ (uint32_t)((uint32_t)1 << ((uint32_t)
VADC_GLOBCFG_DPCAL0_Pos + group_number)));
1556 }
1557 #endif
1558
1559 #if (XMC_VADC_BOUNDARY_AVAILABLE == 1U)
1560 /**
1561 *
1562 * @param global_ptr Constant pointer to the VADC module.
1563 * @param boundary0 Boundary-0 Value<BR>Range[0 - 4095]
1564 * @param boundary1 Boundary-1 Value<BR>Range[0 - 4095]
1565 *
1566 * @return None
1567 *
1568 * \par<b>Description:</b><br>
1569 * Programs the boundaries with \a boundary0 and boundary1 for result comparison.\n\n
These two boundaries can serve as
1570 * absolute boundaries. They defines a range against which the result of a conversion
can be compared. In the
1571 * fast compare mode, the two boundaries provide hysteresis capability to a compare
value. In any case, these boundary
1572 * values entered here form a boundary pallete. There are dedicated upper and lower
boundary registers GLOBBOUND0 and
1573 * GLOBBOUND1 who will derive their values from this palette.
1574 *
1575 * \par<b>Related APIs:</b><BR>
1576 * None
1577 *
1578 */
1579 void XMC_VADC_GLOBAL_SetBoundaries(XMC_VADC_GLOBAL_t *const global_ptr, const uint32_t
boundary0, const uint32_t boundary1);
1580 #endif
1581
1582 #if (XMC_VADC_EMUX_AVAILABLE== 1U)
1583 /**
1584 *
1585 * @param global_ptr Constant pointer to the VADC module
1586 * @param emuxif The EMUX interface<BR>Range[0x0 - 0x1]
1587 * @param group The VADC group which must be bound to the desired emux
1588 *
1589 * @return None
1590 *
1591 * \par<b>Description:</b><br>
1592 * Binds a VADC \a group to an EMUX interface specified in \a emuxif.<BR>\n
1593 * Selects which group's scan request source will control the EMUX interface (set of
control select lines for the EMUX).
1594 * By passing \b group it would configure that group's scan request source to control
the EMUX select lines of the set
1595 * \b emuxif.
1596 *
1597 * \par<b>Related APIs:</b><BR>
1598 * None
1599 */
1600 void XMC_VADC_GLOBAL_BindGroupToEMux(XMC_VADC_GLOBAL_t *const global_ptr, const
uint32_t emuxif, const uint32_t group);
1601 #endif
1602
1603 /**
1604 *
1605 * @param global_ptr Constant pointer to the VADC module.
1606 *
1607 * @return uint32_t Complete global result register value GLOBRES
1608 *
1609 * \par<b>Description:</b><br>
1610 * Retrieves the complete result from the global result register associated with the
\a global_ptr.\n\n This API audits
1611 * the result register GLOBRES for the validity of the data. If the validity is
assured, data is first read
1612 * the global result register, cached locally next and subsequently returned to the
caller.
1613 *
1614 * \par<b>Related APIs:</b><BR>
1615 * XMC_VADC_GLOBAL_GetResult()
1616 */
1617 __STATIC_INLINE uint32_t XMC_VADC_GLOBAL_GetDetailedResult(XMC_VADC_GLOBAL_t *const
global_ptr)
1618 {
1619 XMC_ASSERT("XMC_VADC_GLOBAL_GetDetailedResult:Wrong Module Pointer", (global_ptr ==
VADC))
1620
1621 return(global_ptr->GLOBRES);
1622 }
1623
1624 /**
1625 *
1626 * @param global_ptr Constant pointer to the VADC module.
1627 *
1628 * @return XMC_VADC_RESULT_SIZE_t 16 bit result register value.<BR>
1629 * Range[0x0 - 0X0FFF]
1630 *
1631 * \par<b>Description:</b><br>
1632 * Retrieves the conversion result from the global result register associated with
the \a global_ptr.\n\n This is a
1633 * lightweight version of XMC_VADC_GLOBAL_GetDetailedResult(). The behavior is
exactly the same, just that it is
1634 * only the 16 bit numeric result returned back to the application instead of the
complete GLOBRES register value.
1635 *
1636 * \par<b>Related APIs:</b><BR>
1637 * XMC_VADC_GLOBAL_GetDetailedResult()
1638 */
1639 __STATIC_INLINE XMC_VADC_RESULT_SIZE_t XMC_VADC_GLOBAL_GetResult(XMC_VADC_GLOBAL_t *
const global_ptr)
1640 {
1641 XMC_ASSERT("XMC_VADC_GLOBAL_GetResult:Wrong Module Pointer", (global_ptr == VADC))
1642
1643 return ((XMC_VADC_RESULT_SIZE_t)global_ptr->GLOBRES);
1644 }
1645
1646 /**
1647 *
1648 * @param global_ptr Constant pointer to the VADC module
1649 * @param compare_val Compare value which the result of a conversion will be compared
against.
1650 * <BR>Range[0x0 - 0X0FFF]
1651 *
1652 * @return None
1653 *
1654 * \par<b>Description:</b><br>
1655 * Set compare value in the global result register for fast compare mode.\n\n The
result of a conversion will directly
1656 * be compared to the compare value entered as part of \a compare_val. The
prerequisite is that the channel associated
1657 * with this global register must select an ICLASS which has the conversion mode
configured as fast compare mode. Call
1658 * @ref XMC_VADC_GLOBAL_GetCompareResult() after this API to
1659 *
1660 * \par<b>Related APIs:</b><BR>
1661 * None
1662 */
1663 void XMC_VADC_GLOBAL_SetCompareValue(XMC_VADC_GLOBAL_t *const global_ptr, const
XMC_VADC_RESULT_SIZE_t compare_val);
1664
1665 /**
1666 *
1667 * @param global_ptr Constant pointer to the VADC module
1668 * @return compare high or low. Refer @ref XMC_VADC_FAST_COMPARE_t enum
1669 *
1670 * @return None
1671 *
1672 * \par<b>Description:</b><br>
1673 * Determines the result of fast compare operation.\n\n This API returns the result
of fast compare operation provided
1674 * the valid flag in the global result register GLOBRES is set.
1675 *
1676 * \par<b>Related APIs:</b><BR>
1677 * None
1678 */
1679 XMC_VADC_FAST_COMPARE_t XMC_VADC_GLOBAL_GetCompareResult(XMC_VADC_GLOBAL_t *const
global_ptr);
1680
1681 /**
1682 *
1683 * @param global_ptr Constant pointer to the VADC module
1684 * @param event_type Desired event that must be manually asserted
1685 * Use the enum ::XMC_VADC_GLOBAL_EVENT_t to create a mask to be
used with this argument
1686 * @return None
1687 *
1688 * \par<b>Description:</b><br>
1689 * Manually asserts an event that can lead to an interrupt.\n\n This API manually
asserts the requested event
1690 * (Background request source event or a global result event) by setting the
GLOBEVFLAG register with the specified
1691 * \a event_type.
1692 *
1693 * \par<b>Related APIs:</b><BR>
1694 * None
1695 */
1696
1697 __STATIC_INLINE void XMC_VADC_GLOBAL_TriggerEvent(XMC_VADC_GLOBAL_t *const global_ptr,
const uint32_t event_type)
1698 {
1699 XMC_ASSERT("XMC_VADC_GLOBAL_TriggerEvent:Wrong Module Pointer", (global_ptr == VADC
))
1700 XMC_ASSERT("XMC_VADC_GLOBAL_TriggerEvent:Wrong Global Event",
1701 ((XMC_VADC_GLOBAL_EVENT_BKGNDSOURCE == event_type) || (
XMC_VADC_GLOBAL_EVENT_RESULT == event_type)))
1702
1703 global_ptr->GLOBEFLAG |= event_type;
1704 }
1705
1706 /**
1707 *
1708 * @param global_ptr Constant pointer to the VADC module
1709 * @param event_type Event that must be acknowledged
1710 * Use the enum ::XMC_VADC_GLOBAL_EVENT_t to create a mask to be
used with this argument
1711 *
1712 * @return None
1713 *
1714 * \par<b>Description:</b><br>
1715 * Acknowledges an event that has been asserted manually or automatically.\n\n This
API acknowledges the requested event
1716 * by clearing GLOBEFLAG sticky flag.
1717 *
1718 * \par<b>Related APIs:</b><BR>
1719 * None
1720 */
1721 __STATIC_INLINE void XMC_VADC_GLOBAL_ClearEvent(XMC_VADC_GLOBAL_t *const global_ptr,
const uint32_t event_type)
1722 {
1723 XMC_ASSERT("XMC_VADC_GLOBAL_ClearEvent:Wrong Module Pointer", (global_ptr == VADC))
1724 XMC_ASSERT("XMC_VADC_GLOBAL_ClearEvent:Wrong Global Event",
1725 ((XMC_VADC_GLOBAL_EVENT_BKGNDSOURCE == event_type) || (
XMC_VADC_GLOBAL_EVENT_RESULT == event_type)))
1726
1727 global_ptr->GLOBEFLAG |= ((uint32_t)(event_type << (uint32_t)16));
1728 }
1729
1730 /**
1731 *
1732 * @param global_ptr Constant pointer to the VADC module
1733 * @param sr The service request to which the global result event is connected. Refer
@ref XMC_VADC_SR_t enum
1734 *
1735 * @return None
1736 *
1737 * \par<b>Description:</b><br>
1738 * Binds the global result event to one of the 4 shared service requests.\n\n This
API binds the global result event
1739 * to one of the 4 module wide shared service requests .Sets GLOBEVNP register with
the corresponding \a sr line.
1740 *
1741 * \par<b>Related APIs:</b><BR>
1742 * XMC_VADC_GLOBAL_BackgroundSetReqSrcEventInterruptNode()
1743 */
1744 void XMC_VADC_GLOBAL_SetResultEventInterruptNode(XMC_VADC_GLOBAL_t *const global_ptr,
XMC_VADC_SR_t sr);
1745
1746 /**
1747 *
1748 * @param global_ptr Constant pointer to the VADC module
1749 * @param sr The service request to which the global request source event is
connected. Refer @ref XMC_VADC_SR_t enum
1750 *
1751 * @return None
1752 *
1753 * \par<b>Description:</b><br>
1754 * Binds the background request source event to one of the 4 shared service
requests.\n\n This API binds the background
1755 * request source event to one of the 4 module wide shared service requests. Sets
GLOBEVNP register with the
1756 * corresponding \a sr line.
1757 *
1758 * \par<b>Related APIs:</b><BR>
1759 * XMC_VADC_GLOBAL_SetResultEventInterruptNode()
1760 */
1761 void XMC_VADC_GLOBAL_BackgroundSetReqSrcEventInterruptNode(XMC_VADC_GLOBAL_t *const
global_ptr, XMC_VADC_SR_t sr);
1762
1763 #if(XMC_VADC_SHS_AVAILABLE == 1U)
1764 /**
1765 * @param shs_ptr Constant pointer to the VADC Sample and hold module
1766 * @param config Struct consisting of various SHS related configurations.
1767 *
1768 * @return None
1769 *
1770 * \par<b>Description:</b><br>
1771 * Configure the basic SHS parameters.<BR>\n
1772 * API would initialize the clock divider configuration, the analog reference
selection and
1773 * the calibration order for the Sample and Hold unit.
1774 *
1775 * \par<b>Related APIs:</b><BR>
1776 * None.
1777 */
1778 void XMC_VADC_GLOBAL_SHS_Init(XMC_VADC_GLOBAL_SHS_t *const shs_ptr, const
XMC_VADC_GLOBAL_SHS_CONFIG_t *config);
1779
1780 /**
1781 * @param shs_ptr Constant pointer to the VADC Sample and hold module
1782 * @param config Struct consisting of various step configurations.
1783 *
1784 * @return None
1785 *
1786 * \par<b>Description:</b><br>
1787 * Configures the stepper sequence for the converter.<BR>\n
1788 * Stepper of the SHS can be configured to take up a specific sequence of groups for
conversion.
1789 * The stepper sequence is configured using this API.
1790 *
1791 * \par<b>Related APIs:</b><BR>
1792 * None.
1793 */
1794 __STATIC_INLINE void XMC_VADC_GLOBAL_SHS_SetStepperSequence(XMC_VADC_GLOBAL_SHS_t *
const shs_ptr,
1795 const
XMC_VADC_GLOBAL_SHS_STEP_
CONFIG_t *config)
1796 {
1797 XMC_ASSERT("XMC_VADC_GLOBAL_SHS_StepperInit:Wrong SHS Pointer",
1798 (shs_ptr == (XMC_VADC_GLOBAL_SHS_t*)(void*)SHS0))
1799 XMC_ASSERT("XMC_VADC_GLOBAL_SHS_StepperInit:Wrong config pointer",
1800 (config == (XMC_VADC_GLOBAL_SHS_STEP_CONFIG_t*)NULL))
1801
1802 shs_ptr->STEPCFG = (uint32_t) config->stepcfg;
1803 }
1804
1805
1806 /**
1807 * @param shs_ptr Constant pointer to the VADC Sample and hold module
1808 *
1809 * @return bool returns true if the analog converter is operable
1810 * returns false if the analog converter is powered down
1811 *
1812 * \par<b>Description:</b><br>
1813 * Returns the converter status.<BR>\n
1814 * Returns the ANRDY bit field of the SHSCFG register.
1815 *
1816 * \par<b>Related APIs:</b><BR>
1817 * None.
1818 */
1819 __STATIC_INLINE bool XMC_VADC_GLOBAL_SHS_IsConverterReady(XMC_VADC_GLOBAL_SHS_t *
const shs_ptr)
1820 {
1821 XMC_ASSERT("XMC_VADC_GLOBAL_SHS_IsConverterReady:Wrong SHS Pointer",(shs_ptr == (
XMC_VADC_GLOBAL_SHS_t*)(void*)SHS0))
1822
1823 return((bool)((shs_ptr->STEPCFG >> (uint32_t)SHS_SHSCFG_ANRDY_Pos) & (uint32_t)0x1
));
1824 }
1825
1826
1827 /**
1828 * @param shs_ptr Constant pointer to the VADC Sample and hold module
1829 * @param group_num group number for which the accelerated mode needs to be enabled.<
BR>Range: [0x0 to 0x1]
1830 *
1831 * @return None
1832 *
1833 * \par<b>Description:</b><br>
1834 * Enables the Accelerated timing mode.<BR>\n
1835 * This API is needed when a switch from compatible mode to accelerated mode of
conversion is needed. In
1836 * this mode the ADC module will convert the input depending on the value stored in
the SST bit of the SHS0_TIMCFGx.
1837 * This API would configure the accelerated mode in the SHS0_TIMCFG0 and SHS0_TIMCFG1
registers.
1838 *
1839 * \par<b>Related APIs:</b><BR>
1840 * None.
1841 */
1842 void XMC_VADC_GLOBAL_SHS_EnableAcceleratedMode(XMC_VADC_GLOBAL_SHS_t *const shs_ptr,
XMC_VADC_GROUP_INDEX_t group_num);
1843
1844 /**
1845 * @param shs_ptr Constant pointer to the VADC Sample and hold module
1846 * @param group_num group number for which the accelerated mode needs to be disabled.<
BR>Range: [0x0 to 0x1]
1847 *
1848 * @return None
1849 *
1850 * \par<b>Description:</b><br>
1851 * Enables the Accelerated timing mode.<BR>\n
1852 * This API is needed when a switch from accelerated mode to compatible mode of
conversion is needed.
1853 * This API would clear the accelerated mode in the SHS0_TIMCFG0 and SHS0_TIMCFG1
registers.
1854 *
1855 * \par<b>Related APIs:</b><BR>
1856 * None.
1857 */
1858 void XMC_VADC_GLOBAL_SHS_DisableAcceleratedMode(XMC_VADC_GLOBAL_SHS_t *const shs_ptr,
XMC_VADC_GROUP_INDEX_t group_num);
1859
1860 /**
1861 * @param shs_ptr Constant pointer to the VADC Sample and hold module
1862 * @param group_num group number for which the accelerated mode needs to be enabled.<
BR>Range: [0x0 to 0x1]
1863 * @param sst_value Value of short sample time that needs to be configured.<BR>
1864 * Range: [0x0 to 0x3F]
1865 *
1866 * @return None
1867 *
1868 * \par<b>Description:</b><br>
1869 * Configures the Accelerated timing mode sample time.<BR>\n
1870 * This API is needed when a switch from compatible mode to accelerated mode of
conversion is needed. In
1871 * Accelerated mode the ADC module will convert the input depending on the value
stored in the SST bit of the
1872 * SHS0_TIMCFGx. This API would configure the shot sample time either in
SHS0_TIMCFG0.SST or SHS0_TIMCFG1.SST .
1873 *
1874 * \par<b>Related APIs:</b><BR>
1875 * None.
1876 */
1877 void XMC_VADC_GLOBAL_SHS_SetShortSampleTime(XMC_VADC_GLOBAL_SHS_t *const shs_ptr,
1878 XMC_VADC_GROUP_INDEX_t group_num,
1879 uint8_t sst_value);
1880
1881
1882 /**
1883 * @param shs_ptr Constant pointer to the VADC Sample and hold module
1884 * @param divs_value The clock divider value that is possible
1885 * <BR>Range:[0x0 to 0xF]
1886 * @return None
1887 *
1888 * \par<b>Description:</b><br>
1889 * Configure Sample and hold clock divider value.<BR>\n
1890 * API would initialize the clock divider configuration. This determines the
frequency of conversion
1891 * of the Sample and hold converter.
1892 *
1893 * \par<b>Related APIs:</b><BR>
1894 * None.
1895 */
1896 __STATIC_INLINE void XMC_VADC_GLOBAL_SHS_SetClockDivider(XMC_VADC_GLOBAL_SHS_t *const
shs_ptr, uint8_t divs_value)
1897 {
1898 XMC_ASSERT("XMC_VADC_GLOBAL_SHS_SetClockDivider:Wrong SHS Pointer",
1899 (shs_ptr == (XMC_VADC_GLOBAL_SHS_t*)(void*)SHS0))
1900 XMC_ASSERT("XMC_VADC_GLOBAL_SHS_SetClockDivider:Wrong divide factor selected",
1901 (divs_value < (uint32_t)0x10))
1902
1903 shs_ptr->SHSCFG = (shs_ptr->SHSCFG & (~(uint32_t)SHS_SHSCFG_DIVS_Msk)) | (uint32_t)
SHS_SHSCFG_SCWC_Msk;
1904 shs_ptr->SHSCFG |= ((uint32_t)divs_value << SHS_SHSCFG_DIVS_Pos) | (uint32_t)
SHS_SHSCFG_SCWC_Msk;
1905 }
1906
1907 /**
1908 * @param shs_ptr Constant pointer to the VADC Sample and hold module
1909 * @param gain_value gain value possible
1910 * Range:[0x0 to 0x3]
1911 * @param group_num The Group number for which the configurations applies
1912 * @param ch_num The channel number for which the gain has to be configured
1913 * @return None
1914 *
1915 * \par<b>Description:</b><br>
1916 * Configure the gain value for SHS.<BR>\n
1917 * API would set the gain factor for a selected channel.
1918 *
1919 * \par<b>Related APIs:</b><BR>
1920 * None.
1921 */
1922 void XMC_VADC_GLOBAL_SHS_SetGainFactor(XMC_VADC_GLOBAL_SHS_t *const shs_ptr,
1923 uint8_t gain_value,
1924 XMC_VADC_GROUP_INDEX_t group_num,
1925 uint8_t ch_num);
1926
1927
1928 /**
1929 * @param shs_ptr Constant pointer to the VADC Sample and hold module
1930 * @param max_calibration_time calibration time
1931 * Range:[0x0 to 0x3F]
1932 * @return None
1933 *
1934 * \par<b>Description:</b><br>
1935 * Configure the Maximum calibration timing.<BR>\n
1936 * API would initialize the Maximum time after which the calibration should occur. If
no adc conversion
1937 * occur during this duration then the calibration would run irrespective of
conversions. The max time the
1938 * converter can go without a calibration is set in this API.
1939 *
1940 * \par<b>Related APIs:</b><BR>
1941 * None.
1942 */
1943 __STATIC_INLINE void XMC_VADC_GLOBAL_SHS_SetMaxCalTime(XMC_VADC_GLOBAL_SHS_t *const
shs_ptr,
1944 uint32_t max_calibration_time)
1945 {
1946 XMC_ASSERT("XMC_VADC_GLOBAL_SHS_SetMaxCalTime:Wrong SHS Pointer",
1947 (shs_ptr == (XMC_VADC_GLOBAL_SHS_t*)(void*)SHS0))
1948
1949 shs_ptr->CALCTR &= ~((uint32_t)SHS_CALCTR_CALMAX_Msk);
1950 shs_ptr->CALCTR |= ((uint32_t)max_calibration_time << SHS_CALCTR_CALMAX_Pos);
1951 }
1952
1953
1954 /**
1955 * @param shs_ptr Constant pointer to the VADC Sample and hold module
1956 * @param group_num The Group number for which the configurations applies
1957 * @return None
1958 *
1959 * \par<b>Description:</b><br>
1960 * Enable the Gain and offset calibration.<BR>\n
1961 * Enable the gain and offset calibration for all the Sample and hold units.
1962 *
1963 * \par<b>Related APIs:</b><BR>
1964 * XMC_VADC_GLOBAL_SHS_DisableGainAndOffsetCalibrations()<BR>.
1965 */
1966 void XMC_VADC_GLOBAL_SHS_EnableGainAndOffsetCalibrations(XMC_VADC_GLOBAL_SHS_t *const
shs_ptr,
1967 XMC_VADC_GROUP_INDEX_t
group_num);
1968
1969 /**
1970 * @param shs_ptr Constant pointer to the VADC Sample and hold module
1971 * @param group_num The Group number for which the configurations applies
1972 * @return None
1973 *
1974 * \par<b>Description:</b><br>
1975 * Disable the Gain and offset calibration.<BR>\n
1976 * Disable the gain and offset calibration for all the Sample and hold units.
1977 *
1978 * \par<b>Related APIs:</b><BR>
1979 * XMC_VADC_GLOBAL_SHS_EnableGainAndOffsetCalibrations()<BR>.
1980 */
1981 void XMC_VADC_GLOBAL_SHS_DisableGainAndOffsetCalibrations(XMC_VADC_GLOBAL_SHS_t *const
shs_ptr,
1982 XMC_VADC_GROUP_INDEX_t
group_num);
1983
1984 /**
1985 * @param shs_ptr Constant pointer to the VADC Sample and hold module
1986 * @param group_num The Group number for which the configurations applies
1987 * @param gain_level The gain level whose calibration value has to read.
1988 * @return None
1989 *
1990 * \par<b>Description:</b><br>
1991 * Read the calibration value for the selected gain level.<BR>\n
1992 * Each gain value has a offset calibration value, this API would return the offset
calibration value of the
1993 * selected gain level. This is applicable for all the channels in the group that use
the particular gain level.
1994 *
1995 * \par<b>Related APIs:</b><BR>
1996 * XMC_VADC_GLOBAL_SHS_SetOffsetCalibrationValue()<BR>.
1997 */
1998 uint8_t XMC_VADC_GLOBAL_SHS_GetOffsetCalibrationValue(XMC_VADC_GLOBAL_SHS_t *const
shs_ptr,
1999 XMC_VADC_GROUP_INDEX_t group_num
,
2000 XMC_VADC_SHS_GAIN_LEVEL_t
gain_level);
2001
2002 /**
2003 * @param shs_ptr Constant pointer to the VADC Sample and hold module
2004 * @param group_num The Group number for which the configurations applies
2005 * @param gain_level The gain level whose calibration value has to read.
2006 * @param offset_calibration_value The offset calibration value to be set.
2007 * @return None
2008 *
2009 * \par<b>Description:</b><br>
2010 * Set the calibration value for the selected gain level.<BR>\n
2011 * Each gain value has a offset calibration value, this API would set the offset
value of the selected gain level.
2012 *
2013 * \par<b>Related APIs:</b><BR>
2014 * XMC_VADC_GLOBAL_SHS_GetOffsetCalibrationValue()<BR>.
2015 */
2016 void XMC_VADC_GLOBAL_SHS_SetOffsetCalibrationValue(XMC_VADC_GLOBAL_SHS_t *const
shs_ptr,
2017 XMC_VADC_GROUP_INDEX_t group_num,
2018 XMC_VADC_SHS_GAIN_LEVEL_t
gain_level,
2019 uint8_t offset_calibration_value);
2020
2021 /**
2022 * @param shs_ptr Constant pointer to the VADC Sample and hold module
2023 * @param XMC_VADC_GROUP_INDEX_t The Group number for which the configurations
applies
2024 * @param loop_select The delta sigma loop number for which the configurations
applies
2025 * @param ch_num Channel number for which the configurations applies
2026 * @return None
2027 *
2028 * \par<b>Description:</b><br>
2029 * Configures the delta sigma loop of the SHS.<BR>\n
2030 * There are 2 Delta-Sigma loops that can be configured. This API would configure the
loop (loop_select)
2031 * with the appropriate group_num and channel_num.
2032 * Configures the SHS_LOOP bit fields.
2033 *
2034 * \par<b>Related APIs:</b><BR>
2035 * XMC_VADC_GLOBAL_SHS_EnableSigmaDeltaLoop()<BR>.
2036 */
2037 void XMC_VADC_GLOBAL_SHS_SetSigmaDeltaLoop(XMC_VADC_GLOBAL_SHS_t *const shs_ptr,
2038 XMC_VADC_GROUP_INDEX_t group_num,
2039 XMC_VADC_SHS_LOOP_CH_t loop_select,
2040 uint8_t ch_num);
2041
2042 /**
2043 * @param shs_ptr Constant pointer to the VADC Sample and hold module
2044 * @param loop_select The delta sigma loop number for which the configurations
applies
2045 * @return None
2046 *
2047 * \par<b>Description:</b><br>
2048 * Enable the selected Delta-Sigma loop.<BR>\n
2049 * Configures the SHS_LOOP.LPENx bit field.
2050 *
2051 * \par<b>Related APIs:</b><BR>
2052 * XMC_VADC_GLOBAL_SHS_SetSigmaDeltaLoop()<BR>.
2053 * XMC_VADC_GLOBAL_SHS_EnableGainAndOffsetCalibrations()<BR>.
2054 */
2055 __STATIC_INLINE void XMC_VADC_GLOBAL_SHS_EnableSigmaDeltaLoop(XMC_VADC_GLOBAL_SHS_t *
const shs_ptr,
2056 XMC_VADC_SHS_LOOP_CH_t
loop_select)
2057 {
2058 XMC_ASSERT("XMC_VADC_GLOBAL_SHS_EnableSigmaDeltaLoop:Wrong SHS Pointer",
2059 (shs_ptr == (XMC_VADC_GLOBAL_SHS_t*)(void*)SHS0))
2060 XMC_ASSERT("XMC_VADC_GLOBAL_SHS_EnableSigmaDeltaLoop:Wrong Delta sigma loop
selected",
2061 (loop_select == XMC_VADC_SHS_LOOP_CH_0)||(loop_select ==
XMC_VADC_SHS_LOOP_CH_1))
2062
2063 shs_ptr->LOOP |= (uint32_t)SHS_LOOP_LPEN0_Msk << (uint32_t)loop_select;
2064 }
2065
2066 /**
2067 * @param shs_ptr Constant pointer to the VADC Sample and hold module
2068 * @param loop_select The delta sigma loop number for which the configurations
applies
2069 * @return None
2070 *
2071 * \par<b>Description:</b><br>
2072 * Disable the selected delta sigma loop.<BR>\n
2073 * Configures the SHS_LOOP.LPENx bit field.
2074 *
2075 * \par<b>Related APIs:</b><BR>
2076 * XMC_VADC_GLOBAL_SHS_SetSigmaDeltaLoop()<BR>.
2077 * XMC_VADC_GLOBAL_SHS_EnableGainAndOffsetCalibrations()<BR>.
2078 */
2079 __STATIC_INLINE void XMC_VADC_GLOBAL_SHS_DisableSigmaDeltaLoop(XMC_VADC_GLOBAL_SHS_t *
const shs_ptr,
2080 XMC_VADC_SHS_LOOP_CH_t
loop_select)
2081 {
2082 XMC_ASSERT("XMC_VADC_GLOBAL_SHS_DisableSigmaDeltaLoop:Wrong SHS Pointer",
2083 (shs_ptr == (XMC_VADC_GLOBAL_SHS_t*)(void*)SHS0))
2084 XMC_ASSERT("XMC_VADC_GLOBAL_SHS_DisableSigmaDeltaLoop:Wrong Delta sigma loop
selected",
2085 (loop_select == XMC_VADC_SHS_LOOP_CH_0)||(loop_select ==
XMC_VADC_SHS_LOOP_CH_1))
2086
2087 shs_ptr->LOOP &= ~((uint32_t)SHS_LOOP_LPEN0_Msk << (uint32_t)loop_select);
2088
2089 }
2090
2091 #endif
2092 #if (XMC_VADC_GROUP_AVAILABLE == 1U)
2093 /**
2094 *
2095 * @param group_ptr Constant pointer to the VADC group.
2096 * @param config Pointer to the initialization data structure
2097 *
2098 * @return None
2099 *
2100 * \par<b>Description:</b><br>
2101 * Initializes the VADC group module with the associated configuration structure
pointed by \a config.\n\n It
2102 * initializes the group specified as part of the \group_ptr. It initializes group
conversion class, arbiter
2103 * configuration , boundary configuration by setting GxICLASS,GxARBCFG,GxBOUND,
registers. It also
2104 * configures the EMUX control register if applicable. Refer related API's to change
the configurations later in the
2105 * program.
2106 *
2107 * \par<b>Related APIs:</b><BR>
2108 * XMC_VADC_GROUP_InputClassInit()<BR>
2109 * XMC_VADC_GROUP_SetPowerMode()<BR>
2110 * XMC_VADC_GROUP_SetBoundaries()<BR>
2111 * XMC_VADC_GROUP_ExternalMuxControlInit()<BR>
2112 */
2113 void XMC_VADC_GROUP_Init(XMC_VADC_GROUP_t *const group_ptr, const
XMC_VADC_GROUP_CONFIG_t *config);
2114
2115 /**
2116 *
2117 * @param group_ptr Constant pointer to the VADC group.
2118 * @param config group related conversion class parameter structure
2119 * @param conv_type Use direct channels or EMUX channels. Refer @ref
XMC_VADC_GROUP_CONV_t enum
2120 * @param set_num Conversion class set<BR>
2121 * Range[0x0, 0x1]
2122 *
2123 * @return None
2124 *
2125 * \par<b>Description:</b><br>
2126 * Sets up the conversion settings for vadc group resource associated with \a config
structure. It configures the
2127 * conversion class properties like sampling time and resolution for selected \a
conv_type channels. It initializes
2128 * the G_ICLASS register specified by \a set_num with the required settings.
2129 *
2130 *
2131 * \par<b>Related APIs:</b><BR>
2132 * XMC_VADC_GROUP_Init()
2133 *
2134 */
2135 void XMC_VADC_GROUP_InputClassInit(XMC_VADC_GROUP_t *const group_ptr, const
XMC_VADC_GROUP_CLASS_t config,
2136 const XMC_VADC_GROUP_CONV_t conv_type, const
uint32_t set_num);
2137
2138 /**
2139 *
2140 * @param group_ptr Constant pointer to the VADC Group which must be set as a slave
2141 * @param master_grp The master group number<BR>
2142 * Range: [0x0 - 0x3]
2143 * @param slave_group The slave group number<BR>
2144 * Range: [0x0 - 0x3]
2145 *
2146 * @return None
2147 *
2148 * \par<b>Description:</b><br>
2149 * Configures a VADC Group as a slave group.\n\n Conversion of identically numbered
channels across groups can be
2150 * synchronized. For example, when the trigger to convert CH-1 of Group-2 is
received, it is possible to
2151 * simultaneously request conversion of CH-1 of Group-0 and Group-3. Group-2 in this
example is therefore the
2152 * master group while Groups-0 and 3 are the slave groups. It uses the SYNCCTR
register for the configuration settings.
2153 *
2154 * \par<b>Related APIs:</b><BR>
2155 * XMC_VADC_GROUP_SetSyncMaster()<BR>
2156 * XMC_VADC_GROUP_CheckSlaveReadiness()<BR>
2157 * XMC_VADC_GROUP_EnableChannelSyncRequest()<BR>
2158 *
2159 */
2160 void XMC_VADC_GROUP_SetSyncSlave(XMC_VADC_GROUP_t *const group_ptr, uint32_t
master_grp, uint32_t slave_group);
2161
2162 /**
2163 *
2164 * @param group_ptr Constant pointer to the VADC Group.
2165 * @param power_mode Desired power mode
2166 *
2167 * @return None
2168 *
2169 * \par<b>Description:</b><br>
2170 * Configures the power mode of a VADC group.\n\n For a VADC group to actually
convert an analog signal, its analog
2171 * converter must be turned on.
2172 *
2173 * \par<b>Related APIs:</b><BR>
2174 * None
2175 */
2176 void XMC_VADC_GROUP_SetPowerMode(XMC_VADC_GROUP_t *const group_ptr, const
XMC_VADC_GROUP_POWERMODE_t power_mode);
2177
2178 /**
2179 *
2180 * @param group_ptr Constant pointer to the VADC group.
2181 *
2182 * @return None
2183 *
2184 * \par<b>Description:</b><br>
2185 * Configures a VADC Group as a master group.<BR>\n
2186 * Conversion of identically numbered channels across groups can be
2187 * synchronized. For example, when the trigger to convert CH-1 of Group-2 is
received, it is possible to simultaneously
2188 * request conversion of CH-1 of Group-0 and Group-3. Group-2 in this example is
therefore the master group while
2189 * Groups-0 and 3 are the slave groups.
2190 *
2191 * \par<b>Related APIs:</b><BR>
2192 * None
2193 */
2194 void XMC_VADC_GROUP_SetSyncMaster(XMC_VADC_GROUP_t *const group_ptr);
2195
2196 /**
2197
2198 * @param group_ptr Pointer to the master VADC Group
2199 * @param slave_group The slave VADC Group number
2200 * <BR>Range: [0x0 to 0x3]
2201 * @return None
2202 *
2203 * \par<b>Description:</b><br>
2204 * Configures the ready signal for master group.<BR>\n
2205 * This API would read the \b slave_group number and determine which EVAL
configuration to apply for the given master
2206 * slave set. Checks the readiness of slaves in synchronized conversions. Conversion
of identically numbered channels
2207 * across groups can be synchronized. For example, when the trigger to convert CH-1
of Group-2 is received, it is
2208 * possible to simultaneously request conversion of CH-1 of Group-0 and Group-3.
Group-2 in this example is
2209 * therefore the master group while Groups-0 and 3 are the slave groups. Before the
master can request its slaves
2210 * for synchronized conversion, it has the option of checking the readiness of the
slaves.
2211 *
2212 * \par<b>Related APIs:</b><BR>
2213 * XMC_VADC_GROUP_IgnoreSlaveReadiness()<BR> XMC_VADC_GROUP_SetSyncMaster()
2214 */
2215 void XMC_VADC_GROUP_CheckSlaveReadiness(XMC_VADC_GROUP_t *const group_ptr, uint32_t
slave_group);
2216
2217 /**
2218 *
2219 * @param group_ptr Constant Pointer to the master VADC Group
2220 * @param slave_group The slave VADC Group number
2221 * @return None
2222 *
2223 * \par<b>Description:</b><br>
2224 * Clears the ready signal for master group.<BR>\n
2225 * Ignores the readiness of slaves in synchronized conversions.This API would read
the \b slave_group number and
2226 * determine which EVAL configuration to apply for the given master slave set. Then
clears the configuration if present.
2227 * This API is called when the master should issue the conversion request without
waiting for the slave to
2228 * assert a ready signal. The ready signal is asserted by the slave group(s) when the
conversion is completed
2229 * in these channels.
2230 *
2231 * \par<b>Related APIs:</b><BR>
2232 * XMC_VADC_GROUP_CheckSlaveReadiness()<BR> XMC_VADC_GROUP_SetSyncMaster()<BR>
2233 */
2234 void XMC_VADC_GROUP_IgnoreSlaveReadiness(XMC_VADC_GROUP_t *const group_ptr, uint32_t
slave_group);
2235
2236 /**
2237 *
2238 * @param group_ptr Constant pointer to the master VADC Group
2239 * @param ch_num Channel whose conversion triggers conversion in slave groups
2240 * @return None
2241 *
2242 * \par<b>Description:</b><br>
2243 * Sets up a channel for synchronized conversion.\n\n Conversion of identically
numbered channels across groups
2244 * can be synchronized. For example, when the trigger to
2245 * convert CH-1 of Group-2 is received, it is possible to simultaneously request
conversion of CH-1 of Group-0 and
2246 * Group-3. Group-2 in this example is therefore the master group while Groups-0 and
3 are the slave groups.<br>
2247 * Before the master can request its slaves for synchronized conversion, it has the
option of checking the readiness
2248 * of the slaves.
2249 *
2250 * \par<b>Related APIs:</b><BR>
2251 * None
2252 */
2253 void XMC_VADC_GROUP_EnableChannelSyncRequest(XMC_VADC_GROUP_t *const group_ptr, const
uint32_t ch_num);
2254
2255 /**
2256 *
2257 * @param group_ptr Pointer to the master VADC Group
2258 * @param ch_num Channel whose conversion triggers conversion in slave groups
2259 * @return None
2260 *
2261 * \par<b>Description:</b><br>
2262 * Disable the synchronization request for the particular channel specified as
ch_num. To enable the synchronization
2263 * call the API @ref XMC_VADC_GROUP_EnableChannelSyncRequest().
2264 *
2265 * \par<b>Related APIs:</b><BR>
2266 * None
2267 */
2268 void XMC_VADC_GROUP_DisableChannelSyncRequest(XMC_VADC_GROUP_t *const group_ptr, const
uint32_t ch_num);
2269
2270 /**
2271 *
2272 * @param group_ptr Constant pointer to the VADC group.
2273 *
2274 * @return retuns IDLE if converter is free else returns busy. Refer @ref
XMC_VADC_GROUP_STATE_t enum
2275 *
2276 * \par<b>Description:</b><br>
2277 * Checks the live status of the analog to digital converter. The converter can
either idle doing nothing or busy
2278 * sampling + converting.
2279 *
2280 * \par<b>Related APIs:</b><BR>
2281 * None
2282 */
2283 XMC_VADC_GROUP_STATE_t XMC_VADC_GROUP_IsConverterBusy(XMC_VADC_GROUP_t *const
group_ptr);
2284
2285 /**
2286 *
2287 * @param group_ptr Constant pointer to the VADC group whose global boundary
registers are to be programmed
2288 * @param boundary0 Boundary-0 Value<BR>
2289 * Range: [0x0 - 0x0FFF]
2290 * @param boundary1 Boundary-1 Value<BR>
2291 * Range: [0x0 - 0x0FFF]
2292 *
2293 * @return None
2294 *
2295 * \par<b>Description:</b><br>
2296 * Programs the boundaries with \a boundary0 and boundary1 for result comparison.\n\n
These two boundaries can serve as
2297 * absolute boundaries. They defines a range against which the result of a conversion
can be compared. In the
2298 * fast compare mode, the two boundaries provide hysteresis capability to a compare
value. In any case, these boundary
2299 * values entered here form a boundary pallete. There are dedicated upper and lower
boundary registers G_BOUND0 and
2300 * G_BOUND1 who will derive their values from this palette.
2301 *
2302 * \par<b>Related APIs:</b><BR>
2303 * None
2304 *
2305 */
2306 void XMC_VADC_GROUP_SetBoundaries(XMC_VADC_GROUP_t *const group_ptr,
2307 const uint32_t boundary0,
2308 const uint32_t boundary1);
2309
2310 /**
2311 * @param group_ptr Constant pointer to the VADC group
2312 * @param sr_num The service request number (0 through 3)
2313 * @param type IRQ type (Kernel specific interrupt vs Module wide shared
interrupt )
2314 * @return None
2315 *
2316 * \par<b>Description:</b><br>
2317 * Activates a Service Request line(manually trigger).<BR>\n
2318 * VADC provides few SR lines for each group and a few more which is shared across
all the groups.
2319 * These SR lines can be connected to an NVIC node which in-turn would generate an
interrupt.
2320 * This API would manually trigger the given SR line. Could be used for evaluation
and testing purposes.
2321 *
2322 * \par<b>Related APIs:</b><BR>
2323 * None
2324 */
2325 void XMC_VADC_GROUP_TriggerServiceRequest(XMC_VADC_GROUP_t *const group_ptr,
2326 const uint32_t sr_num,
2327 const XMC_VADC_GROUP_IRQ_t type);
2328
2329 /**
2330 *
2331 * @param group_ptr Constant pointer to the VADC group
2332 * @param emux_cfg EMUX configuration structure
2333 * @return None
2334 *
2335 * \par<b>Description:</b><br>
2336 * Configures group EMUX parameters associated with the \a emux_cfg configuration
structure.\n\n An external emux
2337 * interface allows additional channels to be connected to a VADC group. The
conversion properties
2338 * of such channels can be different from the standard channels which are directly
connected to the VADC group.
2339 * This API configures conversion properties of channels connected via EMUX interface.
2340 *
2341 * \par<b>Related APIs:</b><BR>
2342 * None
2343 */
2344 __STATIC_INLINE void XMC_VADC_GROUP_ExternalMuxControlInit(XMC_VADC_GROUP_t *const
group_ptr,
2345 const
XMC_VADC_GROUP_EMUXCFG_t
emux_cfg)
2346 {
2347 uint32_t emux_config;
2348
2349 XMC_ASSERT("XMC_VADC_GROUP_ExternalMuxControlInit:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
2350
2351 emux_config = ((uint32_t)emux_cfg.starting_external_channel << (uint32_t)
VADC_G_EMUXCTR_EMUXSET_Pos) |
2352 ((uint32_t)emux_cfg.connected_channel << (uint32_t)
VADC_G_EMUXCTR_EMUXCH_Pos);
2353
2354 group_ptr->EMUXCTR = emux_config;
2355 emux_config = ((uint32_t)emux_cfg.emux_coding << (uint32_t)VADC_G_EMUXCTR_EMXCOD_Pos
) |
2356 ((uint32_t)emux_cfg.emux_mode << (uint32_t)
VADC_G_EMUXCTR_EMUXMODE_Pos)|
2357 ((uint32_t)emux_cfg.stce_usage << (uint32_t)VADC_G_EMUXCTR_EMXST_Pos);
2358
2359 #if (XMC_VADC_EMUX_CH_SEL_STYLE == 1U)
2360 emux_config |= ((uint32_t)emux_cfg.emux_channel_select_style << (uint32_t)
VADC_G_EMUXCTR_EMXCSS_Pos);
2361 #endif
2362 group_ptr->EMUXCTR |= (emux_config | ((uint32_t)VADC_G_EMUXCTR_EMXWC_Msk)) ;
2363 }
2364
2365 #if XMC_VADC_BOUNDARY_FLAG_SELECT == 1U
2366
2367 /**
2368 * @param group_ptr Constant pointer to the VADC group
2369 * @param sr Service Request Id
2370 * @param boundary_flag_num The Boundary flag for which the interrupt node needs to
be configured.
2371 * Range: [0x0 to 0x3]
2372 * @return
2373 * None
2374 *
2375 * \par<b>Description:</b><br>
2376 * Connects the boundary event to the SR line of VADC or to a common boundary flag.<BR
>\n
2377 * This API will connect a Service Request line(SR) to a boundary event. Hence to get
a interrupt on this
2378 * Service request line one has to enable the required NVIC node. A call to this API
would configure the register bit
2379 * field GxBFLNP.BFLxNP.
2380 *
2381 * \par<b>Related APIs:</b><br>
2382 * None.
2383 */
2384 void XMC_VADC_GROUP_SetBoundaryEventInterruptNode(XMC_VADC_GROUP_t *const group_ptr,
2385 const uint8_t boundary_flag_num,
2386 const XMC_VADC_BOUNDARY_NODE_t node
);
2387 #endif /* XMC_VADC_BOUNDARY_FLAG_SELECT */
2388
2389 #endif /* XMC_VADC_GROUP_AVAILABLE */
2390
2391 #if (XMC_VADC_GSCAN_AVAILABLE == 1U)
2392 /**
2393 * @param group_ptr Pointer to the VADC group
2394 * @param config Pointer to Scan configuration
2395 * @return None
2396 *
2397 * \par<b>Description:</b><br>
2398 * Initializes the VADC SCAN functional block.<BR>\n
2399 * The GROUP SCAN request source functional block converts channels sequentially
starting with the highest numbered
2400 * channel to the lowest. Channels must register themselves as being part of the the
scan sequence.
2401 * A call to this API will first disable the arbitration slot for queue
(XMC_VADC_GROUP_ScanEnableArbitrationSlot())
2402 * and then it would configure all the related registers with the required
configuration values.
2403 * The arbitration slot is re-enabled at the end of init by invoking
XMC_VADC_GROUP_ScanDisableArbitrationSlot().
2404 * A call to this API would configure the registers GxARBPR, GxASCTRL, GxASMR needed
scan request source.
2405 *
2406 * \par<b>Related APIs:</b><br>
2407 * XMC_VADC_GROUP_ScanEnableArbitrationSlot()<BR>
XMC_VADC_GROUP_ScanDisableArbitrationSlot()<BR>
2408 * XMC_VADC_GROUP_ScanSelectTrigger()<BR> XMC_VADC_GROUP_ScanSelectGating()<BR>
2409 */
2410 void XMC_VADC_GROUP_ScanInit(XMC_VADC_GROUP_t *const group_ptr, const
XMC_VADC_SCAN_CONFIG_t *config);
2411
2412 /**
2413 * @param group_ptr Constant pointer to the VADC group
2414 * @return
2415 * None
2416 *
2417 * \par<b>Description:</b><br>
2418 * Enables arbitration slot of the scan request source.<BR>\n
2419 * If the scan request source must have its conversion request considered by the
arbiter, it must participate in
2420 * the arbitration rounds. Even if a load event occurs the scan channel can only be
converted when the arbiter comes
2421 * to the scan slot. Thus this must be enabled if any conversion need to take place.
2422 * A call to this API would configure the register bit field GxARBPR.ASEN1.
2423 *
2424 * \par<b>Related APIs:</b><br>
2425 * XMC_VADC_GROUP_ScanDisableArbitrationSlot()<BR>
2426 */
2427 __STATIC_INLINE void XMC_VADC_GROUP_ScanEnableArbitrationSlot(XMC_VADC_GROUP_t *const
group_ptr)
2428 {
2429 XMC_ASSERT("XMC_VADC_GROUP_ScanEnableArbitrationSlot:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
2430 group_ptr->ARBPR |= (uint32_t)VADC_G_ARBPR_ASEN1_Msk;
2431 }
2432
2433 /**
2434 * @param group_ptr Constant pointer to the VADC group
2435 * @return
2436 * None
2437 *
2438 * \par<b>Description:</b><br>
2439 * Disables arbitration slot of the scan request source.<BR>\n
2440 * If the scan request source must have its conversion request considered by the
arbiter, it must participate in
2441 * the arbitration rounds. Even if a load event occurs the scan channel can only be
converted when the arbiter comes
2442 * to the scan slot.A call to this API will lead to all conversions request by scan
to be blocked.
2443 * A call to this API would configure the register bit field GxARBPR.ASEN1.
2444 *
2445 * \par<b>Related APIs:</b><br>
2446 * XMC_VADC_GROUP_ScanEnableArbitrationSlot()<BR>
2447 */
2448 __STATIC_INLINE void XMC_VADC_GROUP_ScanDisableArbitrationSlot(XMC_VADC_GROUP_t *const
group_ptr)
2449 {
2450 XMC_ASSERT("XMC_VADC_GROUP_ScanDisableArbitrationSlot:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
2451 group_ptr->ARBPR &= ~((uint32_t)VADC_G_ARBPR_ASEN1_Msk);
2452 }
2453
2454 /**
2455 * @param group_ptr Constant pointer to the VADC group
2456 * @param trigger_input Choice of the input earmarked as a trigger line
2457 * @return
2458 * None
2459 *
2460 * \par<b>Description:</b><br>
2461 * Select Trigger signal for scan request source.<BR>\n
2462 * A scan request source will raise conversion request only if there were either a
request from application or
2463 * occurrence of a hardware trigger. This API selects one of the 16 input lines as a
trigger line. This is
2464 * needed when a hardware trigger is needed for the conversion of the scan request
source.
2465 * Refer to the reference manual to determine the signal that needs to be connected.
2466 * A call to this API would configure the register bit field GxASCTRL.XTSEL.
2467 *
2468 * \par<b>Related APIs:</b><br>
2469 * XMC_VADC_GROUP_ScanSelectGating()<BR> XMC_VADC_GROUP_ScanEnableExternalTrigger()<
BR>
2470 */
2471 void XMC_VADC_GROUP_ScanSelectTrigger(XMC_VADC_GROUP_t *const group_ptr,
XMC_VADC_TRIGGER_INPUT_SELECT_t trigger_input);
2472
2473
2474 /**
2475 * @param group_ptr Constant pointer to the VADC group
2476 * @param trigger_edge Trigger edge selection
2477 * @return
2478 * None
2479 *
2480 * \par<b>Description:</b><br>
2481 * Selects the trigger edge for scan request source.<BR>\n
2482 * A scan request source will raise conversion request only if there were either a
request from application or
2483 * occurrence of a hardware trigger. This API selects one of the 4 possible trigger
edges. This is
2484 * needed when a hardware trigger is needed for the conversion of the scan request
source.
2485 * A call to this API would configure the register bit field GxASCTRL.XTMODE.
2486 *
2487 * \par<b>Related APIs:</b><br>
2488 * XMC_VADC_GROUP_ScanSelectTrigger()<BR>
2489 */
2490 void XMC_VADC_GROUP_ScanSelectTriggerEdge(XMC_VADC_GROUP_t *const group_ptr, const
XMC_VADC_TRIGGER_EDGE_t trigger_edge);
2491
2492 /**
2493 * @param group_ptr Constant pointer to the VADC group
2494 * @param gating_input Module input signal meant to be selected as gating input
2495 * @return
2496 * None
2497 *
2498 * \par<b>Description:</b><br>
2499 * Select Gating signal for scan request source.<BR>\n
2500 * Passage of the trigger input to the request source can be controlled via a gating
signal. Any one of the 16 input
2501 * lines can be chosen as a gating signal. Trigger signal can be given to the scan
request source only
2502 * when the gating signal's active level is detected. Additionally the GxASMR.ENGT
has to be configured for
2503 * the gating signal's active level. A call to this API would configure the register
bit field GxASCTRL.GTSEL.
2504 *
2505 * \par<b>Related APIs:</b><br>
2506 * XMC_VADC_GROUP_ScanSelectTrigger()<BR>
2507 */
2508 void XMC_VADC_GROUP_ScanSelectGating(XMC_VADC_GROUP_t *const group_ptr,
XMC_VADC_GATE_INPUT_SELECT_t gating_input);
2509
2510 /**
2511 * @param group_ptr Constant pointer to the VADC group
2512 * @param mode_sel Select how the gating is applied to the scan request source
2513 * @return
2514 * None
2515 *
2516 * \par<b>Description:</b><br>
2517 * Selects the gating mode of scan request source.<BR>\n
2518 * Passage of the trigger input to the request source can be controlled via a gating
signal.
2519 * This API determines how the gating signal behaves, either active low or active
high.
2520 * If gating signal needs to ignored XMC_VADC_GATEMODE_IGNORE should be used as the \a
mode_sel.
2521 *
2522 * \par<b>Related APIs:</b><BR>
2523 * XMC_VADC_GROUP_ScanSelectGating();
2524 */
2525 __STATIC_INLINE void XMC_VADC_GROUP_ScanSetGatingMode(XMC_VADC_GROUP_t *const
group_ptr, XMC_VADC_GATEMODE_t mode_sel)
2526 {
2527 XMC_ASSERT("XMC_VADC_GROUP_ScanSetGatingMode:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
2528 XMC_ASSERT("XMC_VADC_GROUP_ScanSetGatingMode:Wrong mode selected", (mode_sel <=
XMC_VADC_GATEMODE_ACTIVELOW))
2529
2530 /* Clear the existing gate configuration */
2531 group_ptr->ASMR &= (uint32_t) (~((uint32_t)VADC_G_ASMR_ENGT_Msk));
2532 /* Set the new gating mode */
2533 group_ptr->ASMR |= (uint32_t)((uint32_t)mode_sel << VADC_G_ASMR_ENGT_Pos);
2534 }
2535
2536 /**
2537 * @param group_ptr Constant pointer to the VADC group
2538 * @return
2539 * None
2540 *
2541 * \par<b>Description:</b><br>
2542 * Enables continuous conversion mode.<BR>\n
2543 * Typically for a scan request source to generate conversion request, either a
hardware trigger or a software
2544 * request is a pre-requisite. Using autoscan feature it is possible to start the
conversion once and allow the
2545 * sequence to repeat without any further triggers. Once all channels belonging to a
scan request source have
2546 * been converted, a request source completion event is generated. Generation of this
event can restart the scan
2547 * sequence. Every request source event will cause a load event to occur. A call to
this API would configure
2548 * the register bit field GxASMR.SCAN.
2549 *
2550 * \par<b>Related APIs:</b><br>
2551 * XMC_VADC_GROUP_ScanDisableContinuousMode()<BR>
2552 */
2553 __STATIC_INLINE void XMC_VADC_GROUP_ScanEnableContinuousMode(XMC_VADC_GROUP_t *const
group_ptr)
2554 {
2555 XMC_ASSERT("XMC_VADC_GROUP_ScanEnableContinuousMode:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
2556 group_ptr->ASMR |= (uint32_t)VADC_G_ASMR_SCAN_Msk;
2557 }
2558
2559 /**
2560 * @param group_ptr Constant pointer to the VADC group
2561 * @return
2562 * None
2563 *
2564 * \par<b>Description:</b><br>
2565 * Disables continuous conversion mode.<BR>\n
2566 * Typically for a scan request source to generate conversion request, either a
hardware trigger or a software
2567 * request is a pre-requisite. Using autoscan feature it is possible to start the
conversion once and allow the
2568 * sequence to repeat without any further triggers. Once all channels belonging to a
scan request source have
2569 * been converted, a request source completion event is generated. Generation of this
event can restart the scan
2570 * sequence. By invoking this feature the Autoscan mode of operations is disabled. A
call to this API would configure
2571 * the register bit field GxASMR.SCAN.
2572 *
2573 * \par<b>Related APIs:</b><br>
2574 * XMC_VADC_GROUP_ScanEnableContinuousMode()<BR>
2575 */
2576 __STATIC_INLINE void XMC_VADC_GROUP_ScanDisableContinuousMode(XMC_VADC_GROUP_t *const
group_ptr)
2577 {
2578 XMC_ASSERT("XMC_VADC_GROUP_ScanDisableContinuousMode:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
2579 group_ptr->ASMR &= ~((uint32_t)VADC_G_ASMR_SCAN_Msk);
2580 }
2581
2582 /**
2583 * @param group_ptr Constant pointer to the VADC group
2584 * @return
2585 * None
2586 *
2587 * \par<b>Description:</b><br>
2588 * Generates conversion request (Software initiated conversion).<BR>\n
2589 * A conversion request can be raised either upon detection of a hardware trigger, or
by software. This API forces
2590 * the scan unit to generate a conversion request to the analog converter. It is
assumed that the scan has already
2591 * been filled up with entries. A call to this API would configure the register bit
field GxASMR.LDEV.
2592 *
2593 * \par<b>Related APIs:</b><br>
2594 * None.
2595 */
2596 __STATIC_INLINE void XMC_VADC_GROUP_ScanTriggerConversion(XMC_VADC_GROUP_t *const
group_ptr)
2597 {
2598 XMC_ASSERT("XMC_VADC_GROUP_ScanTriggerConversion:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
2599 group_ptr->ASMR |= (uint32_t)VADC_G_ASMR_LDEV_Msk;
2600 }
2601
2602 /**
2603 * @param group_ptr Constant pointer to the VADC group
2604 * @return
2605 * None
2606 *
2607 * \par<b>Description:</b><br>
2608 * Aborts an ongoing scan sequence conversion.<BR>\n
2609 * An ongoing sequence can be aborted at any time. The scan unit picks the pending
channels one by one from a
2610 * pending register and requests for their conversion. This API essentially clears
the channel pending register thus
2611 * creating an illusion that there are no more channels left in the sequence.
2612 * A call to this API would configure the registers GxASMR, GxASCTRL, GxARBPR to
achieve the sequence abort.
2613 *
2614 * \par<b>Related APIs:</b><br>
2615 * None.
2616 */
2617 void XMC_VADC_GROUP_ScanSequenceAbort(XMC_VADC_GROUP_t *const group_ptr);
2618
2619 /**
2620 * @param group_ptr Constant pointer to the VADC group
2621 * @param ch_num The channel meant to be added to scan sequence
2622 * <BR>Range: [0x0 to 0x7]
2623 * @return
2624 * None
2625 *
2626 * \par<b>Description:</b><br>
2627 * Adds a channel to the scan sequence.<BR>\n
2628 * Call this API to insert a new single channel into the scan request source. This
will be added to the scan
2629 * sequence. The added channel will be part of the conversion sequence when the next
load event occurs.
2630 * A call to this API would configure the register bit fields of GxASSEL.
2631 *
2632 * \par<b>Related APIs:</b><br>
2633 * XMC_VADC_GROUP_ScanAddMultipleChannels()<BR>
2634 */
2635 __STATIC_INLINE void XMC_VADC_GROUP_ScanAddChannelToSequence(XMC_VADC_GROUP_t *const
group_ptr, const uint32_t ch_num)
2636 {
2637 XMC_ASSERT("VADC_GSCAN_AddSingleChannel:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
2638 XMC_ASSERT("XMC_VADC_GROUP_ScanAddChannelToSequence:Wrong Channel Number",
2639 ((ch_num) < XMC_VADC_NUM_CHANNELS_PER_GROUP))
2640 group_ptr->ASSEL |= (uint32_t)((uint32_t)1 << ch_num);
2641 }
2642
2643 /**
2644 * @param group_ptr Constant pointer to the VADC group
2645 * @param ch_mask Mask word indicating channels which form part of scan conversion
sequence
2646 * Bit location 0/1/2/3/4/5/6/7 represents channels-0/1/2/3/4/5/6/7
respectively.
2647 * To Add the channel to the scan sequence enable the respective
bit.
2648 * Passing a 0x0 will clear all the selected channels
2649 * <BR>Range: [0x0 to 0xFF]
2650 * @return
2651 * None
2652 *
2653 * \par<b>Description:</b><br>
2654 * Adds multiple channels to the scan sequence.<BR>\n
2655 * Call this API to insert a multiple channels into the scan request source. This
will be added to a scan
2656 * sequence. The added channels will be a part of the conversion sequence when the
next load event occurs.
2657 * A call to this API would configure the register bit fields of GxASSEL.
2658 *
2659 * \par<b>Related APIs:</b><br>
2660 * XMC_VADC_GROUP_ScanAddChannelToSequence()<BR>
2661 */
2662 __STATIC_INLINE void XMC_VADC_GROUP_ScanAddMultipleChannels(XMC_VADC_GROUP_t *const
group_ptr, const uint32_t ch_mask)
2663 {
2664 XMC_ASSERT("XMC_VADC_GROUP_ScanAddMultipleChannels:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
2665 group_ptr->ASSEL = ch_mask;
2666 }
2667
2668 /**
2669 * @param group_ptr Constant pointer to the VADC group
2670 * @param ch_num The channel being audited for completion of conversion
2671 * <BR>Range: [0x0 to 0x7]
2672 * @return
2673 * bool returns true if the channel is pending conversion else returns false
2674 *
2675 * \par<b>Description:</b><br>
2676 * Determine if the channel is pending for conversion.<BR>\n
2677 * This API will check if the Channel in question is awaiting conversion in the
current arbitration round.
2678 * When a load event occurs the scan sequence is pushed to a pending conversion
register.
2679 * From the pending register the channels are taken up by the converter. This API
would return true
2680 * if the channel is found in the pending register (GxASPND).
2681 *
2682 * \par<b>Related APIs:</b><br>
2683 * XMC_VADC_GROUP_ScanGetNumChannelsPending()<BR>
2684 */
2685 __STATIC_INLINE bool XMC_VADC_GROUP_ScanIsChannelPending(XMC_VADC_GROUP_t *const
group_ptr, const uint32_t ch_num)
2686 {
2687
2688 XMC_ASSERT("XMC_VADC_GROUP_ScanIsChannelPending:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
2689 XMC_ASSERT("XMC_VADC_GROUP_ScanIsChannelPending:Wrong Channel Number", ((ch_num) <
XMC_VADC_NUM_CHANNELS_PER_GROUP))
2690
2691 return( (bool)((uint32_t)(group_ptr->ASPND >> ch_num) & 1U));
2692 }
2693
2694 /**
2695 * @param group_ptr Constant pointer to the VADC group
2696 * @return <BR>
2697 * uint32_t Returns the total channels pending for conversion.
2698 * <BR>Range: [0x0 to 0x8]
2699 *
2700 * \par<b>Description:</b><br>
2701 * Returns the total number of pending channels.<BR>\n
2702 * This API will read the pending channels register and will return the number of
channels that are awaiting conversion.
2703 * When a load event occurs the scan sequence is pushed to a pending conversion
register.
2704 * From the pending register the channels are taken up by the converter. When the API
is called it would
2705 * return the total number of channels pending (GxASPND).
2706 *
2707 * \par<b>Related APIs:</b><br>
2708 * XMC_VADC_GROUP_ScanIsChannelPending()<BR>
2709 */
2710 uint32_t XMC_VADC_GROUP_ScanGetNumChannelsPending(XMC_VADC_GROUP_t *const group_ptr);
2711
2712 /**
2713 * @param group_ptr Constant pointer to the VADC group
2714 * @return
2715 * None
2716 *
2717 * \par<b>Description:</b><br>
2718 * Manually asserts the conversion complete request source event.<BR>\n
2719 * This API will set the request source event for scan. This will trigger a interrupt
if the
2720 * service node pointer for the scan has been configured.
2721 * A call to this API would configure the register bit field GxSEFLAG.SEV1.
2722 *
2723 * \par<b>Related APIs:</b><br>
2724 * None.
2725 */
2726 __STATIC_INLINE void XMC_VADC_GROUP_ScanTriggerReqSrcEvent(XMC_VADC_GROUP_t *const
group_ptr)
2727 {
2728 XMC_ASSERT("XMC_VADC_GROUP_ScanTriggerReqSrcEvent:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
2729 group_ptr->SEFLAG |= (uint32_t)VADC_G_SEFLAG_SEV1_Msk;
2730 }
2731
2732 /**
2733 * @param group_ptr Constant pointer to the VADC group
2734 * @return
2735 * None
2736 *
2737 * \par<b>Description:</b><br>
2738 * Acknowledges the scan conversion complete request source event.<BR>\n
2739 * This API will clear the request source event that occurred. This will clear a
interrupt if it was raised.
2740 * A call to this API would configure the register bit field GxSEFLAG.SEV1.
2741 *
2742 * \par<b>Related APIs:</b><br>
2743 * XMC_VADC_GROUP_ScanTriggerReqSrcEvent()<BR>
2744 */
2745 __STATIC_INLINE void XMC_VADC_GROUP_ScanClearReqSrcEvent(XMC_VADC_GROUP_t *const
group_ptr)
2746 {
2747 XMC_ASSERT("XMC_VADC_GROUP_ScanClearReqSrcEvent:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
2748 group_ptr->SEFCLR |= (uint32_t)VADC_G_SEFCLR_SEV1_Msk;
2749 }
2750
2751 /**
2752 * @param group_ptr Constant pointer to the VADC group
2753 * @return
2754 * bool returns true if the service request event is raised.
2755 * returns false if the service request event was not raised.
2756 *
2757 * \par<b>Description:</b><br>
2758 * Determines if the request source event is asserted.<BR>
2759 * This API will get the status of the scan request source event. Will return a true
2760 * if the event has occurred for scan. A call to this API would access the register
bit field GxSEFLAG.SEV1.
2761 *
2762 * \par<b>Related APIs:</b><br>
2763 * None.
2764 */
2765 __STATIC_INLINE bool XMC_VADC_GROUP_ScanGetReqSrcEventStatus(XMC_VADC_GROUP_t *const
group_ptr)
2766 {
2767 XMC_ASSERT("XMC_VADC_GSCAN_GetRSEvent:Wrong Group Pointer", XMC_VADC_CHECK_GROUP_PTR
(group_ptr))
2768 return( (bool)(group_ptr->SEFLAG & (uint32_t)VADC_G_SEFLAG_SEV1_Msk));
2769 }
2770
2771 /**
2772 * @param group_ptr Constant pointer to the VADC group
2773 * @param sr Service Request Id
2774 * @return
2775 * None
2776 *
2777 * \par<b>Description:</b><br>
2778 * Connects the scan request source event to the SR line of VADC.<BR>\n
2779 * This API will connect a Service Request line(SR) to a scan request source event.
Hence to get a interrupt on this
2780 * Service request line one has to enable the required NVIC node. A call to this API
would configure the register bit
2781 * field GxSEVNP.SEV1NP .
2782 *
2783 * \par<b>Related APIs:</b><br>
2784 * None.
2785 */
2786 void XMC_VADC_GROUP_ScanSetReqSrcEventInterruptNode(XMC_VADC_GROUP_t *const group_ptr,
const XMC_VADC_SR_t sr);
2787
2788 /**
2789 * @param group_ptr Constant pointer to the VADC group
2790 * @return
2791 * None
2792 *
2793 * \par<b>Description:</b><br>
2794 * Enables the trigger for scan request source.<BR>\n
2795 * By using this API, the trigger signal will be activated for the scan request
source. The trigger signal and trigger
2796 * edge will be selected from the ASCTRL register. The Selection of a input will be
done by
2797 * XMC_VADC_GROUP_ScanSelectTrigger(). A call to this API would configure the
register bit field GxASMR.ENTR.
2798 *
2799 * \par<b>Related APIs:</b><br>
2800 * XMC_VADC_GROUP_ScanSelectTrigger()<BR>
XMC_VADC_GROUP_ScanDisableExternalTrigger()<BR>
2801 */
2802 __STATIC_INLINE void XMC_VADC_GROUP_ScanEnableExternalTrigger(XMC_VADC_GROUP_t *const
group_ptr)
2803 {
2804 XMC_ASSERT("XMC_VADC_GROUP_ScanEnableExternalTrigger:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
2805
2806 group_ptr->ASMR |= (uint32_t)VADC_G_ASMR_ENTR_Msk;
2807 }
2808
2809 /**
2810 * @param group_ptr Constant pointer to the VADC group
2811 * @return
2812 * None
2813 *
2814 * \par<b>Description:</b><br>
2815 * Disables the trigger for scan request source.<BR>
2816 * By using this API the trigger will be deactivated for the scan request source.
2817 * This will just deactivate the H/W trigger for the scan request source. If any
configuration were done
2818 * to select the trigger input in GxASCTRL, it will be not be effected by this API.
2819 * A call to this API would configure the register bit field GxASMR.ENTR.
2820 *
2821 * \par<b>Related APIs:</b><br>
2822 * XMC_VADC_GROUP_ScanEnableExternalTrigger()<BR>
2823 */
2824 __STATIC_INLINE void XMC_VADC_GROUP_ScanDisableExternalTrigger(XMC_VADC_GROUP_t *const
group_ptr)
2825 {
2826 XMC_ASSERT("XMC_VADC_GROUP_ScanDisableExternalTrigger:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
2827
2828 group_ptr->ASMR &= ~((uint32_t)VADC_G_ASMR_ENTR_Msk);
2829 }
2830 #endif
2831
2832 /**
2833 * @param global_ptr Pointer to the VADC module
2834 * @param config Pointer to initialization data structure
2835 *
2836 * \par<b>Description:</b><br>
2837 * Initializes the Background scan functional block.<BR>\n
2838 * The BACKGROUND SCAN request source functional block converts channels of all VADC
groups that have not
2839 * been assigned as a priority channel (priority channels can be converted only by
queue and scan). Background Scan
2840 * request source converts the unprioritized channels. Unprioritized channels however
can also be used with queue
2841 * and scan. But a channel which is prioritized can not be used with background
request source.
2842 *
2843 * \par<b>Related APIs:</b><br>
2844 * XMC_VADC_GROUP_BackgroundEnableArbitrationSlot()<BR>
XMC_VADC_GROUP_BackgroundDisableArbitrationSlot()<BR>
2845 * XMC_VADC_GLOBAL_BackgroundSelectTrigger()<BR>
XMC_VADC_GLOBAL_BackgroundSelectGating()<BR>
2846 */
2847 void XMC_VADC_GLOBAL_BackgroundInit(XMC_VADC_GLOBAL_t *const global_ptr, const
XMC_VADC_BACKGROUND_CONFIG_t *config);
2848
2849 #if (XMC_VADC_GROUP_AVAILABLE == 1U)
2850 /**
2851 * @param group_ptr Constant pointer to the VADC group which may receive a
2852 * conversion request from background request source
2853 *
2854 * @return
2855 * None
2856 *
2857 * \par<b>Description:</b><br>
2858 * Enables arbitration slot of the Background request source.<BR>\n
2859 * If the Background request source must have its conversion request considered by
the arbiter, it must participate in
2860 * the arbitration rounds. Even if a load event occurs the Background channel can
only be converted when the arbiter
2861 * comes to the Background slot. Thus this must be enabled if any conversion need to
take place.
2862 * A call to this API would configure the register bit field GxARBPR.ASEN2.
2863 *
2864 * \par<b>Related APIs:</b><br>
2865 * XMC_VADC_GROUP_BackgroundDisableArbitrationSlot()<BR>
2866 */
2867 __STATIC_INLINE void XMC_VADC_GROUP_BackgroundEnableArbitrationSlot(XMC_VADC_GROUP_t *
const group_ptr)
2868 {
2869 XMC_ASSERT("XMC_VADC_GROUP_BackgroundEnableArbitrationSlot:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
2870 group_ptr->ARBPR |= (uint32_t)VADC_G_ARBPR_ASEN2_Msk;
2871 }
2872
2873 /**
2874 * @param group_ptr Constant pointer to the VADC group which may receive a
conversion request
2875 * from background request source
2876 * @return
2877 * None
2878 *
2879 * \par<b>Description:</b><br>
2880 * Disables arbitration slot of the Background request source.<BR>\n
2881 * If the Background request source must have its conversion request considered by
the arbiter, it must participate in
2882 * the arbitration rounds. Even if a load event occurs the Background channel can
only be converted when the arbiter
2883 * comes to the Background slot.A call to this API will lead to all conversions
request by Background to be blocked.
2884 * A call to this API would configure the register bit field GxARBPR.ASEN2
2885 *
2886 * \par<b>Related APIs:</b><br>
2887 * XMC_VADC_GROUP_BackgroundEnableArbitrationSlot()<BR>
2888 */
2889 __STATIC_INLINE void XMC_VADC_GROUP_BackgroundDisableArbitrationSlot(XMC_VADC_GROUP_t
*const group_ptr)
2890 {
2891 XMC_ASSERT("XMC_VADC_GROUP_BackgroundDisableArbitrationSlot:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
2892 group_ptr->ARBPR &= ~((uint32_t)VADC_G_ARBPR_ASEN2_Msk);
2893 }
2894 #endif
2895
2896 /**
2897 * @param global_ptr Pointer to the VADC module
2898 * @param input_num Choice of the input earmarked as a trigger line
2899 * Accepts enum ::XMC_VADC_TRIGGER_INPUT_SELECT_t
2900 * @return
2901 * None
2902 *
2903 * \par<b>Description:</b><br>
2904 * Select Trigger signal for Background request source.<BR>\n
2905 * A Background request source will raise conversion request only if there were
either a request from application or
2906 * occurrence of a hardware trigger. This API selects one of the 16 input lines as a
trigger line. This is
2907 * needed when a hardware trigger is needed for the conversion of the Background
request source.
2908 * Refer to the reference manual to determine the signal that needs to be connected.
2909 * A call to this API would configure the register bit field BRSCTRL.XTSEL.
2910 *
2911 * \par<b>Related APIs:</b><br>
2912 * XMC_VADC_GLOBAL_BackgroundSelectGating()<BR>
XMC_VADC_GLOBAL_BackgroundEnableExternalTrigger()<BR>
2913 */
2914 void XMC_VADC_GLOBAL_BackgroundSelectTrigger(XMC_VADC_GLOBAL_t *const global_ptr,
const uint32_t input_num);
2915
2916
2917 /**
2918 * @param global_ptr Pointer to the VADC module
2919 * @param trigger_edge Select the trigger edge
2920 * @return
2921 * None
2922 *
2923 * \par<b>Description:</b><br>
2924 * Select Trigger edge for Background request source.<BR>\n
2925 * A Background request source will raise conversion request only if there were
either a request from application or
2926 * occurrence of a hardware trigger. This API selects one of the 4 possible values
for the trigger edge. This is
2927 * needed when a hardware trigger is needed for the conversion of the Background
request source.
2928 * A call to this API would configure the register bit field BRSCTRL.XTMODE.
2929 *
2930 * \par<b>Related APIs:</b><br>
2931 * XMC_VADC_GLOBAL_BackgroundSelectGating()<BR>
XMC_VADC_GLOBAL_BackgroundEnableExternalTrigger()<BR>
2932 */
2933 void XMC_VADC_GLOBAL_BackgroundSelectTriggerEdge(XMC_VADC_GLOBAL_t *const global_ptr,
const XMC_VADC_TRIGGER_EDGE_t trigger_edge);
2934
2935 /**
2936 * @param global_ptr Pointer to the VADC module
2937 * @param input_num Module input signal meant to be selected as gating input
2938 * Accepts enum ::XMC_VADC_GATE_INPUT_SELECT_t
2939 * @return
2940 * None
2941 *
2942 * \par<b>Description:</b><br>
2943 * Select Gating signal for Background request source.<BR>\n
2944 * Passage of the trigger input to the request source can be controlled via a gating
signal. Any one of the 16 input
2945 * lines can be chosen as a gating signal. Trigger signal can be given to the
Background request source only
2946 * when the gating signal's active level is detected. Additionally the GxBRSMR.ENGT
has to be configured for
2947 * the gating signal's active level. A call to this API would configure the register
bit field BRSCTRL.GTSEL.
2948 *
2949 * \par<b>Related APIs:</b><br>
2950 * XMC_VADC_GLOBAL_BackgroundSelectTrigger()<BR>
2951 */
2952 void XMC_VADC_GLOBAL_BackgroundSelectGating(XMC_VADC_GLOBAL_t *const global_ptr, const
uint32_t input_num);
2953
2954 /**
2955 * @param group_ptr Constant pointer to the VADC group
2956 * @param mode_sel Select how the gating is applied to the background scan request
source
2957 * @return
2958 * None
2959 *
2960 * <b>Details of function</b><br>
2961 * Selects the gating mode of background request source.<BR>\n
2962 * Passage of the trigger input to the request source can be controlled via a gating
signal.
2963 * This API determines how the gating signal behaves, either active low or active
high.
2964 * If gating signal needs to ignored XMC_VADC_GATEMODE_IGNORE should be used as the \a
mode_sel.
2965 * A call to this API would configure the register bit field BRSMR.ENGT.
2966 *
2967 * \par<b>Related APIs:</b><BR>
2968 * XMC_VADC_GLOBAL_BackgroundSelectGating();
2969 */
2970 __STATIC_INLINE void XMC_VADC_GLOBAL_BackgroundSetGatingMode(XMC_VADC_GLOBAL_t *const
global_ptr,
2971 XMC_VADC_GATEMODE_t
mode_sel)
2972 {
2973 XMC_ASSERT("XMC_VADC_GLOBAL_BackgroundSetGatingMode:Wrong Module Pointer", (
global_ptr == VADC))
2974 XMC_ASSERT("XMC_VADC_GLOBAL_BackgroundSetGatingMode:Wrong mode selected", (mode_sel
<= XMC_VADC_GATEMODE_ACTIVELOW))
2975
2976 /* Clear the existing gate configuration */
2977 global_ptr->BRSMR &= (uint32_t)(~((uint32_t)VADC_BRSMR_ENGT_Msk));
2978 /* Configure the new gating mode*/
2979 global_ptr->BRSMR |= (uint32_t)((uint32_t)mode_sel << VADC_BRSMR_ENGT_Pos);
2980 }
2981
2982
2983 /**
2984 * @param global_ptr Pointer to the VADC module
2985 * @return
2986 * None
2987 *
2988 * \par<b>Description:</b><br>
2989 * Enables continuous conversion mode.<BR>\n
2990 * Typically for a Background request source to generate conversion request, either a
hardware trigger or a software
2991 * request is needed. Using autoscan (continuous conversion)feature it is possible to
start the conversion
2992 * once and allow the sequence to repeat without any further triggers. Once all
channels belonging to a Background
2993 * request source have been converted, a request source completion event is
generated. Generation of this event
2994 * can restart the Background configure sequence. Every request source event will
cause a load event to occur.
2995 * A call to this API would access the register bit field BRSMR.SCAN.
2996 *
2997 * \par<b>Related APIs:</b><br>
2998 * XMC_VADC_GROUP_BackgroundDisableContinuousMode()<BR>
2999 */
3000 __STATIC_INLINE void XMC_VADC_GLOBAL_BackgroundEnableContinuousMode(XMC_VADC_GLOBAL_t
*const global_ptr)
3001 {
3002 XMC_ASSERT("XMC_VADC_GLOBAL_BackgroundEnableContinuousMode:Wrong Module Pointer", (
global_ptr == VADC))
3003 global_ptr->BRSMR |= (uint32_t)VADC_BRSMR_SCAN_Msk;
3004 }
3005
3006 /**
3007 * @param global_ptr Pointer to the VADC module
3008 * @return
3009 * None
3010 *
3011 * \par<b>Description:</b><br>
3012 * Disables continuous conversion mode.<BR>\n
3013 * Typically for a Background request source to generate conversion request, either a
hardware trigger or a software
3014 * request is a pre-requisite. Using autoscan feature it is possible to start the
conversion once and allow the
3015 * sequence to repeat without any further triggers. Once all channels belonging to a
Background request source have
3016 * been converted, a request source completion event is generated. Generation of this
event can restart the Background
3017 * sequence. By invoking this API the Autoscan mode of operations is disabled. A call
to this API would configure the
3018 * register bit field BRSMR.SCAN.
3019 *
3020 * \par<b>Related APIs:</b><br>
3021 * XMC_VADC_GLOBAL_BackgroundEnableContinuousMode()<BR>
3022 */
3023 __STATIC_INLINE void XMC_VADC_GLOBAL_BackgroundDisableContinuousMode(XMC_VADC_GLOBAL_t
*const global_ptr)
3024 {
3025 XMC_ASSERT("XMC_VADC_GLOBAL_BackgroundDisableContinuousMode:Wrong Module Pointer", (
global_ptr == VADC))
3026 global_ptr->BRSMR &= ~((uint32_t)VADC_BRSMR_SCAN_Msk);
3027 }
3028
3029 /**
3030 * @param global_ptr Pointer to the VADC module
3031 * @return
3032 * None
3033 *
3034 * \par<b>Description:</b><br>
3035 * Generates conversion request (Software initiated conversion).<BR>\n
3036 * A conversion request can be raised either upon detection of a hardware trigger, or
by software. This API forces
3037 * the scan unit to generate a conversion request to the analog converter. It is
assumed that the background scan
3038 * has already been filled up with entries. A call to this API would set the register
bit field BRSMR.LDEV.
3039 *
3040 * \par<b>Related APIs:</b><br>
3041 * None.
3042 */
3043 __STATIC_INLINE void XMC_VADC_GLOBAL_BackgroundTriggerConversion(XMC_VADC_GLOBAL_t *
const global_ptr)
3044 {
3045 XMC_ASSERT("XMC_VADC_GLOBAL_BackgroundTriggerConversion:Wrong Module Pointer", (
global_ptr == VADC))
3046 global_ptr->BRSMR |= (uint32_t)VADC_BRSMR_LDEV_Msk;
3047 }
3048
3049 /**
3050 * @param global_ptr Pointer to the VADC module
3051 * @return
3052 * None
3053 *
3054 * \par<b>Description:</b><br>
3055 * Aborts an ongoing background scan conversion(sequence).<BR>\n
3056 * An ongoing sequence can be aborted at any time. The scan unit picks the pending
channels one by one from a
3057 * pending register and requests for their conversion. This API essentially clears
the channel pending register thus
3058 * creating an illusion that there are no more channels left in the sequence.
3059 * A call to this API would configure the registers BRSMR, BRSCTRL, GxARBPR(if group
is available) to abort the
3060 * current scan sequence.
3061 *
3062 * \par<b>Related APIs:</b><br>
3063 * None.
3064 */
3065 void XMC_VADC_GLOBAL_BackgroundAbortSequence(XMC_VADC_GLOBAL_t *const global_ptr);
3066
3067 /**
3068 * @param global_ptr Pointer to the VADC module
3069 * @param grp_num ID of the VADC group whose unprioritized channels have been
assigned to background scan
3070 * Request source
3071 * @param ch_num The unprioritized channel meant to be added to the scan sequence
3072 * <BR>Range: [0x0 to 0x7]
3073 * @return
3074 * None
3075 *
3076 * \par<b>Description:</b><br>
3077 * Adds a channel to the background scan sequence.<BR>\n
3078 * Call this API to insert a new single channel into the background scan request
source. This will be added to the scan
3079 * sequence. The added channel will be part of the conversion sequence when the next
load event occurs.
3080 * A call to this API would configure the register bit fields of BRSSEL.
3081 *
3082 * \par<b>Related APIs:</b><br>
3083 * XMC_VADC_GLOBAL_BackgroundAddMultipleChannels()<BR>
3084 */
3085 __STATIC_INLINE void XMC_VADC_GLOBAL_BackgroundAddChannelToSequence(XMC_VADC_GLOBAL_t
*const global_ptr,
3086 const uint32_t
grp_num,
3087 const uint32_t
ch_num)
3088 {
3089 XMC_ASSERT("XMC_VADC_GLOBAL_BackgroundAddChannelToSequence:Wrong Module Pointer", (
global_ptr == VADC))
3090 XMC_ASSERT("XMC_VADC_GLOBAL_BackgroundAddChannelToSequence:Wrong Group Number",((
grp_num) < XMC_VADC_MAXIMUM_NUM_GROUPS))
3091 XMC_ASSERT("XMC_VADC_GLOBAL_BackgroundAddChannelToSequence:Wrong Channel Number",
3092 ((ch_num) < XMC_VADC_NUM_CHANNELS_PER_GROUP))
3093
3094 global_ptr->BRSSEL[grp_num] |= (uint32_t)((uint32_t)1 << ch_num);
3095 }
3096
3097 /**
3098 * @param global_ptr Pointer to the VADC module
3099 * @param grp_num ID of the VADC group whose unprioritized channels have been
assigned to background scan
3100 * @param ch_mask Mask word indicating channels which form part of scan conversion
sequence
3101 * Bit location 0/1/2/3/4/5/6/7 represents channels-0/1/2/3/4/5/6/7
respectively.
3102 * To Add the channel to the scan sequence enable the respective
bit.
3103 * Passing a 0x0 will clear all the previously selected channels
3104 * <BR>Range: [0x0 to 0xFF]
3105 * @return
3106 * None
3107 *
3108 * \par<b>Description:</b><br>
3109 * Adds multiple channels to the scan sequence.<BR>\n
3110 * Call this API to insert a multiple channels into the scan request source. This
will be added to a scan
3111 * sequence. The added channels will be a part of the conversion sequence when the
next load event occurs.
3112 * A call to this API would configure the register bit fields of BRSSEL.
3113 *
3114 * \par<b>Related APIs:</b><br>
3115 * XMC_VADC_GLOBAL_BackgroundAddChannelToSequence()<BR>
3116 */
3117 __STATIC_INLINE void XMC_VADC_GLOBAL_BackgndAddMultipleChannels(XMC_VADC_GLOBAL_t *
const global_ptr,
3118 const uint32_t grp_num
,
3119 const uint32_t ch_mask
)
3120 {
3121 XMC_ASSERT("XMC_VADC_GLOBAL_BackgndAddMultipleChannels:Wrong Module Pointer", (
global_ptr == VADC))
3122 XMC_ASSERT("XMC_VADC_GLOBAL_BackgndAddMultipleChannels:Wrong Group Number", ((
grp_num) < XMC_VADC_MAXIMUM_NUM_GROUPS))
3123 global_ptr->BRSSEL[grp_num] |= ch_mask;
3124 }
3125
3126 /**
3127 * @param global_ptr Pointer to the VADC module
3128 * @param grp_num ID of the VADC group whose unprioritized channels have been
assigned to background scan RS
3129 * @param ch_num The channel being audited for completion of conversion
3130 * <BR>Range: [0x0 to 0x7]
3131 * @return
3132 * bool returns true if the channel is pending conversion else returns false
3133 *
3134 * \par<b>Description:</b><br>
3135 * Determine if the channel is pending.<BR>\n
3136 * This API will check if the Channel in question is awaiting conversion in the
current arbitration round.
3137 * When a load event occurs the scan sequence is pushed to a pending conversion
register.
3138 * From the pending register the channels are taken up by the converter. This API
would return true
3139 * if the channel is found in the pending register (BRSPND[\b grp_num]).
3140 *
3141 * \par<b>Related APIs:</b><br>
3142 * XMC_VADC_GLOBAL_BackgroundGetNumChannelsPending()<BR>
3143 */
3144 __STATIC_INLINE bool XMC_VADC_GLOBAL_BackgroundIsChannelPending(XMC_VADC_GLOBAL_t *
const global_ptr,
3145 const uint32_t grp_num
,
3146 const uint32_t ch_num)
3147 {
3148 XMC_ASSERT("XMC_VADC_GLOBAL_BackgroundIsChannelPending:Wrong Module Pointer", (
global_ptr == VADC))
3149 XMC_ASSERT("XMC_VADC_GLOBAL_BackgroundIsChannelPending:Wrong Group Number", ((
grp_num) < XMC_VADC_MAXIMUM_NUM_GROUPS))
3150 XMC_ASSERT("XMC_VADC_GLOBAL_BackgroundIsChannelPending:Wrong Channel Number",
3151 ((ch_num) < XMC_VADC_NUM_CHANNELS_PER_GROUP))
3152
3153 return( (bool)(global_ptr->BRSPND[grp_num] & (uint32_t)((uint32_t)1 << ch_num)));
3154 }
3155
3156 /**
3157 * @param global_ptr Pointer to the VADC module
3158 * @return <BR>
3159 * uint32_t Returns the total channels pending for conversion.
3160 * <BR>Range: [0x0 to (0x8*number of groups)]
3161 *
3162 * \par<b>Description:</b><br>
3163 * Returns the number of pending channels.<BR>\n
3164 * This API will read the pending channels register and will return the number of
channels that are awaiting conversion.
3165 * When a load event occurs the scan sequence is pushed to a pending conversion
register.
3166 * From the pending register the channels are taken up by the converter. When the API
is called it would
3167 * return the total number of channels pending (BRSPND[\b grp_num]).
3168 *
3169 * \par<b>Related APIs:</b><br>
3170 * XMC_VADC_GLOBAL_BackgroundIsChannelPending()<BR>
3171 */
3172 uint32_t XMC_VADC_GLOBAL_BackgroundGetNumChannelsPending(XMC_VADC_GLOBAL_t *const
global_ptr);
3173
3174 /**
3175 * @param global_ptr Pointer to the VADC module
3176 * @return
3177 * None
3178 *
3179 * \par<b>Description:</b><br>
3180 * Manually asserts the conversion complete request source event.<BR>\n
3181 * This API will set the request source event for background scan. This will trigger
a interrupt if the
3182 * service node pointer for the scan has been configured.
3183 * A call to this API would configure the register bit field GLOBEFLAG.SEVGLB.
3184 *
3185 * \par<b>Related APIs:</b><br>
3186 * None.
3187 */
3188 __STATIC_INLINE void XMC_VADC_GLOBAL_BackgroundTriggerReqSrcEvent(XMC_VADC_GLOBAL_t *
const global_ptr)
3189 {
3190 XMC_ASSERT("XMC_VADC_GLOBAL_BackgroundTriggerReqSrcEvent:Wrong Module Pointer", (
global_ptr == VADC))
3191 global_ptr->GLOBEFLAG |= (uint32_t)VADC_GLOBEFLAG_SEVGLB_Msk;
3192 }
3193
3194 /**
3195 * @param global_ptr Pointer to the VADC module
3196 * @return
3197 * None
3198 *
3199 * \par<b>Description:</b><br>
3200 * Acknowledges the background scan conversion complete request source event.<BR>\n
3201 * This API will clear the request source event that occurred. This will clear a
interrupt if it was raised.
3202 * A call to this API would configure the register bit field GLOBEFLAG.SEVGLB
3203 *
3204 * \par<b>Related APIs:</b><br>
3205 * XMC_VADC_GLOBAL_BackgroundTriggerReqSrcEvent()<BR>
3206 */
3207 __STATIC_INLINE void XMC_VADC_GLOBAL_BackgroundClearReqSrcEvent(XMC_VADC_GLOBAL_t *
const global_ptr)
3208 {
3209 XMC_ASSERT("XMC_VADC_GLOBAL_BackgroundClearReqSrcEvent:Wrong Module Pointer", (
global_ptr == VADC))
3210 global_ptr->GLOBEFLAG |= (uint32_t)VADC_GLOBEFLAG_SEVGLBCLR_Msk;
3211 }
3212
3213 /**
3214 * @param global_ptr Pointer to the VADC module
3215 * @return
3216 * bool returns true if the service request event is raised.
3217 * returns false if the service request event was not raised.
3218 *
3219 * \par<b>Description:</b><br>
3220 * Determines if the request source event is asserted.<BR>
3221 * This API will get the status of the background scan request source event. Will
return a true
3222 * if the event has occurred for background scan. A call to this API would configure
the register
3223 * bit field GLOBEFLAG.SEVGLB.
3224 *
3225 * \par<b>Related APIs:</b><br>
3226 * None.
3227 */
3228 __STATIC_INLINE bool XMC_VADC_GLOBAL_BackgroundGetReqSrcEventStatus(XMC_VADC_GLOBAL_t
*const global_ptr)
3229 {
3230 XMC_ASSERT("XMC_VADC_GLOBAL_BackgroundGetReqSrcEventStatus:Wrong Module Pointer", (
global_ptr == VADC))
3231 return((bool)(global_ptr->GLOBEFLAG & (uint32_t)VADC_GLOBEFLAG_SEVGLB_Msk));
3232 }
3233
3234 /**
3235 * @param global_ptr Pointer to the VADC module
3236 * @return
3237 * None
3238 *
3239 * \par<b>Description:</b><br>
3240 * Enables the trigger for background scan request source.<BR>\n
3241 * By using this API the trigger will be activated for the scan request source. The
trigger signal and trigger
3242 * edge will be selected from the BRSCTRL register. The Selection of a input will be
done by
3243 * XMC_VADC_GLOBAL_BackgroundSelectTrigger(). A call to this API would configure the
register bit field BRSMR.ENTR.
3244 *
3245 * \par<b>Related APIs:</b><br>
3246 * XMC_VADC_GLOBAL_BackgroundSelectTrigger()<BR>
XMC_VADC_GLOBAL_BackgroundDisableExternalTrigger()<BR>
3247 */
3248 __STATIC_INLINE void XMC_VADC_GLOBAL_BackgroundEnableExternalTrigger(XMC_VADC_GLOBAL_t
*const global_ptr)
3249 {
3250 XMC_ASSERT("XMC_VADC_GLOBAL_BackgroundEnableExternalTrigger:Wrong Group Pointer", (
global_ptr == VADC))
3251
3252 global_ptr->BRSMR |= (uint32_t)VADC_BRSMR_ENTR_Msk;
3253 }
3254
3255 /**
3256 * @param global_ptr Pointer to the VADC module
3257 * @return
3258 * None
3259 *
3260 * \par<b>Description:</b><br>
3261 * Disables the trigger for background scan request source.<BR>
3262 * By using this API the trigger will be deactivated for the background scan request
source.
3263 * This will just deactivate the H/W trigger for the background scan request source.
If any configuration was done
3264 * to select the trigger input in BRSCTRL will be not be effected. A call to this API
would configure the register
3265 * bit field BRSMR.ENTR.
3266 *
3267 * \par<b>Related APIs:</b><br>
3268 * XMC_VADC_GLOBAL_BackgroundEnableExternalTrigger()<BR>
3269 */
3270 __STATIC_INLINE void XMC_VADC_GLOBAL_BackgroundDisableExternalTrigger(
XMC_VADC_GLOBAL_t *const global_ptr)
3271 {
3272 XMC_ASSERT("XMC_VADC_GLOBAL_BackgroundDisableExternalTrigger:Wrong Group Pointer", (
global_ptr == VADC))
3273
3274 global_ptr->BRSMR &= ~((uint32_t)VADC_BRSMR_ENTR_Msk);
3275 }
3276
3277 #if (XMC_VADC_QUEUE_AVAILABLE == 1U)
3278 /**
3279 * @param group_ptr Pointer to the VADC group
3280 * @param config Pointer to initialization data structure
3281 * @return
3282 * None
3283 *
3284 * \par<b>Description:</b><br>
3285 * Initializes VADC QUEUE functional block.<BR>\n
3286 * The QUEUE request source functional block converts channels stored in a queue. The
first channel entered into the
3287 * queue is converted first. A channel once converted, can be placed back into the
queue if desired(refill).
3288 * A call to this API will first disable the arbitration slot for queue
(XMC_VADC_GROUP_QueueEnableArbitrationSlot())
3289 * and then it would configure all the related registers with the required
configuration values.
3290 * The arbitration slot is re-enabled at the end of init by invoking
XMC_VADC_GROUP_QueueDisableArbitrationSlot().
3291 * A call to this API would configure the registers GxARBPR, GxQCTRL0, GxQMR0 to
configure the queue request
3292 * source.
3293 *
3294 * \par<b>Related APIs:</b><br>
3295 * XMC_VADC_GROUP_QueueEnableArbitrationSlot()<BR>
XMC_VADC_GROUP_QueueDisableArbitrationSlot()<BR>
3296 * XMC_VADC_GROUP_QueueSelectTrigger()<BR> XMC_VADC_GROUP_QueueSelectGating()<BR>
3297 */
3298 void XMC_VADC_GROUP_QueueInit(XMC_VADC_GROUP_t *const group_ptr, const
XMC_VADC_QUEUE_CONFIG_t *config);
3299
3300 /**
3301 * @param group_ptr Constant pointer to the VADC group
3302 * @return
3303 * None
3304 *
3305 * \par<b>Description:</b><br>
3306 * Enables arbitration slot of the queue request source.<BR>\n
3307 * If the QUEUE request source must have its conversion request considered by the
arbiter, it must participate in
3308 * the arbitration rounds. Even if a load event occurs the queue channel can only be
converted when the arbiter comes
3309 * to the queue slot. Thus this must be enabled if any conversion need to take place.
3310 * A call to this API would configure the register bit field GxARBPR.ASEN0.
3311 *
3312 * \par<b>Related APIs:</b><br>
3313 * XMC_VADC_GROUP_QueueDisableArbitrationSlot()<BR>
3314 */
3315 __STATIC_INLINE void XMC_VADC_GROUP_QueueEnableArbitrationSlot(XMC_VADC_GROUP_t *const
group_ptr)
3316 {
3317 XMC_ASSERT("XMC_VADC_GROUP_QueueEnableArbitrationSlot:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr));
3318 group_ptr->ARBPR |= (uint32_t)((uint32_t)1 << VADC_G_ARBPR_ASEN0_Pos);
3319 }
3320
3321 /**
3322 * @param group_ptr Constant pointer to the VADC group
3323 * @return
3324 * None
3325 *
3326 * \par<b>Description:</b><br>
3327 * Disables arbitration slot of the queue request source.<BR>\n
3328 * If the QUEUE request source must have its conversion request considered by the
arbiter, it must participate in
3329 * the arbitration rounds. Even if a load event occurs the queue channel can only be
converted when the arbiter comes
3330 * to the queue slot.A call to this API will lead to all conversions request by queue
to be blocked.
3331 * A call to this API would configure the register bit field GxARBPR.ASEN0.
3332 *
3333 * \par<b>Related APIs:</b><br>
3334 * XMC_VADC_GROUP_QueueEnableArbitrationSlot()<BR>
3335 */
3336 __STATIC_INLINE void XMC_VADC_GROUP_QueueDisableArbitrationSlot(XMC_VADC_GROUP_t *
const group_ptr)
3337 {
3338 XMC_ASSERT("XMC_VADC_GROUP_QueueDisableArbitrationSlot:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr));
3339 group_ptr->ARBPR &= ~((uint32_t)VADC_G_ARBPR_ASEN0_Msk);
3340 }
3341
3342 /**
3343 * @param group_ptr Constant pointer to the VADC group
3344 * @param input_num Choice of the input earmarked as a trigger line
3345 * @return
3346 * None
3347 *
3348 * \par<b>Description:</b><br>
3349 * Select Trigger signal for queue request source.<BR>\n
3350 * A queue request source will raise conversion request only if there were either a
request from application or
3351 * occurrence of a hardware trigger. This API selects one of the 16 input lines as a
trigger line. This is
3352 * needed when a hardware trigger is needed for the conversion of the queue request
source.
3353 * Refer to the reference manual to determine the signal that needs to be connected.
3354 * A call to this API would configure the register bit field GxQCTRL0.XTSEL.
3355 *
3356 * \par<b>Related APIs:</b><br>
3357 * XMC_VADC_GROUP_QueueSelectGating()<BR>
XMC_VADC_GROUP_QueueEnableExternalTrigger()<BR>
3358 */
3359 void XMC_VADC_GROUP_QueueSelectTrigger(XMC_VADC_GROUP_t *const group_ptr,
3360 const XMC_VADC_TRIGGER_INPUT_SELECT_t input_num
);
3361
3362 /**
3363 * @param group_ptr Constant pointer to the VADC group
3364 * @param trigger_edge Choice of the trigger edge
3365 * @return
3366 * None
3367 *
3368 * \par<b>Description:</b><br>
3369 * Select Trigger signal edge for queue request source.<BR>\n
3370 * A queue request source will raise conversion request only if there were either a
request from application or
3371 * occurrence of a hardware trigger. This API selects one of the 4 trigger edges.
This is
3372 * needed when a hardware trigger is needed for the conversion of the queue request
source.
3373 * Refer to the reference manual to determine the signal that needs to be connected.
3374 * A call to this API would configure the register bit field GxQCTRL0.XTMODE.
3375 *
3376 * \par<b>Related APIs:</b><br>
3377 * XMC_VADC_GROUP_QueueSelectGating()<BR>
XMC_VADC_GROUP_QueueEnableExternalTrigger()<BR>
3378 */
3379 void XMC_VADC_GROUP_QueueSelectTriggerEdge(XMC_VADC_GROUP_t *const group_ptr, const
XMC_VADC_TRIGGER_EDGE_t trigger_edge);
3380
3381 /**
3382 * @param group_ptr Constant pointer to the VADC group
3383 * @param input_num Choice of the input earmarked as the gating line
3384 * @return
3385 * None
3386 *
3387 * \par<b>Description:</b><br>
3388 * Select Gating signal for queue request source.<BR>\n
3389 * Passage of the trigger input to the request source can be controlled via a gating
signal. Any one of the 16 input
3390 * lines can be chosen as a gating signal. Trigger signal can be given to the queue
request source only
3391 * when the gating signal's active level is detected. Additionally the GxQMR0.ENGT
has to be configured for
3392 * the gating signal's active level. A call to this API would configure the register
bit field GxQCTRL0.GTSEL.
3393 *
3394 * \par<b>Related APIs:</b><br>
3395 * XMC_VADC_GROUP_QueueSelectTrigger()<BR>
3396 */
3397 void XMC_VADC_GROUP_QueueSelectGating(XMC_VADC_GROUP_t *const group_ptr, const
XMC_VADC_GATE_INPUT_SELECT_t input_num);
3398
3399 /**
3400 * @param group_ptr Constant pointer to the VADC group
3401 * @param mode_sel Select how the gating is applied to the queue request source
3402 * @return
3403 * None
3404 *
3405 * <b>Details of function</b><br>
3406 * Selects the gating mode of queue request source.<BR>\n
3407 * Passage of the trigger input to the request source can be controlled via a gating
signal.
3408 * This API determines how the gating signal behaves, either active low or active
high.
3409 * If gating signal needs to ignored XMC_VADC_GATEMODE_IGNORE should be used as the \a
mode_sel.
3410 * A call to this API would configure the register bit field GxQMR0.ENGT.
3411 *
3412 * \par<b>Related APIs:</b><BR>
3413 * XMC_VADC_GROUP_QueueSelectGating();
3414 */
3415 __STATIC_INLINE void XMC_VADC_GROUP_QueueSetGatingMode(XMC_VADC_GROUP_t *const
group_ptr, XMC_VADC_GATEMODE_t mode_sel)
3416 {
3417 XMC_ASSERT("XMC_VADC_GROUP_QueueSetGatingMode:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
3418 XMC_ASSERT("XMC_VADC_GROUP_QueueSetGatingMode:Wrong mode selected", (mode_sel <=
XMC_VADC_GATEMODE_ACTIVELOW))
3419
3420 /* Clear the existing gate configuration */
3421 group_ptr->QMR0 &= (uint32_t)(~((uint32_t) VADC_G_QMR0_ENGT_Msk));
3422 /* Set the new gating mode */
3423 group_ptr->QMR0 |= (uint32_t)((uint32_t)mode_sel << VADC_G_QMR0_ENGT_Pos);
3424 }
3425
3426
3427 /**
3428 * @param group_ptr Constant pointer to the VADC group
3429 * @return
3430 * None
3431 *
3432 * \par<b>Description:</b><br>
3433 * Generates conversion request (Software initiated conversion).<BR>
3434 * A conversion request can be raised either upon detection of a hardware trigger, or
by software. This API forces
3435 * the queue unit to generate a conversion request to the analog converter. It is
assumed that the queue has already
3436 * been filled up with entries. A call to this API would configure the register bit
field GxQMR0.TREV.
3437 *
3438 * \par<b>Note:</b><br>
3439 * The conversion of queue entry will start immediately after the entry has been
loaded into GxQINR0.
3440 * This happens only if the queue entry has been loaded into the register without the
need for the H/W trigger.\n
3441 * If a H/W Trigger is selected while loading the entry, the conversion will occur in
one of the 2 ways.
3442 * <LI> The H/W generates a trigger needed for the queue request source.
3443 * <LI> The Conversion is triggered manually by calling this API.
3444 *
3445 * \par<b>Related APIs:</b><br>
3446 * XMC_VADC_GROUP_QueueInsertChannel()<BR>
3447 */
3448 __STATIC_INLINE void XMC_VADC_GROUP_QueueTriggerConversion(XMC_VADC_GROUP_t *const
group_ptr)
3449 {
3450 XMC_ASSERT("XMC_VADC_GROUP_QueueTriggerConversion:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
3451 group_ptr->QMR0 |= (uint32_t)((uint32_t)1 << VADC_G_QMR0_TREV_Pos);
3452 }
3453
3454 /**
3455 * @param group_ptr Constant pointer to the VADC group
3456 * @return
3457 * uint32_t returns the total number of channels.
3458 * <BR>Range: [0x0 to 0x8]
3459 *
3460 * \par<b>Description:</b><br>
3461 * Returns the number of channels present in the queue.<BR>\n
3462 * This API will return the queue buffer size. This buffer will be consisting of
valid queue entries which
3463 * will be converted when a trigger event occurs. All the entries that are loaded
onto the GxQINR0 will
3464 * be added to the queue buffer. Hence if an application needs to get the number of
valid queue entries
3465 * this API would provide the interface. A call to this API would access the
registers GxQBUR0, GxQSR0 in order
3466 * to determine the queue length.
3467 *
3468 * \par<b>Related APIs:</b><br>
3469 * XMC_VADC_GROUP_QueueInsertChannel()<BR>
3470 */
3471 uint32_t XMC_VADC_GROUP_QueueGetLength(XMC_VADC_GROUP_t *const group_ptr);
3472
3473 /**
3474 * @param group_ptr Constant pointer to the VADC group
3475 * @return
3476 * None
3477 *
3478 * \par<b>Description:</b><br>
3479 * Aborts an ongoing conversion by flushing the queue.<BR>\n
3480 * This API will flush the queue buffer. Ongoing conversion of the Queue request
source will
3481 * not be effected by this API. This would clear all the contents that are present in
the queue buffer.
3482 * A call to this API would configure the registers GxQCTRL0, GxQMR0, GxARBPR in
order to abort
3483 * the queue sequence.
3484 *
3485 * \par<b>Related APIs:</b><br>
3486 * XMC_VADC_GROUP_QueueRemoveChannel()<BR> XMC_VADC_GROUP_QueueFlushEntries() <BR>
3487 */
3488 void XMC_VADC_GROUP_QueueAbortSequence(XMC_VADC_GROUP_t *const group_ptr);
3489
3490 /**
3491 * @param group_ptr Constant pointer to the VADC group
3492 * @return
3493 * None
3494 *
3495 * \par<b>Description:</b><br>
3496 * Flushing the queue Entry.<BR>\n
3497 * This API will flush one entry in the queue buffer. Ongoing conversion of the Queue
request source will
3498 * not be effected by this API. This would clear all the contents that are present in
the queue buffer.
3499 * A call to this API would configure the registers GxQMR0. This is a Blocking API,
i.e will only exit when
3500 * all the entries are removed from the queue.
3501 *
3502 * \par<b>Related APIs:</b><br>
3503 * XMC_VADC_GROUP_QueueRemoveChannel()<BR> XMC_VADC_GROUP_QueueAbortSequence(0<BR>
3504 */
3505 __STATIC_INLINE void XMC_VADC_GROUP_QueueFlushEntries(XMC_VADC_GROUP_t *const
group_ptr)
3506 {
3507 /* Initiate flushing of the queue */
3508 group_ptr->QMR0 |= (uint32_t)VADC_G_QMR0_FLUSH_Msk;
3509
3510 while( !((group_ptr->QSR0)& (uint32_t)VADC_G_QSR0_EMPTY_Msk))
3511 {
3512 /* Wait until the queue is indeed flushed */
3513 }
3514 }
3515
3516
3517 /**
3518 * @param group_ptr Constant pointer to the VADC group
3519 * @return
3520 * None
3521 *
3522 * \par<b>Description:</b><br>
3523 * Clears the next valid channel in the queue buffer.<BR>\n
3524 * A queue entry lined up for conversion can be removed and replaced by its
successor. The call to this API will
3525 * first check if a valid queue entry is present in the queue backup register if
present would clear its valid flag.
3526 * If no valid queue entries are present in the backup then the first channel
3527 * present in the queue buffer would be cleared.
3528 * A call to this API would configure the registers GxQCTRL0, GxQMR0, GxARBPR in
order to clear a
3529 * channel from the queue.
3530 *
3531 * \par<b>Related APIs:</b><br>
3532 * XMC_VADC_GROUP_QueueInsertChannel()<BR>
3533 */
3534 void XMC_VADC_GROUP_QueueRemoveChannel(XMC_VADC_GROUP_t *const group_ptr);
3535
3536 /**
3537 *
3538 * @param group_ptr Constant pointer to the VADC group
3539 * @param entry Details of the node being added
3540 * @return
3541 * None
3542 *
3543 * \par<b>Description:</b><br>
3544 * Inserts a queue entry to the tail of the queue buffer.<BR>\n
3545 * This API will insert a new channel into the queue buffer. The Queue will start
conversion of
3546 * the channels from the head of the buffer. This Insert will place the entry after
the last valid entry.
3547 * If no valid entries are present then this API will place the Queue entry at the
head of the buffer.
3548 * Then the successive call to the insert will place the new entry after the last
entry.
3549 * A call to this API would configure the register GxQINR0 for a single queue entry.
3550 *
3551 * \par<b>Related APIs:</b><br>
3552 * XMC_VADC_GROUP_QueueRemoveChannel()<BR>
3553 */
3554 __STATIC_INLINE void XMC_VADC_GROUP_QueueInsertChannel(XMC_VADC_GROUP_t *const
group_ptr,
3555 const XMC_VADC_QUEUE_ENTRY_t
entry)
3556 {
3557 XMC_ASSERT("XMC_VADC_GROUP_QueueInsertChannel:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
3558 /* Insert the channel physically and get the length of the queue*/
3559 group_ptr->QINR0 = entry.qinr0;
3560 }
3561
3562 /**
3563 * @param group_ptr Constant pointer to the VADC group
3564 * @return
3565 * int32_t Returns -1 if there are no channels for conversion
3566 * Else would return the next valid channel for conversion.
3567 * <BR>Range: [0x0 to 0x8]
3568 *
3569 * \par<b>Description:</b><br>
3570 * Returns the next entry in the queue request source for conversion.<BR>\n
3571 * Identifies the channel in the queue lined up for conversion next.
3572 * API will return a valid queue entry from the queue buffer. First checks for the
valid channel entry
3573 * in the backup register and returns if present. If the valid entry has not been
found in the backup register
3574 * then the queue buffer is searched for a valid entry. A call to this API would
access the registers GxQ0R0,
3575 * GxQBUR0 to determine the next channel.
3576 *
3577 * \par<b>Related APIs:</b><br>
3578 * XMC_VADC_GROUP_QueueRemoveChannel()<BR> XMC_VADC_GROUP_QueueInsertChannel()<BR>
3579 */
3580 int32_t XMC_VADC_GROUP_QueueGetNextChannel(XMC_VADC_GROUP_t *const group_ptr);
3581
3582 /**
3583 * @param group_ptr Constant pointer to the VADC group
3584 * @return
3585 * int32_t Returns -1 if there is no channel that have been interrupted.
3586 * Else would return the channel that is interrupted.
3587 * <BR>Range: [0x0 to 0x8]
3588 *
3589 * \par<b>Description:</b><br>
3590 * Identifies the channel whose conversion was suspended.<BR>\n
3591 * When using cancel inject repeat mode the canceled conversion will be placed in the
backup register.
3592 * This API will return the valid queue channel number from the backup register. This
happens when ever
3593 * there is a high priority conversion interrupts the conversion of queue request
source. This forces the channel
3594 * to goto the backup register. A call to this API would access the register GxQBUR0
to determine the
3595 * interrupted channel.
3596 *
3597 * \par<b>Related APIs:</b><br>
3598 * None.
3599 */
3600 int32_t XMC_VADC_GROUP_QueueGetInterruptedChannel(XMC_VADC_GROUP_t *const group_ptr);
3601
3602 /**
3603 * @param group_ptr Constant pointer to the VADC group
3604 * @return
3605 * None
3606 *
3607 * \par<b>Description:</b><br>
3608 * Manually asserts the conversion complete request source event.<BR>\n
3609 * This API will set the request source event for queue. This will trigger a
interrupt if the
3610 * service node pointer for the scan has been configured.
3611 * A call to this API would configure the register bit field GxSEFLAG.SEV0.
3612 *
3613 * \par<b>Related APIs:</b><br>
3614 * XMC_VADC_GROUP_QueueClearReqSrcEvent()<BR>
3615 */
3616 __STATIC_INLINE void XMC_VADC_GROUP_QueueTriggerReqSrcEvent(XMC_VADC_GROUP_t *const
group_ptr)
3617 {
3618 XMC_ASSERT("XMC_VADC_GROUP_QueueTriggerReqSrcEvent:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
3619 group_ptr->SEFLAG |= 1U;
3620 }
3621
3622 /**
3623 * @param group_ptr Constant pointer to the VADC group
3624 * @return
3625 * None
3626 *
3627 * \par<b>Description:</b><br>
3628 * Acknowledges the conversion complete request source event.<BR>\n
3629 * This API will clear the request source event that occurred. This will clear a
interrupt if it was raised.
3630 * A call to this API would configure the register bit field GxSEFCLR.SEV0.
3631 *
3632 * \par<b>Related APIs:</b><br>
3633 * XMC_VADC_GROUP_QueueTriggerReqSrcEvent()<BR>
3634 */
3635 __STATIC_INLINE void XMC_VADC_GROUP_QueueClearReqSrcEvent(XMC_VADC_GROUP_t *const
group_ptr)
3636 {
3637 XMC_ASSERT("XMC_VADC_GROUP_QueueClearReqSrcEvent:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
3638 group_ptr->SEFCLR |= (uint32_t)VADC_G_SEFCLR_SEV0_Msk;
3639 }
3640
3641 /**
3642 * @param group_ptr Constant pointer to the VADC group
3643 * @return
3644 * bool returns true if the service request event is raised.
3645 * returns false if the service request event was not raised.
3646 *
3647 * \par<b>Description:</b><br>
3648 * Determines if the request source event is asserted.<BR>
3649 * This API will get the status of the queue request source event. Will return a true
3650 * if the event has occurred for queue. A call to this API would acces the register
bit field GxSEFLAG.SEV0.
3651 *
3652 * \par<b>Related APIs:</b><br>
3653 * None.
3654 */
3655 __STATIC_INLINE bool XMC_VADC_GROUP_QueueGetReqSrcEventStatus(XMC_VADC_GROUP_t *const
group_ptr)
3656 {
3657
3658 XMC_ASSERT("XMC_VADC_GROUP_QueueGetReqSrcEventStatus:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
3659 return(group_ptr->SEFLAG & (uint32_t)VADC_G_SEFLAG_SEV0_Msk);
3660 }
3661
3662 /**
3663 * @param group_ptr Constant pointer to the VADC group
3664 * @param sr The service request line (Common SR lines, Group specific SR lines)
3665 * @return
3666 * None
3667 *
3668 * \par<b>Description:</b><br>
3669 * Connects the event to the SR line of VADC.<BR>\n
3670 * This API will connect a Service Request line(SR) to a queue request source event.
Hence to get a interrupt on this
3671 * Service request line one has to enable the required NVIC node. A call to this API
would configure the register
3672 * bit field GxSEVNP.SEVNP0.
3673 *
3674 * \par<b>Related APIs:</b><br>
3675 * None.
3676 */
3677 void XMC_VADC_GROUP_QueueSetReqSrcEventInterruptNode(XMC_VADC_GROUP_t *const group_ptr
, const XMC_VADC_SR_t sr);
3678
3679 /**
3680 * @param group_ptr Constant pointer to the VADC group
3681 * @return
3682 * None
3683 *
3684 * \par<b>Description:</b><br>
3685 * Enables the trigger for queue request source.<BR>\n
3686 * By using this API the trigger will be activated for the queue request source. The
trigger signal and trigger
3687 * edge will be selected from the QCTRL register. The Selection of a input will be
done by
3688 * XMC_VADC_GROUP_QueueSelectTrigger(). A call to this API would configure the
register bit field GxQMR0.ENTR
3689 *
3690 * \par<b>Related APIs:</b><br>
3691 * XMC_VADC_GROUP_QueueSelectTrigger()<BR>
XMC_VADC_GROUP_QueueDisableExternalTrigger()<BR>
3692 */
3693 __STATIC_INLINE void XMC_VADC_GROUP_QueueEnableExternalTrigger(XMC_VADC_GROUP_t *const
group_ptr)
3694 {
3695 XMC_ASSERT("XMC_VADC_GROUP_QueueEnableExternalTrigger:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
3696
3697 group_ptr->QMR0 |= (uint32_t)VADC_G_QMR0_ENTR_Msk;
3698 }
3699
3700 /**
3701 * @param group_ptr Constant pointer to the VADC group
3702 * @return
3703 * None
3704 *
3705 * \par<b>Description:</b><br>
3706 * Disables the trigger for queue request source.<BR>
3707 * By using this API the trigger will be deactivated for the queue request source.
3708 * This will just deactivate the H/W trigger for the queue request source. If any
configuration was done
3709 * to select the trigger input in GxQCTRL0 will be not be effected. A call to this
API would configure the
3710 * register bit field GxQMR0.ENTR
3711 *
3712 * \par<b>Related APIs:</b><br>
3713 * XMC_VADC_GROUP_QueueEnableExternalTrigger()<BR>
3714 */
3715 __STATIC_INLINE void XMC_VADC_GROUP_QueueDisableExternalTrigger(XMC_VADC_GROUP_t *
const group_ptr)
3716 {
3717 XMC_ASSERT("XMC_VADC_GROUP_QueueDisableExternalTrigger:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
3718
3719 group_ptr->QMR0 &= ~((uint32_t)VADC_G_QMR0_ENTR_Msk);
3720 }
3721 #endif
3722
3723 #if (XMC_VADC_GROUP_AVAILABLE == 1U)
3724 /**
3725 * @param group_ptr Constant pointer to the VADC group
3726 * @param ch_num The channel being initialized
3727 * <BR>Range: [0x0 to 0x7]
3728 * @param config Pointer to initialization data
3729 * @return
3730 * None
3731 *
3732 * \par<b>Description:</b><br>
3733 * Initializes the ADC channel for conversion.<BR>\n
3734 * This API will do the channel related initializations. This includes configuration
of the CHCTR settings
3735 * and boundary flag settings. This must be called in the application in order to
enable the conversion of
3736 * a channel. After a request source has been initialized this API has to be called
for each channel that
3737 * has to be converted. A call to this API would configure the registers GxCHCTR
GxBFL GxALIAS GxCHASS
3738 * GxBFLC(depending on device) in order to configure the channel.
3739 *
3740 * \par<b>Related APIs:</b><br>
3741 * None.
3742 */
3743 void XMC_VADC_GROUP_ChannelInit(XMC_VADC_GROUP_t *const group_ptr, const uint32_t
ch_num,
3744 const XMC_VADC_CHANNEL_CONFIG_t *config);
3745
3746 /**
3747 * @param group_ptr Constant pointer to the VADC group
3748 * @param src_ch_num Channel which will be converted by \b alias_ch_num, when
called by the request source.
3749 * <BR>Range:[0x0 to 0x7]
3750 * @param alias_ch_num This is the alias channel (Ch-0 or Ch-1)
3751 * <BR>Range:[0x0, 0x1]
3752 * @return
3753 * None
3754 *
3755 * \par<b>Description:</b><br>
3756 * Sets the Alias channel(\b alias_ch_num) to convert from the source channel(\b
src_ch_num).<BR>\n
3757 * When a alias configuration takes place the request source(queue/scan/background)
will not call channel \b src_ch_num.
3758 * The Request sources will call the channel \b alias_ch_num , this would invoke the
conversion of
3759 * the pin associated with \b src_ch_num. The configuration of the alias channel (\b
alias_ch_num) will be used
3760 * for the conversion.\n
3761 * When an alias channel (Ch-0 or Ch-1) receives a trigger, it converts the aliased
channel (\b src_ch_num).
3762 * The properties of Ch-0 or Ch-1 (as indicated in \b alias_ch_num ) apply when \b
src_ch_num is converted.
3763 * A call to this API would configure the register GxALIAS.
3764 *
3765 * \par<b>Note:</b><br>
3766 * Alias Channel (\b alias_ch_num) and the source channel (\b src_ch_num) cannot be
the same.
3767 * If they are, that alias feature is not used for the conversion. In order to Reset
the alias
3768 * feature that was previously selected this method can be used.
3769 *
3770 * \par<b>Related APIs:</b><br>
3771 * None.
3772 */
3773 void XMC_VADC_GROUP_SetChannelAlias(XMC_VADC_GROUP_t *const group_ptr,
3774 const uint32_t src_ch_num,
3775 const uint32_t alias_ch_num);
3776
3777 /**
3778 * @param group_ptr Constant pointer to the VADC group
3779 * @param ch_num Channel whose input was converted
3780 * <BR>Range: [0x0 to 0x7]
3781 * @return
3782 * bool Returns true if there was violation w.r.t the specified boundaries.
3783 *
3784 * \par<b>Description:</b><br>
3785 * Determines if the result of the channel confines with the specified boundaries.<BR
>\n
3786 * An application may not necessarily always need to know the exact value of the
converted result, but merely
3787 * an indication if the generated result is within stipulated boundaries. Generation
of Channel event can be subject
3788 * to channel event generation criteria (Generate always, Never generate, Generate if
result is out of bounds,
3789 * Generate if result is within bounds). When interrupts are not enabled, this API
can be used to determine the
3790 * nature of the result. A call to this API would access the registers GxCHCTR and
GxCEFLAG in order to determine
3791 * if a violation has occured.
3792 *
3793 * \par<b>Related APIs:</b><br>
3794 * None
3795 */
3796 bool XMC_VADC_GROUP_ChannelIsResultOutOfBounds(XMC_VADC_GROUP_t *const group_ptr,
const uint32_t ch_num);
3797
3798 /**
3799 * @param group_ptr Constant pointer to the VADC group
3800 * @param ch_num Channel whose input is to be converted
3801 * <BR>Range: [0x0 to 0x7]
3802 * @param ref Reference voltage
3803 * @return
3804 * None
3805 *
3806 * \par<b>Description:</b><br>
3807 * Selects the reference voltage for conversion.<BR>\n
3808 * An internal voltage reference (VARef) or an external voltage reference fed to Ch-0
can serve as a voltage reference
3809 * for conversions. A call to this API would configure the register bit field
GxCHCTR.REFSEL.
3810 *
3811 * \par<b>Related APIs:</b><br>
3812 * None.
3813 */
3814 void XMC_VADC_GROUP_ChannelSetInputReference(XMC_VADC_GROUP_t *const group_ptr, const
uint32_t ch_num,
3815 const XMC_VADC_CHANNEL_REF_t ref);
3816
3817 /**
3818 * @param group_ptr Constant pointer to the VADC group
3819 * @param ch_num Channel whose i/p is to be converted
3820 * <BR>Range: [0x0 to 0x7]
3821 * @param result_reg_num Result Register associated with this channel
3822 * @return
3823 * None
3824 *
3825 * \par<b>Description:</b><br>
3826 * Selects the target result register.<BR>\n
3827 * There are upto 16 result registers which a channel can choose from to store the
results of conversion.
3828 * This selects only the group related result registers. A call to this API would
configure the register
3829 * bit field GxCHCTR.RESREG.
3830 *
3831 * \par<b>Related APIs:</b><br>
3832 * None.
3833 */
3834 void XMC_VADC_GROUP_ChannelSetResultRegister(XMC_VADC_GROUP_t *const group_ptr,
3835 const uint32_t ch_num,
3836 const uint32_t result_reg_num);
3837
3838 /**
3839 *
3840 * @param group_ptr Constant pointer to the VADC group
3841 * @param ch_num Channel whose associated result register is to be found
3842 * <BR>Range: [0x0 to 0x7]
3843 * @return
3844 * uint8_t returns the Group result register to which it is linked to.
3845 * <BR>Range: [0x0 to 0xF]
3846 *
3847 * \par<b>Description:</b><br>
3848 * Returns the result register associated with this channel.<br>\n
3849 * There are upto 16 result registers which a channel can choose from to store the
results of conversion.
3850 * This returns only the group related result registers. A call to this API would
access the register
3851 * bit field GxCHCTR.RESREG.
3852 *
3853 * \par<b>Related APIs:</b><br>
3854 * None.
3855 */
3856 uint8_t XMC_VADC_GROUP_ChannelGetResultRegister(XMC_VADC_GROUP_t *const group_ptr,
const uint32_t ch_num);
3857
3858 /**
3859 * @param group_ptr Constant pointer to the VADC group
3860 * @param ch_num Channel whose channel event is to be asserted
3861 * <BR>Range: [0x0 to 0x7]
3862 * @return
3863 * None
3864 *
3865 * \par<b>Description:</b><br>
3866 * Manually asserts a Channel event.<BR>\n
3867 * It is merely the channel event which is asserted. For this asserted event to lead
to an interrupt, it must
3868 * have been bound to an SR and that SR must have been enabled. It can potentially
lead to an interrupt if the
3869 * SR line is connected to an NVIC node. A call to this API would configure the
register bit fields of GxCEFLAG.
3870 *
3871 * \par<b>Related APIs:</b><br>
3872 * XMC_VADC_GROUP_ChannelClearEvent().
3873 */
3874 void XMC_VADC_GROUP_ChannelTriggerEvent(XMC_VADC_GROUP_t *const group_ptr, const
uint32_t ch_num);
3875
3876 /**
3877 * @param group_ptr Constant pointer to the VADC group
3878 * @param ch_num Channel whose channel event is to be acknowledged
3879 * <BR>Range: [0x0 to 0x7]
3880 * @return
3881 * None
3882 *
3883 * \par<b>Description:</b><br>
3884 * Acknowledges a Channel event.<BR>\n
3885 * When a channel event is raised after the conversion of that channel, it has to be
cleared. This API would clear
3886 * the Channel event of a particular channel if it has occurred. A call to this API
would configure the register
3887 * bit fields of GxCEFCLR.
3888 *
3889 * \par<b>Related APIs:</b><br>
3890 * XMC_VADC_GROUP_ChannelTriggerEvent().
3891 */
3892 __STATIC_INLINE void XMC_VADC_GROUP_ChannelClearEvent(XMC_VADC_GROUP_t *const
group_ptr, const uint32_t ch_num)
3893 {
3894
3895 XMC_ASSERT("XMC_VADC_GROUP_ChannelClearEvent:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
3896 XMC_ASSERT("XMC_VADC_GROUP_ChannelClearEvent:Wrong Channel Number", ((ch_num) <
XMC_VADC_NUM_CHANNELS_PER_GROUP))
3897 group_ptr->CEFCLR |= (uint32_t)((uint32_t)1 << ch_num);
3898 }
3899
3900 /**
3901 * @param group_ptr Constant pointer to the VADC group
3902 * @param ch_num Channel whose channel event is to be connected to a service
request line
3903 * <BR>Range: [0x0 to 0x7]
3904 * @param sr The service request line to which the channel event is to be
connected
3905 * @return
3906 * None
3907 *
3908 * \par<b>Description:</b><br>
3909 * Binds a channel event to a requested Service Request line.<BR>\n
3910 * The channel event is connected to a service request line. For an event to result
in an interrupt, this service
3911 * request line must be enabled in VADC and the NVIC node which this service request
line is connected to must have
3912 * interrupt generation enabled. A call to this API would configure the register bit
fields of GxCEVNP0.
3913 *
3914 * \par<b>Related APIs:</b><br>
3915 * XMC_VADC_GROUP_ChannelTriggerEvent()<BR> XMC_VADC_GROUP_ChannelClearEvent()
3916 */
3917 void XMC_VADC_GROUP_ChannelSetEventInterruptNode(XMC_VADC_GROUP_t *const group_ptr,
3918 const uint32_t ch_num,
3919 const XMC_VADC_SR_t sr);
3920
3921 /**
3922 * @param group_ptr Constant pointer to the VADC group
3923 * @param ch_num Channel whose channel event is being configured
3924 * <BR>Range: [0x0 to 0x7]
3925 * @param criteria The condition under which the channel may assert its channel event
3926 * @return
3927 * None
3928 *
3929 * \par<b>Description:</b><br>
3930 * Defines the conditions under which a channel may assert its channel event.<BR>\n
3931 * The channel event can be generated under the following conditions - Always, Never,
Result Out of bounds and Result
3932 * inside the boundaries. A call to this API would configure the register bit field
GxCHCTR.CHEVMODE.
3933 *
3934 * \par<b>Related APIs:</b><br>
3935 * XMC_VADC_GROUP_ChannelTriggerEvent()<BR> XMC_VADC_GROUP_ChannelClearEvent()<BR>
3936 * XMC_VADC_GROUP_ChannelSetEventInterruptNode()<BR>
3937 */
3938 void XMC_VADC_GROUP_ChannelTriggerEventGenCriteria(XMC_VADC_GROUP_t *const group_ptr,
3939 const uint32_t ch_num,
3940 const XMC_VADC_CHANNEL_EVGEN_t
criteria);
3941
3942
3943 /**
3944 * @param group_ptr Constant pointer to the VADC group
3945 * @param ch_num Channel whose channel event is being configured
3946 * <BR>Range: [0x0 to 0x7]
3947 * @param boundary_sel Select the upper/lower boundary configuration .
3948 * @param selection The boundary value selected for \b boundary_sel.
3949 * @return
3950 * None
3951 *
3952 * \par<b>Description:</b><br>
3953 * Configure the boundary selection for the given channel<BR>\n
3954 * The channel event can be generated under the following conditions - Always, Never,
Result Out of bounds and Result
3955 * inside the boundaries. The boundary values to which results are compared can be
selected from several sources.
3956 * A call to this API would configure the register bit field GxCHCTR.BNDSELL or
GxCHCTR.BNDSELU .
3957 *
3958 * \par<b>Related APIs:</b><br>
3959 * None.
3960 */
3961 void XMC_VADC_GROUP_ChannelSetBoundarySelection(XMC_VADC_GROUP_t *const group_ptr,
3962 const uint32_t ch_num,
3963 XMC_VADC_BOUNDARY_SELECT_t
boundary_sel,
3964 XMC_VADC_CHANNEL_BOUNDARY_t selection
);
3965
3966 /**
3967 * @param group_ptr Constant pointer to the VADC group
3968 * @param res_reg_num Result register which is intended to be initialized
3969 * <BR>Range: [0x0 to 0xF]
3970 * @param config Pointer to initialization data
3971 * @return
3972 * None
3973 *
3974 * \par<b>Description:</b><br>
3975 * Initializes a Group Result Register.<BR>
3976 * Various options needed for the working of the result result will be configured
with this API.
3977 * This would determine the result handling of the group registers. This API must be
called after
3978 * the channel Init (XMC_VADC_GROUP_ChannelInit())to initialize the result register
that is selected for the channel.
3979 * This API would also determine if the result register that is being configured has
to a part of a FIFO buffer.
3980 * In this API one can also configure the various result handling options line
FIR/IIR filters and it order.
3981 * Also configures the Data reduction to accumulate 2/3/4 results need to be done.
This API will also configure
3982 * the result event generation. A call to this API would configure the register
GxRCR with the \b config .
3983 *
3984 * \par<b>Related APIs:</b><br>
3985 * XMC_VADC_GROUP_AddResultToFifo()<BR> XMC_VADC_GROUP_EnableResultEvent()<br>
XMC_VADC_GROUP_DisableResultEvent()<BR>
3986 */
3987 __STATIC_INLINE void XMC_VADC_GROUP_ResultInit(XMC_VADC_GROUP_t *const group_ptr,
3988 const uint32_t res_reg_num,
3989 const XMC_VADC_RESULT_CONFIG_t *config)
3990 {
3991 XMC_ASSERT("XMC_VADC_GROUP_ResultInit:Wrong Group Pointer", XMC_VADC_CHECK_GROUP_PTR
(group_ptr))
3992 group_ptr->RCR[res_reg_num] = config->g_rcr;
3993
3994 }
3995
3996
3997 /**
3998 * @param group_ptr Constant pointer to the VADC group
3999 * @param res_reg Register which is required to be a part of results FIFO
4000 * <BR>Range: [0x0 to 0xF]
4001 * @return
4002 * None
4003 *
4004 * \par<b>Description:</b><br>
4005 * Adds result register to Result FIFO.<BR>\n
4006 * Sometimes, the rate of consumption of results by application software may not
match the rate at which the
4007 * results are produced. A Result FIFO thus helps a slow consumer to read out results
without loss of data.
4008 * When a result register is added to fifo, it is in fact chained to its higher
numbered neighbor. For example, if
4009 * Result Register-5 is to be added to FIFO, it gets chained to Result Register-6.
Results are written to Register-6
4010 * while the same can be read out of Register-5 leisurely by software.
4011 * A call to this API would configure the register bit field GxRCR.FEN.
4012 *
4013 * \par<b>Note:</b><br>
4014 * The FIFO is always read by the software with the lowest numbered result register.
4015 * The hardware will write the results from the highest numbered result register.
4016 *
4017 * \par<b>Related APIs:</b><br>
4018 * None.
4019 */
4020 void XMC_VADC_GROUP_AddResultToFifo(XMC_VADC_GROUP_t *const group_ptr, const uint32_t
res_reg);
4021
4022 /**
4023 * @param group_ptr Constant pointer to the VADC group
4024 * @param res_reg Result Register for which event generation is to be enabled
4025 * <BR>Range: [0x0 to 0xF]
4026 * @return
4027 * None
4028 *
4029 * \par<b>Description:</b><br>
4030 * Enables result event generation.<BR>\n
4031 * Once the results of conversion are available, the result event (which is being
enabled in this function)
4032 * if connected to a service request line(Group or Shared service request) can lead
to an interrupt. It is therefore
4033 * not only necessary to enable the event, but also to connect it to a service
request line. The
4034 * service request generation capability must also be enabled and so should the
corresponding NVIC node.
4035 * A call to this API would configure the register bit field GxRCR.SRGEN.
4036 *
4037 * \par<b>Related APIs:</b><br>
4038 * XMC_VADC_GROUP_SetResultInterruptNode().
4039 */
4040 __STATIC_INLINE void XMC_VADC_GROUP_EnableResultEvent(XMC_VADC_GROUP_t *const
group_ptr, const uint32_t res_reg)
4041 {
4042
4043 XMC_ASSERT("XMC_VADC_GROUP_EnableResultEvent:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
4044 XMC_ASSERT("XMC_VADC_GROUP_EnableResultEvent:Wrong Result Register", ((res_reg) <
XMC_VADC_NUM_RESULT_REGISTERS))
4045 group_ptr->RCR[res_reg] |= (uint32_t)VADC_G_RCR_SRGEN_Msk;
4046 }
4047
4048 /**
4049 * @param group_ptr Constant pointer to the VADC group
4050 * @param res_reg Result Register for which event generation is to be disabled
4051 * <BR>Range: [0x0 to 0xF]
4052 * @return
4053 * None
4054 *
4055 * \par<b>Description:</b><br>
4056 * Disable result event generation.<BR>\n
4057 * This would just disable the event. It would not alter anything w.r.t the SR line
if it was configured.
4058 * A call to this API would configure the register bit field GxRCR.SRGEN.
4059 *
4060 * \par<b>Related APIs:</b><br>
4061 * XMC_VADC_GROUP_EnableResultEvent().
4062 */
4063 __STATIC_INLINE void XMC_VADC_GROUP_DisableResultEvent(XMC_VADC_GROUP_t *const
group_ptr, const uint32_t res_reg)
4064 {
4065 XMC_ASSERT("XMC_VADC_GROUP_DisableResultEvent:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
4066 XMC_ASSERT("XMC_VADC_GROUP_DisableResultEvent:Wrong Result Register", ((res_reg) <
XMC_VADC_NUM_RESULT_REGISTERS))
4067 group_ptr->RCR[res_reg] &= ~((uint32_t)VADC_G_RCR_SRGEN_Msk);
4068 }
4069
4070 /**
4071 * @param group_ptr Constant pointer to the VADC group
4072 * @param res_reg Result Register from which the result of conversion is to be read
out
4073 * <BR>Range: [0x0 to 0xF]
4074 * @return
4075 * uint32_t returns the complete result register GxRESy.
4076 *
4077 * \par<b>Description:</b><br>
4078 * Returns the result register completely (result of conversion as well as other
info).<BR>\n
4079 * The Result register will have information regarding the channel that is requesting
the conversion,
4080 * if the result is valid, if the fast compare bit, Data Reduction Counter, and the
request source information.
4081 * All these information will be returned back. And if the user is polling for the
result he can use the
4082 * result if the valid bit is set. A call to this API would return the complete
register GxRES.
4083 *
4084 * \par<b>Related APIs:</b><br>
4085 * XMC_VADC_GROUP_GetResult().
4086 */
4087 __STATIC_INLINE uint32_t XMC_VADC_GROUP_GetDetailedResult(XMC_VADC_GROUP_t *const
group_ptr, const uint32_t res_reg)
4088 {
4089 XMC_ASSERT("XMC_VADC_GROUP_GetDetailedResult:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
4090 XMC_ASSERT("XMC_VADC_GROUP_GetDetailedResult:Wrong Result Register", ((res_reg) <
XMC_VADC_NUM_RESULT_REGISTERS))
4091 return(group_ptr->RES[res_reg]);
4092 }
4093
4094 /**
4095 * @param group_ptr Constant pointer to the VADC group
4096 * @param res_reg Result Register from which the result of conversion is to be read
out
4097 * <BR>Range: [0x0 to 0xF]
4098 * @return
4099 * XMC_VADC_RESULT_SIZE_t Result register values.
4100 * <BR>Range:[ 0x0 to 0xFFF] (Result of single conversion. Accumulated
results not considered for range)
4101 *
4102 * \par<b>Description:</b><br>
4103 * Returns the result of the conversion.<BR>\n
4104 * This API will only return the result of the conversion and will strip out the
other information that is present
4105 * in the result register. A call to this API would access the register bit field
GxRES.RESULT.
4106 *
4107 * \par<b>Related APIs:</b><br>
4108 * XMC_VADC_GROUP_GetDetailedResult().
4109 */
4110 __STATIC_INLINE XMC_VADC_RESULT_SIZE_t XMC_VADC_GROUP_GetResult(XMC_VADC_GROUP_t *
const group_ptr,
4111 const uint32_t res_reg
)
4112 {
4113 XMC_ASSERT("XMC_VADC_GROUP_GetResult:Wrong Group Pointer", XMC_VADC_CHECK_GROUP_PTR(
group_ptr))
4114 XMC_ASSERT("XMC_VADC_GROUP_GetResult:Wrong Result Register", ((res_reg) <
XMC_VADC_NUM_RESULT_REGISTERS))
4115
4116 return ((XMC_VADC_RESULT_SIZE_t)group_ptr->RES[res_reg]);
4117 }
4118
4119 /**
4120 *
4121 * @param group_ptr Constant pointer to the VADC group
4122 * @param res_reg Result Register for which the compare value is being set
4123 * <BR>Range: [0x0 to 0xF]
4124 * @param compare_val The compare value itself
4125 * <BR>Range: [0x0 to 0xFFF]
4126 * @return
4127 * None
4128 *
4129 * \par<b>Description:</b><br>
4130 * Configures the compare value (relevant to the Fast Compare Mode).<BR>\n
4131 * A channel input can be converted and its value stored in its result register.
Alternatively, the channel input can
4132 * be converted and compared against a compare value. This is the fast compare mode
typically utilized by applications
4133 * that are not interested in absolute converted value of an analog input, but rather
a binary decision on how the
4134 * input fares against a preset compare value. The channel should have had already
chosen the correct ICLASS with
4135 * the fast compare mode enabled. \b compare_val would be the compare value on which
FCM bit in the result
4136 * register will be set. The FCM bit will be set if the analog voltage is greater
than the compare value.
4137 * A call to this API would configure the register bit field GxRES.RESULT.
4138 *
4139 * \par<b>Related APIs:</b><br>
4140 * XMC_VADC_GROUP_GetFastCompareResult().
4141 */
4142 void XMC_VADC_GROUP_SetResultFastCompareValue(XMC_VADC_GROUP_t *const group_ptr,
4143 const uint32_t res_reg,
4144 const XMC_VADC_RESULT_SIZE_t compare_val
);
4145
4146 /**
4147 * @param group_ptr Constant pointer to the VADC group
4148 * @param res_reg Result Register for which the compare value is being set
4149 * <BR>Range: [0x0 to 0xF]
4150 * @return
4151 * ::XMC_VADC_FAST_COMPARE If the input is greater or lower than the compare value
returns the appropriate enum.
4152 * if the valid flag was not set then it would return
XMC_VADC_FAST_COMPARE_UNKNOWN.
4153 *
4154 * \par<b>Description:</b><br>
4155 * Determines the input is greater/lower than the compare value.<BR>\n
4156 * This API determines if the input is greater/lower than the preset compare value.
4157 * A call to this API would access the register bit field GxRES.FCM.
4158 *
4159 * \par<b>Related APIs:</b><br>
4160 * XMC_VADC_GROUP_SetResultFastCompareValue().
4161 */
4162 XMC_VADC_FAST_COMPARE_t XMC_VADC_GROUP_GetFastCompareResult(XMC_VADC_GROUP_t *const
group_ptr, const uint32_t res_reg);
4163
4164 /**
4165 * @param group_ptr Constant pointer to the VADC group
4166 * @param res_reg Result Register for which the result event is being asserted
4167 * <BR>Range: [0x0 to 0xF]
4168 * @return
4169 * None
4170 *
4171 * \par<b>Description:</b><br>
4172 * Manually asserts the result event.<BR>\n
4173 * The result event must necessarily be connected to a SR line. The SR in turn must
have been enabled along with the
4174 * corresponding NVIC node. Only then will the assertion of RES event lead to an
interrupt.
4175 * A call to this API would access the register bit fieldS OF GxREFLAG.
4176 *
4177 * \par<b>Related APIs:</b><br>
4178 * XMC_VADC_GROUP_ClearResultEvent().
4179 */
4180 __STATIC_INLINE void XMC_VADC_GROUP_TriggerResultEvent(XMC_VADC_GROUP_t *const
group_ptr, const uint32_t res_reg)
4181 {
4182 XMC_ASSERT("XMC_VADC_GROUP_TriggerResultEvent:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
4183 XMC_ASSERT("XMC_VADC_GROUP_TriggerResultEvent:Wrong Result Register", ((res_reg) <
XMC_VADC_NUM_RESULT_REGISTERS))
4184 group_ptr->REFLAG = (uint32_t)((uint32_t)1 << res_reg);
4185 }
4186
4187 /**
4188 * @param group_ptr Constant pointer to the VADC group
4189 * @param res_reg Result Register for which the result event is being acknowledged
4190 * <BR>Range: [0x0 to 0xF]
4191 * @return
4192 * None
4193 *
4194 * \par<b>Description:</b><br>
4195 * Acknowledges a Result event.<BR>\n
4196 * When a Result event is raised after the conversion of that associated channel has
produced a result and
4197 * it has to be cleared. This API would clear the Channel event of a particular
channel if it has occurred.
4198 * A call to this API would access the register bit fields of GxREFCLR.
4199 *
4200 * \par<b>Related APIs:</b><br>
4201 * XMC_VADC_GROUP_ChannelTriggerEvent().
4202 */
4203 __STATIC_INLINE void XMC_VADC_GROUP_ClearResultEvent(XMC_VADC_GROUP_t *const group_ptr
, const uint32_t res_reg)
4204 {
4205 XMC_ASSERT("XMC_VADC_GROUP_ClearResultEvent:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
4206 XMC_ASSERT("XMC_VADC_GROUP_ClearResultEvent:Wrong Result Register", ((res_reg) <
XMC_VADC_NUM_RESULT_REGISTERS))
4207 group_ptr->REFCLR = (uint32_t)((uint32_t)1 << res_reg);
4208 }
4209
4210 /**
4211 * @param group_ptr Constant pointer to the VADC group
4212 * @param res_reg Result Register for which the result event is being asserted
4213 * <BR>Range: [0x0 to 0xF]
4214 * @param sr The SR line to which the result event must be connected
4215 * @return
4216 * None
4217 *
4218 * \par<b>Description:</b><br>
4219 * Binds a result event to a requested Service Request line.<BR>\n
4220 * The result event is connected to a service request line. For an event to result in
an interrupt, this service
4221 * request line must be enabled in VADC and the NVIC node which this service request
line is connected to must have
4222 * interrupt generation enabled. A call to this API would access the registers
GxREVNP0 GxREVNP1.
4223 *
4224 * \par<b>Related APIs:</b><br>
4225 * XMC_VADC_GROUP_TriggerResultEvent()<BR> XMC_VADC_GROUP_ClearResultEvent()
4226 */
4227 void XMC_VADC_GROUP_SetResultInterruptNode(XMC_VADC_GROUP_t *const group_ptr,
4228 const uint32_t res_reg,
4229 const XMC_VADC_SR_t sr);
4230
4231 /**
4232 * @param group_ptr Constant pointer to the VADC group
4233 * @param res_reg Result Register which forms a part of FIFO
4234 * <BR>Range: [0x0 to 0xF]
4235 * @return
4236 * uint32_t returns the Result register number which is the tail of the FIFO,\b
res_reg is apart of this FIFO.
4237 *
4238 * \par<b>Description:</b><br>
4239 * Returns the the FIFO tail (register from where to read the results).<BR>\n
4240 * The analog converter writes to the head of the FIFO. It is the head of the FIFO
which is bound to the channel.
4241 * Applications read the result from the tail of the FIFO. This API would return the
result
4242 * register from where a user can call the API XMC_VADC_GROUP_GetResult() to read the
result stored in the FIFO.
4243 * A call to this API would access the register bit field GxRCR.FEN.
4244 *
4245 * \par<b>Related APIs:</b><br>
4246 * XMC_VADC_GROUP_GetResultFifoHead()<BR>
4247 */
4248 uint32_t XMC_VADC_GROUP_GetResultFifoTail(XMC_VADC_GROUP_t *const group_ptr, uint32_t
res_reg);
4249
4250 /**
4251 * @param group_ptr Constant pointer to the VADC group
4252 * @param res_reg Result Register which forms a part of fifo
4253 * <BR>Range: [0x0 to 0xF]
4254 * @return
4255 * uint32_t returns the Result register number which is the head of the FIFO,\b
res_reg is apart of this FIFO.
4256 *
4257 * \par<b>Description:</b><br>
4258 * Returns the the FIFO head (register to which the results are written by H/W).<BR>\n
4259 * The analog converter writes to the head of the FIFO. It is the head of the FIFO
which is bound to the channel.
4260 * Applications read the result from the tail of the FIFO. This API would just return
the head of the FIFO
4261 * from where the results are being added to the FIFO.
4262 * A call to this API would access the register bit field GxRCR.FEN.
4263 *
4264 * \par<b>Related APIs:</b><br>
4265 * XMC_VADC_GROUP_GetResultFifoHead()<BR>
4266 */
4267 uint32_t XMC_VADC_GROUP_GetResultFifoHead(XMC_VADC_GROUP_t *const group_ptr,const
uint32_t res_reg);
4268
4269 /**
4270 *
4271 * @param group_ptr Constant pointer to the VADC group
4272 * @param res_reg Result Register in question
4273 * <BR>Range: [0x0 to 0xF]
4274 * @return
4275 * bool returns true if the \b res_reg is the FIFO head.
4276 *
4277 * \par<b>Description:</b><br>
4278 * Determines if the requested register is the head of a FIFO.<BR>\n
4279 * The analog converter writes to the head of the FIFO. It is the head of the FIFO
which is bound to the channel.
4280 * Applications read the result from the tail of the FIFO.
4281 * A call to this API would access the register bit field GxRCR.FEN.
4282 *
4283 * \par<b>Related APIs:</b><br>
4284 * XMC_VADC_GROUP_GetResultFifoHead()<BR>
4285 */
4286 bool XMC_VADC_GROUP_IsResultRegisterFifoHead(XMC_VADC_GROUP_t *const group_ptr, const
uint32_t res_reg);
4287
4288 /**
4289 *
4290 * @param group_ptr Constant pointer to the VADC group
4291 * @param res_reg Result Register number<BR>
4292 * <BR>Range: [0x0 to 0xF]
4293 * @return
4294 * bool returns true if the \b res_reg is the FIFO member, else false.
4295 *
4296 * \par<b>Description:</b><br>
4297 * Determines whether the specified register is a FIFO member or not.<BR>\n
4298 * The analog converter writes to the head of the FIFO. It is the head of the FIFO
which is bound to the channel.
4299 * Applications read the result from the tail of the FIFO.
4300 * A call to this API would access the register bit field GxRCR.FEN.
4301 *
4302 */
4303 __STATIC_INLINE bool XMC_VADC_GROUP_IsResultRegisterInFifo(XMC_VADC_GROUP_t *const
group_ptr,
4304 const uint32_t
res_reg)
4305 {
4306
4307 XMC_ASSERT("XMC_VADC_GROUP_IsResultRegisterInFifo:Wrong Group Pointer",
XMC_VADC_CHECK_GROUP_PTR(group_ptr))
4308 XMC_ASSERT("XMC_VADC_GROUP_IsResultRegisterInFifo:Wrong Result Register",
4309 ((res_reg) < XMC_VADC_NUM_RESULT_REGISTERS))
4310 return( (bool)(group_ptr->RCR[res_reg] & (uint32_t)VADC_G_RCR_FEN_Msk));
4311 }
4312 #endif
4313
4314 #ifdef __cplusplus
4315 }
4316 #endif
4317
4318 /**
4319 * @}
4320 */
4321
4322 /**
4323 * @}
4324 */
4325
4326
4327 #endif /* XMC_VADC_H */
4328