1 /**
2  * @file xmc_ledts.h
3  * @date 2015-06-20
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-20:
40  *     - Initial draft<br>
41  *     - Documentation improved <br>
42  *     - New API added: XMC_LEDTS_SetActivePADNo() <br>
43  *
44  * 2015-06-20:
45  *     - Removed version macros and declaration of GetDriverVersion API
46  *
47  * @endcond
48  *
49  */
50 
51 #ifndef XMC_LEDTS_H
52 #define XMC_LEDTS_H
53 
54 /*********************************************************************************************************************
55  * HEADER FILES
56  ********************************************************************************************************************/
57 #include <xmc_common.h>
58 
59 #if defined(LEDTS0)
60 #include "xmc_scu.h"
61 
62 /**
63  * @addtogroup XMClib XMC Peripheral Library
64  * @{
65  */
66 
67 /**
68  * @addtogroup LEDTS
69  * @brief LED and Touch-Sense control(LEDTS) driver for the XMC controller family.
70  *
71  * The LED and Touch-Sense (LEDTS) drives LEDs and controls touch pads used as human-machine interface (HMI) in an
72  * application. The LEDTS can measure the capacitance of up to 8 touch pads, can also drive up to 64 LEDs in an LED matrix.
73  * Touch pads and LEDs can share pins to minimize the number of pins needed for such applications, this is realized by
74  * the module controlling the touch pads and driving the LEDs in a time-division multiplexed manner.
75  *
76  * This device contains LEDTS kernel that has an LED driving function and a touch-sensing function.
77  *
78  * It is recommended to set up all configurations for the LEDTS in all Special Function Registers(SFR) before
79  * enabling and starting LED and/or touch-sense function(s).
80  *
81  * This Low Level Driver(LLD) provides APIs to configure and control LED functionality, Touch-Sense functionality and
82  * features common to both functionalities.
83  *
84  * LED features:
85  * -# Configuration structure to configure LED functionality (XMC_LEDTS_LED_CONFIG_t) and initialization funtion
86  *    (XMC_LEDTS_InitLED()).
87  * -# Selection of number of LED columns, active column level and enabling LED funtionality (XMC_LEDTS_InitLED()).
88  * -# Setting line pattern to be displayed on LED column (XMC_LEDTS_SetLEDLinePattern()).
89  * -# Brightness control of LED column (XMC_LEDTS_SetColumnBrightness()).
90  * -# Setting number of columns to be activated (XMC_LEDTS_SetNumOfLEDColumns()).
91  *
92  * Touch-Sense features:
93  * -# Configuration structure to perform basic Touch-Sense functionality (XMC_LEDTS_TS_CONFIG_BASIC_t) settings and
94  *    initialization funtion (XMC_LEDTS_InitTSBasic()).
95  * -# Configuration structure to perform advanced Touch-Sense functionality (XMC_LEDTS_TS_CONFIG_ADVANCED_t) settings
96  *    and initialization function (XMC_LEDTS_InitTSAdvanced()).
97  * -# Setting number of touch inputs and acculumate count on touch input (XMC_LEDTS_InitTSBasic()).
98  * -# Enabling/disabling of common compare, Touch-Sense counter auto reset and Touch-Sense funtionality.
99  *    (XMC_LEDTS_InitTSBasic()).
100  * -# Set number of mask bits for time frame validation and first touch input to be active. (XMC_LEDTS_InitTSAdvanced()).
101  * -# Enable/disable time frame interrupt, external pull-up on touch pin and hardware or software control of
102  *    pad turn (XMC_LEDTS_InitTSAdvanced()).
103  * -# Setting size of common oscillation window for all touch-sense inputs (XMC_LEDTS_SetCommonOscillationWindow()).
104  * -# Setting size of oscillation window for a touch-sense input (XMC_LEDTS_SetOscillationWindow()).
105  *
106  * Common features:
107  * -# Global configuration structure XMC_LEDTS_GLOBAL_CONFIG_t and initialization function XMC_LEDTS_InitGlobal().
108  * -# Selection of Clock source for LEDTS module (XMC_LEDTS_InitGlobal()).
109  * -# Kick-start and stop of LEDTS module (XMC_LEDTS_StartCounter() / XMC_LEDTS_StopCounter()).
110  * -# Read and clear of interrupt status flags (XMC_LEDTS_ReadInterruptFlag() / XMC_LEDTS_ClearInterruptFlag()).
111  * -# Reading of previous active column number (XMC_LEDTS_ReadFNCOL()).
112  * -# Enable/Disable Interrupts(XMC_LEDTS_EnableInterrupt() / XMC_LEDTS_DisableInterrupt()).
113  * @{
114  */
115 
116 /*********************************************************************************************************************
117  * MACROS
118  ********************************************************************************************************************/
119 
120 #if defined(LEDTS0)
121 #define XMC_LEDTS0 ((XMC_LEDTS_GLOBAL_t *) LEDTS0)     /**< Typedef for LEDTS kernel0*/
122 #define XMC_LEDTS_CHECK_LEDTS0(PTR) (PTR == XMC_LEDTS0)
123 #else
124 #define XMC_LEDTS_CHECK_LEDTS0(PTR) 0
125 #endif
126 
127 #if defined(LEDTS1)
128 #define XMC_LEDTS1 ((XMC_LEDTS_GLOBAL_t *) LEDTS1)     /**< Typedef for LEDTS kernel1*/
129 #define XMC_LEDTS_CHECK_LEDTS1(PTR) (PTR == XMC_LEDTS1)
130 #else
131 #define XMC_LEDTS_CHECK_LEDTS1(PTR) 0
132 #endif
133 
134 #if defined(LEDTS2)
135 #define XMC_LEDTS2 ((XMC_LEDTS_GLOBAL_t *) LEDTS2)     /**< Typedef for LEDTS kernel2*/
136 #define XMC_LEDTS_CHECK_LEDTS2(PTR) (PTR == XMC_LEDTS2)
137 #else
138 #define XMC_LEDTS_CHECK_LEDTS2(PTR) 0
139 #endif
140 
141 #define XMC_LEDTS_CHECK_KERNEL_PTR(PTR)  (XMC_LEDTS_CHECK_LEDTS0(PTR) || \
142                                           XMC_LEDTS_CHECK_LEDTS1(PTR) || \
143                                           XMC_LEDTS_CHECK_LEDTS2(PTR))
144 
145 /**
146  * Defines LEDTS module structure. This holds data and configuration registers of LEDTS modules. Use type
147  * XMC_LEDTS_GLOBAL_t for this data structure.\n
148  */
149 typedef struct XMC_LEDTS_GLOBAL{                    /*!< (@ 0x50020000) LEDTS Structure                   */
150   __I  uint32_t  ID;                                /*!< (@ 0x50020000) Module Identification Register    */
151   __IO uint32_t  GLOBCTL;                           /*!< (@ 0x50020004) Global Control Register           */
152   __IO uint32_t  FNCTL;                             /*!< (@ 0x50020008) Function Control Register         */
153   __O  uint32_t  EVFR;                              /*!< (@ 0x5002000C) Event Flag Register               */
154   __IO uint32_t  TSVAL;                             /*!< (@ 0x50020010) Touch-sense TS-Counter Value      */
155   __IO uint32_t  LINE[2];                           /*!< (@ 0x50020014) Line Pattern Register 0           */
156   __IO uint32_t  LDCMP[2];                          /*!< (@ 0x5002001C) LED Compare Register 0            */
157   __IO uint32_t  TSCMP[2];                          /*!< (@ 0x50020024) Touch-sense Compare Register 0    */
158  } XMC_LEDTS_GLOBAL_t;
159 
160 /*********************************************************************************************************************
161  * ENUMS
162  ********************************************************************************************************************/
163 /**
164  * Defines typedef for LEDTS Global data structure. Use type XMC_LEDTS_t for this data structure.\n
165  */
166 typedef XMC_LEDTS_GLOBAL_t XMC_LEDTS_t;
167 
168 #if defined(LEDTS0)
169 #define XMC_LEDTS0 ((XMC_LEDTS_GLOBAL_t *) LEDTS0)     /**< Typedef for LEDTS kernel0*/
170 #endif
171 
172 #if defined(LEDTS1)
173 #define XMC_LEDTS1 ((XMC_LEDTS_GLOBAL_t *) LEDTS1)     /**< Typedef for LEDTS kernel1*/
174 #endif
175 
176 
177 /**
178  *  Defines return value of an API. Use type XMC_LEDTS_STATUS_t for this enum.
179  */
180 typedef enum XMC_LEDTS_STATUS
181 {
182   XMC_LEDTS_STATUS_SUCCESS  =  0,           /**< API fulfills request */
183   XMC_LEDTS_STATUS_RUNNING  =  1,           /**< The kernel-counter is currently running */
184   XMC_LEDTS_STATUS_ERROR    =  2,           /**< API cannot fulfill request */
185   XMC_LEDTS_STATUS_IDLE     =  3            /**< The kernel-counter is currently idle */
186 } XMC_LEDTS_STATUS_t;
187 
188 /**
189  *  Defines return value for checking interrupt flag. Use type XMC_LEDTS_FLAG_STATUS_t for this enum.
190  */
191 typedef enum XMC_LEDTS_FLAG_STATUS
192 {
193   XMC_LEDTS_FLAG_STATUS_NO   = 0,            /**< Flag not raised */
194   XMC_LEDTS_FLAG_STATUS_YES  = 1             /**< Flag is raised */
195 } XMC_LEDTS_FLAG_STATUS_t;
196 
197 /**
198  *  Defines Touch-Sense function enable/disable. Use type XMC_LEDTS_TS_FUNC_t for this enum.
199  */
200 typedef enum XMC_LEDTS_TS_FUNC
201 {
202   XMC_LEDTS_TS_FUNC_DISABLE = 0,             /**< Disable touch-sense function */
203   XMC_LEDTS_TS_FUNC_ENABLE  = 1              /**< Enable touch-sense function */
204 } XMC_LEDTS_TS_FUNC_t;
205 
206 /**
207  *  Defines LED function enable/disable. Use type XMC_LEDTS_LED_FUNC_t for this enum.
208  */
209 typedef enum XMC_LEDTS_LED_FUNC
210 {
211   XMC_LEDTS_LED_FUNC_DISABLE = 0,            /**< Disable LED function */
212   XMC_LEDTS_LED_FUNC_ENABLE  = 1             /**< Enable LED function */
213 } XMC_LEDTS_LED_FUNC_t;
214 
215 /**
216  *  Defines Clock master enable/disable. Use type for XMC_LEDTS_CLOCK_TYPE_t for this enum.
217  */
218 typedef enum XMC_LEDTS_CLOCK_TYPE
219 {
220   XMC_LEDTS_CLOCK_TYPE_MASTER = 0,           /**< Kernel generates its own clock */
221   XMC_LEDTS_CLOCK_TYPE_SLAVE  = 1            /**< Clock is taken from another master kernel */
222 } XMC_LEDTS_CLOCK_TYPE_t;
223 
224 /**
225  *  Defines enable/disable of autoscan time period synchronization. Use type XMC_LEDTS_TP_SYNC_t for this enum.
226  */
227 typedef enum XMC_LEDTS_TP_SYNC
228 {
229   XMC_LEDTS_TP_SYNC_DISABLE = 0,             /**< Synchronization is disabled */
230   XMC_LEDTS_TP_SYNC_ENABLE  = 1              /**< Synchronization enabled on Kernel0 autoscan time period */
231 } XMC_LEDTS_TP_SYNC_t;
232 
233 /**
234  *  Defines Suspend request configuration. Use type XMC_LEDTS_SUSPEND_t for this enum.
235  */
236 typedef enum XMC_LEDTS_SUSPEND
237 {
238   XMC_LEDTS_SUSPEND_DISABLE = 0,             /**< Ignore suspend request */
239   XMC_LEDTS_SUSPEND_ENABLE  = 1              /**< Enable suspend according to request */
240 } XMC_LEDTS_SUSPEND_t;
241 
242 /**
243  *  Defines number of bits to mask for time frame event validation. Use type XMC_LEDTS_TS_COUNTER_MASK_t for this enum.
244  */
245 typedef enum XMC_LEDTS_TS_COUNTER_MASK
246 {
247   XMC_LEDTS_TS_COUNTER_MASK_1_LSB = 0,       /**< Mask LSB bit only */
248   XMC_LEDTS_TS_COUNTER_MASK_2_LSB = 1,       /**< Mask 2 LSB bits */
249   XMC_LEDTS_TS_COUNTER_MASK_3_LSB = 2,       /**< Mask 3 LSB bits */
250   XMC_LEDTS_TS_COUNTER_MASK_4_LSB = 3,       /**< Mask 4 LSB bits */
251   XMC_LEDTS_TS_COUNTER_MASK_5_LSB = 4,       /**< Mask 5 LSB bits */
252   XMC_LEDTS_TS_COUNTER_MASK_6_LSB = 5,       /**< Mask 6 LSB bits */
253   XMC_LEDTS_TS_COUNTER_MASK_7_LSB = 6,       /**< Mask 7 LSB bits */
254   XMC_LEDTS_TS_COUNTER_MASK_8_LSB = 7        /**< Mask 8 LSB bits */
255 } XMC_LEDTS_TS_COUNTER_MASK_t;
256 
257 /**
258  *  Defines Enable/disable of (extended) time frame validation. Use type XMC_LEDTS_TF_VALIDATION_t for this enum.
259  */
260 typedef enum XMC_LEDTS_TF_VALIDATION
261 {
262   XMC_LEDTS_TF_VALIDATION_DISABLE = 0,       /**< Disable time frame validation */
263   XMC_LEDTS_TF_VALIDATION_ENABLE  = 1        /**< Enable time frame validation */
264 } XMC_LEDTS_TF_VALIDATION_t;
265 
266 /**
267  *  Defines Enable or disable interrupts. Use type XMC_LEDTS_INTERRUPT_t for this enum.
268  */
269 typedef enum XMC_LEDTS_INTERRUPT
270 {
271   XMC_LEDTS_INTERRUPT_TIMESLICE  = LEDTS_GLOBCTL_ITS_EN_Msk,  /**< Enable or Disable time slice interrupt */
272   XMC_LEDTS_INTERRUPT_TIMEFRAME  = LEDTS_GLOBCTL_ITF_EN_Msk,  /**< Enable or Disable time frame interrupt */
273   XMC_LEDTS_INTERRUPT_TIMEPERIOD = LEDTS_GLOBCTL_ITP_EN_Msk   /**< Enable or Disable autoscan time period interrupt */
274 } XMC_LEDTS_INTERRUPT_t;
275 
276 /**
277  *  Defines Touch-Sense TSIN pad turn. Use type XMC_LEDTS_PAD_TURN_t for this enum.
278  */
279 typedef enum XMC_LEDTS_PAD_TURN
280 {
281   XMC_LEDTS_PAD_TURN_0 = 0,       /**< TSIN0 is next or currently active */
282   XMC_LEDTS_PAD_TURN_1 = 1,       /**< TSIN1 is next or currently active */
283   XMC_LEDTS_PAD_TURN_2 = 2,       /**< TSIN2 is next or currently active */
284   XMC_LEDTS_PAD_TURN_3 = 3,       /**< TSIN3 is next or currently active */
285   XMC_LEDTS_PAD_TURN_4 = 4,       /**< TSIN4 is next or currently active */
286   XMC_LEDTS_PAD_TURN_5 = 5,       /**< TSIN5 is next or currently active */
287   XMC_LEDTS_PAD_TURN_6 = 6,       /**< TSIN6 is next or currently active */
288   XMC_LEDTS_PAD_TURN_7 = 7        /**< TSIN7 is next or currently active */
289 } XMC_LEDTS_PAD_TURN_t;
290 
291 /**
292  *  Defines software control for Touch-Sense pad turn. Use type XMC_LEDTS_PAD_TURN_SW_CONTROL_t for this enum.
293  */
294 typedef enum XMC_LEDTS_PAD_TURN_SW_CONTROL
295 {
296   XMC_LEDTS_SW_CONTROL_DISABLE = 0,             /**< Disable software control. Auto hardware control */
297   XMC_LEDTS_SW_CONTROL_ENABLE  = 1              /**< Enable software control for pad turn */
298 } XMC_LEDTS_PAD_TURN_SW_CONTROL_t;
299 
300 /**
301  *  Defines External pull-up on touch-sense pin. Use type XMC_LEDTS_EXT_PULLUP_COLA_t for this enum.
302  */
303 typedef enum XMC_LEDTS_EXT_PULLUP_COLA
304 {
305   XMC_LEDTS_EXT_PULLUP_COLA_DISABLE = 0,         /**< Disable external pull-up. Internal pull-up is active */
306   XMC_LEDTS_EXT_PULLUP_COLA_ENABLE  = 1          /**< Enable external pull-up */
307 } XMC_LEDTS_EXT_PULLUP_COLA_t;
308 
309 /**
310  *  Defines number of accumulation counts on Touch-Sense input. Use type XMC_LEDTS_ACCUMULATION_COUNT_t for this enum.
311  */
312 typedef enum XMC_LEDTS_ACCUMULATION_COUNT
313 {
314   XMC_LEDTS_ACCUMULATION_COUNT_1_TIME   = 0,         /**< Accumulate once */
315   XMC_LEDTS_ACCUMULATION_COUNT_2_TIMES  = 1,         /**< Accumulate twice */
316   XMC_LEDTS_ACCUMULATION_COUNT_3_TIMES  = 2,         /**< Accumulate thrice */
317   XMC_LEDTS_ACCUMULATION_COUNT_4_TIMES  = 3,         /**< Accumulate 4 times */
318   XMC_LEDTS_ACCUMULATION_COUNT_5_TIMES  = 4,         /**< Accumulate 5 times*/
319   XMC_LEDTS_ACCUMULATION_COUNT_6_TIMES  = 5,         /**< Accumulate 6 times */
320   XMC_LEDTS_ACCUMULATION_COUNT_7_TIMES  = 6,         /**< Accumulate 7 times*/
321   XMC_LEDTS_ACCUMULATION_COUNT_8_TIMES  = 7,         /**< Accumulate 8 times */
322   XMC_LEDTS_ACCUMULATION_COUNT_9_TIMES  = 8,         /**< Accumulate 9 times*/
323   XMC_LEDTS_ACCUMULATION_COUNT_10_TIMES = 9,         /**< Accumulate 10 times */
324   XMC_LEDTS_ACCUMULATION_COUNT_11_TIMES = 10,        /**< Accumulate 11 times*/
325   XMC_LEDTS_ACCUMULATION_COUNT_12_TIMES = 11,        /**< Accumulate 12 times*/
326   XMC_LEDTS_ACCUMULATION_COUNT_13_TIMES = 12,        /**< Accumulate 13 times*/
327   XMC_LEDTS_ACCUMULATION_COUNT_14_TIMES = 13,        /**< Accumulate 14 times*/
328   XMC_LEDTS_ACCUMULATION_COUNT_15_TIMES = 14,        /**< Accumulate 15 times*/
329   XMC_LEDTS_ACCUMULATION_COUNT_16_TIMES = 15         /**< Accumulate 16 times*/
330 } XMC_LEDTS_ACCUMULATION_COUNT_t;
331 
332 /**
333  *  Defines enable/disable of common compare configuration for Touch-Sense. Use type XMC_LEDTS_COMMON_COMPARE_t
334  *  for this enum.
335  */
336 typedef enum XMC_LEDTS_COMMON_COMPARE
337 {
338   XMC_LEDTS_COMMON_COMPARE_DISABLE = 0,         /**< Disable common compare for touch-sense */
339   XMC_LEDTS_COMMON_COMPARE_ENABLE  = 1          /**< Enable common compare for touch-sense */
340 } XMC_LEDTS_COMMON_COMPARE_t;
341 
342 /**
343  *  Defines extended Touch-Sense output for pin-low-level. Use type XMC_LEDTS_EXTEND_TS_OUTPUT_t for this enum.
344  */
345 typedef enum XMC_LEDTS_EXTEND_TS_OUTPUT
346 {
347   XMC_LEDTS_EXTEND_TS_OUTPUT_BY_1_CLK  = 0,     /**< Extend Touch-Sense output for pin-low-level by 1 ledts_clk */
348   XMC_LEDTS_EXTEND_TS_OUTPUT_BY_4_CLK  = 1,     /**< Extend Touch-Sense output for pin-low-level by 4 ledts_clk */
349   XMC_LEDTS_EXTEND_TS_OUTPUT_BY_8_CLK  = 2,     /**< Extend Touch-Sense output for pin-low-level by 8 ledts_clk */
350   XMC_LEDTS_EXTEND_TS_OUTPUT_BY_16_CLK = 3      /**< Extend Touch-Sense output for pin-low-level by 16 ledts_clk */
351 } XMC_LEDTS_EXTEND_TS_OUTPUT_t;
352 
353 /**
354  *  Defines enable/disable of Touch-Sense counter auto reset configuration. Use type XMC_LEDTS_TS_COUNTER_AUTO_RESET_t
355  *  for this enum.
356  */
357 typedef enum XMC_LEDTS_TS_COUNTER_AUTO_RESET
358 {
359   XMC_LEDTS_TS_COUNTER_AUTO_RESET_DISABLE = 0,     /**< Disable Touch-Sense counter automatic reset */
360   XMC_LEDTS_TS_COUNTER_AUTO_RESET_ENABLE  = 1      /**< Enable Touch-Sense counter automatic reset to 0x00 */
361 } XMC_LEDTS_TS_COUNTER_AUTO_RESET_t;
362 
363 /**
364  *  Defines enable/disable of Touch-Sense counter saturation configuration. Use type XMC_LEDTS_TS_COUNTER_SATURATION_t
365  *  for this enum.
366  */
367 typedef enum XMC_LEDTS_TS_COUNTER_SATURATION
368 {
369   XMC_LEDTS_TS_COUNTER_SATURATION_DISABLE = 0, /**< Disabled. Touch-Sense counter overflows when it reaches 0xFF */
370   XMC_LEDTS_TS_COUNTER_SATURATION_ENABLE  = 1  /**< Enabled. Touch-Sense counter stops counting when it reaches 0xFF */
371 } XMC_LEDTS_TS_COUNTER_SATURATION_t;
372 
373 /**
374  *  Defines number of Touch-Sense Input (for HW pad turn control). Use type XMC_LEDTS_NUMBER_TS_INPUT_t for this enum.
375  */
376 typedef enum XMC_LEDTS_NUMBER_TS_INPUT
377 {
378   XMC_LEDTS_NUMBER_TS_INPUT_1  = 0,      /**< Only TSIN0 is used */
379   XMC_LEDTS_NUMBER_TS_INPUT_2 = 1,       /**< TSIN0 & TSIN1 are used */
380   XMC_LEDTS_NUMBER_TS_INPUT_3 = 2,       /**< TSIN0-TSIN2 are used */
381   XMC_LEDTS_NUMBER_TS_INPUT_4 = 3,       /**< TSIN0-TSIN3 are used */
382   XMC_LEDTS_NUMBER_TS_INPUT_5 = 4,       /**< TSIN0-TSIN4 are used */
383   XMC_LEDTS_NUMBER_TS_INPUT_6 = 5,       /**< TSIN0-TSIN5 are used */
384   XMC_LEDTS_NUMBER_TS_INPUT_7 = 6,       /**< TSIN0-TSIN6 are used */
385   XMC_LEDTS_NUMBER_TS_INPUT_8 = 7        /**< TSIN0-TSIN7 are used */
386 } XMC_LEDTS_NUMBER_TS_INPUT_t;
387 
388 /**
389  *  Defines level of LED column when active. Use type XMC_LEDTS_ACTIVE_LEVEL_LED_COL_t for this enum.
390  */
391 typedef enum XMC_LEDTS_ACTIVE_LEVEL_LED_COL
392 {
393   XMC_LEDTS_ACTIVE_LEVEL_LED_COL_LOW  = 0, /**< LED column pins output low when active */
394   XMC_LEDTS_ACTIVE_LEVEL_LED_COL_HIGH = 1  /**< LED column pins output high when active */
395 } XMC_LEDTS_ACTIVE_LEVEL_LED_COL_t;
396 
397 /**
398  *  Defines Number of LED columns. Use type XMC_LEDTS_NUMBER_LED_COLUMNS_t for this enum.
399  */
400 typedef enum XMC_LEDTS_NUMBER_LED_COLUMNS
401 {
402   XMC_LEDTS_NUMBER_LED_COLUMNS_1 = 0,     /**< COLA only if TS is enabled, else COL0 only */
403   XMC_LEDTS_NUMBER_LED_COLUMNS_2 = 1,     /**< COLA,COL0 if TS is enabled, else COL0-1 */
404   XMC_LEDTS_NUMBER_LED_COLUMNS_3 = 2,     /**< COLA,COL0-1 if TS is enabled, else COL0-2 */
405   XMC_LEDTS_NUMBER_LED_COLUMNS_4 = 3,     /**< COLA,COL0-2 if TS is enabled, else COL0-3 */
406   XMC_LEDTS_NUMBER_LED_COLUMNS_5 = 4,     /**< COLA,COL0-3 if TS is enabled, else COL0-4 */
407   XMC_LEDTS_NUMBER_LED_COLUMNS_6 = 5,     /**< COLA,COL0-4 if TS is enabled, else COL0-5 */
408   XMC_LEDTS_NUMBER_LED_COLUMNS_7 = 6,     /**< COLA,COL0-5 if TS is enabled, else COL0-6 */
409   XMC_LEDTS_NUMBER_LED_COLUMNS_8 = 7      /**< Only possible if TS is disabled; COLA,COL0-6 used */
410 } XMC_LEDTS_NUMBER_LED_COLUMNS_t;
411 
412 /**
413  *  Defines Interrupt flag status. Use type XMC_LEDTS_TS_INTERRUPT_FLAG_t for this enum.
414  */
415 typedef enum XMC_LEDTS_INTERRUPT_FLAG
416 {
417   XMC_LEDTS_INTERRUPT_FLAG_TIMESLICE = LEDTS_EVFR_TSF_Msk,                 /**< Time slice interrupt flag status */
418   XMC_LEDTS_INTERRUPT_FLAG_TIMEFRAME = LEDTS_EVFR_TFF_Msk,                 /**< Time frame interrupt flag status */
419   XMC_LEDTS_INTERRUPT_FLAG_TIMEPERIOD = LEDTS_EVFR_TPF_Msk,                /**< Time period interrupt flag status */
420   XMC_LEDTS_INTERRUPT_FLAG_TSCOUNTER_OVERFLOW = LEDTS_EVFR_TSCTROVF_Msk,   /**< TS counter overflow flag status */
421 } XMC_LEDTS_TS_INTERRUPT_FLAG_t;
422 
423 /**
424  *  Defines (Extended) Time frame interrupt flag status. Use type XMC_LEDTS_TF_INTERRUPT_FLAG_t for this enum.
425  */
426 typedef enum XMC_LEDTS_TF_INTERRUPT_FLAG
427 {
428   XMC_LEDTS_TF_INTERRUPT_FLAG_INACTIVE = 0,          /**< (Extended) Time frame interrupt not active */
429   XMC_LEDTS_TF_INTERRUPT_FLAG_ACTIVE   = 1           /**< (Extended) Time frame interrupt active */
430 } XMC_LEDTS_TF_INTERRUPT_FLAG_t;
431 
432 /**
433  *  Defines Autoscan time period interrupt flag status. Use type XMC_LEDTS_AUTOSCAN_INTERRUPT_FLAG_t for this enum.
434  */
435 typedef enum XMC_LEDTS_AUTOSCAN_INTERRUPT_FLAG
436 {
437   XMC_LEDTS_AUTOSCAN_INTERRUPT_FLAG_INACTIVE = 0,    /**< Autoscan time period interrupt not active */
438   XMC_LEDTS_AUTOSCAN_INTERRUPT_FLAG_ACTIVE   = 1     /**< Autoscan time period interrupt active */
439 } XMC_LEDTS_AUTOSCAN_INTERRUPT_FLAG_t;
440 
441 /**
442  *  Defines Touch-Sense counter overflow indication. Use type XMC_LEDTS_TS_COUNTER_OVERLOW_FLAG_t for this enum.
443  */
444 typedef enum XMC_LEDTS_TS_COUNTER_OVERLOW_FLAG
445 {
446   XMC_LEDTS_TS_COUNTER_OVERLOW_FLAG_NO  = 0,         /**< Touch-sense counter has not overflowed */
447   XMC_LEDTS_TS_COUNTER_OVERLOW_FLAG_YES = 1          /**< Touch-sense counter has overflowed at least once */
448 } XMC_LEDTS_TS_COUNTER_OVERLOW_FLAG_t;
449 
450 /**
451  *  Defines available LED columns. Use type XMC_LEDTS_LED_COLUMN_t for this enum.
452  */
453 typedef enum XMC_LEDTS_LED_COLUMN
454 {
455   XMC_LEDTS_LED_COLUMN_0 = 0,       /**< Denotes LED Column 0 */
456   XMC_LEDTS_LED_COLUMN_1 = 1,       /**< Denotes LED Column 1 */
457   XMC_LEDTS_LED_COLUMN_2 = 2,       /**< Denotes LED Column 2 */
458   XMC_LEDTS_LED_COLUMN_3 = 3,       /**< Denotes LED Column 3 */
459   XMC_LEDTS_LED_COLUMN_4 = 4,       /**< Denotes LED Column 4 */
460   XMC_LEDTS_LED_COLUMN_5 = 5,       /**< Denotes LED Column 5 */
461   XMC_LEDTS_LED_COLUMN_6 = 6,       /**< Denotes LED Column 6 */
462   XMC_LEDTS_LED_COLUMN_A = 7        /**< Denotes LED Column A */
463 } XMC_LEDTS_LED_COLUMN_t;
464 
465 /**
466  *  Defines available Touch-Sense inputs. Use type XMC_LEDTS_TS_INPUT_t for this enum.
467  */
468 typedef enum XMC_LEDTS_TS_INPUT
469 {
470   XMC_LEDTS_TS_INPUT_0 = 0,         /**< TSIN0 - Denotes touch-sense line 1 */
471   XMC_LEDTS_TS_INPUT_1 = 1,         /**< TSIN1 - Denotes touch-sense line 2 */
472   XMC_LEDTS_TS_INPUT_2 = 2,         /**< TSIN2 - Denotes touch-sense line 3*/
473   XMC_LEDTS_TS_INPUT_3 = 3,         /**< TSIN3 - Denotes touch-sense line 4*/
474   XMC_LEDTS_TS_INPUT_4 = 4,         /**< TSIN4 - Denotes touch-sense line 5*/
475   XMC_LEDTS_TS_INPUT_5 = 5,         /**< TSIN5 - Denotes touch-sense line 6*/
476   XMC_LEDTS_TS_INPUT_6 = 6,         /**< TSIN6 - Denotes touch-sense line 7*/
477   XMC_LEDTS_TS_INPUT_7 = 7          /**< TSIN7 - Denotes touch-sense line 8*/
478 } XMC_LEDTS_TS_INPUT_t;
479 
480 /*********************************************************************************************************************
481  * DATA STRUCTURES
482  ********************************************************************************************************************/
483  /*Anonymous structure/union guard start*/
484  #if defined(__CC_ARM)
485   #pragma push
486   #pragma anon_unions
487 #elif defined(__TASKING__)
488   #pragma warning 586
489 #endif
490 
491 /**
492  *  Data structure for initialization of global features common to LED and touch-sense function. Use
493  *  type XMC_LEDTS_GLOBAL_CONFIG_t for this structure.
494  */
495 typedef struct XMC_LEDTS_GLOBAL_CONFIG
496 {
497   union
498   {
499     struct
500     {
501       uint32_t : 2;
502       uint32_t clock_generation:1;          /**< When this bit is set LEDTS counter takes its clock from another master
503                                                  kernel. Kernel generates its own clock when this bit is not set (CMTR).
504 												 Refer  @ref XMC_LEDTS_CLOCK_TYPE_t enum for possible values. */
505 
506       uint32_t autoscan_synchronization:1;  /**< Set this bit to synchronize start of autoscan time period with master
507                                                  kernel(ENSYNC). Refer @ref XMC_LEDTS_TP_SYNC_t enum for possible values. */
508       uint32_t : 4;
509       uint32_t suspend_response:1;          /**< Suspend request configuration(SUSCFG).
510                                                  Refer @ref XMC_LEDTS_SUSPEND_t enum for possible values.*/
511     };
512     uint32_t globctl;
513   };
514 }XMC_LEDTS_GLOBAL_CONFIG_t;
515 
516 /**
517  *  Data structure for LED function initialization. Use type XMC_LEDTS_LED_CONFIG_t for this structure.
518  */
519 typedef struct XMC_LEDTS_LED_CONFIG
520 {
521   union
522   {
523     struct
524     {
525       uint32_t : 28;
526       uint32_t column_active_level:1;   /**< When this bit is set LED column level is active high, otherwise column
527 	                                         level is active low(COLLEV). Refer @ref XMC_LEDTS_ACTIVE_LEVEL_LED_COL_t
528 											 enum for possible values.*/
529 
530       uint32_t no_of_led_columns:3;     /**< Defines number of LED columns(NR_LEDCOL). Range 0 - 7.
531                                              Refer @ref XMC_LEDTS_NUMBER_LED_COLUMNS_t enum for possible values. */
532     };
533     uint32_t fnctl;
534   };
535 }XMC_LEDTS_LED_CONFIG_t;
536 
537 /**
538  *  Data structure for basic Touch-Sense function initialization. Use type XMC_LEDTS_TS_CONFIG_BASIC_t for
539  *  this structure.
540  */
541 typedef struct XMC_LEDTS_TS_CONFIG_BASIC
542 {
543   union
544   {
545     struct
546     {
547       uint32_t : 16;
548       uint32_t no_of_accumulation:4; /**< Defines number of times touch-sense input pin is enabled in touch-sense
549 	                                      time slice of consecutive frames(ACCCNT). Range 0 - 15.
550                                           Refer @ref XMC_LEDTS_ACCUMULATION_COUNT_t enum type for possible values. */
551 
552       uint32_t common_compare:1;     /**< When this bit is set it enables common compare for all touch sense inputs.
553                                           Disables common compare when not set(TSCCMP).
554                                           Refer @ref XMC_LEDTS_COMMON_COMPARE_t enum for possible values.*/
555       uint32_t : 2;
556       uint32_t counter_auto_reset:1; /**< When this bit is set TS-counter is automatically reset to 00H on first pad
557 	                                      turn of a new touch-sense pin(TSCTRR).
558                                           Refer @ref XMC_LEDTS_TS_COUNTER_AUTO_RESET_t enum for possible values.*/
559 
560       uint32_t counter_saturation:1; /**< When this bit is set TS-counter stops counting in the touch-sense time slice
561 	                                         of the same frame when it reaches FFH (TSCTRSAT).
562                                              Refer @ref XMC_LEDTS_TS_COUNTER_SATURATION_t enum for possible values. */
563 
564       uint32_t no_of_touch_inputs:3; /**< Defines number of touch-sense inputs (NR_TSIN). Range 0 - 7.
565 	                                      Refer @ref XMC_LEDTS_NUMBER_TS_INPUT_t enum for possible values. */
566     };
567     uint32_t fnctl;
568   };
569 }XMC_LEDTS_TS_CONFIG_BASIC_t;
570 
571 /**
572  *  Data structure for advanced Touch-Sense function initialization. Use type XMC_LEDTS_TS_CONFIG_ADVANCED_t
573  *  for this structure.
574  */
575 typedef struct XMC_LEDTS_TS_CONFIG_ADVANCED
576 {
577   union
578   {
579     struct
580     {
581       uint32_t : 9;
582       uint32_t validation_mask:3;       /**< This bit-field defines number of LSB bits to mask for TS counter and shadow
583 	                                         TS counter comparison when Time Frame validation is enabled(MASKVAL).
584                                              Refer @ref XMC_LEDTS_TS_COUNTER_MASK_t enum for possible values.*/
585 
586       uint32_t time_frame_validation:1; /**< Disable or enable (extended) time frame validation(FENVAL).
587 	                                         when validation fails time frame interrupt is not triggered.
588 											 Refer @ref XMC_LEDTS_TF_VALIDATION_t enum for possible values.*/
589       uint32_t : 1;
590       uint32_t : 1;
591     };
592     uint32_t globctl;
593   };
594   union
595   {
596     struct
597     {
598       uint32_t first_pad_turn:3;        /**< This bit-field denotes TSIN[x] pin on which oscillations are measured
599 	                                         currently/next(PADT). Refer @ref XMC_LEDTS_PAD_TURN_t enum for possible
600 											 values.*/
601 
602       uint32_t pad_turn_control:1;      /**< Control pad turn via HW or SW(PADTSW).
603                                              Refer @ref XMC_LEDTS_PAD_TURN_SW_CONTROL_t enum for possible values. */
604 
605       uint32_t external_pullup:1;       /**< Disable or enable external pull-up on touch pin(EPULL).
606                                              Refer @ref XMC_LEDTS_EXT_PULLUP_COLA_t enum for possible values. */
607       uint32_t : 16;
608       uint32_t pin_low_extend:2;        /**< This bit extends touch-sense output for pin-low-level configuration for
609                                              adjustment of oscillation per user system.
610 											 Refer @ref XMC_LEDTS_EXTEND_TS_OUTPUT_t enum for possible values. */
611     };
612     uint32_t fnctl;
613   };
614 }XMC_LEDTS_TS_CONFIG_ADVANCED_t;
615 
616 /*Anonymous structure/union guard end*/
617 #if defined(__CC_ARM)
618   #pragma pop
619 #elif defined(__TASKING__)
620   #pragma warning restore
621 #endif
622 
623 #ifdef __cplusplus
624 extern "C" {
625 #endif
626 /*********************************************************************************************************************
627  * API Prototypes
628  ********************************************************************************************************************/
629 
630 /**
631  *
632  * @param ledts   Constant pointer to LEDTS module structure. Refer @ref XMC_LEDTS_GLOBAL_t data structure.<BR>
633  * @param config  Pointer to constant LEDTS Global configuration structure. Refer @ref XMC_LEDTS_GLOBAL_CONFIG_t
634  *                data structure.<BR>
635  *
636  * @return
637  *      XMC_LEDTS_STATUS_SUCCESS - on success.<BR>
638  *      XMC_LEDTS_STATUS_RUNNING - LEDTS module currently active. Refer @ref XMC_LEDTS_STATUS_t enum type.<BR>
639  *
640  * \par<b>Description</b><br>
641  * Initializes and configures GLOBCTL register of \a ledts with configuration data pointed by \a config.
642  * \par
643  * This API selects clock source (GLOBCTL.CMTR), enables/disables auto scan sync(GLOBCTL.ENSYNC) &
644  * suspend config(GLOBCTL.SUSCFG).<BR>
645  * Call this API to initialize global register fields common to both LED and touch-sense(TS).\n
646  *
647  * \par<b>Note</b><BR>
648  * LEDTS should be stopped by using XMC_LEDTS_StopCounter()before calling this API.\n
649  *
650  * \par<b>Related API's</b><BR>
651  * XMC_LEDTS_StopCounter()\n
652  *
653  */
654 XMC_LEDTS_STATUS_t XMC_LEDTS_InitGlobal(XMC_LEDTS_t *const ledts, const XMC_LEDTS_GLOBAL_CONFIG_t *config);
655 
656 /**
657  *
658  * @param ledts   Constant pointer to LEDTS module structure. Refer @ref XMC_LEDTS_GLOBAL_t data structure.<BR>
659  * @param config  Pointer to constant LEDTS LED configuration structure. Refer @ref XMC_LEDTS_LED_CONFIG_t
660  *                data structure.<BR>
661  *
662  * @return
663  *      XMC_LEDTS_STATUS_SUCCESS - on success.<BR>
664  *      XMC_LEDTS_STATUS_RUNNING - LEDTS module currently active/running. Refer @ref XMC_LEDTS_STATUS_t enum type.<BR>
665  *
666  * \par<b>Description</b><br>
667  * Configures FNCTL register of \a ledts with configuration data pointed by \a config and enables LED functionality.
668  * \par
669  * This API sets number of LED columns(FNCTL.NR_LEDCOL), column level(FNCTL.COLLEV) and enables LED
670  * functionality(GLOBCTL.LD_EN).
671  * \par
672  * Call this API to Configure \a FNCTL & \a GLOBCTL registers for LED-driving function. Global initialization of
673  * LEDTS module should be done by calling XMC_LEDTS_InitGlobal() prior to calling this API.\n
674  *
675  * \par<b>Note</b><BR>
676  * LEDTS should be stopped by using XMC_LEDTS_StopCounter() before calling this API.\n
677  *
678  * \par<b>Related API's</b><BR>
679  * XMC_LEDTS_StopCounter() XMC_LEDTS_InitGlobal()\n
680  *
681  */
682 XMC_LEDTS_STATUS_t XMC_LEDTS_InitLED(XMC_LEDTS_t *const ledts, const XMC_LEDTS_LED_CONFIG_t *config);
683 
684 /**
685  *
686  * @param ledts   Constant pointer to LEDTS module structure. Refer @ref XMC_LEDTS_GLOBAL_t data structure.<BR>
687  * @param config  Pointer to constant LEDTS TS basic configuration structure. Refer @ref XMC_LEDTS_TS_CONFIG_BASIC_t
688  *                data structure.<BR>
689  *
690  * @return
691  *      XMC_LEDTS_STATUS_SUCCESS - on success.<BR>
692  *      XMC_LEDTS_STATUS_RUNNING - LEDTS module currently active/running. Refer @ref XMC_LEDTS_STATUS_t enum type.<BR>
693  *
694  * \par<b>Description</b><br>
695  * Configures FNCTL register of \a ledts for basic touch sense functionality with configuration data pointed by \a config
696  * and enables TS functionality.
697  * \par
698  * This API sets number of touch inputs(FNCTL.NR_TSIN), accumulate count on touch input(FNCTL.ACCCNT).
699  * \par
700  * This API Enables/disables common compare(FNCTL.TSCCMP), TS counter auto reset(FNCTL.TSCTRR), counter
701  * saturation(FNCTL.TSCTRSAT) and enables TS functionality(GLOBCTL.TS_EN).
702  * \par
703  * Call this API to configure \a FNCTL & \a GLOBCTL registers for basic touch sense function. Global initialization
704  * of LEDTS module should be done by calling XMC_LEDTS_InitGlobal() prior to calling this API.\n
705  *
706  * \par<b>Note</b><BR>
707  * LEDTS should be stopped by using XMC_LEDTS_StopCounter() before calling this API.\n
708  *
709  * \par<b>Related API's</b><BR>
710  * XMC_LEDTS_StopCounter() XMC_LEDTS_InitGlobal()\n
711  *
712  */
713 XMC_LEDTS_STATUS_t XMC_LEDTS_InitTSBasic(XMC_LEDTS_t *const ledts, const XMC_LEDTS_TS_CONFIG_BASIC_t *config);
714 
715 /**
716  *
717  * @param ledts   Constant pointer to LEDTS module structure. Refer @ref XMC_LEDTS_GLOBAL_t data structure.<BR>
718  * @param config  Pointer to constant LEDTS TS advanced configuration structure.
719  *                Refer @ref XMC_LEDTS_TS_CONFIG_ADVANCED_t data structure.<BR>
720  *
721  * @return
722  *      XMC_LEDTS_STATUS_SUCCESS - on success.<BR>
723  *      XMC_LEDTS_STATUS_RUNNING - LEDTS module currently active/running. Refer @ref XMC_LEDTS_STATUS_t enum type.<BR>
724  *
725  * \par<b>Description</b><br>
726  * Configures FNCTL register of \a ledts for advanced touch sense functionality with configuration data pointed by
727  * \a config.
728  * \par
729  * This API sets number of mask-bits for time frame validation(GLOBCTL.MASKVAL) & first touch input to be active(if
730  * pad turn control is set to S/W)(FNCTL.PADT).
731  * \par
732  * Enables/disables time frame interrupt(GLOBCTL.ITF_EN), external pull up on touch pin(FNCTL.EPULL) & H/W or S/W
733  * control of pad turn(if set to H/W, touch input activation is done in round-robin sequence, starting from TSIN0)
734  * (FNCTL.PADTSW).
735  * \par
736  * Call this API to initialize registers for advanced touch sense function. Before calling this API Call
737  * XMC_LEDTS_InitGlobal() to do Global initialization and XMC_LEDTS_InitTSBasic() to do basic init of touch-sense.\n
738  *
739  * \par<b>Note</b><BR>
740  * LEDTS should be stopped by using XMC_LEDTS_StopCounter() before calling this API.\n
741  *
742  * \par<b>Related API's</b><BR>
743  * XMC_LEDTS_StopCounter(), XMC_LEDTS_InitTSBasic().\n
744  *
745  */
746 XMC_LEDTS_STATUS_t XMC_LEDTS_InitTSAdvanced (XMC_LEDTS_t *const ledts, const XMC_LEDTS_TS_CONFIG_ADVANCED_t *config);
747 
748 /**
749  *
750  * @param ledts      Constant pointer to LEDTS module structure. Refer @ref XMC_LEDTS_GLOBAL_t data structure.<BR>
751  * @param prescaler  Constant prescaler value. Range: 0H to FFFFH.<BR>
752  *
753  * @return
754  *      None.<BR>
755  *
756  * \par<b>Description</b><br>
757  * Kick-starts the LEDTS module by programming CLK_PS bit field of GLOBCTL register with \a prescaler value to start
758  * the LEDTS-counter.
759  * \par
760  * To set LEDTS counter at least one of the touch-sense or LED function should be enabled.
761  * Call this API to start LEDTS counter.\n
762  *
763  * \par<b>Note</b><BR>
764  * This should be called after all used modules have been initialized.\n
765  *
766  * \par<b>Related API's</b><BR>
767  * XMC_LEDTS_StopCounter(), XMC_LEDTS_InitLED(), XMC_LEDTS_InitTSBasic(), XMC_LEDTS_InitTSAdvanced().\n
768  *
769  */
770 void XMC_LEDTS_StartCounter(XMC_LEDTS_t *const ledts, const uint16_t prescaler);
771 
772 /**
773  *
774  * @param ledts  Constant pointer to LEDTS module structure. Refer @ref XMC_LEDTS_GLOBAL_t data structure.<BR>
775  *
776  * @return
777  *      None.<BR>
778  *
779  * \par<b>Description</b><br>
780  * Stops the LEDTS module by programming the CLK_PS bit field(with value = 0) of GLOBCTL register. <br>
781  * This could be done when it is required to change some module configuration which requires the LEDTS-counter
782  * to be stopped before the register bit/bit field can be programmed.<br> Call this API to stop LEDTS counter.\n
783  *
784  * \par<b>Related API's</b><BR>
785  * XMC_LEDTS_StartCounter(), XMC_LEDTS_InitLED(), XMC_LEDTS_InitTSBasic(), XMC_LEDTS_InitTSAdvanced().\n
786  *
787  */
788 void XMC_LEDTS_StopCounter(XMC_LEDTS_t *const ledts);
789 
790 /**
791  *
792  * @param ledts  Constant pointer to LEDTS module structure. Refer @ref XMC_LEDTS_GLOBAL_t data structure.<BR>
793  * @param interrupt_mask  mask value of @ref XMC_LEDTS_INTERRUPT_t enum type.<BR>
794  *
795  * @return
796  *      None.<BR>
797  *
798  * \par<b>Description</b><br>
799  * Enables requested interrupt type by configuring GLOBCTL register with masked value \a interrupt_mask.<BR>
800  * \par
801  * This API can be used to enable time slice(GLOBCTL.ITS_EN) or time frame(GLOBCTL.ITF_EN )or time period
802  * (GLOBCTL.ITP_EN)interrupt or any combination of these interrupts by passing appropriate bitwise ORed mask value.\n
803  *
804  * \par<b>Related API's</b><BR>
805  * XMC_LEDTS_DisableInterrupt().\n
806  *
807  */
XMC_LEDTS_EnableInterrupt(XMC_LEDTS_t * const ledts,uint32_t interrupt_mask)808 __STATIC_INLINE void XMC_LEDTS_EnableInterrupt(XMC_LEDTS_t *const ledts, uint32_t interrupt_mask)
809 {
810   XMC_ASSERT("XMC_LEDTS_EnableInterrupt:Wrong Module Pointer", XMC_LEDTS_CHECK_KERNEL_PTR(ledts));
811 
812   ledts->GLOBCTL |= interrupt_mask;
813 }
814 
815 /**
816  *
817  * @param ledts  Constant pointer to LEDTS module structure. Refer @ref XMC_LEDTS_GLOBAL_t data structure.<BR>
818  * @param interrupt_mask  mask value of @ref XMC_LEDTS_INTERRUPT_t enum type.<BR>
819  *
820  * @return
821  *      None.<BR>
822  *
823  * \par<b>Description</b><br>
824  * Disables requested interrupt type by configuring GLOBCTL register with masked value \a interrupt_mask.<BR>
825  * \par
826  * This API can be used to disable time slice(GLOBCTL.ITS_EN) or time frame(GLOBCTL.ITF_EN )or time period
827  * (GLOBCTL.ITP_EN)interrupt or any combination of these interrupts by passing appropriate bitwise ORed mask value.\n
828  *
829  * \par<b>Related API's</b><BR>
830  * XMC_LEDTS_EnableInterrupt().\n
831  *
832  */
XMC_LEDTS_DisableInterrupt(XMC_LEDTS_t * const ledts,uint32_t interrupt_mask)833 __STATIC_INLINE void XMC_LEDTS_DisableInterrupt(XMC_LEDTS_t *const ledts, uint32_t interrupt_mask)
834 {
835   XMC_ASSERT("XMC_LEDTS_DisableInterrupt:Wrong Module Pointer", XMC_LEDTS_CHECK_KERNEL_PTR(ledts));
836 
837   ledts->GLOBCTL &= ~interrupt_mask;
838 }
839 
840 /**
841  *
842  * @param ledts  Constant pointer to LEDTS module structure. Refer @ref XMC_LEDTS_GLOBAL_t data structure.<BR>
843  *
844  * @return
845  *      Status flags for events. Possible event flags are 0x01(time slice), 0x02(time frame),
846         0x04(time period), 0x08(TS counter overflow).<BR>
847  *
848  * \par<b>Description</b><br>
849  * Returns interrupt status flag by reading TSF(time slice), TFF(time frame), TPF(time period), TSCTROVF
850  * (touch sense counter overflow) fields of EVFR register.<br>
851  * Typically used in interrupt handler to find out which event has triggered the interrupt.\n
852  *
853  * \par<b>Note</b><BR>
854  * These flags are set on event regardless of corresponding interrupt is enabled or not.\n
855  *
856  * \par<b>Related API's</b><BR>
857  * XMC_LEDTS_ClearInterruptFlag().\n
858  *
859  */
860 uint32_t XMC_LEDTS_ReadInterruptFlag(XMC_LEDTS_t *const ledts);
861 
862 /**
863  *
864  * @param ledts  Constant pointer to LEDTS module structure. Refer @ref XMC_LEDTS_GLOBAL_t data structure.<BR>
865  * @param interrupt_mask  mask value of @ref XMC_LEDTS_INTERRUPT_t enum type.<BR>
866  *
867  * @return
868  *      None.<BR>
869  *
870  * \par<b>Description</b><br>
871  * Clears interrupt status flags in EVFR register as indicated by mask value \a interrupt_mask.<br>
872  * This API sets EVFR.CTSF, EVFR.CTFF, EVFR.CTPF bit fields to clear time slice, time frame or time period interrupts
873  * respectively.
874  * \par
875  * Typically used along with XMC_LEDTS_ReadInterruptFlag() to figure out which event triggered the interrupt.\n
876  *
877  * \par<b>Note</b><BR>
878  * Calling this API moves interrupt from pending/active state to inactive state. If the interrupt is pulsed,
879  * failing to clear the event bit might cause CPU to immediately re-enter the interrupt service routine(ISR).\n
880  *
881  * \par<b>Related API's</b><BR>
882  * XMC_LEDTS_ReadInterruptFlag().\n
883  *
884  */
885 void XMC_LEDTS_ClearInterruptFlag(XMC_LEDTS_t *const ledts, uint32_t interrupt_mask);
886 
887 /**
888  *
889  * @param ledts    Constant pointer to LEDTS module structure. Refer @ref XMC_LEDTS_GLOBAL_t data structure.<BR>
890  * @param pad_num  Pad number. Range refer @ref XMC_LEDTS_NUMBER_TS_INPUT_t enum type.<BR>
891  *
892  * @return
893  *      None.<BR>
894  *
895  * \par<b>Description</b><br>
896  * Sets TSIN[x] (where x corresponds to \a active pad number to be set) field of TSIN[x](x = 0-7) .<br>
897  * This is the TSIN[x] pin that is next or currently active in pad turn.<br>
898  * Call this API to set the active pad turn.
899  * \par
900  * Touch sense functionality should be initialized and configured before calling this API.\n
901  *
902  */
903 void XMC_LEDTS_SetActivePADNo(XMC_LEDTS_t *const ledts, XMC_LEDTS_NUMBER_TS_INPUT_t pad_num);
904 
905 /**
906  *
907  * @param ledts    Constant pointer to LEDTS module structure. Refer @ref XMC_LEDTS_GLOBAL_t data structure.<BR>
908  * @param column   Column number. Range refer @ref XMC_LEDTS_LED_COLUMN_t enum type.<BR>
909  * @param pattern  Pattern to be displayed. Range: 0H to FFH.<BR>
910  *
911  * @return
912  *      None.<BR>
913  *
914  * \par<b>Description</b><br>
915  * Sets LINE_x (where x corresponds to \a column number) field of LINEx(x = 0-1) register to \a pattern value.<br>
916  * This value is output on LINE_x when LED \a column x is active.<br> Call this API to set desired LED pattern.
917  * \par
918  * LED functionality should be initialized and configured before calling this API.\n
919  *
920  */
921 void XMC_LEDTS_SetLEDLinePattern(XMC_LEDTS_t *const ledts, XMC_LEDTS_LED_COLUMN_t column, const uint8_t pattern);
922 
923 /**
924  *
925  * @param ledts       Constant pointer to LEDTS module structure. Refer @ref XMC_LEDTS_GLOBAL_t data structure.<BR>
926  * @param column      Column number. Range refer @ref XMC_LEDTS_LED_COLUMN_t enum type.<BR>
927  * @param brightness  LED brightness level. Range: 0H(min brightness) to FFH(max brightness).<BR>
928  *
929  * @return
930  *      None.<BR>
931  *
932  * \par<b>Description</b><br>
933  * Programs CMP_LDx (where x denotes \a column number) field of LDCMPx(x = 0-1)register to the requested \a brightness
934  * level.
935  * \par
936  * The LDCMPx registers hold the COMPARE values for their respective LED columns. These values are used for LED
937  * brightness control. Call this API to control brightness level of the LED.
938  * \par
939  * LED functionality should be initialized and configured before calling this API.\n
940  *
941  */
942 void XMC_LEDTS_SetColumnBrightness(XMC_LEDTS_t *const ledts, XMC_LEDTS_LED_COLUMN_t column, const uint8_t brightness);
943 
944 /**
945  *
946  * @param ledts        Constant pointer to LEDTS module structure. Refer @ref XMC_LEDTS_GLOBAL_t data structure.<BR>
947  * @param common_size  Requested common oscillation window width. Range: FFH(min) to 00H.(max)<BR>
948  *
949  * @return
950  *      None.<BR>
951  *
952  * \par<b>Description</b><br>
953  * Programs the respective LDCMP1 register bit field CMP_LDA_TSCOM with \a common_size.
954  * \par
955  * Call this API to adjust the size of the common oscillation window to increase/decrease the number of recorded
956  * number of oscillation counts for all touch-sense inputs.\n
957  *
958  */
959 void XMC_LEDTS_SetCommonOscillationWindow(XMC_LEDTS_t *const ledts, const uint8_t common_size);
960 
961 /**
962  *
963  * @param ledts  Constant pointer to LEDTS module structure. Refer @ref XMC_LEDTS_GLOBAL_t data structure.<BR>
964  *
965  * @return
966  *      uint32_t Previous active LED column number. Range: 0 to 7.<BR>
967  *
968  * \par<b>Description</b><br>
969  * Returns active LED column number in previous time-slice by reading FNCOL bit field of FNCTL register.
970  * Call this API to figure out active column during previous time slice.\n
971  *
972  */
973 uint32_t XMC_LEDTS_ReadFNCOL(XMC_LEDTS_t *const ledts);
974 
975 /**
976  *
977  * @param ledts  Constant pointer to LEDTS module structure. Refer @ref XMC_LEDTS_GLOBAL_t data structure<BR>
978  * @param count  Number of LED columns to be enabled. Range: 0 to 7.<BR>
979  *
980  * @return
981  *      None.<BR>
982  *
983  * \par<b>Description</b><br>
984  * Sets \a count number of LED columns active by programming NR_LEDCOL bit field of FNCTL register.<BR>
985  * \par
986  * Call this API to set desired number of LED columns active.\n
987  *
988  * \par<b>Note</b><BR>
989  * NR_LEDCOL bit field can only be modified when LEDTS counter is not running, use XMC_LEDTS_StopCounter()
990  * to stop LEDTS module before calling this API.\n
991  *
992  * \par<b>Related API's</b><BR>
993  * XMC_LEDTS_StopCounter().\n
994  */
995 void XMC_LEDTS_SetNumOfLEDColumns(XMC_LEDTS_t *const ledts, uint8_t count);
996 
997 /**
998  *
999  * @param ledts  Constant pointer to LEDTS module structure. Refer @ref XMC_LEDTS_GLOBAL_t data structure.<BR>
1000  *
1001  * @return
1002  *      uint16_t Shadow touch sense counter value. Range: 0H to FFFFH.<BR>
1003  *
1004  * \par<b>Description</b><br>
1005  * Returns latched touch sense counter value by reading the TSCTRVALR field of TSVAL register.<BR>
1006  * \par
1007  * This API is typically called in time frame(TF) event handler to get oscillation count of the touch-sense input
1008  * active in previous time frame.\n
1009  *
1010  * \par<b>Note</b><BR>
1011  * This is the latched value of the TS-counter(on every extended time frame event).\n
1012  *
1013  * \par<b>Related API's</b><BR>
1014  * XMC_LEDTS_ReadInterruptFlag().\n
1015  */
1016 uint16_t XMC_LEDTS_ReadTSVAL(XMC_LEDTS_t *const ledts);
1017 
1018 /**
1019  *
1020  * @param ledts     Constant pointer to LEDTS module structure. Refer @ref XMC_LEDTS_GLOBAL_t data structure.<BR>
1021  * @param touchpad  Touch-sense input pad number. Range refer @ref XMC_LEDTS_NUMBER_TS_INPUT_t enum type.<BR>
1022  * @param size      Requested oscillation window width. Range: 0H(max) to FFH(min).<BR>
1023  *
1024  * @return
1025  *      None.<BR>
1026  *
1027  * \par<b>Description</b><br>
1028  * Sets the size of \a touchpad touch sense oscillation window to \a size.
1029  * \par
1030  * This API programs the respective CMP_TSx(where x is \a touchpad number) bit fields of TSCMPx(x = 0-1) register.
1031  * \a size value determines the size of the pad oscillation window for each pad input lines during their pad turn.
1032  * \par
1033  * Call this API to increase/decrease recorded number of oscillation counts for the requested touch-sense input.\n
1034  *
1035  */
1036 void XMC_LEDTS_SetOscillationWindow(XMC_LEDTS_t *const ledts, XMC_LEDTS_NUMBER_TS_INPUT_t touchpad, const uint8_t size);
1037 
1038 #ifdef __cplusplus
1039 }
1040 #endif
1041 
1042 /**
1043  * @}
1044  */
1045 
1046 /**
1047  * @}
1048  */
1049 
1050 #endif /* LEDTS0 */
1051 
1052 #endif /* XMC_LEDTS_H */
1053