OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [Common/] [drivers/] [LuminaryMicro/] [pwm.h] - Blame information for rev 610

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.