1 //*****************************************************************************
\r
3 // pwm.h - API function protoypes for Pulse Width Modulation (PWM) ports
\r
5 // Copyright (c) 2005-2008 Luminary Micro, Inc. All rights reserved.
\r
7 // Software License Agreement
\r
9 // Luminary Micro, Inc. (LMI) is supplying this software for use solely and
\r
10 // exclusively on LMI's microcontroller products.
\r
12 // The software is owned by LMI and/or its suppliers, and is protected under
\r
13 // applicable copyright laws. All rights are reserved. You may not combine
\r
14 // this software with "viral" open-source software in order to form a larger
\r
15 // program. Any use in violation of the foregoing restrictions may subject
\r
16 // the user to criminal sanctions under applicable laws, as well as to civil
\r
17 // liability for the breach of the terms and conditions of this license.
\r
19 // THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
\r
20 // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
\r
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
\r
22 // LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
\r
23 // CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
\r
25 // This is part of revision 2523 of the Stellaris Peripheral Driver Library.
\r
27 //*****************************************************************************
\r
32 //*****************************************************************************
\r
34 // If building with a C++ compiler, make all of the definitions in this header
\r
35 // have a C binding.
\r
37 //*****************************************************************************
\r
43 //*****************************************************************************
\r
45 // The following defines are passed to PWMGenConfigure() as the ulConfig
\r
46 // parameter and specify the configuration of the PWM generator.
\r
48 //*****************************************************************************
\r
49 #define PWM_GEN_MODE_DOWN 0x00000000 // Down count mode
\r
50 #define PWM_GEN_MODE_UP_DOWN 0x00000002 // Up/Down count mode
\r
51 #define PWM_GEN_MODE_SYNC 0x00000038 // Synchronous updates
\r
52 #define PWM_GEN_MODE_NO_SYNC 0x00000000 // Immediate updates
\r
53 #define PWM_GEN_MODE_DBG_RUN 0x00000004 // Continue running in debug mode
\r
54 #define PWM_GEN_MODE_DBG_STOP 0x00000000 // Stop running in debug mode
\r
55 #define PWM_GEN_MODE_FAULT_LATCHED \
\r
56 0x00040000 // Fault is latched
\r
57 #define PWM_GEN_MODE_FAULT_UNLATCHED \
\r
58 0x00000000 // Fault is not latched
\r
59 #define PWM_GEN_MODE_FAULT_MINPER \
\r
60 0x00020000 // Enable min fault period
\r
61 #define PWM_GEN_MODE_FAULT_NO_MINPER \
\r
62 0x00000000 // Disable min fault period
\r
63 #define PWM_GEN_MODE_FAULT_EXT 0x00010000 // Enable extended fault support
\r
64 #define PWM_GEN_MODE_FAULT_LEGACY \
\r
65 0x00000000 // Disable extended fault support
\r
66 #define PWM_GEN_MODE_DB_NO_SYNC 0x00000000 // Deadband updates occur
\r
68 #define PWM_GEN_MODE_DB_SYNC_LOCAL \
\r
69 0x0000A800 // Deadband updates locally
\r
71 #define PWM_GEN_MODE_DB_SYNC_GLOBAL \
\r
72 0x0000FC00 // Deadband updates globally
\r
74 #define PWM_GEN_MODE_GEN_NO_SYNC \
\r
75 0x00000000 // Generator mode updates occur
\r
77 #define PWM_GEN_MODE_GEN_SYNC_LOCAL \
\r
78 0x00000280 // Generator mode updates locally
\r
80 #define PWM_GEN_MODE_GEN_SYNC_GLOBAL \
\r
81 0x000003C0 // Generator mode updates globally
\r
84 //*****************************************************************************
\r
86 // Defines for enabling, disabling, and clearing PWM generator interrupts and
\r
89 //*****************************************************************************
\r
90 #define PWM_INT_CNT_ZERO 0x00000001 // Int if COUNT = 0
\r
91 #define PWM_INT_CNT_LOAD 0x00000002 // Int if COUNT = LOAD
\r
92 #define PWM_INT_CNT_AU 0x00000004 // Int if COUNT = CMPA U
\r
93 #define PWM_INT_CNT_AD 0x00000008 // Int if COUNT = CMPA D
\r
94 #define PWM_INT_CNT_BU 0x00000010 // Int if COUNT = CMPA U
\r
95 #define PWM_INT_CNT_BD 0x00000020 // Int if COUNT = CMPA D
\r
96 #define PWM_TR_CNT_ZERO 0x00000100 // Trig if COUNT = 0
\r
97 #define PWM_TR_CNT_LOAD 0x00000200 // Trig if COUNT = LOAD
\r
98 #define PWM_TR_CNT_AU 0x00000400 // Trig if COUNT = CMPA U
\r
99 #define PWM_TR_CNT_AD 0x00000800 // Trig if COUNT = CMPA D
\r
100 #define PWM_TR_CNT_BU 0x00001000 // Trig if COUNT = CMPA U
\r
101 #define PWM_TR_CNT_BD 0x00002000 // Trig if COUNT = CMPA D
\r
103 //*****************************************************************************
\r
105 // Defines for enabling, disabling, and clearing PWM interrupts.
\r
107 //*****************************************************************************
\r
108 #define PWM_INT_GEN_0 0x00000001 // Generator 0 interrupt
\r
109 #define PWM_INT_GEN_1 0x00000002 // Generator 1 interrupt
\r
110 #define PWM_INT_GEN_2 0x00000004 // Generator 2 interrupt
\r
111 #define PWM_INT_GEN_3 0x00000008 // Generator 3 interrupt
\r
113 #define PWM_INT_FAULT 0x00010000 // Fault interrupt
\r
115 #define PWM_INT_FAULT0 0x00010000 // Fault0 interrupt
\r
116 #define PWM_INT_FAULT1 0x00020000 // Fault1 interrupt
\r
117 #define PWM_INT_FAULT2 0x00040000 // Fault2 interrupt
\r
118 #define PWM_INT_FAULT3 0x00080000 // Fault3 interrupt
\r
119 #define PWM_INT_FAULT_M 0x000F0000 // Fault interrupt source mask
\r
121 //*****************************************************************************
\r
123 // Defines to identify the generators within a module.
\r
125 //*****************************************************************************
\r
126 #define PWM_GEN_0 0x00000040 // Offset address of Gen0
\r
127 #define PWM_GEN_1 0x00000080 // Offset address of Gen1
\r
128 #define PWM_GEN_2 0x000000C0 // Offset address of Gen2
\r
129 #define PWM_GEN_3 0x00000100 // Offset address of Gen3
\r
131 #define PWM_GEN_0_BIT 0x00000001 // Bit-wise ID for Gen0
\r
132 #define PWM_GEN_1_BIT 0x00000002 // Bit-wise ID for Gen1
\r
133 #define PWM_GEN_2_BIT 0x00000004 // Bit-wise ID for Gen2
\r
134 #define PWM_GEN_3_BIT 0x00000008 // Bit-wise ID for Gen3
\r
136 #define PWM_GEN_EXT_0 0x00000800 // Offset of Gen0 ext address range
\r
137 #define PWM_GEN_EXT_1 0x00000880 // Offset of Gen1 ext address range
\r
138 #define PWM_GEN_EXT_2 0x00000900 // Offset of Gen2 ext address range
\r
139 #define PWM_GEN_EXT_3 0x00000980 // Offset of Gen3 ext address range
\r
141 //*****************************************************************************
\r
143 // Defines to identify the outputs within a module.
\r
145 //*****************************************************************************
\r
146 #define PWM_OUT_0 0x00000040 // Encoded offset address of PWM0
\r
147 #define PWM_OUT_1 0x00000041 // Encoded offset address of PWM1
\r
148 #define PWM_OUT_2 0x00000082 // Encoded offset address of PWM2
\r
149 #define PWM_OUT_3 0x00000083 // Encoded offset address of PWM3
\r
150 #define PWM_OUT_4 0x000000C4 // Encoded offset address of PWM4
\r
151 #define PWM_OUT_5 0x000000C5 // Encoded offset address of PWM5
\r
152 #define PWM_OUT_6 0x00000106 // Encoded offset address of PWM6
\r
153 #define PWM_OUT_7 0x00000107 // Encoded offset address of PWM7
\r
155 #define PWM_OUT_0_BIT 0x00000001 // Bit-wise ID for PWM0
\r
156 #define PWM_OUT_1_BIT 0x00000002 // Bit-wise ID for PWM1
\r
157 #define PWM_OUT_2_BIT 0x00000004 // Bit-wise ID for PWM2
\r
158 #define PWM_OUT_3_BIT 0x00000008 // Bit-wise ID for PWM3
\r
159 #define PWM_OUT_4_BIT 0x00000010 // Bit-wise ID for PWM4
\r
160 #define PWM_OUT_5_BIT 0x00000020 // Bit-wise ID for PWM5
\r
161 #define PWM_OUT_6_BIT 0x00000040 // Bit-wise ID for PWM6
\r
162 #define PWM_OUT_7_BIT 0x00000080 // Bit-wise ID for PWM7
\r
164 //*****************************************************************************
\r
166 // Defines to identify each of the possible fault trigger conditions in
\r
167 // PWM_FAULT_GROUP_0
\r
169 //*****************************************************************************
\r
170 #define PWM_FAULT_GROUP_0 0
\r
172 #define PWM_FAULT_FAULT0 0x00000001
\r
173 #define PWM_FAULT_FAULT1 0x00000002
\r
174 #define PWM_FAULT_FAULT2 0x00000004
\r
175 #define PWM_FAULT_FAULT3 0x00000008
\r
176 #define PWM_FAULT_ACMP0 0x00010000
\r
177 #define PWM_FAULT_ACMP1 0x00020000
\r
178 #define PWM_FAULT_ACMP2 0x00040000
\r
180 //*****************************************************************************
\r
182 // Defines to identify the sense of each of the external FAULTn signals
\r
184 //*****************************************************************************
\r
185 #define PWM_FAULT0_SENSE_HIGH 0x00000000
\r
186 #define PWM_FAULT0_SENSE_LOW 0x00000001
\r
187 #define PWM_FAULT1_SENSE_HIGH 0x00000000
\r
188 #define PWM_FAULT1_SENSE_LOW 0x00000002
\r
189 #define PWM_FAULT2_SENSE_HIGH 0x00000000
\r
190 #define PWM_FAULT2_SENSE_LOW 0x00000004
\r
191 #define PWM_FAULT3_SENSE_HIGH 0x00000000
\r
192 #define PWM_FAULT3_SENSE_LOW 0x00000008
\r
194 //*****************************************************************************
\r
196 // API Function prototypes
\r
198 //*****************************************************************************
\r
199 extern void PWMGenConfigure(unsigned long ulBase, unsigned long ulGen,
\r
200 unsigned long ulConfig);
\r
201 extern void PWMGenPeriodSet(unsigned long ulBase, unsigned long ulGen,
\r
202 unsigned long ulPeriod);
\r
203 extern unsigned long PWMGenPeriodGet(unsigned long ulBase,
\r
204 unsigned long ulGen);
\r
205 extern void PWMGenEnable(unsigned long ulBase, unsigned long ulGen);
\r
206 extern void PWMGenDisable(unsigned long ulBase, unsigned long ulGen);
\r
207 extern void PWMPulseWidthSet(unsigned long ulBase, unsigned long ulPWMOut,
\r
208 unsigned long ulWidth);
\r
209 extern unsigned long PWMPulseWidthGet(unsigned long ulBase,
\r
210 unsigned long ulPWMOut);
\r
211 extern void PWMDeadBandEnable(unsigned long ulBase, unsigned long ulGen,
\r
212 unsigned short usRise, unsigned short usFall);
\r
213 extern void PWMDeadBandDisable(unsigned long ulBase, unsigned long ulGen);
\r
214 extern void PWMSyncUpdate(unsigned long ulBase, unsigned long ulGenBits);
\r
215 extern void PWMSyncTimeBase(unsigned long ulBase, unsigned long ulGenBits);
\r
216 extern void PWMOutputState(unsigned long ulBase, unsigned long ulPWMOutBits,
\r
218 extern void PWMOutputInvert(unsigned long ulBase, unsigned long ulPWMOutBits,
\r
220 extern void PWMOutputFaultLevel(unsigned long ulBase,
\r
221 unsigned long ulPWMOutBits,
\r
222 tBoolean bDriveHigh);
\r
223 extern void PWMOutputFault(unsigned long ulBase, unsigned long ulPWMOutBits,
\r
224 tBoolean bFaultSuppress);
\r
225 extern void PWMGenIntRegister(unsigned long ulBase, unsigned long ulGen,
\r
226 void (*pfnIntHandler)(void));
\r
227 extern void PWMGenIntUnregister(unsigned long ulBase, unsigned long ulGen);
\r
228 extern void PWMFaultIntRegister(unsigned long ulBase,
\r
229 void (*pfnIntHandler)(void));
\r
230 extern void PWMFaultIntUnregister(unsigned long ulBase);
\r
231 extern void PWMGenIntTrigEnable(unsigned long ulBase, unsigned long ulGen,
\r
232 unsigned long ulIntTrig);
\r
233 extern void PWMGenIntTrigDisable(unsigned long ulBase, unsigned long ulGen,
\r
234 unsigned long ulIntTrig);
\r
235 extern unsigned long PWMGenIntStatus(unsigned long ulBase, unsigned long ulGen,
\r
237 extern void PWMGenIntClear(unsigned long ulBase, unsigned long ulGen,
\r
238 unsigned long ulInts);
\r
239 extern void PWMIntEnable(unsigned long ulBase, unsigned long ulGenFault);
\r
240 extern void PWMIntDisable(unsigned long ulBase, unsigned long ulGenFault);
\r
241 extern void PWMFaultIntClear(unsigned long ulBase);
\r
242 extern unsigned long PWMIntStatus(unsigned long ulBase, tBoolean bMasked);
\r
243 extern void PWMFaultIntClearExt(unsigned long ulBase,
\r
244 unsigned long ulFaultInts);
\r
245 extern void PWMGenFaultConfigure(unsigned long ulBase, unsigned long ulGen,
\r
246 unsigned long ulMinFaultPeriod,
\r
247 unsigned long ulFaultSenses);
\r
248 extern void PWMGenFaultTriggerSet(unsigned long ulBase, unsigned long ulGen,
\r
249 unsigned long ulGroup,
\r
250 unsigned long ulFaultTriggers);
\r
251 extern unsigned long PWMGenFaultTriggerGet(unsigned long ulBase,
\r
252 unsigned long ulGen,
\r
253 unsigned long ulGroup);
\r
254 extern unsigned long PWMGenFaultStatus(unsigned long ulBase,
\r
255 unsigned long ulGen,
\r
256 unsigned long ulGroup);
\r
257 extern void PWMGenFaultClear(unsigned long ulBase, unsigned long ulGen,
\r
258 unsigned long ulGroup,
\r
259 unsigned long ulFaultTriggers);
\r
261 //*****************************************************************************
\r
263 // Mark the end of the C bindings section for C++ compilers.
\r
265 //*****************************************************************************
\r
270 #endif // __PWM_H__
\r