MotorWare f2806x Driver API Documentation
pll.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--*/
38 
39 
40 // **************************************************************************
41 // the includes
42 
44 
45 
46 // **************************************************************************
47 // the defines
48 
49 
50 // **************************************************************************
51 // the globals
52 
53 
54 // **************************************************************************
55 // the functions
56 
57 void PLL_disable(PLL_Handle pllHandle)
58 {
59  PLL_Obj *pll = (PLL_Obj *)pllHandle;
60 
61 
63 
64  // set the bits
66 
68 
69  return;
70 } // end of PLL_disable() function
71 
72 
74 {
75  PLL_Obj *pll = (PLL_Obj *)pllHandle;
76 
77 
79 
80  // set the bits
82 
84 
85  return;
86 } // end of PLL_disableClkDetect() function
87 
88 
90 {
91  PLL_Obj *pll = (PLL_Obj *)pllHandle;
92 
93 
95 
96  // clear the bits
98 
100 
101  return;
102 } // end of PLL_disableNormRdy() function
103 
104 
105 void PLL_disableOsc(PLL_Handle pllHandle)
106 {
107  PLL_Obj *pll = (PLL_Obj *)pllHandle;
108 
109 
111 
112  // set the bits
114 
116 
117  return;
118 } // end of PLL_disableOsc() function
119 
120 
121 void PLL_enable(PLL_Handle pllHandle)
122 {
123  PLL_Obj *pll = (PLL_Obj *)pllHandle;
124 
125 
127 
128  // clear the bits
129  pll->PLLSTS &= (~PLL_PLLSTS_PLLOFF_BITS);
130 
132 
133  return;
134 } // end of PLL_enable() function
135 
136 
138 {
139  PLL_Obj *pll = (PLL_Obj *)pllHandle;
140 
141 
143 
144  // clear the bits
145  pll->PLLSTS &= (~PLL_PLLSTS_MCLKOFF_BITS);
146 
148 
149  return;
150 } // end of PLL_enableClkDetect() function
151 
152 
154 {
155  PLL_Obj *pll = (PLL_Obj *)pllHandle;
156 
157 
159 
160  // set the bits
161  pll->PLLSTS |= (uint16_t)PLL_PLLSTS_NORMRDYE_BITS;
162 
164 
165  return;
166 } // end of PLL_enableNormRdy() function
167 
168 
169 void PLL_enableOsc(PLL_Handle pllHandle)
170 {
171  PLL_Obj *pll = (PLL_Obj *)pllHandle;
172 
173 
175 
176  // clear the bits
177  pll->PLLSTS &= (~PLL_PLLSTS_OSCOFF_BITS);
178 
180 
181  return;
182 } // end of PLL_enableOsc() function
183 
184 
186 {
187  PLL_Obj *pll = (PLL_Obj *)pllHandle;
188 
189 
190  // get the clock rate
192 
193  return(clkFreq);
194 } // end of PLL_getClkFreq() function
195 
196 
198 {
199  PLL_Obj *pll = (PLL_Obj *)pllHandle;
200 
201  // mask the bits
203 
204  return(status);
205 } // end of PLL_getClkStatus() function
206 
207 
209 {
210  PLL_Obj *pll = (PLL_Obj *)pllHandle;
211 
212  // mask the bits
214 
215  return(divSelect);
216 } // end of PLL_getDivideSelect() function
217 
218 
220 {
221  volatile PLL_Obj *pll = (PLL_Obj *)pllHandle;
222 
223 
224  // mask the bits
226 
227  return(status);
228 } // end of PLL_getLockStatus() function
229 
230 
231 PLL_Handle PLL_init(void *pMemory, const size_t numBytes)
232 {
233  PLL_Handle pllHandle;
234 
235 
236  if(numBytes < sizeof(PLL_Obj))
237  return((PLL_Handle)NULL);
238 
239  // assign the handle
240  pllHandle = (PLL_Handle)pMemory;
241 
242  return(pllHandle);
243 } // end of PLL_init() function
244 
245 
247 {
248  PLL_Obj *pll = (PLL_Obj *)pllHandle;
249 
250 
252 
253  // set the bits
255 
257 
258  return;
259 } // end of PLL_resetClkDetect() function
260 
261 
262 void PLL_setClkFreq(PLL_Handle pllHandle,const PLL_ClkFreq_e clkFreq)
263 {
264  PLL_Obj *pll = (PLL_Obj *)pllHandle;
265 
266 
268 
269  // set the bits
270  pll->PLLCR = clkFreq;
271 
273 
274  return;
275 } // end of PLL_setClkFreq() function
276 
277 
278 void PLL_setDivideSelect(PLL_Handle pllHandle,const PLL_DivideSelect_e divSelect)
279 {
280  PLL_Obj *pll = (PLL_Obj *)pllHandle;
281 
282 
284 
285  // clear the bits
286  pll->PLLSTS &= (~PLL_PLLSTS_DIVSEL_BITS);
287 
288  // set the bits
289  pll->PLLSTS |= divSelect;
290 
292 
293  return;
294 } // end of PLL_setDivideSelect() function
295 
296 
297 void PLL_setLockPeriod(PLL_Handle pllHandle, const uint16_t lockPeriod)
298 {
299  PLL_Obj *pll = (PLL_Obj *)pllHandle;
300 
301 
303 
304  // set the bits
305  pll->PLLLOCKPRD = lockPeriod;
306 
308 
309  return;
310 } // end of PLL_setLockPeriod() function
311 
312 
313 // end of file
void PLL_disableClkDetect(PLL_Handle pllHandle)
Disables the clock detect logic.
Definition: pll.c:73
#define DISABLE_PROTECTED_REGISTER_WRITE_MODE
Define to disable protected register writes.
Definition: cpu.h:101
#define PLL_PLLSTS_MCLKOFF_BITS
Defines the location of the MCLKOFF bits in the PLLSTS register.
Definition: pll.h:99
#define PLL_PLLSTS_PLLLOCKS_BITS
Defines the location of the PLLLOCKS bits in the PLLSTS register.
Definition: pll.h:79
#define PLL_PLLSTS_NORMRDYE_BITS
Defines the location of the NORMRDYE bits in the PLLSTS register.
Definition: pll.h:107
void PLL_enable(PLL_Handle pllHandle)
Enables the phase lock loop (PLL)
Definition: pll.c:121
volatile uint16_t PLLSTS
PLL Status Register.
Definition: pll.h:171
#define PLL_PLLSTS_OSCOFF_BITS
Defines the location of the OSCOFF bits in the PLLSTS register.
Definition: pll.h:95
PLL_LockStatus_e PLL_getLockStatus(PLL_Handle pllHandle)
Gets the phase lock loop (PLL) lock status.
Definition: pll.c:219
void PLL_disableNormRdy(PLL_Handle pllHandle)
Disables the NORMRDY signal.
Definition: pll.c:89
#define PLL_PLLSTS_MCLKCLR_BITS
Defines the location of the MCLKCLR bits in the PLLSTS register.
Definition: pll.h:91
PLL_ClkStatus_e PLL_getClkStatus(PLL_Handle pllHandle)
Gets the phase lock loop (PLL) clock status.
Definition: pll.c:197
void PLL_disable(PLL_Handle pllHandle)
Disables the phase lock loop (PLL)
Definition: pll.c:57
#define ENABLE_PROTECTED_REGISTER_WRITE_MODE
Define to allow protected register writes.
Definition: cpu.h:93
void PLL_setDivideSelect(PLL_Handle pllHandle, const PLL_DivideSelect_e divSelect)
Sets the phase lock loop (PLL) divide select value.
Definition: pll.c:278
PLL_ClkFreq_e PLL_getClkFreq(PLL_Handle pllHandle)
Gets the phase lock loop (PLL) clock frequency.
Definition: pll.c:185
void PLL_disableOsc(PLL_Handle pllHandle)
Disables the oscillator.
Definition: pll.c:105
void PLL_enableNormRdy(PLL_Handle pllHandle)
Enables the NORMRDY signal.
Definition: pll.c:153
struct _PLL_Obj_ * PLL_Handle
Defines the phase lock loop (PLL) handle.
Definition: pll.h:181
void PLL_enableClkDetect(PLL_Handle pllHandle)
Enables the clock detect logic.
Definition: pll.c:137
Contains public interface to various functions related to the phase-locked loop (PLL) object...
Defines the phase lock loop (PLL) object.
Definition: pll.h:169
void PLL_setClkFreq(PLL_Handle pllHandle, const PLL_ClkFreq_e clkFreq)
Sets the phase lock loop (PLL) clock frequency.
Definition: pll.c:262
PLL_ClkFreq_e
Enumeration to define the phase lock loop (PLL) clock frequency.
Definition: pll.h:116
PLL_DivideSelect_e
Enumeration to define the phase lock loop (PLL) divide select.
Definition: pll.h:141
#define PLL_PLLSTS_PLLOFF_BITS
Defines the location of the PLLOFF bits in the PLLSTS register.
Definition: pll.h:83
PLL_DivideSelect_e PLL_getDivideSelect(PLL_Handle pllHandle)
Gets the phase lock loop (PLL) divide select value.
Definition: pll.c:208
#define PLL_PLLCR_DIV_BITS
Defines the location of the DIV bits in the PLLCR register.
Definition: pll.h:74
void PLL_setLockPeriod(PLL_Handle pllHandle, const uint16_t lockPeriod)
Sets the phase lock loop (PLL) lock time.
Definition: pll.c:297
volatile uint16_t PLLLOCKPRD
PLL Lock Period Register.
Definition: pll.h:173
PLL_Handle PLL_init(void *pMemory, const size_t numBytes)
Initializes the phase lock loop (PLL) object handle.
Definition: pll.c:231
#define PLL_PLLSTS_MCLKSTS_BITS
Defines the location of the MCLKSTS bits in the PLLSTS register.
Definition: pll.h:87
volatile uint16_t PLLCR
PLL Control Register.
Definition: pll.h:175
void PLL_resetClkDetect(PLL_Handle pllHandle)
Resets the phase lock loop (PLL) clock detect logic.
Definition: pll.c:246
#define PLL_PLLSTS_DIVSEL_BITS
Defines the location of the DIVSEL bits in the PLLSTS register.
Definition: pll.h:103
PLL_LockStatus_e
Enumeration to define the phase lock loop (PLL) clock lock status.
Definition: pll.h:160
PLL_ClkStatus_e
Enumeration to define the phase lock loop (PLL) clock status.
Definition: pll.h:151
void PLL_enableOsc(PLL_Handle pllHandle)
Enables the oscillator.
Definition: pll.c:169