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