MotorWare f2806x Driver API Documentation
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
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 
71 {
72  CAP_Obj *cap = (CAP_Obj *)capHandle;
73 
74  // clear the bits
76 
77  return;
78 } // end of CAP_disableCaptureLoad() function
79 
81 {
82  CAP_Obj *cap = (CAP_Obj *)capHandle;
83 
84 
85  // set the bit
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 
103 {
104  CAP_Obj *cap = (CAP_Obj *)capHandle;
105 
106  // clear the bits
108 
109  return;
110 } // end of CAP_disableTimestampCounter() function
111 
113 {
114  CAP_Obj *cap = (CAP_Obj *)capHandle;
115 
116  // clear the 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 
134 {
135  CAP_Obj *cap = (CAP_Obj *)capHandle;
136 
137 
138  // set the bit
140 
141  return;
142 } // end of CAP_enableSyncIn() function
143 
145 {
146  CAP_Obj *cap = (CAP_Obj *)capHandle;
147 
148  // clear the 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 
181 {
182  CAP_Obj *cap = (CAP_Obj *)capHandle;
183 
184 
185  // clear the bits
187 
188  return;
189 } // end of CAP_setCapContinuous() function
190 
192 {
193  CAP_Obj *cap = (CAP_Obj *)capHandle;
194 
195 
196  // clear the 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 
214 {
215  CAP_Obj *cap = (CAP_Obj *)capHandle;
216 
217 
218  // clear the 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
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
void CAP_setModeApwm(CAP_Handle capHandle)
Sets capture peripheral up for APWM mode.
Definition: cap.c:213
void CAP_disableInt(CAP_Handle capHandle, const CAP_Int_Type_e intType)
Disables capture (CAP) interrupt source.
Definition: cap.c:91
void CAP_setModeCap(CAP_Handle capHandle)
Sets capture peripheral up for capture mode.
Definition: cap.c:202
void CAP_enableSyncIn(CAP_Handle capHandle)
Enables counter synchronization.
Definition: cap.c:133
volatile uint16_t ECEINT
Capture Interrupt Enable Register.
Definition: cap.h:323
Defines the capture (CAP) object.
Definition: cap.h:312
void CAP_disableSyncIn(CAP_Handle capHandle)
Disables counter synchronization.
Definition: cap.c:80
struct _CAP_Obj_ * CAP_Handle
Defines the capture (CAP) handle.
Definition: cap.h:333
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
#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
Enumeration to define the capture (CAP) interrupts.
Definition: cap.h:203
void CAP_setSyncOut(CAP_Handle capHandle, const CAP_SyncOut_e syncOut)
Set the sync out mode.
Definition: cap.c:238
void CAP_enableCaptureLoad(CAP_Handle capHandle)
Enables loading of CAP1-4 on capture event.
Definition: cap.c:112
volatile uint16_t ECCTL1
Capture Control Register 1.
Definition: cap.h:321
void CAP_disableCaptureLoad(CAP_Handle capHandle)
Disables loading of CAP1-4 on capture event.
Definition: cap.c:70
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
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
Enumeration to define the capture (CAP) Stop/Wrap modes.
Definition: cap.h:265
void CAP_enableTimestampCounter(CAP_Handle capHandle)
Enables Time Stamp counter to running.
Definition: cap.c:144
#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
Enumeration to define the Sync Out options.
Definition: cap.h:302
#define CAP_ECCTL2_SYNCIEN_BITS
Defines the location of the SYNCI_EN bits in the ECCTL2 register.
Definition: cap.h:144
CAP_Polarity_e
Enumeration to define the capture (CAP) event polarities.
Definition: cap.h:285
void CAP_disableTimestampCounter(CAP_Handle capHandle)
Disables Time Stamp counter from running.
Definition: cap.c:102
CAP_Reset_e
Enumeration to define the capture (CAP) event resets.
Definition: cap.h:294
#define CAP_ECCTL2_CONTONESHOT_BITS
Defines the location of the CONT/ONESHOT bits in the ECCTL2 register.
Definition: cap.h:160
#define CAP_ECCTL1_CAPLDEN_BITS
Defines the location of the CAPLDEN bits in the ECCTL1 register.
Definition: cap.h:91
volatile uint16_t ECCTL2
Capture Control Register 2.
Definition: cap.h:322
#define CAP_ECCTL2_SYNCOSEL_BITS
Defines the location of the SYNCO_SEL bits in the ECCTL2 register.
Definition: cap.h:140
Contains public interface to various functions related to the Enhanced Capture (CAP) object...
#define CAP_ECCTL2_TSCTRSTOP_BITS
Defines the location of the TSCTRSTOP bits in the ECCTL2 register.
Definition: cap.h:148
CAP_Handle CAP_init(void *pMemory, const size_t numBytes)
Initializes the capture (CAP) object handle.
Definition: cap.c:56
void CAP_enableInt(CAP_Handle capHandle, const CAP_Int_Type_e intType)
Enables capture (CAP) interrupt source.
Definition: cap.c:122
CAP_Event_e
Enumeration to define the capture (CAP) events.
Definition: cap.h:275
void CAP_setCapContinuous(CAP_Handle capHandle)
Sets up for continuous Capture.
Definition: cap.c:180
void CAP_setCapOneShot(CAP_Handle capHandle)
Sets up for one-shot Capture.
Definition: cap.c:191