1 |
581 |
jeremybenn |
//*****************************************************************************
|
2 |
|
|
//
|
3 |
|
|
// pwm.h - API function protoypes 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 635 of the Stellaris Driver Library.
|
25 |
|
|
//
|
26 |
|
|
//*****************************************************************************
|
27 |
|
|
|
28 |
|
|
#ifndef __PWM_H__
|
29 |
|
|
#define __PWM_H__
|
30 |
|
|
|
31 |
|
|
#ifdef __cplusplus
|
32 |
|
|
extern "C"
|
33 |
|
|
{
|
34 |
|
|
#endif
|
35 |
|
|
|
36 |
|
|
//*****************************************************************************
|
37 |
|
|
//
|
38 |
|
|
// The following defines are passed to PWMGenConfigure() as the ulConfig
|
39 |
|
|
// parameter and specify the configuration of the PWM generator.
|
40 |
|
|
//
|
41 |
|
|
//*****************************************************************************
|
42 |
|
|
#define PWM_GEN_MODE_DOWN 0x00000000 // Down count mode
|
43 |
|
|
#define PWM_GEN_MODE_UP_DOWN 0x00000002 // Up/Down count mode
|
44 |
|
|
#define PWM_GEN_MODE_SYNC 0x00000038 // Synchronous updates
|
45 |
|
|
#define PWM_GEN_MODE_NO_SYNC 0x00000000 // Immediate updates
|
46 |
|
|
#define PWM_GEN_MODE_DBG_RUN 0x00000004 // Continue running in debug mode
|
47 |
|
|
#define PWM_GEN_MODE_DBG_STOP 0x00000000 // Stop running in debug mode
|
48 |
|
|
|
49 |
|
|
//*****************************************************************************
|
50 |
|
|
//
|
51 |
|
|
// Defines for enabling, disabling, and clearing PWM generator interrupts and
|
52 |
|
|
// triggers.
|
53 |
|
|
//
|
54 |
|
|
//*****************************************************************************
|
55 |
|
|
#define PWM_INT_CNT_ZERO 0x00000001 // Int if COUNT = 0
|
56 |
|
|
#define PWM_INT_CNT_LOAD 0x00000002 // Int if COUNT = LOAD
|
57 |
|
|
#define PWM_INT_CNT_AU 0x00000004 // Int if COUNT = CMPA U
|
58 |
|
|
#define PWM_INT_CNT_AD 0x00000008 // Int if COUNT = CMPA D
|
59 |
|
|
#define PWM_INT_CNT_BU 0x00000010 // Int if COUNT = CMPA U
|
60 |
|
|
#define PWM_INT_CNT_BD 0x00000020 // Int if COUNT = CMPA D
|
61 |
|
|
#define PWM_TR_CNT_ZERO 0x00000100 // Trig if COUNT = 0
|
62 |
|
|
#define PWM_TR_CNT_LOAD 0x00000200 // Trig if COUNT = LOAD
|
63 |
|
|
#define PWM_TR_CNT_AU 0x00000400 // Trig if COUNT = CMPA U
|
64 |
|
|
#define PWM_TR_CNT_AD 0x00000800 // Trig if COUNT = CMPA D
|
65 |
|
|
#define PWM_TR_CNT_BU 0x00001000 // Trig if COUNT = CMPA U
|
66 |
|
|
#define PWM_TR_CNT_BD 0x00002000 // Trig if COUNT = CMPA D
|
67 |
|
|
|
68 |
|
|
//*****************************************************************************
|
69 |
|
|
//
|
70 |
|
|
// Defines for enabling, disabling, and clearing PWM interrupts.
|
71 |
|
|
//
|
72 |
|
|
//*****************************************************************************
|
73 |
|
|
#define PWM_INT_GEN_0 0x00000001 // Generator 0 interrupt
|
74 |
|
|
#define PWM_INT_GEN_1 0x00000002 // Generator 1 interrupt
|
75 |
|
|
#define PWM_INT_GEN_2 0x00000004 // Generator 2 interrupt
|
76 |
|
|
#define PWM_INT_FAULT 0x00010000 // Fault interrupt
|
77 |
|
|
|
78 |
|
|
//*****************************************************************************
|
79 |
|
|
//
|
80 |
|
|
// Defines to identify the generators within a module.
|
81 |
|
|
//
|
82 |
|
|
//*****************************************************************************
|
83 |
|
|
#define PWM_GEN_0 0x00000040 // Offset address of Gen0
|
84 |
|
|
#define PWM_GEN_1 0x00000080 // Offset address of Gen1
|
85 |
|
|
#define PWM_GEN_2 0x000000C0 // Offset address of Gen2
|
86 |
|
|
|
87 |
|
|
#define PWM_GEN_0_BIT 0x00000001 // Bit-wise ID for Gen0
|
88 |
|
|
#define PWM_GEN_1_BIT 0x00000002 // Bit-wise ID for Gen1
|
89 |
|
|
#define PWM_GEN_2_BIT 0x00000004 // Bit-wise ID for Gen2
|
90 |
|
|
|
91 |
|
|
//*****************************************************************************
|
92 |
|
|
//
|
93 |
|
|
// Defines to identify the outputs within a module.
|
94 |
|
|
//
|
95 |
|
|
//*****************************************************************************
|
96 |
|
|
#define PWM_OUT_0 0x00000040 // Encoded offset address of PWM0
|
97 |
|
|
#define PWM_OUT_1 0x00000041 // Encoded offset address of PWM1
|
98 |
|
|
#define PWM_OUT_2 0x00000082 // Encoded offset address of PWM2
|
99 |
|
|
#define PWM_OUT_3 0x00000083 // Encoded offset address of PWM3
|
100 |
|
|
#define PWM_OUT_4 0x000000C4 // Encoded offset address of PWM4
|
101 |
|
|
#define PWM_OUT_5 0x000000C5 // Encoded offset address of PWM5
|
102 |
|
|
|
103 |
|
|
#define PWM_OUT_0_BIT 0x00000001 // Bit-wise ID for PWM0
|
104 |
|
|
#define PWM_OUT_1_BIT 0x00000002 // Bit-wise ID for PWM1
|
105 |
|
|
#define PWM_OUT_2_BIT 0x00000004 // Bit-wise ID for PWM2
|
106 |
|
|
#define PWM_OUT_3_BIT 0x00000008 // Bit-wise ID for PWM3
|
107 |
|
|
#define PWM_OUT_4_BIT 0x00000010 // Bit-wise ID for PWM4
|
108 |
|
|
#define PWM_OUT_5_BIT 0x00000020 // Bit-wise ID for PWM5
|
109 |
|
|
|
110 |
|
|
//*****************************************************************************
|
111 |
|
|
//
|
112 |
|
|
// API Function prototypes
|
113 |
|
|
//
|
114 |
|
|
//*****************************************************************************
|
115 |
|
|
extern void PWMGenConfigure(unsigned long ulBase, unsigned long ulGen,
|
116 |
|
|
unsigned long ulConfig);
|
117 |
|
|
extern void PWMGenPeriodSet(unsigned long ulBase, unsigned long ulGen,
|
118 |
|
|
unsigned long ulPeriod);
|
119 |
|
|
extern unsigned long PWMGenPeriodGet(unsigned long ulBase,
|
120 |
|
|
unsigned long ulGen);
|
121 |
|
|
extern void PWMGenEnable(unsigned long ulBase, unsigned long ulGen);
|
122 |
|
|
extern void PWMGenDisable(unsigned long ulBase, unsigned long ulGen);
|
123 |
|
|
extern void PWMPulseWidthSet(unsigned long ulBase, unsigned long ulPWMOut,
|
124 |
|
|
unsigned long ulWidth);
|
125 |
|
|
extern unsigned long PWMPulseWidthGet(unsigned long ulBase,
|
126 |
|
|
unsigned long ulPWMOut);
|
127 |
|
|
extern void PWMDeadBandEnable(unsigned long ulBase, unsigned long ulGen,
|
128 |
|
|
unsigned short usRise, unsigned short usFall);
|
129 |
|
|
extern void PWMDeadBandDisable(unsigned long ulBase, unsigned long ulGen);
|
130 |
|
|
extern void PWMSyncUpdate(unsigned long ulBase, unsigned long ulGenBits);
|
131 |
|
|
extern void PWMSyncTimeBase(unsigned long ulBase, unsigned long ulGenBits);
|
132 |
|
|
extern void PWMOutputState(unsigned long ulBase, unsigned long ulPWMOutBits,
|
133 |
|
|
tBoolean bEnable);
|
134 |
|
|
extern void PWMOutputInvert(unsigned long ulBase, unsigned long ulPWMOutBits,
|
135 |
|
|
tBoolean bInvert);
|
136 |
|
|
extern void PWMOutputFault(unsigned long ulBase, unsigned long ulPWMOutBits,
|
137 |
|
|
tBoolean bFaultKill);
|
138 |
|
|
extern void PWMGenIntRegister(unsigned long ulBase, unsigned long ulGen,
|
139 |
|
|
void (*pfIntHandler)(void));
|
140 |
|
|
extern void PWMGenIntUnregister(unsigned long ulBase, unsigned long ulGen);
|
141 |
|
|
extern void PWMFaultIntRegister(unsigned long ulBase,
|
142 |
|
|
void (*pfIntHandler)(void));
|
143 |
|
|
extern void PWMFaultIntUnregister(unsigned long ulBase);
|
144 |
|
|
extern void PWMGenIntTrigEnable(unsigned long ulBase, unsigned long ulGen,
|
145 |
|
|
unsigned long ulIntTrig);
|
146 |
|
|
extern void PWMGenIntTrigDisable(unsigned long ulBase, unsigned long ulGen,
|
147 |
|
|
unsigned long ulIntTrig);
|
148 |
|
|
extern unsigned long PWMGenIntStatus(unsigned long ulBase, unsigned long ulGen,
|
149 |
|
|
tBoolean bMasked);
|
150 |
|
|
extern void PWMGenIntClear(unsigned long ulBase, unsigned long ulGen,
|
151 |
|
|
unsigned long ulInts);
|
152 |
|
|
extern void PWMIntEnable(unsigned long ulBase, unsigned long ulGenFault);
|
153 |
|
|
extern void PWMIntDisable(unsigned long ulBase, unsigned long ulGenFault);
|
154 |
|
|
extern void PWMFaultIntClear(unsigned long ulBase);
|
155 |
|
|
extern unsigned long PWMIntStatus(unsigned long ulBase, tBoolean bMasked);
|
156 |
|
|
|
157 |
|
|
#ifdef __cplusplus
|
158 |
|
|
}
|
159 |
|
|
#endif
|
160 |
|
|
|
161 |
|
|
#endif // __PWM_H__
|