1 //###########################################################################
2 //
3 // FILE: F2837xD_ECap.c
4 //
5 // TITLE: F2837xD eCAP Initialization & Support Functions.
6 //
7 //###########################################################################
8 // $TI Release: F2837xD Support Library v3.05.00.00 $
9 // $Release Date: Tue Jun 26 03:15:23 CDT 2018 $
10 // $Copyright:
11 // Copyright (C) 2013-2018 Texas Instruments Incorporated - http://www.ti.com/
12 //
13 // Redistribution and use in source and binary forms, with or without
14 // modification, are permitted provided that the following conditions
15 // are met:
16 //
17 // Redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 //
20 // Redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the
23 // distribution.
24 //
25 // Neither the name of Texas Instruments Incorporated nor the names of
26 // its contributors may be used to endorse or promote products derived
27 // from this software without specific prior written permission.
28 //
29 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 // $
41 //###########################################################################
42
43 //
44 // Included Files
45 //
46 #include "F2837xD_device.h"
47 #include "F2837xD_Examples.h"
48
49 //
50 // InitECap - This function initializes the eCAP(s) to a known state.
51 //
InitECap(void)52 void InitECap(void)
53 {
54 // Initialize eCAP1/2/3/4/5/6
55
56 //tbd...
57 }
58
59 //
60 // InitECapGpio - This function initializes GPIO pins to function as ECAP pins
61 // Each GPIO pin can be configured as a GPIO pin or up to 3
62 // different peripheral functional pins. By default all pins
63 // come up as GPIO inputs after reset.
64 // Caution:
65 // For each eCAP peripheral
66 // Only one GPIO pin should be enabled for ECAP operation.
67 // Comment out other unwanted lines.
68 //
InitECapGpio()69 void InitECapGpio()
70 {
71 }
72
73 //
74 // InitECap1Gpio - Initialize ECAP1 GPIOs
75 //
InitECap1Gpio(Uint16 pin)76 void InitECap1Gpio(Uint16 pin)
77 {
78 EALLOW;
79 InputXbarRegs.INPUT7SELECT = pin; // Set eCAP1 source to GPIO-pin
80 EDIS;
81 }
82
83 //
84 // InitECap2Gpio - Initialize ECAP2 GPIOs
85 //
InitECap2Gpio(Uint16 pin)86 void InitECap2Gpio(Uint16 pin)
87 {
88 EALLOW;
89 InputXbarRegs.INPUT8SELECT = pin; // Set eCAP2 source to GPIO-pin
90 EDIS;
91 }
92
93 //
94 // InitECap3Gpio - Initialize ECAP3 GPIOs
95 //
InitECap3Gpio(Uint16 pin)96 void InitECap3Gpio(Uint16 pin)
97 {
98 EALLOW;
99 InputXbarRegs.INPUT9SELECT = pin; // Set eCAP3 source to GPIO-pin
100 EDIS;
101 }
102
103 //
104 // InitECap4Gpio - Initialize ECAP4 GPIOs
105 //
InitECap4Gpio(Uint16 pin)106 void InitECap4Gpio(Uint16 pin)
107 {
108 EALLOW;
109 InputXbarRegs.INPUT10SELECT = pin; // Set eCAP4 source to GPIO-pin
110 EDIS;
111 }
112
113 //
114 // InitECap5Gpio - Initialize ECAP5 GPIOs
115 //
InitECap5Gpio(Uint16 pin)116 void InitECap5Gpio(Uint16 pin)
117 {
118 EALLOW;
119 InputXbarRegs.INPUT11SELECT = pin; // Set eCAP5 source to GPIO-pin
120 EDIS;
121 }
122
123 //
124 // InitECap6Gpio - Initialize ECAP6 GPIOs
125 //
InitECap6Gpio(Uint16 pin)126 void InitECap6Gpio(Uint16 pin)
127 {
128 EALLOW;
129 InputXbarRegs.INPUT12SELECT = pin; // Set eCAP6 source to GPIO-pin
130 EDIS;
131 }
132
133 //
134 // InitAPwm1Gpio - Initialize EPWM1 GPIOs
135 //
InitAPwm1Gpio()136 void InitAPwm1Gpio()
137 {
138 EALLOW;
139 OutputXbarRegs.OUTPUT3MUX0TO15CFG.bit.MUX0 = 3; // Select ECAP1.OUT on Mux0
140 OutputXbarRegs.OUTPUT3MUXENABLE.bit.MUX0 = 1; // Enable MUX0 for ECAP1.OUT
141 GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 3; // Select OUTPUTXBAR3 on GPIO5
142 EDIS;
143 }
144
145 //
146 // End of file
147 //
148