1 /**
2  * @file xmc4_eru.c
3  * @date 2015-02-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 <br>
41  *
42  * @endcond
43  */
44 #include "xmc_eru.h"
45 
46 #if UC_FAMILY == XMC4
47 #include "xmc_scu.h"
48 
49 /*********************************************************************************************************************
50  * API IMPLEMENTATION
51  ********************************************************************************************************************/
52 /* Enable the clock and De-assert the ERU module from the reset state. */
XMC_ERU_Enable(XMC_ERU_t * const eru)53 void XMC_ERU_Enable(XMC_ERU_t *const eru)
54 {
55 #if defined(XMC_ERU1)
56   if (eru == XMC_ERU1)
57   {
58 #if defined(CLOCK_GATING_SUPPORTED)
59     XMC_SCU_CLOCK_UngatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_ERU1);
60 #endif
61     XMC_SCU_RESET_DeassertPeripheralReset(XMC_SCU_PERIPHERAL_RESET_ERU1);
62   }
63 #else
64   XMC_UNUSED_ARG(eru);
65   #endif
66 }
67 
68 /* Disable the clock and Reset the ERU module. */
XMC_ERU_Disable(XMC_ERU_t * const eru)69 void XMC_ERU_Disable(XMC_ERU_t *const eru)
70 {
71 #if defined(XMC_ERU1)
72   if (eru == XMC_ERU1)
73   {
74     XMC_SCU_RESET_AssertPeripheralReset(XMC_SCU_PERIPHERAL_RESET_ERU1);
75 #if defined(CLOCK_GATING_SUPPORTED)
76       XMC_SCU_CLOCK_GatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_ERU1);
77     #endif
78   }
79 #else
80   XMC_UNUSED_ARG(eru);
81 #endif
82 }
83 
84 #endif /* if( UC_FAMILY == XMC1 ) */
85