1 |
581 |
jeremybenn |
//*****************************************************************************
|
2 |
|
|
//
|
3 |
|
|
// hw_pwm.h - Defines and Macros for Pulse Width Modulation (PWM) ports
|
4 |
|
|
//
|
5 |
|
|
// Copyright (c) 2005,2006 Luminary Micro, Inc. All rights reserved.
|
6 |
|
|
//
|
7 |
|
|
// Software License Agreement
|
8 |
|
|
//
|
9 |
|
|
// Luminary Micro, Inc. (LMI) is supplying this software for use solely and
|
10 |
|
|
// exclusively on LMI's Stellaris Family of microcontroller products.
|
11 |
|
|
//
|
12 |
|
|
// The software is owned by LMI and/or its suppliers, and is protected under
|
13 |
|
|
// applicable copyright laws. All rights are reserved. Any use in violation
|
14 |
|
|
// of the foregoing restrictions may subject the user to criminal sanctions
|
15 |
|
|
// under applicable laws, as well as to civil liability for the breach of the
|
16 |
|
|
// terms and conditions of this license.
|
17 |
|
|
//
|
18 |
|
|
// THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
19 |
|
|
// OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
20 |
|
|
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
21 |
|
|
// LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
|
22 |
|
|
// CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
23 |
|
|
//
|
24 |
|
|
// This is part of revision 991 of the Stellaris Driver Library.
|
25 |
|
|
//
|
26 |
|
|
//*****************************************************************************
|
27 |
|
|
|
28 |
|
|
#ifndef __HW_PWM_H__
|
29 |
|
|
#define __HW_PWM_H__
|
30 |
|
|
|
31 |
|
|
//*****************************************************************************
|
32 |
|
|
//
|
33 |
|
|
// PWM Module Register Offsets.
|
34 |
|
|
//
|
35 |
|
|
//*****************************************************************************
|
36 |
|
|
#define PWM_O_CTL 0x00000000 // PWM Master Control register
|
37 |
|
|
#define PWM_O_SYNC 0x00000004 // PWM Time Base Sync register
|
38 |
|
|
#define PWM_O_ENABLE 0x00000008 // PWM Output Enable register
|
39 |
|
|
#define PWM_O_INVERT 0x0000000C // PWM Output Inversion register
|
40 |
|
|
#define PWM_O_FAULT 0x00000010 // PWM Output Fault register
|
41 |
|
|
#define PWM_O_INTEN 0x00000014 // PWM Interrupt Enable register
|
42 |
|
|
#define PWM_O_RIS 0x00000018 // PWM Interrupt Raw Status reg.
|
43 |
|
|
#define PWM_O_ISC 0x0000001C // PWM Interrupt Status register
|
44 |
|
|
#define PWM_O_STATUS 0x00000020 // PWM Status register
|
45 |
|
|
|
46 |
|
|
//*****************************************************************************
|
47 |
|
|
//
|
48 |
|
|
// The following define the bit fields in the PWM Master Control register.
|
49 |
|
|
//
|
50 |
|
|
//*****************************************************************************
|
51 |
|
|
#define PWM_CTL_GLOBAL_SYNC2 0x00000004 // Global sync generator 2
|
52 |
|
|
#define PWM_CTL_GLOBAL_SYNC1 0x00000002 // Global sync generator 1
|
53 |
|
|
#define PWM_CTL_GLOBAL_SYNC0 0x00000001 // Global sync generator 0
|
54 |
|
|
|
55 |
|
|
//*****************************************************************************
|
56 |
|
|
//
|
57 |
|
|
// The following define the bit fields in the PWM Time Base Sync register.
|
58 |
|
|
//
|
59 |
|
|
//*****************************************************************************
|
60 |
|
|
#define PWM_SYNC_SYNC2 0x00000004 // Reset generator 2 counter
|
61 |
|
|
#define PWM_SYNC_SYNC1 0x00000002 // Reset generator 1 counter
|
62 |
|
|
#define PWM_SYNC_SYNC0 0x00000001 // Reset generator 0 counter
|
63 |
|
|
|
64 |
|
|
//*****************************************************************************
|
65 |
|
|
//
|
66 |
|
|
// The following define the bit fields in the PWM Output Enable register.
|
67 |
|
|
//
|
68 |
|
|
//*****************************************************************************
|
69 |
|
|
#define PWM_ENABLE_PWM5EN 0x00000020 // PWM5 pin enable
|
70 |
|
|
#define PWM_ENABLE_PWM4EN 0x00000010 // PWM4 pin enable
|
71 |
|
|
#define PWM_ENABLE_PWM3EN 0x00000008 // PWM3 pin enable
|
72 |
|
|
#define PWM_ENABLE_PWM2EN 0x00000004 // PWM2 pin enable
|
73 |
|
|
#define PWM_ENABLE_PWM1EN 0x00000002 // PWM1 pin enable
|
74 |
|
|
#define PWM_ENABLE_PWM0EN 0x00000001 // PWM0 pin enable
|
75 |
|
|
|
76 |
|
|
//*****************************************************************************
|
77 |
|
|
//
|
78 |
|
|
// The following define the bit fields in the PWM Inversion register.
|
79 |
|
|
//
|
80 |
|
|
//*****************************************************************************
|
81 |
|
|
#define PWM_INVERT_PWM5INV 0x00000020 // PWM5 pin invert
|
82 |
|
|
#define PWM_INVERT_PWM4INV 0x00000010 // PWM4 pin invert
|
83 |
|
|
#define PWM_INVERT_PWM3INV 0x00000008 // PWM3 pin invert
|
84 |
|
|
#define PWM_INVERT_PWM2INV 0x00000004 // PWM2 pin invert
|
85 |
|
|
#define PWM_INVERT_PWM1INV 0x00000002 // PWM1 pin invert
|
86 |
|
|
#define PWM_INVERT_PWM0INV 0x00000001 // PWM0 pin invert
|
87 |
|
|
|
88 |
|
|
//*****************************************************************************
|
89 |
|
|
//
|
90 |
|
|
// The following define the bit fields in the PWM Fault register.
|
91 |
|
|
//
|
92 |
|
|
//*****************************************************************************
|
93 |
|
|
#define PWM_FAULT_FAULT5 0x00000020 // PWM5 pin fault
|
94 |
|
|
#define PWM_FAULT_FAULT4 0x00000010 // PWM5 pin fault
|
95 |
|
|
#define PWM_FAULT_FAULT3 0x00000008 // PWM5 pin fault
|
96 |
|
|
#define PWM_FAULT_FAULT2 0x00000004 // PWM5 pin fault
|
97 |
|
|
#define PWM_FAULT_FAULT1 0x00000002 // PWM5 pin fault
|
98 |
|
|
#define PWM_FAULT_FAULT0 0x00000001 // PWM5 pin fault
|
99 |
|
|
|
100 |
|
|
//*****************************************************************************
|
101 |
|
|
//
|
102 |
|
|
// PWM Interrupt Register bit definitions.
|
103 |
|
|
//
|
104 |
|
|
//*****************************************************************************
|
105 |
|
|
#define PWM_INT_INTFAULT 0x00010000 // Fault interrupt pending
|
106 |
|
|
|
107 |
|
|
//*****************************************************************************
|
108 |
|
|
//
|
109 |
|
|
// The following define the bit fields in the PWM Status register.
|
110 |
|
|
//
|
111 |
|
|
//*****************************************************************************
|
112 |
|
|
#define PWM_STATUS_FAULT 0x00000001 // Fault status
|
113 |
|
|
|
114 |
|
|
//*****************************************************************************
|
115 |
|
|
//
|
116 |
|
|
// PWM Generator standard offsets.
|
117 |
|
|
//
|
118 |
|
|
//*****************************************************************************
|
119 |
|
|
#define PWM_GEN_0_OFFSET 0x00000040 // PWM0 base
|
120 |
|
|
#define PWM_GEN_1_OFFSET 0x00000080 // PWM1 base
|
121 |
|
|
#define PWM_GEN_2_OFFSET 0x000000C0 // PWM2 base
|
122 |
|
|
|
123 |
|
|
#define PWM_O_X_CTL 0x00000000 // Gen Control Reg
|
124 |
|
|
#define PWM_O_X_INTEN 0x00000004 // Gen Int/Trig Enable Reg
|
125 |
|
|
#define PWM_O_X_RIS 0x00000008 // Gen Raw Int Status Reg
|
126 |
|
|
#define PWM_O_X_ISC 0x0000000C // Gen Int Status Reg
|
127 |
|
|
#define PWM_O_X_LOAD 0x00000010 // Gen Load Reg
|
128 |
|
|
#define PWM_O_X_COUNT 0x00000014 // Gen Counter Reg
|
129 |
|
|
#define PWM_O_X_CMPA 0x00000018 // Gen Compare A Reg
|
130 |
|
|
#define PWM_O_X_CMPB 0x0000001C // Gen Compare B Reg
|
131 |
|
|
#define PWM_O_X_GENA 0x00000020 // Gen Generator A Ctrl Reg
|
132 |
|
|
#define PWM_O_X_GENB 0x00000024 // Gen Generator B Ctrl Reg
|
133 |
|
|
#define PWM_O_X_DBCTL 0x00000028 // Gen Dead Band Ctrl Reg
|
134 |
|
|
#define PWM_O_X_DBRISE 0x0000002C // Gen DB Rising Edge Delay Reg
|
135 |
|
|
#define PWM_O_X_DBFALL 0x00000030 // Gen DB Falling Edge Delay Reg
|
136 |
|
|
|
137 |
|
|
//*****************************************************************************
|
138 |
|
|
//
|
139 |
|
|
// PWM_X Control Register bit definitions.
|
140 |
|
|
//
|
141 |
|
|
//*****************************************************************************
|
142 |
|
|
#define PWM_X_CTL_ENABLE 0x00000001 // Master enable for gen block
|
143 |
|
|
#define PWM_X_CTL_MODE 0x00000002 // Counter mode, down or up/down
|
144 |
|
|
#define PWM_X_CTL_DEBUG 0x00000004 // Debug mode
|
145 |
|
|
#define PWM_X_CTL_LOADUPD 0x00000008 // Update mode for the load reg
|
146 |
|
|
#define PWM_X_CTL_CMPAUPD 0x00000010 // Update mode for comp A reg
|
147 |
|
|
#define PWM_X_CTL_CMPBUPD 0x00000020 // Update mode for comp B reg
|
148 |
|
|
|
149 |
|
|
//*****************************************************************************
|
150 |
|
|
//
|
151 |
|
|
// PWM_X Interrupt/Trigger Enable Register bit definitions.
|
152 |
|
|
//
|
153 |
|
|
//*****************************************************************************
|
154 |
|
|
#define PWM_X_INTEN_INTCNTZERO 0x00000001 // Int if COUNT = 0
|
155 |
|
|
#define PWM_X_INTEN_INTCNTLOAD 0x00000002 // Int if COUNT = LOAD
|
156 |
|
|
#define PWM_X_INTEN_INTCMPAU 0x00000004 // Int if COUNT = CMPA U
|
157 |
|
|
#define PWM_X_INTEN_INTCMPAD 0x00000008 // Int if COUNT = CMPA D
|
158 |
|
|
#define PWM_X_INTEN_INTCMPBU 0x00000010 // Int if COUNT = CMPA U
|
159 |
|
|
#define PWM_X_INTEN_INTCMPBD 0x00000020 // Int if COUNT = CMPA D
|
160 |
|
|
#define PWM_X_INTEN_TRCNTZERO 0x00000100 // Trig if COUNT = 0
|
161 |
|
|
#define PWM_X_INTEN_TRCNTLOAD 0x00000200 // Trig if COUNT = LOAD
|
162 |
|
|
#define PWM_X_INTEN_TRCMPAU 0x00000400 // Trig if COUNT = CMPA U
|
163 |
|
|
#define PWM_X_INTEN_TRCMPAD 0x00000800 // Trig if COUNT = CMPA D
|
164 |
|
|
#define PWM_X_INTEN_TRCMPBU 0x00001000 // Trig if COUNT = CMPA U
|
165 |
|
|
#define PWM_X_INTEN_TRCMPBD 0x00002000 // Trig if COUNT = CMPA D
|
166 |
|
|
|
167 |
|
|
//*****************************************************************************
|
168 |
|
|
//
|
169 |
|
|
// PWM_X Raw Interrupt Status Register bit definitions.
|
170 |
|
|
//
|
171 |
|
|
//*****************************************************************************
|
172 |
|
|
#define PWM_X_RIS_INTCNTZERO 0x00000001 // PWM_X_COUNT = 0 int
|
173 |
|
|
#define PWM_X_RIS_INTCNTLOAD 0x00000002 // PWM_X_COUNT = PWM_X_LOAD int
|
174 |
|
|
#define PWM_X_RIS_INTCMPAU 0x00000004 // PWM_X_COUNT = PWM_X_CMPA U int
|
175 |
|
|
#define PWM_X_RIS_INTCMPAD 0x00000008 // PWM_X_COUNT = PWM_X_CMPA D int
|
176 |
|
|
#define PWM_X_RIS_INTCMPBU 0x00000010 // PWM_X_COUNT = PWM_X_CMPB U int
|
177 |
|
|
#define PWM_X_RIS_INTCMPBD 0x00000020 // PWM_X_COUNT = PWM_X_CMPB D int
|
178 |
|
|
|
179 |
|
|
//*****************************************************************************
|
180 |
|
|
//
|
181 |
|
|
// PWM_X Interrupt Status Register bit definitions.
|
182 |
|
|
//
|
183 |
|
|
//*****************************************************************************
|
184 |
|
|
#define PWM_X_INT_INTCNTZERO 0x00000001 // PWM_X_COUNT = 0 received
|
185 |
|
|
#define PWM_X_INT_INTCNTLOAD 0x00000002 // PWM_X_COUNT = PWM_X_LOAD rcvd
|
186 |
|
|
#define PWM_X_INT_INTCMPAU 0x00000004 // PWM_X_COUNT = PWM_X_CMPA U rcvd
|
187 |
|
|
#define PWM_X_INT_INTCMPAD 0x00000008 // PWM_X_COUNT = PWM_X_CMPA D rcvd
|
188 |
|
|
#define PWM_X_INT_INTCMPBU 0x00000010 // PWM_X_COUNT = PWM_X_CMPB U rcvd
|
189 |
|
|
#define PWM_X_INT_INTCMPBD 0x00000020 // PWM_X_COUNT = PWM_X_CMPB D rcvd
|
190 |
|
|
|
191 |
|
|
//*****************************************************************************
|
192 |
|
|
//
|
193 |
|
|
// PWM_X Generator A/B Control Register bit definitions.
|
194 |
|
|
//
|
195 |
|
|
//*****************************************************************************
|
196 |
|
|
#define PWM_X_GEN_Y_ACTZERO 0x00000003 // Act PWM_X_COUNT = 0
|
197 |
|
|
#define PWM_X_GEN_Y_ACTLOAD 0x0000000C // Act PWM_X_COUNT = PWM_X_LOAD
|
198 |
|
|
#define PWM_X_GEN_Y_ACTCMPAU 0x00000030 // Act PWM_X_COUNT = PWM_X_CMPA U
|
199 |
|
|
#define PWM_X_GEN_Y_ACTCMPAD 0x000000C0 // Act PWM_X_COUNT = PWM_X_CMPA D
|
200 |
|
|
#define PWM_X_GEN_Y_ACTCMPBU 0x00000300 // Act PWM_X_COUNT = PWM_X_CMPB U
|
201 |
|
|
#define PWM_X_GEN_Y_ACTCMPBD 0x00000C00 // Act PWM_X_COUNT = PWM_X_CMPB D
|
202 |
|
|
|
203 |
|
|
//*****************************************************************************
|
204 |
|
|
//
|
205 |
|
|
// PWM_X Generator A/B Control Register action definitions.
|
206 |
|
|
//
|
207 |
|
|
//*****************************************************************************
|
208 |
|
|
#define PWM_GEN_ACT_NONE 0x0 // Do nothing
|
209 |
|
|
#define PWM_GEN_ACT_INV 0x1 // Invert the output signal
|
210 |
|
|
#define PWM_GEN_ACT_ZERO 0x2 // Set the output signal to zero
|
211 |
|
|
#define PWM_GEN_ACT_ONE 0x3 // Set the output signal to one
|
212 |
|
|
#define PWM_GEN_ACT_ZERO_SHIFT 0 // Shift amount for the zero action
|
213 |
|
|
#define PWM_GEN_ACT_LOAD_SHIFT 2 // Shift amount for the load action
|
214 |
|
|
#define PWM_GEN_ACT_A_UP_SHIFT 4 // Shift amount for the A up action
|
215 |
|
|
#define PWM_GEN_ACT_A_DN_SHIFT 6 // Shift amount for the A dn action
|
216 |
|
|
#define PWM_GEN_ACT_B_UP_SHIFT 8 // Shift amount for the B up action
|
217 |
|
|
#define PWM_GEN_ACT_B_DN_SHIFT 10 // Shift amount for the B dn action
|
218 |
|
|
|
219 |
|
|
//*****************************************************************************
|
220 |
|
|
//
|
221 |
|
|
// PWM_X Dead Band Control Register bit definitions.
|
222 |
|
|
//
|
223 |
|
|
//*****************************************************************************
|
224 |
|
|
#define PWM_DBCTL_ENABLE 0x00000001 // Enable dead band insertion
|
225 |
|
|
|
226 |
|
|
//*****************************************************************************
|
227 |
|
|
//
|
228 |
|
|
// PWM Register reset values.
|
229 |
|
|
//
|
230 |
|
|
//*****************************************************************************
|
231 |
|
|
#define PWM_RV_CTL 0x00000000 // Master control of the PWM module
|
232 |
|
|
#define PWM_RV_SYNC 0x00000000 // Counter synch for PWM generators
|
233 |
|
|
#define PWM_RV_ENABLE 0x00000000 // Master enable for the PWM
|
234 |
|
|
// output pins
|
235 |
|
|
#define PWM_RV_INVERT 0x00000000 // Inversion control for
|
236 |
|
|
// PWM output pins
|
237 |
|
|
#define PWM_RV_FAULT 0x00000000 // Fault handling for the PWM
|
238 |
|
|
// output pins
|
239 |
|
|
#define PWM_RV_INTEN 0x00000000 // Interrupt enable
|
240 |
|
|
#define PWM_RV_RIS 0x00000000 // Raw interrupt status
|
241 |
|
|
#define PWM_RV_ISC 0x00000000 // Interrupt status and clearing
|
242 |
|
|
#define PWM_RV_STATUS 0x00000000 // Status
|
243 |
|
|
#define PWM_RV_X_CTL 0x00000000 // Master control of the PWM
|
244 |
|
|
// generator block
|
245 |
|
|
#define PWM_RV_X_INTEN 0x00000000 // Interrupt and trigger enable
|
246 |
|
|
#define PWM_RV_X_RIS 0x00000000 // Raw interrupt status
|
247 |
|
|
#define PWM_RV_X_ISC 0x00000000 // Interrupt status and clearing
|
248 |
|
|
#define PWM_RV_X_LOAD 0x00000000 // The load value for the counter
|
249 |
|
|
#define PWM_RV_X_COUNT 0x00000000 // The current counter value
|
250 |
|
|
#define PWM_RV_X_CMPA 0x00000000 // The comparator A value
|
251 |
|
|
#define PWM_RV_X_CMPB 0x00000000 // The comparator B value
|
252 |
|
|
#define PWM_RV_X_GENA 0x00000000 // Controls PWM generator A
|
253 |
|
|
#define PWM_RV_X_GENB 0x00000000 // Controls PWM generator B
|
254 |
|
|
#define PWM_RV_X_DBCTL 0x00000000 // Control the dead band generator
|
255 |
|
|
#define PWM_RV_X_DBRISE 0x00000000 // The dead band rising edge delay
|
256 |
|
|
// count
|
257 |
|
|
#define PWM_RV_X_DBFALL 0x00000000 // The dead band falling edge delay
|
258 |
|
|
// count
|
259 |
|
|
|
260 |
|
|
#endif // __HW_PWM_H__
|