MotorWare f2806x Driver API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

cap.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2 * Copyright (c) 2015, Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * --/COPYRIGHT--*/
37
38
39 // **************************************************************************
40 // the includes
41 #include "sw/drivers/cap/src/32b/f28x/f2806x/cap.h"
42
43
44 // **************************************************************************
45 // the defines
46
47
48 // **************************************************************************
49 // the globals
50
51
52 // **************************************************************************
53 // the functions
54
55
56 CAP_Handle CAP_init(void *pMemory, const size_t numBytes)
57 {
58 CAP_Handle capHandle;
59
60
61 if(numBytes < sizeof(CAP_Obj))
62 return((CAP_Handle)NULL);
63
64 // assign the handle
65 capHandle = (CAP_Handle)pMemory;
66
67 return(capHandle);
68 } // end of CAP_init() function
69
70 void CAP_disableCaptureLoad(CAP_Handle capHandle)
71 {
72 CAP_Obj *cap = (CAP_Obj *)capHandle;
73
74 // clear the bits
75 cap->ECCTL1 &= ~CAP_ECCTL1_CAPLDEN_BITS;
76
77 return;
78 } // end of CAP_disableCaptureLoad() function
79
80 void CAP_disableSyncIn(CAP_Handle capHandle)
81 {
82 CAP_Obj *cap = (CAP_Obj *)capHandle;
83
84
85 // set the bit
86 cap->ECCTL2 &= ~CAP_ECCTL2_SYNCIEN_BITS;
87
88 return;
89 } // end of CAP_disableSyncIn() function
90
91 void CAP_disableInt(CAP_Handle capHandle, const CAP_Int_Type_e intType)
92 {
93 CAP_Obj *cap = (CAP_Obj *)capHandle;
94
95
96 // clear the bits
97 cap->ECEINT &= ~intType;
98
99 return;
100 } // end of CAP_disableInt() function
101
102 void CAP_disableTimestampCounter(CAP_Handle capHandle)
103 {
104 CAP_Obj *cap = (CAP_Obj *)capHandle;
105
106 // clear the bits
107 cap->ECCTL2 &= ~CAP_ECCTL2_TSCTRSTOP_BITS;
108
109 return;
110 } // end of CAP_disableTimestampCounter() function
111
112 void CAP_enableCaptureLoad(CAP_Handle capHandle)
113 {
114 CAP_Obj *cap = (CAP_Obj *)capHandle;
115
116 // clear the bits
117 cap->ECCTL1 |= CAP_ECCTL1_CAPLDEN_BITS;
118
119 return;
120 } // end of CAP_enableCaptureLoad() function
121
122 void CAP_enableInt(CAP_Handle capHandle, const CAP_Int_Type_e intType)
123 {
124 CAP_Obj *cap = (CAP_Obj *)capHandle;
125
126
127 // clear the bits
128 cap->ECEINT |= intType;
129
130 return;
131 } // end of CAP_enableInt() function
132
133 void CAP_enableSyncIn(CAP_Handle capHandle)
134 {
135 CAP_Obj *cap = (CAP_Obj *)capHandle;
136
137
138 // set the bit
139 cap->ECCTL2 |= CAP_ECCTL2_SYNCIEN_BITS;
140
141 return;
142 } // end of CAP_enableSyncIn() function
143
144 void CAP_enableTimestampCounter(CAP_Handle capHandle)
145 {
146 CAP_Obj *cap = (CAP_Obj *)capHandle;
147
148 // clear the bits
149 cap->ECCTL2 |= CAP_ECCTL2_TSCTRSTOP_BITS;
150
151 return;
152 } // end of CAP_enableTimestampCounter() function
153
154 void CAP_setCapEvtPolarity(CAP_Handle capHandle, const CAP_Event_e event, const CAP_Polarity_e polarity)
155 {
156 CAP_Obj *cap = (CAP_Obj *)capHandle;
157
158 // clear the bits
159 cap->ECCTL1 &= ~(1 << (2 * event));
160
161 // Set the new value
162 cap->ECCTL1 |= (polarity << (2 * event));
163
164 return;
165 } // end of CAP_setCapEvtPolarity() function
166
167 void CAP_setCapEvtReset(CAP_Handle capHandle, const CAP_Event_e event, const CAP_Reset_e reset)
168 {
169 CAP_Obj *cap = (CAP_Obj *)capHandle;
170
171 // clear the bits
172 cap->ECCTL1 &= ~(1 << (1 + (2 * event)));
173
174 // Set the new value
175 cap->ECCTL1 |= (reset << (1 + (2 * event)));
176
177 return;
178 } // end of CAP_setCapEvtReset() function
179
180 void CAP_setCapContinuous(CAP_Handle capHandle)
181 {
182 CAP_Obj *cap = (CAP_Obj *)capHandle;
183
184
185 // clear the bits
186 cap->ECCTL2 &= (~CAP_ECCTL2_CONTONESHOT_BITS);
187
188 return;
189 } // end of CAP_setCapContinuous() function
190
191 void CAP_setCapOneShot(CAP_Handle capHandle)
192 {
193 CAP_Obj *cap = (CAP_Obj *)capHandle;
194
195
196 // clear the bits
197 cap->ECCTL2 |= CAP_ECCTL2_CONTONESHOT_BITS;
198
199 return;
200 } // end of CAP_setCapOneShot() function
201
202 void CAP_setModeCap(CAP_Handle capHandle)
203 {
204 CAP_Obj *cap = (CAP_Obj *)capHandle;
205
206
207 // clear the bits
208 cap->ECCTL2 &= (~CAP_ECCTL2_CAPAPWM_BITS);
209
210 return;
211 } // end of CAP_setModeCap() function
212
213 void CAP_setModeApwm(CAP_Handle capHandle)
214 {
215 CAP_Obj *cap = (CAP_Obj *)capHandle;
216
217
218 // clear the bits
219 cap->ECCTL2 |= CAP_ECCTL2_CAPAPWM_BITS;
220
221 return;
222 } // end of CAP_setModeApwm() function
223
224 void CAP_setStopWrap(CAP_Handle capHandle, const CAP_Stop_Wrap_e stopWrap)
225 {
226 CAP_Obj *cap = (CAP_Obj *)capHandle;
227
228
229 // clear the bits
230 cap->ECCTL2 &= (~CAP_ECCTL2_STOP_WRAP_BITS);
231
232 // Set the new value
233 cap->ECCTL2 |= stopWrap;
234
235 return;
236 } // end of CAP_setStopWrap() function
237
238 void CAP_setSyncOut(CAP_Handle capHandle, const CAP_SyncOut_e syncOut)
239 {
240 CAP_Obj *cap = (CAP_Obj *)capHandle;
241
242
243 // clear the bits
244 cap->ECCTL2 &= (~CAP_ECCTL2_SYNCOSEL_BITS);
245
246 // Set the new value
247 cap->ECCTL2 |= syncOut;
248
249 return;
250 } // end of CAP_setSyncOut() function
251
252 // end of file
CAP_setModeApwm
void CAP_setModeApwm(CAP_Handle capHandle)
Sets capture peripheral up for APWM mode.
Definition: cap.c:213
CAP_disableInt
void CAP_disableInt(CAP_Handle capHandle, const CAP_Int_Type_e intType)
Disables capture (CAP) interrupt source.
Definition: cap.c:91
CAP_setModeCap
void CAP_setModeCap(CAP_Handle capHandle)
Sets capture peripheral up for capture mode.
Definition: cap.c:202
CAP_enableSyncIn
void CAP_enableSyncIn(CAP_Handle capHandle)
Enables counter synchronization.
Definition: cap.c:133
_CAP_Obj_::ECEINT
volatile uint16_t ECEINT
Capture Interrupt Enable Register.
Definition: cap.h:323
_CAP_Obj_
Defines the capture (CAP) object.
Definition: cap.h:312
CAP_disableSyncIn
void CAP_disableSyncIn(CAP_Handle capHandle)
Disables counter synchronization.
Definition: cap.c:80
CAP_Handle
struct _CAP_Obj_ * CAP_Handle
Defines the capture (CAP) handle.
Definition: cap.h:333
CAP_setCapEvtReset
void CAP_setCapEvtReset(CAP_Handle capHandle, const CAP_Event_e event, const CAP_Reset_e reset)
Sets the capture event counter reset configuration.
Definition: cap.c:167
CAP_ECCTL2_CAPAPWM_BITS
#define CAP_ECCTL2_CAPAPWM_BITS
Defines the location of the CAP/APWM bits in the ECCTL2 register.
Definition: cap.h:132
CAP_Int_Type_e
CAP_Int_Type_e
Enumeration to define the capture (CAP) interrupts.
Definition: cap.h:203
CAP_setSyncOut
void CAP_setSyncOut(CAP_Handle capHandle, const CAP_SyncOut_e syncOut)
Set the sync out mode.
Definition: cap.c:238
CAP_enableCaptureLoad
void CAP_enableCaptureLoad(CAP_Handle capHandle)
Enables loading of CAP1-4 on capture event.
Definition: cap.c:112
_CAP_Obj_::ECCTL1
volatile uint16_t ECCTL1
Capture Control Register 1.
Definition: cap.h:321
CAP_disableCaptureLoad
void CAP_disableCaptureLoad(CAP_Handle capHandle)
Disables loading of CAP1-4 on capture event.
Definition: cap.c:70
CAP_setCapEvtPolarity
void CAP_setCapEvtPolarity(CAP_Handle capHandle, const CAP_Event_e event, const CAP_Polarity_e polarity)
Sets the capture event polarity.
Definition: cap.c:154
CAP_setStopWrap
void CAP_setStopWrap(CAP_Handle capHandle, const CAP_Stop_Wrap_e stopWrap)
Set the stop/wrap mode.
Definition: cap.c:224
CAP_Stop_Wrap_e
CAP_Stop_Wrap_e
Enumeration to define the capture (CAP) Stop/Wrap modes.
Definition: cap.h:265
CAP_enableTimestampCounter
void CAP_enableTimestampCounter(CAP_Handle capHandle)
Enables Time Stamp counter to running.
Definition: cap.c:144
CAP_ECCTL2_STOP_WRAP_BITS
#define CAP_ECCTL2_STOP_WRAP_BITS
Defines the location of the STOP_WRAP bits in the ECCTL2 register.
Definition: cap.h:156
CAP_SyncOut_e
CAP_SyncOut_e
Enumeration to define the Sync Out options.
Definition: cap.h:302
CAP_ECCTL2_SYNCIEN_BITS
#define CAP_ECCTL2_SYNCIEN_BITS
Defines the location of the SYNCI_EN bits in the ECCTL2 register.
Definition: cap.h:144
CAP_Polarity_e
CAP_Polarity_e
Enumeration to define the capture (CAP) event polarities.
Definition: cap.h:285
CAP_disableTimestampCounter
void CAP_disableTimestampCounter(CAP_Handle capHandle)
Disables Time Stamp counter from running.
Definition: cap.c:102
CAP_Reset_e
CAP_Reset_e
Enumeration to define the capture (CAP) event resets.
Definition: cap.h:294
CAP_ECCTL2_CONTONESHOT_BITS
#define CAP_ECCTL2_CONTONESHOT_BITS
Defines the location of the CONT/ONESHOT bits in the ECCTL2 register.
Definition: cap.h:160
CAP_ECCTL1_CAPLDEN_BITS
#define CAP_ECCTL1_CAPLDEN_BITS
Defines the location of the CAPLDEN bits in the ECCTL1 register.
Definition: cap.h:91
_CAP_Obj_::ECCTL2
volatile uint16_t ECCTL2
Capture Control Register 2.
Definition: cap.h:322
CAP_ECCTL2_SYNCOSEL_BITS
#define CAP_ECCTL2_SYNCOSEL_BITS
Defines the location of the SYNCO_SEL bits in the ECCTL2 register.
Definition: cap.h:140
cap.h
Contains public interface to various functions related to the Enhanced Capture (CAP) object...
CAP_ECCTL2_TSCTRSTOP_BITS
#define CAP_ECCTL2_TSCTRSTOP_BITS
Defines the location of the TSCTRSTOP bits in the ECCTL2 register.
Definition: cap.h:148
CAP_init
CAP_Handle CAP_init(void *pMemory, const size_t numBytes)
Initializes the capture (CAP) object handle.
Definition: cap.c:56
CAP_enableInt
void CAP_enableInt(CAP_Handle capHandle, const CAP_Int_Type_e intType)
Enables capture (CAP) interrupt source.
Definition: cap.c:122
CAP_Event_e
CAP_Event_e
Enumeration to define the capture (CAP) events.
Definition: cap.h:275
CAP_setCapContinuous
void CAP_setCapContinuous(CAP_Handle capHandle)
Sets up for continuous Capture.
Definition: cap.c:180
CAP_setCapOneShot
void CAP_setCapOneShot(CAP_Handle capHandle)
Sets up for one-shot Capture.
Definition: cap.c:191