Tiva Driver Lib
pwm.h
1 //*****************************************************************************
2 //
3 // pwm.h - API function protoypes for Pulse Width Modulation (PWM) ports
4 //
5 // Copyright (c) 2005-2013 Texas Instruments Incorporated. All rights reserved.
6 // Software License Agreement
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions
10 // are met:
11 //
12 // Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright
16 // notice, this list of conditions and the following disclaimer in the
17 // documentation and/or other materials provided with the
18 // distribution.
19 //
20 // Neither the name of Texas Instruments Incorporated nor the names of
21 // its contributors may be used to endorse or promote products derived
22 // from this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 //
36 // This is part of revision 1.1 of the Tiva Peripheral Driver Library.
37 //
38 //*****************************************************************************
39 
40 #ifndef __DRIVERLIB_PWM_H__
41 #define __DRIVERLIB_PWM_H__
42 
43 //*****************************************************************************
44 //
45 // If building with a C++ compiler, make all of the definitions in this header
46 // have a C binding.
47 //
48 //*****************************************************************************
49 #ifdef __cplusplus
50 extern "C"
51 {
52 #endif
53 
54 //*****************************************************************************
55 //
56 // The following defines are passed to PWMGenConfigure() as the ui32Config
57 // parameter and specify the configuration of the PWM generator.
58 //
59 //*****************************************************************************
60 #define PWM_GEN_MODE_DOWN 0x00000000 // Down count mode
61 #define PWM_GEN_MODE_UP_DOWN 0x00000002 // Up/Down count mode
62 #define PWM_GEN_MODE_SYNC 0x00000038 // Synchronous updates
63 #define PWM_GEN_MODE_NO_SYNC 0x00000000 // Immediate updates
64 #define PWM_GEN_MODE_DBG_RUN 0x00000004 // Continue running in debug mode
65 #define PWM_GEN_MODE_DBG_STOP 0x00000000 // Stop running in debug mode
66 #define PWM_GEN_MODE_FAULT_LATCHED \
67  0x00040000 // Fault is latched
68 #define PWM_GEN_MODE_FAULT_UNLATCHED \
69  0x00000000 // Fault is not latched
70 #define PWM_GEN_MODE_FAULT_MINPER \
71  0x00020000 // Enable min fault period
72 #define PWM_GEN_MODE_FAULT_NO_MINPER \
73  0x00000000 // Disable min fault period
74 #define PWM_GEN_MODE_FAULT_EXT 0x00010000 // Enable extended fault support
75 #define PWM_GEN_MODE_FAULT_LEGACY \
76  0x00000000 // Disable extended fault support
77 #define PWM_GEN_MODE_DB_NO_SYNC 0x00000000 // Deadband updates occur
78  // immediately
79 #define PWM_GEN_MODE_DB_SYNC_LOCAL \
80  0x0000A800 // Deadband updates locally
81  // synchronized
82 #define PWM_GEN_MODE_DB_SYNC_GLOBAL \
83  0x0000FC00 // Deadband updates globally
84  // synchronized
85 #define PWM_GEN_MODE_GEN_NO_SYNC \
86  0x00000000 // Generator mode updates occur
87  // immediately
88 #define PWM_GEN_MODE_GEN_SYNC_LOCAL \
89  0x00000280 // Generator mode updates locally
90  // synchronized
91 #define PWM_GEN_MODE_GEN_SYNC_GLOBAL \
92  0x000003C0 // Generator mode updates globally
93  // synchronized
94 
95 //*****************************************************************************
96 //
97 // Defines for enabling, disabling, and clearing PWM generator interrupts and
98 // triggers.
99 //
100 //*****************************************************************************
101 #define PWM_INT_CNT_ZERO 0x00000001 // Int if COUNT = 0
102 #define PWM_INT_CNT_LOAD 0x00000002 // Int if COUNT = LOAD
103 #define PWM_INT_CNT_AU 0x00000004 // Int if COUNT = CMPA U
104 #define PWM_INT_CNT_AD 0x00000008 // Int if COUNT = CMPA D
105 #define PWM_INT_CNT_BU 0x00000010 // Int if COUNT = CMPA U
106 #define PWM_INT_CNT_BD 0x00000020 // Int if COUNT = CMPA D
107 #define PWM_TR_CNT_ZERO 0x00000100 // Trig if COUNT = 0
108 #define PWM_TR_CNT_LOAD 0x00000200 // Trig if COUNT = LOAD
109 #define PWM_TR_CNT_AU 0x00000400 // Trig if COUNT = CMPA U
110 #define PWM_TR_CNT_AD 0x00000800 // Trig if COUNT = CMPA D
111 #define PWM_TR_CNT_BU 0x00001000 // Trig if COUNT = CMPA U
112 #define PWM_TR_CNT_BD 0x00002000 // Trig if COUNT = CMPA D
113 
114 //*****************************************************************************
115 //
116 // Defines for enabling, disabling, and clearing PWM interrupts.
117 //
118 //*****************************************************************************
119 #define PWM_INT_GEN_0 0x00000001 // Generator 0 interrupt
120 #define PWM_INT_GEN_1 0x00000002 // Generator 1 interrupt
121 #define PWM_INT_GEN_2 0x00000004 // Generator 2 interrupt
122 #define PWM_INT_GEN_3 0x00000008 // Generator 3 interrupt
123 #define PWM_INT_FAULT0 0x00010000 // Fault0 interrupt
124 #define PWM_INT_FAULT1 0x00020000 // Fault1 interrupt
125 #define PWM_INT_FAULT2 0x00040000 // Fault2 interrupt
126 #define PWM_INT_FAULT3 0x00080000 // Fault3 interrupt
127 #define PWM_INT_FAULT_M 0x000F0000 // Fault interrupt source mask
128 
129 //*****************************************************************************
130 //
131 // Defines to identify the generators within a module.
132 //
133 //*****************************************************************************
134 #define PWM_GEN_0 0x00000040 // Offset address of Gen0
135 #define PWM_GEN_1 0x00000080 // Offset address of Gen1
136 #define PWM_GEN_2 0x000000C0 // Offset address of Gen2
137 #define PWM_GEN_3 0x00000100 // Offset address of Gen3
138 
139 #define PWM_GEN_0_BIT 0x00000001 // Bit-wise ID for Gen0
140 #define PWM_GEN_1_BIT 0x00000002 // Bit-wise ID for Gen1
141 #define PWM_GEN_2_BIT 0x00000004 // Bit-wise ID for Gen2
142 #define PWM_GEN_3_BIT 0x00000008 // Bit-wise ID for Gen3
143 
144 #define PWM_GEN_EXT_0 0x00000800 // Offset of Gen0 ext address range
145 #define PWM_GEN_EXT_1 0x00000880 // Offset of Gen1 ext address range
146 #define PWM_GEN_EXT_2 0x00000900 // Offset of Gen2 ext address range
147 #define PWM_GEN_EXT_3 0x00000980 // Offset of Gen3 ext address range
148 
149 //*****************************************************************************
150 //
151 // Defines to identify the outputs within a module.
152 //
153 //*****************************************************************************
154 #define PWM_OUT_0 0x00000040 // Encoded offset address of PWM0
155 #define PWM_OUT_1 0x00000041 // Encoded offset address of PWM1
156 #define PWM_OUT_2 0x00000082 // Encoded offset address of PWM2
157 #define PWM_OUT_3 0x00000083 // Encoded offset address of PWM3
158 #define PWM_OUT_4 0x000000C4 // Encoded offset address of PWM4
159 #define PWM_OUT_5 0x000000C5 // Encoded offset address of PWM5
160 #define PWM_OUT_6 0x00000106 // Encoded offset address of PWM6
161 #define PWM_OUT_7 0x00000107 // Encoded offset address of PWM7
162 
163 #define PWM_OUT_0_BIT 0x00000001 // Bit-wise ID for PWM0
164 #define PWM_OUT_1_BIT 0x00000002 // Bit-wise ID for PWM1
165 #define PWM_OUT_2_BIT 0x00000004 // Bit-wise ID for PWM2
166 #define PWM_OUT_3_BIT 0x00000008 // Bit-wise ID for PWM3
167 #define PWM_OUT_4_BIT 0x00000010 // Bit-wise ID for PWM4
168 #define PWM_OUT_5_BIT 0x00000020 // Bit-wise ID for PWM5
169 #define PWM_OUT_6_BIT 0x00000040 // Bit-wise ID for PWM6
170 #define PWM_OUT_7_BIT 0x00000080 // Bit-wise ID for PWM7
171 
172 //*****************************************************************************
173 //
174 // Defines to identify each of the possible fault trigger conditions in
175 // PWM_FAULT_GROUP_0.
176 //
177 //*****************************************************************************
178 #define PWM_FAULT_GROUP_0 0
179 
180 #define PWM_FAULT_FAULT0 0x00000001
181 #define PWM_FAULT_FAULT1 0x00000002
182 #define PWM_FAULT_FAULT2 0x00000004
183 #define PWM_FAULT_FAULT3 0x00000008
184 #define PWM_FAULT_ACMP0 0x00010000
185 #define PWM_FAULT_ACMP1 0x00020000
186 #define PWM_FAULT_ACMP2 0x00040000
187 
188 //*****************************************************************************
189 //
190 // Defines to identify each of the possible fault trigger conditions in
191 // PWM_FAULT_GROUP_1.
192 //
193 //*****************************************************************************
194 #define PWM_FAULT_GROUP_1 1
195 
196 #define PWM_FAULT_DCMP0 0x00000001
197 #define PWM_FAULT_DCMP1 0x00000002
198 #define PWM_FAULT_DCMP2 0x00000004
199 #define PWM_FAULT_DCMP3 0x00000008
200 #define PWM_FAULT_DCMP4 0x00000010
201 #define PWM_FAULT_DCMP5 0x00000020
202 #define PWM_FAULT_DCMP6 0x00000040
203 #define PWM_FAULT_DCMP7 0x00000080
204 
205 //*****************************************************************************
206 //
207 // Defines to identify the sense of each of the external FAULTn signals
208 //
209 //*****************************************************************************
210 #define PWM_FAULT0_SENSE_HIGH 0x00000000
211 #define PWM_FAULT0_SENSE_LOW 0x00000001
212 #define PWM_FAULT1_SENSE_HIGH 0x00000000
213 #define PWM_FAULT1_SENSE_LOW 0x00000002
214 #define PWM_FAULT2_SENSE_HIGH 0x00000000
215 #define PWM_FAULT2_SENSE_LOW 0x00000004
216 #define PWM_FAULT3_SENSE_HIGH 0x00000000
217 #define PWM_FAULT3_SENSE_LOW 0x00000008
218 
219 //*****************************************************************************
220 //
221 // API Function prototypes
222 //
223 //*****************************************************************************
224 extern void PWMGenConfigure(uint32_t ui32Base, uint32_t ui32Gen,
225  uint32_t ui32Config);
226 extern void PWMGenPeriodSet(uint32_t ui32Base, uint32_t ui32Gen,
227  uint32_t ui32Period);
228 extern uint32_t PWMGenPeriodGet(uint32_t ui32Base,
229  uint32_t ui32Gen);
230 extern void PWMGenEnable(uint32_t ui32Base, uint32_t ui32Gen);
231 extern void PWMGenDisable(uint32_t ui32Base, uint32_t ui32Gen);
232 extern void PWMPulseWidthSet(uint32_t ui32Base, uint32_t ui32PWMOut,
233  uint32_t ui32Width);
234 extern uint32_t PWMPulseWidthGet(uint32_t ui32Base,
235  uint32_t ui32PWMOut);
236 extern void PWMDeadBandEnable(uint32_t ui32Base, uint32_t ui32Gen,
237  uint16_t ui16Rise, uint16_t ui16Fall);
238 extern void PWMDeadBandDisable(uint32_t ui32Base, uint32_t ui32Gen);
239 extern void PWMSyncUpdate(uint32_t ui32Base, uint32_t ui32GenBits);
240 extern void PWMSyncTimeBase(uint32_t ui32Base, uint32_t ui32GenBits);
241 extern void PWMOutputState(uint32_t ui32Base, uint32_t ui32PWMOutBits,
242  bool bEnable);
243 extern void PWMOutputInvert(uint32_t ui32Base, uint32_t ui32PWMOutBits,
244  bool bInvert);
245 extern void PWMOutputFaultLevel(uint32_t ui32Base,
246  uint32_t ui32PWMOutBits,
247  bool bDriveHigh);
248 extern void PWMOutputFault(uint32_t ui32Base, uint32_t ui32PWMOutBits,
249  bool bFaultSuppress);
250 extern void PWMGenIntRegister(uint32_t ui32Base, uint32_t ui32Gen,
251  void (*pfnIntHandler)(void));
252 extern void PWMGenIntUnregister(uint32_t ui32Base, uint32_t ui32Gen);
253 extern void PWMFaultIntRegister(uint32_t ui32Base,
254  void (*pfnIntHandler)(void));
255 extern void PWMFaultIntUnregister(uint32_t ui32Base);
256 extern void PWMGenIntTrigEnable(uint32_t ui32Base, uint32_t ui32Gen,
257  uint32_t ui32IntTrig);
258 extern void PWMGenIntTrigDisable(uint32_t ui32Base, uint32_t ui32Gen,
259  uint32_t ui32IntTrig);
260 extern uint32_t PWMGenIntStatus(uint32_t ui32Base, uint32_t ui32Gen,
261  bool bMasked);
262 extern void PWMGenIntClear(uint32_t ui32Base, uint32_t ui32Gen,
263  uint32_t ui32Ints);
264 extern void PWMIntEnable(uint32_t ui32Base, uint32_t ui32GenFault);
265 extern void PWMIntDisable(uint32_t ui32Base, uint32_t ui32GenFault);
266 extern void PWMFaultIntClear(uint32_t ui32Base);
267 extern uint32_t PWMIntStatus(uint32_t ui32Base, bool bMasked);
268 extern void PWMFaultIntClearExt(uint32_t ui32Base,
269  uint32_t ui32FaultInts);
270 extern void PWMGenFaultConfigure(uint32_t ui32Base, uint32_t ui32Gen,
271  uint32_t ui32MinFaultPeriod,
272  uint32_t ui32FaultSenses);
273 extern void PWMGenFaultTriggerSet(uint32_t ui32Base, uint32_t ui32Gen,
274  uint32_t ui32Group,
275  uint32_t ui32FaultTriggers);
276 extern uint32_t PWMGenFaultTriggerGet(uint32_t ui32Base,
277  uint32_t ui32Gen,
278  uint32_t ui32Group);
279 extern uint32_t PWMGenFaultStatus(uint32_t ui32Base,
280  uint32_t ui32Gen,
281  uint32_t ui32Group);
282 extern void PWMGenFaultClear(uint32_t ui32Base, uint32_t ui32Gen,
283  uint32_t ui32Group,
284  uint32_t ui32FaultTriggers);
285 
286 //*****************************************************************************
287 //
288 // Mark the end of the C bindings section for C++ compilers.
289 //
290 //*****************************************************************************
291 #ifdef __cplusplus
292 }
293 #endif
294 
295 #endif // __DRIVERLIB_PWM_H__
uint32_t PWMPulseWidthGet(uint32_t ui32Base, uint32_t ui32PWMOut)
Definition: pwm.c:518
void PWMGenFaultClear(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Group, uint32_t ui32FaultTriggers)
Definition: pwm.c:1879
void PWMGenIntUnregister(uint32_t ui32Base, uint32_t ui32Gen)
Definition: pwm.c:1089
void PWMDeadBandDisable(uint32_t ui32Base, uint32_t ui32Gen)
Definition: pwm.c:624
void PWMOutputState(uint32_t ui32Base, uint32_t ui32PWMOutBits, bool bEnable)
Definition: pwm.c:726
void PWMFaultIntClearExt(uint32_t ui32Base, uint32_t ui32FaultInts)
Definition: pwm.c:1595
void PWMIntEnable(uint32_t ui32Base, uint32_t ui32GenFault)
Definition: pwm.c:1433
void PWMDeadBandEnable(uint32_t ui32Base, uint32_t ui32Gen, uint16_t ui16Rise, uint16_t ui16Fall)
Definition: pwm.c:581
void PWMFaultIntUnregister(uint32_t ui32Base)
Definition: pwm.c:1213
void PWMGenIntRegister(uint32_t ui32Base, uint32_t ui32Gen, void(*pfnIntHandler)(void))
Definition: pwm.c:1039
uint32_t PWMGenFaultStatus(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Group)
Definition: pwm.c:1830
void PWMIntDisable(uint32_t ui32Base, uint32_t ui32GenFault)
Definition: pwm.c:1467
uint32_t PWMGenFaultTriggerGet(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Group)
Definition: pwm.c:1771
void PWMGenFaultTriggerSet(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Group, uint32_t ui32FaultTriggers)
Definition: pwm.c:1708
void PWMGenFaultConfigure(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32MinFaultPeriod, uint32_t ui32FaultSenses)
Definition: pwm.c:1640
uint32_t PWMIntStatus(uint32_t ui32Base, bool bMasked)
Definition: pwm.c:1542
void PWMGenPeriodSet(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Period)
Definition: pwm.c:278
void PWMGenIntTrigEnable(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32IntTrig)
Definition: pwm.c:1262
void PWMOutputInvert(uint32_t ui32Base, uint32_t ui32PWMOutBits, bool bInvert)
Definition: pwm.c:774
void PWMOutputFault(uint32_t ui32Base, uint32_t ui32PWMOutBits, bool bFaultSuppress)
Definition: pwm.c:883
void PWMFaultIntRegister(uint32_t ui32Base, void(*pfnIntHandler)(void))
Definition: pwm.c:1168
void PWMSyncUpdate(uint32_t ui32Base, uint32_t ui32GenBits)
Definition: pwm.c:656
uint32_t PWMGenIntStatus(uint32_t ui32Base, uint32_t ui32Gen, bool bMasked)
Definition: pwm.c:1343
void PWMGenDisable(uint32_t ui32Base, uint32_t ui32Gen)
Definition: pwm.c:412
void PWMPulseWidthSet(uint32_t ui32Base, uint32_t ui32PWMOut, uint32_t ui32Width)
Definition: pwm.c:447
void PWMSyncTimeBase(uint32_t ui32Base, uint32_t ui32GenBits)
Definition: pwm.c:688
void PWMOutputFaultLevel(uint32_t ui32Base, uint32_t ui32PWMOutBits, bool bDriveHigh)
Definition: pwm.c:830
void PWMGenIntTrigDisable(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32IntTrig)
Definition: pwm.c:1304
void PWMGenEnable(uint32_t ui32Base, uint32_t ui32Gen)
Definition: pwm.c:383
void PWMGenConfigure(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Config)
Definition: pwm.c:200
uint32_t PWMGenPeriodGet(uint32_t ui32Base, uint32_t ui32Gen)
Definition: pwm.c:336
void PWMGenIntClear(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Ints)
Definition: pwm.c:1398
void PWMFaultIntClear(uint32_t ui32Base)
Definition: pwm.c:1511