1 /**
2 * @file xmc_eru.h
3 * @date 2016-03-10
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 <br>
41 * - Documentation updates <br>
42 *
43 * 2015-06-20:
44 * - Removed version macros and declaration of GetDriverVersion API <br>
45 *
46 * 2015-10-07:
47 * - Doc update for XMC_ERU_ETL_CONFIG_t field <br>
48 *
49 * 2016-03-10:
50 * - XMC_ERU_ETL_GetEdgeDetection() API is added to get the configured edge for event generation. <br>
51 *
52 * @endcond
53 */
54
55 #ifndef XMC_ERU_H
56 #define XMC_ERU_H
57
58 /*********************************************************************************************************************
59 * HEADER FILES
60 ********************************************************************************************************************/
61
62 #include "xmc_common.h"
63
64 /**
65 * @addtogroup XMClib XMC Peripheral Library
66 * @{
67 */
68
69 /**
70 * @addtogroup ERU
71 * @brief Event Request Unit (ERU) driver for the XMC microcontroller family.
72 *
73 * The Event Request Unit (ERU) is a versatile multiple input event detection and processing unit.
74 * The ERU module can be used to expand the P-to-P connections of the device: ports-to-peripherals,
75 * peripherals-to-peripherals and ports-to-ports. It also offers configurable logic, that allows the generation of
76 * triggers, pattern detection and real-time signal monitoring.
77 *
78 * @image html "eru_overview.png"
79 *
80 * The driver is divided into two sections:
81 * \par Event trigger logic (ERU_ETL):
82 * This section of the LLD provides the configuration structure XMC_ERU_ETL_CONFIG_t and the initialization function
83 * XMC_ERU_ETL_Init().\n
84 * It can be used to:
85 * -# Select one out of two inputs (A and B). For each of these two inputs, a vector of 4 possible signals is available.
86 * (XMC_ERU_ETL_SetSource())
87 * -# Logically combine the two input signals to a common trigger. (XMC_ERU_ETL_SetSource())
88 * -# Define the transition (edge selection, or by software) that leads to a trigger event and can also store this status.
89 * (XMC_ERU_ETL_SetEdgeDetection() and XMC_ERU_ETL_SetStatusFlag())
90 * -# Distribute the events and status flags to the output channels. (XMC_ERU_ETL_EnableOutputTrigger())
91 *
92 * \par Output gating unit (ERU_OGU):
93 * This section of the LLD provides the provides the configuration structure XMC_ERU_OGU_CONFIG_t and the initialization
94 * function XMC_ERU_ETL_OGU_Init().
95 * It can be used to:
96 * -# Combine the trigger events and status information and gates the output depending on a gating signal.
97 * (XMC_ERU_OGU_EnablePatternDetection(), XMC_ERU_OGU_DisablePeripheralTrigger(), XMC_ERU_OGU_SetServiceRequestMode())
98 * @{
99 */
100
101 /*********************************************************************************************************************
102 * MACROS
103 ********************************************************************************************************************/
104
105 #if defined(ERU0)
106 #define XMC_ERU0 ((XMC_ERU_t *) ERU0_BASE) /**< ERU module 0 */
107 #endif
108
109 #if defined(ERU1)
110 #define XMC_ERU1 ((XMC_ERU_t *) ERU1_BASE) /**< ERU module 1, only available in XMC4 family */
111 #endif
112
113 #if UC_FAMILY == XMC1
114 #include "xmc1_eru_map.h"
115 #endif
116
117 #if UC_FAMILY == XMC4
118 #include "xmc4_eru_map.h"
119 #endif
120
121 #if defined(XMC_ERU0) && defined(XMC_ERU1)
122 #define XMC_ERU_CHECK_MODULE_PTR(PTR) (((PTR)== XMC_ERU0) | ((PTR)== XMC_ERU1))
123 #elif defined(XMC_ERU0)
124 #define XMC_ERU_CHECK_MODULE_PTR(PTR) (((PTR)== XMC_ERU0))
125 #elif defined(XMC_ERU1)
126 #define XMC_ERU_CHECK_MODULE_PTR(PTR) (((PTR)== XMC_ERU0))
127 #endif
128
129 /*********************************************************************************************************************
130 * ENUMS
131 ********************************************************************************************************************/
132
133 /**
134 * Defines input signal for path A of ERSx(Event request source, x = [0 to 3]) unit.
135 * @image html "eru_input_a.png" "ETLx Input A selection"
136 */
137 typedef enum XMC_ERU_ETL_INPUT_A
138 {
139 XMC_ERU_ETL_INPUT_A0 = 0x0U, /**< input A0 is selected */
140 XMC_ERU_ETL_INPUT_A1 = 0x1U, /**< input A1 is selected */
141 XMC_ERU_ETL_INPUT_A2 = 0x2U, /**< input A2 is selected */
142 XMC_ERU_ETL_INPUT_A3 = 0x3U /**< input A3 is selected */
143 } XMC_ERU_ETL_INPUT_A_t;
144
145 /**
146 * Defines input signal for path B of ERSx(Event request source, x = [0 to 3]) unit.
147 * @image html "eru_input_b.png" "ETLx Input B selection"
148 */
149 typedef enum XMC_ERU_ETL_INPUT_B
150 {
151 XMC_ERU_ETL_INPUT_B0 = 0x0U, /**< input B0 is selected */
152 XMC_ERU_ETL_INPUT_B1 = 0x1U, /**< input B1 is selected */
153 XMC_ERU_ETL_INPUT_B2 = 0x2U, /**< input B2 is selected */
154 XMC_ERU_ETL_INPUT_B3 = 0x3U /**< input B3 is selected */
155 } XMC_ERU_ETL_INPUT_B_t;
156
157 /**
158 * Defines input path combination along with polarity for event generation by ERSx(Event request source) unit to
159 * ETLx(Event trigger logic),x = [0 to 3] unit.
160 * @image html "eru_input_trigger.png" "ETLx input trigger signal generation"
161 */
162 typedef enum XMC_ERU_ETL_SOURCE
163 {
164 XMC_ERU_ETL_SOURCE_A = 0x0U, /**< select (A) path as a event source */
165 XMC_ERU_ETL_SOURCE_B = 0x1U, /**< select (B) path as a event source */
166 XMC_ERU_ETL_SOURCE_A_OR_B = 0x2U, /**< select (A <b>OR</b> B) path as a event source */
167 XMC_ERU_ETL_SOURCE_A_AND_B = 0x3U, /**< select (A <b>AND</b> B) path as a event source */
168 XMC_ERU_ETL_SOURCE_NOT_A = 0x4U, /**< select (inverted A) path as a event source */
169 XMC_ERU_ETL_SOURCE_NOT_A_OR_B = 0x6U, /**< select (inverted A <b>OR</b> B) path as a event source */
170 XMC_ERU_ETL_SOURCE_NOT_A_AND_B = 0x7U, /**< select (inverted A <b>AND</b> B) path as a event source */
171 XMC_ERU_ETL_SOURCE_NOT_B = 0x9U, /**< select (inverted B) path as a event source */
172 XMC_ERU_ETL_SOURCE_A_OR_NOT_B = 0xaU, /**< select (A <b>OR</b> inverted B) path as a event source */
173 XMC_ERU_ETL_SOURCE_A_AND_NOT_B = 0xbU, /**< select (A <b>AND</b> inverted B) path as a event source */
174 XMC_ERU_ETL_SOURCE_NOT_A_OR_NOT_B = 0xeU, /**< select (inverted A <b>OR</b> inverted B) path as a event
175 source */
176 XMC_ERU_ETL_SOURCE_NOT_A_AND_NOT_B = 0xfU /**< select (inverted A <b>AND</b> inverted B) path as a event
177 source */
178 } XMC_ERU_ETL_SOURCE_t;
179
180 /**
181 * Defines trigger edge for the event generation by ETLx (Event Trigger Logic, x = [0 to 3]) unit, by getting the signal
182 * from ERSx(Event request source, x = [0 to 3]) unit.
183 */
184 typedef enum XMC_ERU_ETL_EDGE_DETECTION
185 {
186 XMC_ERU_ETL_EDGE_DETECTION_DISABLED = 0U, /**< no event enabled */
187 XMC_ERU_ETL_EDGE_DETECTION_RISING = 1U, /**< detection of rising edge generates the event */
188 XMC_ERU_ETL_EDGE_DETECTION_FALLING = 2U, /**< detection of falling edge generates the event */
189 XMC_ERU_ETL_EDGE_DETECTION_BOTH = 3U /**< detection of either edges generates the event */
190 } XMC_ERU_ETL_EDGE_DETECTION_t;
191
192 /**
193 * Defines Output Channel of OGUy(Output gating unit y = [0 to 3]) to be mapped by the trigger pulse generated by
194 * ETLx(Event Trigger Logic, x = [0 to 3]) unit.
195 * @note Generation of output trigger pulse need to be enabled @ref XMC_ERU_OGU_PERIPHERAL_TRIGGER_t
196 * @image html "eru_connection_matrix.png" "ERU_ETL ERU_OGU Connection matrix"
197 */
198 typedef enum XMC_ERU_ETL_OUTPUT_TRIGGER_CHANNEL
199 {
200 XMC_ERU_ETL_OUTPUT_TRIGGER_CHANNEL0 = 0U, /**< Event from input ETLx triggers output OGU0 */
201 XMC_ERU_ETL_OUTPUT_TRIGGER_CHANNEL1 = 1U, /**< Event from input ETLx triggers output OGU1 */
202 XMC_ERU_ETL_OUTPUT_TRIGGER_CHANNEL2 = 2U, /**< Event from input ETLx triggers output OGU2 */
203 XMC_ERU_ETL_OUTPUT_TRIGGER_CHANNEL3 = 3U, /**< Event from input ETLx triggers output OGU3 */
204 } XMC_ERU_ETL_OUTPUT_TRIGGER_CHANNEL_t;
205
206 /**
207 * Defines generation of the trigger pulse by ETLx(Event Trigger Logic, x = [0 to 3]) unit.
208 * Use type XMC_ERU_ETL_OUTPUT_TRIGGER_t for this enum.
209 */
210 typedef enum XMC_ERU_ETL_OUTPUT_TRIGGER
211 {
212 XMC_ERU_ETL_OUTPUT_TRIGGER_DISABLED = 0U, /**< trigger pulse generation disabled */
213 XMC_ERU_ETL_OUTPUT_TRIGGER_ENABLED = 1U /**< trigger pulse generation enabled */
214 } XMC_ERU_ETL_OUTPUT_TRIGGER_t;
215
216 /**
217 * Defines status flag reset mode generated by ETLx(Event Trigger Logic, x = [0 to 3]) unit.
218 * Use type XMC_ERU_ETL_STATUS_FLAG_MODE_t for this enum.
219 */
220 typedef enum XMC_ERU_ETL_STATUS_FLAG_MODE
221 {
222 XMC_ERU_ETL_STATUS_FLAG_MODE_SWCTRL = 0U, /**< Status flag is in sticky mode. Retain the same state until
223 cleared by software. In case of pattern match this mode
224 is used. */
225 XMC_ERU_ETL_STATUS_FLAG_MODE_HWCTRL = 1U /**< Status flag is in non-sticky mode. Automatically cleared by
226 the opposite edge detection.\n
227 eg. if positive edge is selected as trigger event, for the
228 negative edge event the status flag is cleared. */
229 } XMC_ERU_ETL_STATUS_FLAG_MODE_t;
230
231 /**
232 * Defines pattern detection feature to be enabled or not in OGUy(Output gating unit, y = [0 to 3]).
233 *
234 */
235 typedef enum XMC_ERU_OGU_PATTERN_DETECTION
236 {
237 XMC_ERU_OGU_PATTERN_DETECTION_DISABLED = 0U, /**< Pattern match is disabled */
238 XMC_ERU_OGU_PATTERN_DETECTION_ENABLED = 1U /**< Pattern match is enabled, the selected status flags of
239 ETLx(Event Trigger Logic, x = [0 to 3]) unit, are
240 used in pattern detection. */
241 } XMC_ERU_OGU_PATTERN_DETECTION_t;
242
243 /**
244 * Defines the inputs for Pattern detection. The configured status flag signal from the ETLx(Event Trigger Logic,
245 * x = [0 to 3]) unit indicates the pattern to be detected.
246 */
247 typedef enum XMC_ERU_OGU_PATTERN_DETECTION_INPUT
248 {
249 XMC_ERU_OGU_PATTERN_DETECTION_INPUT0 = 1U, /**< Status flag ETL0, participating in pattern match */
250 XMC_ERU_OGU_PATTERN_DETECTION_INPUT1 = 2U, /**< Status flag ETL1, participating in pattern match */
251 XMC_ERU_OGU_PATTERN_DETECTION_INPUT2 = 4U, /**< Status flag ETL0, participating in pattern match */
252 XMC_ERU_OGU_PATTERN_DETECTION_INPUT3 = 8U /**< Status flag ETL0, participating in pattern match */
253 } XMC_ERU_OGU_PATTERN_DETECTION_INPUT_t;
254
255 /**
256 * Defines peripheral trigger signal for event generation. Based on the selected peripheral for event generation,
257 * the trigger signal is mapped.
258 */
259 typedef enum XMC_ERU_OGU_PERIPHERAL_TRIGGER
260 {
261 XMC_ERU_OGU_PERIPHERAL_TRIGGER1 = 1U, /**< OGUy1 signal is mapped for event generation */
262 XMC_ERU_OGU_PERIPHERAL_TRIGGER2 = 2U, /**< OGUy2 signal is mapped for event generation */
263 XMC_ERU_OGU_PERIPHERAL_TRIGGER3 = 3U /**< OGUy3 signal is mapped for event generation */
264 } XMC_ERU_OGU_PERIPHERAL_TRIGGER_t;
265
266 /**
267 * Defines the gating scheme for service request generation. In later stage of the OGUy(Output gating unit,
268 * y = [0 to 3]) based on the gating scheme selected ERU_GOUTy(gated output signal) output is defined.
269 * @image html "interrupt_gating_signal.png" "Interrupt gating signal"
270 */
271 typedef enum XMC_ERU_OGU_SERVICE_REQUEST
272 {
273 XMC_ERU_OGU_SERVICE_REQUEST_DISABLED = 0U, /**< Service request blocked, ERUx_GOUTy = 0 */
274 XMC_ERU_OGU_SERVICE_REQUEST_ON_TRIGGER = 1U, /**< Service request generated enabled, ERUx_GOUTy = 1 */
275 XMC_ERU_OGU_SERVICE_REQUEST_ON_TRIGGER_AND_PATTERN_MATCH = 2U, /**< Service request generated on trigger
276 event and input pattern match,
277 ERUx_GOUTy = ~pattern matching result*/
278 XMC_ERU_OGU_SERVICE_REQUEST_ON_TRIGGER_AND_PATTERN_MISMATCH = 3U/**< Service request generated on trigger
279 event and input pattern mismatch,
280 ERUx_GOUTy = pattern matching result*/
281 } XMC_ERU_OGU_SERVICE_REQUEST_t;
282
283 /*********************************************************************************************************************
284 * DATA STRUCTURES
285 ********************************************************************************************************************/
286 /*Anonymous structure/union guard start*/
287 #if defined(__CC_ARM)
288 #pragma push
289 #pragma anon_unions
290 #elif defined(__TASKING__)
291 #pragma warning 586
292 #endif
293
294 /**
295 * ERU module
296 */
297 typedef struct {
298 union {
299 __IO uint32_t EXISEL;
300
301 struct {
302 __IO uint32_t EXS0A : 2;
303 __IO uint32_t EXS0B : 2;
304 __IO uint32_t EXS1A : 2;
305 __IO uint32_t EXS1B : 2;
306 __IO uint32_t EXS2A : 2;
307 __IO uint32_t EXS2B : 2;
308 __IO uint32_t EXS3A : 2;
309 __IO uint32_t EXS3B : 2;
310 } EXISEL_b;
311 };
312 __I uint32_t RESERVED0[3];
313
314 union {
315 __IO uint32_t EXICON[4];
316
317 struct {
318 __IO uint32_t PE : 1;
319 __IO uint32_t LD : 1;
320 __IO uint32_t ED : 2;
321 __IO uint32_t OCS : 3;
322 __IO uint32_t FL : 1;
323 __IO uint32_t SS : 4;
324 __I uint32_t RESERVED1 : 20;
325 } EXICON_b[4];
326 };
327
328 union {
329 __IO uint32_t EXOCON[4];
330
331 struct {
332 __IO uint32_t ISS : 2;
333 __IO uint32_t GEEN : 1;
334 __I uint32_t PDR : 1;
335 __IO uint32_t GP : 2;
336 uint32_t : 6;
337 __IO uint32_t IPEN : 4;
338 __I uint32_t RESERVED2 : 16;
339 } EXOCON_b[4];
340 };
341 } XMC_ERU_t;
342
343 /**
344 * \if XMC4
345 * Structure for initializing ERUx_ETLy (x = [0..1], y = [0..4]) module.
346 * \endif
347 * \if XMC1
348 * Structure for initializing ERUx_ETLy (x = [0], y = [0..4]) module.
349 * \endif
350 */
351 typedef struct XMC_ERU_ETL_CONFIG
352 {
353 union
354 {
355 uint32_t input; /**< While configuring the bit fields, the values have to be shifted according to the position */
356 struct
357 {
358 uint32_t input_a: 2; /**< Configures input A. Refer @ref XMC_ERU_ETL_INPUT_A_t for valid values */
359 uint32_t input_b: 2; /**< Configures input B. Refer @ref XMC_ERU_ETL_INPUT_B_t for valid values */
360 uint32_t : 28;
361 };
362 };
363
364 union
365 {
366 uint32_t raw;
367 struct
368 {
369 uint32_t enable_output_trigger: 1; /**< Enables the generation of trigger pulse(PE), for the configured edge
370 detection. This accepts boolean values as input. */
371 uint32_t status_flag_mode: 1; /**< Enables the status flag auto clear(LD), for the opposite edge of the
372 configured event edge. This accepts boolean values as input. */
373 uint32_t edge_detection: 2; /**< Configure the event trigger edge(FE, RE).
374 Refer @ref XMC_ERU_ETL_EDGE_DETECTION_t for valid values. */
375 uint32_t output_trigger_channel: 3; /**< Output channel select(OCS) for ETLx output trigger pulse.
376 Refer @ref XMC_ERU_ETL_OUTPUT_TRIGGER_CHANNEL_t for valid values. */
377 uint32_t : 1;
378 uint32_t source: 4; /**< Input path combination along with polarity for event generation.
379 Refer @ref XMC_ERU_ETL_SOURCE_t for valid values. */
380 uint32_t : 20;
381 };
382 };
383 } XMC_ERU_ETL_CONFIG_t;
384
385 /**
386 * \if XMC4
387 * Structure for initializing ERUx_OGUy (x = [0..1], y = [0..4]) module.
388 * \endif
389 * \if XMC1
390 * Structure for initializing ERUx_OGUy (x = [0], y = [0..4]) module.
391 * \endif
392 */
393 typedef union XMC_ERU_OGU_CONFIG
394 {
395 uint32_t raw;
396
397 struct
398 {
399 uint32_t peripheral_trigger: 2; /**< peripheral trigger(ISS) input selection.
400 Refer @ref XMC_ERU_OGU_PERIPHERAL_TRIGGER_t for valid values. */
401 uint32_t enable_pattern_detection: 1; /**< Enable generation of(GEEN) event for pattern detection result change.
402 This accepts boolean values as input. */
403 uint32_t : 1;
404 uint32_t service_request: 2; /**< Gating(GP) on service request generation for pattern detection result.
405 Refer @ref XMC_ERU_OGU_SERVICE_REQUEST_t for valid values. */
406 uint32_t : 6;
407 uint32_t pattern_detection_input: 4; /**< Enable input for the pattern detection(IPENx, x = [0 to 3]).
408 Refer @ref XMC_ERU_OGU_PATTERN_DETECTION_INPUT_t for valid values.
409 <b>OR</b> combination of the enum items given as input */
410 uint32_t : 16;
411 };
412 } XMC_ERU_OGU_CONFIG_t;
413
414 /*Anonymous structure/union guard end */
415 #if defined(__CC_ARM)
416 #pragma pop
417 #elif defined(__TASKING__)
418 #pragma warning restore
419 #endif
420 /*********************************************************************************************************************
421 * API PROTOTYPES
422 ********************************************************************************************************************/
423
424 #ifdef __cplusplus
425 extern "C" {
426 #endif
427
428 /**
429 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address
430 *
431 * @return None
432 *
433 * \par<b>Description:</b><br>
434 * \if XMC4
435 * If ERU1 module is selected, it enables clock and releases reset.<br>
436 * \endif
437 * \if XMC1
438 * Abstract API, not mandatory to call. <br>
439 * \endif
440 * \par
441 * This API is called by XMC_ERU_ETL_Init() or XMC_ERU_OGU_Init() and therefore no need to call it explicitly during
442 * initialization sequence. Call this API to enable ERU1 module once again if the module is disabled by calling
443 * XMC_ERU_Disable(). For ERU0 module clock gating and reset features are not available.
444 *
445 * \par<b>Note:</b><br>
446 * \if XMC4
447 * 1. Required to configure ERU1 module again after calling XMC_ERU_Disable(). Since the all the registers are
448 * reset with default values.
449 * \endif
450 * \par<b>Related APIs:</b><BR>
451 * XMC_ERU_ETL_Init(), XMC_ERU_OGU_Init(), XMC_ERU_Disable().
452 */
453 void XMC_ERU_Enable(XMC_ERU_t *const eru);
454
455 /**
456 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address
457 *
458 * @return None
459 *
460 * \par<b>Description:</b><br>
461 * \if XMC4
462 * Disables clock and releases reset for ERU1 module.<br>
463 * \endif
464 * \if XMC1
465 * Abstract API, not mandatory to call. <br>
466 * \endif
467 *
468 * \par<b>Note:</b><br>
469 * \if XMC4
470 * 1. Required to configure ERU1 module again after calling XMC_ERU_ETL_Init() or XMC_ERU_OGU_Init(). Since the all the
471 * registers are reset with default values.
472 * \endif
473 * \par<b>Related APIs:</b><BR>
474 * XMC_ERU_Enable()
475 */
476 void XMC_ERU_Disable(XMC_ERU_t *const eru);
477
478 /* ERU_ETL APIs */
479
480 /**
481 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address
482 * @param channel ERU_ETLx(Event trigger logic unit) channel
483 * Range : [0 to 3]
484 * @param config pointer to a constant ERU_ETLx configuration data structure.
485 * Refer data structure XMC_ERU_ETL_CONFIG_t for detail.
486 *
487 * @return None
488 *
489 * <b>Description:</b><br>
490 * Initializes the selected ERU_ETLx \a channel with the \a config structure.<br>
491 *
492 * Invokes XMC_ERU_Enable() to enable \a eru module clock. Then configures
493 * <ul>
494 * <li>Input signal for path A and Path B,</li>
495 * <li>Trigger pulse generation,</li>
496 * <li>status flag clear mode,</li>
497 * <li>Event Trigger edge,</li>
498 * <li>Output Channel of OGUy(Output gating unit y = [0 to 3]) to be mapped by the trigger pulse,</li>
499 * <li>input path combination along with polarity for event generation</li>
500 * </ul>.
501 */
502 void XMC_ERU_ETL_Init(XMC_ERU_t *const eru, const uint8_t channel, const XMC_ERU_ETL_CONFIG_t *const config);
503
504 /**
505 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address.
506 * @param channel ERU_ETLx(Event trigger logic unit) channel.
507 * Range : [0 to 3]
508 * @param input_a input signal for path A of ERSx(Event request source, x = [0 to 3]) unit.\n
509 * Refer XMC_ERU_ETL_INPUT_A_t for valid value or xmc1_eru_map.h/xmc4_eru_map.h file where the mapping of
510 * the input is done based on selected signal.\n
511 * e.g: ERU0_ETL3_INPUTA_P2_7.
512 * @param input_b input signal for path B of ERSx(Event request source, x = [0 to 3]) unit.\n
513 * Refer XMC_ERU_ETL_INPUT_B_t for valid value or xmc1_eru_map.h/xmc4_eru_map.h file where the mapping of
514 * the input is done based on selected signal.\n
515 * e.g: ERU0_ETL0_INPUTB_P2_0.
516 *
517 * @return None
518 *
519 * \par<b>Description:</b><br>
520 * Configures the event source for path A and path B in with selected \a input_a and \a input_b respectively.<br>
521 * \par
522 * These values are set during initialization in XMC_ERU_ETL_Init(). Call this to change the input, as needed later in
523 * the program. According to the ports/peripheral selected, the event source has to be changed.
524 */
525 void XMC_ERU_ETL_SetInput(XMC_ERU_t *const eru,
526 const uint8_t channel,
527 const XMC_ERU_ETL_INPUT_A_t input_a,
528 const XMC_ERU_ETL_INPUT_B_t input_b);
529
530 /**
531 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address.
532 * @param channel ERU_ETLx(Event trigger logic unit) channel.
533 * Range : [0 to 3]
534 * @param source input path combination along with polarity for event generation by ERSx(Event request source) unit.
535 * Refer @ref XMC_ERU_ETL_SOURCE_t enum for valid input values.
536 *
537 * @return None
538 *
539 * \par<b>Description:</b><br>
540 * Select input path combination along with polarity for event generation by setting (SS, NA, NB) bits in
541 * ERSx(Event request source) unit <br>
542 * \par
543 * The signal ERSxO is generated from the selection and this is connected to ETLx(Event trigger logic,
544 * x = [0 to 3]) for further action. These values are set during initialization in XMC_ERU_ETL_Init(). Call this to
545 * change the source, as needed later in the program.
546 */
547 void XMC_ERU_ETL_SetSource(XMC_ERU_t *const eru,
548 const uint8_t channel,
549 const XMC_ERU_ETL_SOURCE_t source);
550
551 /**
552 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address.
553 * @param channel ERU_ETLx(Event trigger logic unit) channel.
554 * Range : [0 to 3]
555 * @param edge_detection event trigger edge.
556 * Refer @ref XMC_ERU_ETL_EDGE_DETECTION_t enum for valid values.
557 *
558 * @return None
559 *
560 * \par<b>Description:</b><br>
561 * Configure event trigger edge/s by setting (RE, FE) bits of EXICONx(x = [0 to 3]) register.<br>
562 * \par
563 * Rising edge, falling edge or either edges can be selected to generate the event.These values are set during
564 * initialization in XMC_ERU_ETL_Init(). Call this to change the trigger edge, as needed later in the program.
565 */
566 void XMC_ERU_ETL_SetEdgeDetection(XMC_ERU_t *const eru,
567 const uint8_t channel,
568 const XMC_ERU_ETL_EDGE_DETECTION_t edge_detection);
569
570 /**
571 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address.
572 * @param channel ERU_ETLx(Event trigger logic unit) channel.
573 * Range : [0 to 3]
574 *
575 * @return XMC_ERU_ETL_EDGE_DETECTION_t indicate which egde/s is configured for event generation
576 *
577 * \par<b>Description:</b><br>
578 * Return event trigger edge/s by reading (RE, FE) bits of EXICONx(x = [0 to 3]) register.<br>
579 * \par
580 * Rising edge, falling edge or either edges can be selected to generate the event.
581 * Call this to get the configured trigger edge. */
582 XMC_ERU_ETL_EDGE_DETECTION_t XMC_ERU_ETL_GetEdgeDetection(XMC_ERU_t *const eru,
583 const uint8_t channel);
584 /**
585 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address.
586 * @param channel ERU_ETLx(Event trigger logic unit) channel.
587 * Range : [0 to 3]
588 *
589 * @return None
590 *
591 * \par<b>Description:</b><br>
592 * Set the status flag bit(FL) in EXICONx(x = [0 to 3]).<br>
593 * \par
594 * The status flag indicates that the configured event has occurred. This status flag is used in Pattern match detection
595 * by OGUy(Output gating unit, y = [0 to 3]).
596 * \par
597 * \par<b>Related APIs:</b><BR>
598 * XMC_ERU_ETL_ClearStatusFlag(), XMC_ERU_ETL_GetStatusFlag()
599 */
XMC_ERU_ETL_SetStatusFlag(XMC_ERU_t * const eru,const uint8_t channel)600 __STATIC_INLINE void XMC_ERU_ETL_SetStatusFlag(XMC_ERU_t *const eru, const uint8_t channel)
601 {
602 XMC_ASSERT("XMC_ERU_ETL_SetStatusFlag:Invalid Module Pointer", XMC_ERU_CHECK_MODULE_PTR(eru));
603 XMC_ASSERT("XMC_ERU_ETL_SetStatusFlag:Invalid Channel Number", (channel < 4U));
604
605 eru->EXICON_b[channel].FL = true;
606 }
607
608 /**
609 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address.
610 * @param channel ERU_ETLx(Event trigger logic unit) channel.
611 * Range : [0 to 3]
612 *
613 * @return None
614 *
615 * \par<b>Description:</b><br>
616 * Set the status flag bit(FL) in EXICONx(x = [0 to 3]).<br>
617 * \par
618 * If auto clear of the status flag is not enabled by detection of the opposite edge of the event edge, this API clears
619 * the Flag. SO that next event is considered as new event.
620 * \par<b>Related APIs:</b><BR>
621 * XMC_ERU_ETL_SetStatusFlag(), XMC_ERU_ETL_GetStatusFlag()
622 */
XMC_ERU_ETL_ClearStatusFlag(XMC_ERU_t * const eru,const uint8_t channel)623 __STATIC_INLINE void XMC_ERU_ETL_ClearStatusFlag(XMC_ERU_t *const eru, const uint8_t channel)
624 {
625 XMC_ASSERT("XMC_ERU_ETL_ClearStatusFlag:Invalid Module Pointer", XMC_ERU_CHECK_MODULE_PTR(eru));
626 XMC_ASSERT("XMC_ERU_ETL_ClearStatusFlag:Invalid Channel Number", (channel < 4U));
627
628 eru->EXICON_b[channel].FL = false;
629 }
630
631 /**
632 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address.
633 * @param channel ERU_ETLx(Event trigger logic unit) channel.
634 * Range : [0 to 3].
635 *
636 * @return uint32_t Current state of the status flag bit(FL). Result is in 32-bit format.
637 *
638 * \par<b>Description:</b><br>
639 * Returns status flag state of \a channel.
640 * \par
641 * The function can typically be used to clear the status flag using software, when auto clear is not enabled.
642 *
643 * \par<b>Related APIs:</b><BR>
644 * XMC_ERU_ETL_SetStatusFlag(), XMC_ERU_ETL_ClearStatusFlag()
645 */
XMC_ERU_ETL_GetStatusFlag(XMC_ERU_t * const eru,const uint8_t channel)646 __STATIC_INLINE uint32_t XMC_ERU_ETL_GetStatusFlag(XMC_ERU_t *const eru, const uint8_t channel)
647 {
648 XMC_ASSERT("XMC_ERU_ETL_GetStatusFlag:Invalid Module Pointer", XMC_ERU_CHECK_MODULE_PTR(eru));
649 XMC_ASSERT("XMC_ERU_ETL_GetStatusFlag:Invalid Channel Number", (channel < 4U));
650
651 return (uint32_t)eru->EXICON_b[channel].FL;
652 }
653
654 /**
655 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address.
656 * @param channel ERU_ETLx(Event trigger logic unit) channel.
657 * Range : [0 to 3].
658 * @param mode Set whether status flag has to be cleared by software or hardware.
659 * Refer @ref XMC_ERU_ETL_STATUS_FLAG_MODE_t for valid value.
660 *
661 * @return None
662 *
663 * \par<b>Description:</b><br>
664 * Set the mode for status flag mode by setting (LD) bit in EXICONx(x = \a channel) register.<br>
665 * \par
666 * If SWCTRL is selected, status flag has to be cleared by software. This is typically used for pattern match detection.
667 * If HWCTRL is selected, status flag is cleared by hardware. If Positive edge is selected as event edge, for negative
668 * edge status flag is cleared and vice versa.This is typically used for continuous event detection.These values are set
669 * during initialization in XMC_ERU_ETL_Init(). Call this to change the trigger edge, as needed later in the program.
670 *
671 * \par<b>Related APIs:</b><BR>
672 * XMC_ERU_ETL_ClearStatusFlag(), XMC_ERU_ETL_GetStatusFlag()
673 */
674 void XMC_ERU_ETL_SetStatusFlagMode(XMC_ERU_t *const eru,
675 const uint8_t channel,
676 const XMC_ERU_ETL_STATUS_FLAG_MODE_t mode);
677
678 /**
679 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address.
680 * @param channel ERU_ETLx(Event trigger logic unit) channel.
681 * Range : [0 to 3].
682 * @param trigger Output Channel of OGUy(Output gating unit y = [0 to 3]) to be mapped by the trigger pulse
683 * Refer @ref XMC_ERU_ETL_OUTPUT_TRIGGER_CHANNEL_t for valid value.
684 *
685 * @return None
686 *
687 * \par<b>Description:</b><br>
688 * Configure which Channel of OGUy(Output gating unit y = [0 to 3]) to be mapped by the trigger pulse generated by
689 * ETLx(Event Trigger Logic, x = \a channel) by setting (OCS and PE) bit fields.
690 * \par
691 * The trigger pulse is generated for one clock pulse along with the flag status update. This is typically used to
692 * trigger the ISR for the external events. The configured OGUy(Output gating unit y = [0 to 3]), generates the event
693 * based on the trigger pulse.If output trigger pulse generation is disabled by XMC_ERU_ETL_DisableOutputTrigger(),
694 * XMC_ERU_ETL_EnableOutputTrigger() can called to reconfigure. These values are set during initialization in
695 * XMC_ERU_ETL_Init(). Call this to change the trigger edge, as needed later in the program.
696 *
697 * \par<b>Related APIs:</b><BR>
698 * XMC_ERU_ETL_DisableOutputTrigger()
699 */
700 void XMC_ERU_ETL_EnableOutputTrigger(XMC_ERU_t *const eru,
701 const uint8_t channel,
702 const XMC_ERU_ETL_OUTPUT_TRIGGER_CHANNEL_t trigger);
703
704 /**
705 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address.
706 * @param channel ERU_ETLx(Event trigger logic unit) channel.
707 * Range : [0 to 3].
708 *
709 * @return None
710 *
711 * \par<b>Description:</b><br>
712 * Disables the trigger pulse generation by clearing the (PE) of the EXICONx(x = \a channel).
713 * \par
714 * Typically this can used when only pattern match is being used for event generation.
715 *
716 * \par<b>Related APIs:</b><BR>
717 * XMC_ERU_ETL_EnableOutputTrigger()
718 */
719 void XMC_ERU_ETL_DisableOutputTrigger(XMC_ERU_t *const eru, const uint8_t channel);
720
721 /* ERU_OGU APIs */
722
723 /**
724 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address
725 * @param channel ERU_OGUy(Output gating unit) channel
726 * Range : [0 to 3]
727 * @param config pointer to constant ERU_OGUy configuration data structure.
728 * Refer data structure XMC_ERU_OGU_CONFIG_t for detail.
729 *
730 * @return None
731 *
732 * <b>Description:</b><br>
733 * Initializes the selected ERU_OGUy \a channel with the \a config structure.<br>
734 *
735 * Invokes XMC_ERU_Enable() to enable \a eru module clock. Then configures
736 * <ul>
737 * <li>Pattern detection,</li>
738 * <li>Peripheral trigger input,</li>
739 * <li>Gating for service request generation</li>
740 * </ul>.
741 */
742 void XMC_ERU_OGU_Init(XMC_ERU_t *const eru,
743 const uint8_t channel,
744 const XMC_ERU_OGU_CONFIG_t *const config);
745
746 /**
747 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address
748 * @param channel ERU_OGUy(Output gating unit) channel
749 * Range : [0 to 3]
750 * @param input ERU_ETLx(x = [0 to 3]), for pattern match detection.
751 * Refer @ref XMC_ERU_OGU_PATTERN_DETECTION_INPUT_t for valid values. Logical <b>OR</b> combination of the
752 * enum items can be passed as the input.
753 *
754 * @return None
755 *
756 * \par<b>Description:</b><br>
757 * Configures ERU_ETLx(x = [0 to 3]) for pattern match detection by setting IPENx(x = [0 to 3]) and GEEN bits.
758 * \par
759 * These bits are dedicated to each channel of the ERU_ETLx(x = [0 to 3]). These values are set during initialization in
760 * XMC_ERU_OGU_Init(). Call this to change the pattern, as needed later in the program.
761 *
762 * \par<b>Related APIs:</b><BR>
763 * XMC_ERU_OGU_DisablePatternDetection(), XMC_ERU_OGU_GetPatternDetectionStatus()
764 */
765 void XMC_ERU_OGU_EnablePatternDetection(XMC_ERU_t *const eru,
766 const uint8_t channel,
767 const XMC_ERU_OGU_PATTERN_DETECTION_INPUT_t input);
768
769 /**
770 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address
771 * @param channel ERU_OGUy(Output gating unit) channel
772 * Range : [0 to 3]
773 *
774 * @return None
775 *
776 * \par<b>Description:</b><br>
777 * Disable the pattern detection by clearing (GEEN) bit.
778 * \par
779 * Typically XMC_ERU_OGU_DisablePatternDetection is used when events has to be generated peripheral triggers.
780 *
781 * \par<b>Related APIs:</b><BR>
782 * XMC_ERU_OGU_EnablePatternDetection(), XMC_ERU_OGU_GetPatternDetectionStatus()
783 */
784 void XMC_ERU_OGU_DisablePatternDetection(XMC_ERU_t *const eru, const uint8_t channel);
785
786 /**
787 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address
788 * @param channel ERU_OGUy(Output gating unit) channel
789 * Range : [0 to 3]
790 *
791 * @return uint32_t returns the pattern match result. Result is in 32-bit format.
792 *
793 * \par<b>Description:</b><br>
794 * This API returns the pattern match result by reading (PDR) bit.
795 * \par
796 * \par<b>Related APIs:</b><BR>
797 * XMC_ERU_OGU_EnablePatternDetection(), XMC_ERU_OGU_DisablePatternDetection()
798 */
XMC_ERU_OGU_GetPatternDetectionStatus(XMC_ERU_t * const eru,const uint8_t channel)799 __STATIC_INLINE uint32_t XMC_ERU_OGU_GetPatternDetectionStatus(XMC_ERU_t *const eru,
800 const uint8_t channel)
801 {
802 XMC_ASSERT("XMC_ERU_OGU_GetPatternDetectionStatus:Invalid Module Pointer", XMC_ERU_CHECK_MODULE_PTR(eru));
803 XMC_ASSERT("XMC_ERU_OGU_GetPatternDetectionStatus:Invalid Channel Number", (channel < 4U));
804
805 return (uint32_t)eru->EXOCON_b[channel].PDR;
806 }
807
808 /**
809 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address
810 * @param channel ERU_OGUy(Output gating unit) channel
811 * Range : [0 to 3]
812 * @param peripheral_trigger which peripheral trigger signal is used for event generation.
813 * Refer @ref XMC_ERU_OGU_PERIPHERAL_TRIGGER_t for the valid values, or
814 xmc1_eru_map.h/xmc4_eru_map.h file where the mapping of the peripheral input is done based
815 on input. e.g: ERU0_OGU0_PERIPHERAL_TRIGGER_CCU40_SR0.
816 *
817 * @return None
818 *
819 * \par<b>Description:</b><br>
820 * Configures peripheral trigger input, by setting (ISS) bit.
821 * \par
822 * Based on the peripheral the input signal has to be selected. These values are set during initialization in
823 * XMC_ERU_OGU_Init(). Call this to change the input, as needed later in the program.
824 *
825 * \par<b>Related APIs:</b><BR>
826 * XMC_ERU_OGU_DisablePeripheralTrigger()
827 */
828 void XMC_ERU_OGU_EnablePeripheralTrigger(XMC_ERU_t *const eru,
829 const uint8_t channel,
830 const XMC_ERU_OGU_PERIPHERAL_TRIGGER_t peripheral_trigger);
831
832 /**
833 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address
834 * @param channel ERU_OGUy(Output gating unit) channel
835 * Range : [0 to 3]
836 *
837 * @return None
838 *
839 * \par<b>Description:</b><br>
840 * Disables event generation based on peripheral trigger by clearing (ISS) bit.
841 * \par
842 * This is typically used when peripheral trigger is no longer need. After calling
843 * XMC_ERU_OGU_DisablePeripheralTrigger(), XMC_ERU_OGU_EnablePeripheralTrigger() has to be called to reconfigure the
844 * signals again.
845 *
846 * \par<b>Related APIs:</b><BR>
847 * XMC_ERU_OGU_EnablePeripheralTrigger()
848 */
849 void XMC_ERU_OGU_DisablePeripheralTrigger(XMC_ERU_t *const eru,
850 const uint8_t channel);
851
852 /**
853 * @param eru A constant pointer to XMC_ERU_t, pointing to the ERU base address
854 * @param channel ERU_OGUy(Output gating unit) channel
855 * Range : [0 to 3]
856 * @param mode gating scheme for service request generation.
857 * Refer @ref XMC_ERU_OGU_SERVICE_REQUEST_t for valid values.
858 *
859 * @return None
860 *
861 * \par<b>Description:</b><br>
862 * Configures the gating scheme for service request generation by setting (GP) bit.<br>
863 * \par
864 * Typically this function is used to change the service request generation scheme. These values are set during
865 * initialization in XMC_ERU_OGU_Init(). Call this to change the gating mode, as needed later in the program.
866 *
867 */
868 void XMC_ERU_OGU_SetServiceRequestMode(XMC_ERU_t *const eru,
869 const uint8_t channel,
870 const XMC_ERU_OGU_SERVICE_REQUEST_t mode);
871
872 #ifdef __cplusplus
873 }
874 #endif
875
876 /**
877 * @} (end addtogroup ERU)
878 */
879
880 /**
881 * @} (end addtogroup XMClib)
882 */
883
884 #endif /* XMC_ERU_H */
885