MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

drv8301kit_revD/f28x/f2806x/src/hal.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2 * Copyright (c) 2012, 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--*/
36
37
38 // **************************************************************************
39 // the includes
40
41 // drivers
42
43 // modules
44
45 // platforms
46 #include "hal.h"
47 #include "user.h"
48 #include "hal_obj.h"
49
50 #ifdef FLASH
51 #pragma CODE_SECTION(HAL_setupFlash,"ramfuncs");
52 #endif
53
54 // **************************************************************************
55 // the defines
56
57
58 // **************************************************************************
59 // the globals
60
61 HAL_Obj hal;
62
63
64 // **************************************************************************
65 // the functions
66
67 void HAL_cal(HAL_Handle handle)
68 {
69 HAL_Obj *obj = (HAL_Obj *)handle;
70
71
72 // enable the ADC clock
73 CLK_enableAdcClock(obj->clkHandle);
74
75
76 // Run the Device_cal() function
77 // This function copies the ADC and oscillator calibration values from TI reserved
78 // OTP into the appropriate trim registers
79 // This boot ROM automatically calls this function to calibrate the interal
80 // oscillators and ADC with device specific calibration data.
81 // If the boot ROM is bypassed by Code Composer Studio during the development process,
82 // then the calibration must be initialized by the application
83 ENABLE_PROTECTED_REGISTER_WRITE_MODE;
84 (*Device_cal)();
85 DISABLE_PROTECTED_REGISTER_WRITE_MODE;
86
87 // run offsets calibration in user's memory
88 HAL_AdcOffsetSelfCal(handle);
89
90 // run oscillator compensation
91 HAL_OscTempComp(handle);
92
93 // disable the ADC clock
94 CLK_disableAdcClock(obj->clkHandle);
95
96 return;
97 } // end of HAL_cal() function
98
99
100 void HAL_OscTempComp(HAL_Handle handle)
101 {
102 HAL_Obj *obj = (HAL_Obj *)handle;
103 uint16_t Temperature;
104
105 // disable the ADCs
106 ADC_disable(obj->adcHandle);
107
108 // power up the bandgap circuit
109 ADC_enableBandGap(obj->adcHandle);
110
111 // set the ADC voltage reference source to internal
112 ADC_setVoltRefSrc(obj->adcHandle,ADC_VoltageRefSrc_Int);
113
114 // enable the ADC reference buffers
115 ADC_enableRefBuffers(obj->adcHandle);
116
117 // Set main clock scaling factor (max45MHz clock for the ADC module)
118 ADC_setDivideSelect(obj->adcHandle,ADC_DivideSelect_ClkIn_by_2);
119
120 // power up the ADCs
121 ADC_powerUp(obj->adcHandle);
122
123 // enable the ADCs
124 ADC_enable(obj->adcHandle);
125
126 // enable non-overlap mode
127 ADC_enableNoOverlapMode(obj->adcHandle);
128
129 // connect channel A5 internally to the temperature sensor
130 ADC_setTempSensorSrc(obj->adcHandle, ADC_TempSensorSrc_Int);
131
132 // set SOC0 channel select to ADCINA5
133 ADC_setSocChanNumber(obj->adcHandle, ADC_SocNumber_0, ADC_SocChanNumber_A5);
134
135 // set SOC0 acquisition period to 26 ADCCLK
136 ADC_setSocSampleDelay(obj->adcHandle, ADC_SocNumber_0, ADC_SocSampleDelay_64_cycles);
137
138 // connect ADCINT1 to EOC0
139 ADC_setIntSrc(obj->adcHandle, ADC_IntNumber_1, ADC_IntSrc_EOC0);
140
141 // clear ADCINT1 flag
142 ADC_clearIntFlag(obj->adcHandle, ADC_IntNumber_1);
143
144 // enable ADCINT1
145 ADC_enableInt(obj->adcHandle, ADC_IntNumber_1);
146
147 // force start of conversion on SOC0
148 ADC_setSocFrc(obj->adcHandle, ADC_SocFrc_0);
149
150 // wait for end of conversion
151 while (ADC_getIntFlag(obj->adcHandle, ADC_IntNumber_1) == 0){}
152
153 // clear ADCINT1 flag
154 ADC_clearIntFlag(obj->adcHandle, ADC_IntNumber_1);
155
156 Temperature = ADC_readResult(obj->adcHandle, ADC_ResultNumber_0);
157
158 HAL_osc1Comp(handle, Temperature);
159
160 HAL_osc2Comp(handle, Temperature);
161
162 return;
163 } // end of HAL_OscTempComp() function
164
165
166 void HAL_osc1Comp(HAL_Handle handle, const int16_t sensorSample)
167 {
168 int16_t compOscFineTrim;
169 HAL_Obj *obj = (HAL_Obj *)handle;
170
171 ENABLE_PROTECTED_REGISTER_WRITE_MODE;
172
173 compOscFineTrim = ((sensorSample - getRefTempOffset())*(int32_t)getOsc1FineTrimSlope()
174 + OSC_POSTRIM_OFF + FP_ROUND )/FP_SCALE + getOsc1FineTrimOffset() - OSC_POSTRIM;
175
176 if(compOscFineTrim > 31)
177 {
178 compOscFineTrim = 31;
179 }
180 else if(compOscFineTrim < -31)
181 {
182 compOscFineTrim = -31;
183 }
184
185 OSC_setTrim(obj->oscHandle, OSC_Number_1, HAL_getOscTrimValue(getOsc1CoarseTrim(), compOscFineTrim));
186
187 DISABLE_PROTECTED_REGISTER_WRITE_MODE;
188
189 return;
190 } // end of HAL_osc1Comp() function
191
192
193 void HAL_osc2Comp(HAL_Handle handle, const int16_t sensorSample)
194 {
195 int16_t compOscFineTrim;
196 HAL_Obj *obj = (HAL_Obj *)handle;
197
198 ENABLE_PROTECTED_REGISTER_WRITE_MODE;
199
200 compOscFineTrim = ((sensorSample - getRefTempOffset())*(int32_t)getOsc2FineTrimSlope()
201 + OSC_POSTRIM_OFF + FP_ROUND )/FP_SCALE + getOsc2FineTrimOffset() - OSC_POSTRIM;
202
203 if(compOscFineTrim > 31)
204 {
205 compOscFineTrim = 31;
206 }
207 else if(compOscFineTrim < -31)
208 {
209 compOscFineTrim = -31;
210 }
211
212 OSC_setTrim(obj->oscHandle, OSC_Number_2, HAL_getOscTrimValue(getOsc2CoarseTrim(), compOscFineTrim));
213
214 DISABLE_PROTECTED_REGISTER_WRITE_MODE;
215
216 return;
217 } // end of HAL_osc2Comp() function
218
219
220 uint16_t HAL_getOscTrimValue(int16_t coarse, int16_t fine)
221 {
222 uint16_t regValue = 0;
223
224 if(fine < 0)
225 {
226 regValue = ((-fine) | 0x20) << 9;
227 }
228 else
229 {
230 regValue = fine << 9;
231 }
232
233 if(coarse < 0)
234 {
235 regValue |= ((-coarse) | 0x80);
236 }
237 else
238 {
239 regValue |= coarse;
240 }
241
242 return regValue;
243 } // end of HAL_getOscTrimValue() function
244
245
246 void HAL_AdcOffsetSelfCal(HAL_Handle handle)
247 {
248 HAL_Obj *obj = (HAL_Obj *)handle;
249 uint16_t AdcConvMean;
250
251 // disable the ADCs
252 ADC_disable(obj->adcHandle);
253
254 // power up the bandgap circuit
255 ADC_enableBandGap(obj->adcHandle);
256
257 // set the ADC voltage reference source to internal
258 ADC_setVoltRefSrc(obj->adcHandle,ADC_VoltageRefSrc_Int);
259
260 // enable the ADC reference buffers
261 ADC_enableRefBuffers(obj->adcHandle);
262
263 // Set main clock scaling factor (max45MHz clock for the ADC module)
264 ADC_setDivideSelect(obj->adcHandle,ADC_DivideSelect_ClkIn_by_2);
265
266 // power up the ADCs
267 ADC_powerUp(obj->adcHandle);
268
269 // enable the ADCs
270 ADC_enable(obj->adcHandle);
271
272 //Select VREFLO internal connection on B5
273 ADC_enableVoltRefLoConv(obj->adcHandle);
274
275 //Select channel B5 for all SOC
276 HAL_AdcCalChanSelect(handle, ADC_SocChanNumber_B5);
277
278 //Apply artificial offset (+80) to account for a negative offset that may reside in the ADC core
279 ADC_setOffTrim(obj->adcHandle, 80);
280
281 //Capture ADC conversion on VREFLO
282 AdcConvMean = HAL_AdcCalConversion(handle);
283
284 //Set offtrim register with new value (i.e remove artical offset (+80) and create a two's compliment of the offset error)
285 ADC_setOffTrim(obj->adcHandle, 80 - AdcConvMean);
286
287 //Select external ADCIN5 input pin on B5
288 ADC_disableVoltRefLoConv(obj->adcHandle);
289
290 return;
291 } // end of HAL_AdcOffsetSelfCal() function
292
293
294 void HAL_AdcCalChanSelect(HAL_Handle handle, const ADC_SocChanNumber_e chanNumber)
295 {
296 HAL_Obj *obj = (HAL_Obj *)handle;
297
298 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_0,chanNumber);
299 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_1,chanNumber);
300 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_2,chanNumber);
301 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_3,chanNumber);
302 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_4,chanNumber);
303 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_5,chanNumber);
304 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_6,chanNumber);
305 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_7,chanNumber);
306 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_8,chanNumber);
307 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_9,chanNumber);
308 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_10,chanNumber);
309 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_11,chanNumber);
310 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_12,chanNumber);
311 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_13,chanNumber);
312 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_14,chanNumber);
313 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_15,chanNumber);
314
315 return;
316 } // end of HAL_AdcCalChanSelect() function
317
318
319 uint16_t HAL_AdcCalConversion(HAL_Handle handle)
320 {
321 HAL_Obj *obj = (HAL_Obj *)handle;
322 uint16_t index, SampleSize, Mean;
323 uint32_t Sum;
324 ADC_SocSampleDelay_e ACQPS_Value;
325
326 index = 0; //initialize index to 0
327 SampleSize = 256; //set sample size to 256 (**NOTE: Sample size must be multiples of 2^x where is an integer >= 4)
328 Sum = 0; //set sum to 0
329 Mean = 999; //initialize mean to known value
330
331 //Set the ADC sample window to the desired value (Sample window = ACQPS + 1)
332 ACQPS_Value = ADC_SocSampleDelay_7_cycles;
333
334 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_0,ACQPS_Value);
335 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_1,ACQPS_Value);
336 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_2,ACQPS_Value);
337 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_3,ACQPS_Value);
338 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_4,ACQPS_Value);
339 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_5,ACQPS_Value);
340 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_6,ACQPS_Value);
341 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_7,ACQPS_Value);
342 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_8,ACQPS_Value);
343 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_9,ACQPS_Value);
344 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_10,ACQPS_Value);
345 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_11,ACQPS_Value);
346 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_12,ACQPS_Value);
347 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_13,ACQPS_Value);
348 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_14,ACQPS_Value);
349 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_15,ACQPS_Value);
350
351 // Enabled ADCINT1 and ADCINT2
352 ADC_enableInt(obj->adcHandle, ADC_IntNumber_1);
353 ADC_enableInt(obj->adcHandle, ADC_IntNumber_2);
354
355 // Disable continuous sampling for ADCINT1 and ADCINT2
356 ADC_setIntMode(obj->adcHandle, ADC_IntNumber_1, ADC_IntMode_EOC);
357 ADC_setIntMode(obj->adcHandle, ADC_IntNumber_2, ADC_IntMode_EOC);
358
359 //ADCINTs trigger at end of conversion
360 ADC_setIntPulseGenMode(obj->adcHandle, ADC_IntPulseGenMode_Prior);
361
362 // Setup ADCINT1 and ADCINT2 trigger source
363 ADC_setIntSrc(obj->adcHandle, ADC_IntNumber_1, ADC_IntSrc_EOC6);
364 ADC_setIntSrc(obj->adcHandle, ADC_IntNumber_2, ADC_IntSrc_EOC14);
365
366 // Setup each SOC's ADCINT trigger source
367 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_0, ADC_Int2TriggersSOC);
368 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_1, ADC_Int2TriggersSOC);
369 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_2, ADC_Int2TriggersSOC);
370 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_3, ADC_Int2TriggersSOC);
371 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_4, ADC_Int2TriggersSOC);
372 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_5, ADC_Int2TriggersSOC);
373 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_6, ADC_Int2TriggersSOC);
374 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_7, ADC_Int2TriggersSOC);
375 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_8, ADC_Int1TriggersSOC);
376 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_9, ADC_Int1TriggersSOC);
377 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_10, ADC_Int1TriggersSOC);
378 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_11, ADC_Int1TriggersSOC);
379 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_12, ADC_Int1TriggersSOC);
380 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_13, ADC_Int1TriggersSOC);
381 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_14, ADC_Int1TriggersSOC);
382 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_15, ADC_Int1TriggersSOC);
383
384 // Delay before converting ADC channels
385 usDelay(ADC_DELAY_usec);
386
387 ADC_setSocFrcWord(obj->adcHandle, 0x00FF);
388
389 while( index < SampleSize )
390 {
391 //Wait for ADCINT1 to trigger, then add ADCRESULT0-7 registers to sum
392 while (ADC_getIntFlag(obj->adcHandle, ADC_IntNumber_1) == 0){}
393
394 //Must clear ADCINT1 flag since INT1CONT = 0
395 ADC_clearIntFlag(obj->adcHandle, ADC_IntNumber_1);
396
397 Sum += ADC_readResult(obj->adcHandle, ADC_ResultNumber_0);
398 Sum += ADC_readResult(obj->adcHandle, ADC_ResultNumber_1);
399 Sum += ADC_readResult(obj->adcHandle, ADC_ResultNumber_2);
400 Sum += ADC_readResult(obj->adcHandle, ADC_ResultNumber_3);
401 Sum += ADC_readResult(obj->adcHandle, ADC_ResultNumber_4);
402 Sum += ADC_readResult(obj->adcHandle, ADC_ResultNumber_5);
403 Sum += ADC_readResult(obj->adcHandle, ADC_ResultNumber_6);
404 Sum += ADC_readResult(obj->adcHandle, ADC_ResultNumber_7);
405
406 //Wait for ADCINT2 to trigger, then add ADCRESULT8-15 registers to sum
407 while (ADC_getIntFlag(obj->adcHandle, ADC_IntNumber_2) == 0){}
408
409 //Must clear ADCINT2 flag since INT2CONT = 0
410 ADC_clearIntFlag(obj->adcHandle, ADC_IntNumber_2);
411
412 Sum += ADC_readResult(obj->adcHandle, ADC_ResultNumber_8);
413 Sum += ADC_readResult(obj->adcHandle, ADC_ResultNumber_9);
414 Sum += ADC_readResult(obj->adcHandle, ADC_ResultNumber_10);
415 Sum += ADC_readResult(obj->adcHandle, ADC_ResultNumber_11);
416 Sum += ADC_readResult(obj->adcHandle, ADC_ResultNumber_12);
417 Sum += ADC_readResult(obj->adcHandle, ADC_ResultNumber_13);
418 Sum += ADC_readResult(obj->adcHandle, ADC_ResultNumber_14);
419 Sum += ADC_readResult(obj->adcHandle, ADC_ResultNumber_15);
420
421 index+=16;
422
423 } // end data collection
424
425 //Disable ADCINT1 and ADCINT2 to STOP the ping-pong sampling
426 ADC_disableInt(obj->adcHandle, ADC_IntNumber_1);
427 ADC_disableInt(obj->adcHandle, ADC_IntNumber_2);
428
429 //Calculate average ADC sample value
430 Mean = Sum / SampleSize;
431
432 // Clear start of conversion trigger
433 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_0, ADC_NoIntTriggersSOC);
434 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_1, ADC_NoIntTriggersSOC);
435 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_2, ADC_NoIntTriggersSOC);
436 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_3, ADC_NoIntTriggersSOC);
437 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_4, ADC_NoIntTriggersSOC);
438 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_5, ADC_NoIntTriggersSOC);
439 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_6, ADC_NoIntTriggersSOC);
440 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_7, ADC_NoIntTriggersSOC);
441 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_8, ADC_NoIntTriggersSOC);
442 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_9, ADC_NoIntTriggersSOC);
443 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_10, ADC_NoIntTriggersSOC);
444 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_11, ADC_NoIntTriggersSOC);
445 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_12, ADC_NoIntTriggersSOC);
446 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_13, ADC_NoIntTriggersSOC);
447 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_14, ADC_NoIntTriggersSOC);
448 ADC_setupSocTrigSrc(obj->adcHandle, ADC_SocNumber_15, ADC_NoIntTriggersSOC);
449
450 //return the average
451 return(Mean);
452 } // end of HAL_AdcCalConversion() function
453
454
455 void HAL_disableWdog(HAL_Handle halHandle)
456 {
457 HAL_Obj *hal = (HAL_Obj *)halHandle;
458
459
460 WDOG_disable(hal->wdogHandle);
461
462
463 return;
464 } // end of HAL_disableWdog() function
465
466
467 void HAL_disableGlobalInts(HAL_Handle handle)
468 {
469 HAL_Obj *obj = (HAL_Obj *)handle;
470
471
472 CPU_disableGlobalInts(obj->cpuHandle);
473
474 return;
475 } // end of HAL_disableGlobalInts() function
476
477
478 void HAL_enableAdcInts(HAL_Handle handle)
479 {
480 HAL_Obj *obj = (HAL_Obj *)handle;
481
482
483 // enable the PIE interrupts associated with the ADC interrupts
484 PIE_enableAdcInt(obj->pieHandle,ADC_IntNumber_1);
485
486
487 // enable the ADC interrupts
488 ADC_enableInt(obj->adcHandle,ADC_IntNumber_1);
489
490
491 // enable the cpu interrupt for ADC interrupts
492 CPU_enableInt(obj->cpuHandle,CPU_IntNumber_10);
493
494 return;
495 } // end of HAL_enableAdcInts() function
496
497
498 void HAL_enableDebugInt(HAL_Handle handle)
499 {
500 HAL_Obj *obj = (HAL_Obj *)handle;
501
502
503 CPU_enableDebugInt(obj->cpuHandle);
504
505 return;
506 } // end of HAL_enableDebugInt() function
507
508
509 void HAL_enableDrv(HAL_Handle handle)
510 {
511 HAL_Obj *obj = (HAL_Obj *)handle;
512
513 DRV8301_enable(obj->drv8301Handle);
514
515 return;
516 } // end of HAL_enableDrv() function
517
518
519 void HAL_enableGlobalInts(HAL_Handle handle)
520 {
521 HAL_Obj *obj = (HAL_Obj *)handle;
522
523
524 CPU_enableGlobalInts(obj->cpuHandle);
525
526 return;
527 } // end of HAL_enableGlobalInts() function
528
529
530 void HAL_enablePwmInt(HAL_Handle handle)
531 {
532 HAL_Obj *obj = (HAL_Obj *)handle;
533
534
535 PIE_enablePwmInt(obj->pieHandle,PWM_Number_1);
536
537
538 // enable the interrupt
539 PWM_enableInt(obj->pwmHandle[PWM_Number_1]);
540
541
542 // enable the cpu interrupt for EPWM1_INT
543 CPU_enableInt(obj->cpuHandle,CPU_IntNumber_3);
544
545 return;
546 } // end of HAL_enablePwmInt() function
547
548
549 void HAL_enableTimer0Int(HAL_Handle handle)
550 {
551 HAL_Obj *obj = (HAL_Obj *)handle;
552
553
554 PIE_enableTimer0Int(obj->pieHandle);
555
556
557 // enable the interrupt
558 TIMER_enableInt(obj->timerHandle[0]);
559
560
561 // enable the cpu interrupt for TINT0
562 CPU_enableInt(obj->cpuHandle,CPU_IntNumber_1);
563
564 return;
565 } // end of HAL_enablePwmInt() function
566
567
568 void HAL_setupFaults(HAL_Handle handle)
569 {
570 HAL_Obj *obj = (HAL_Obj *)handle;
571 uint_least8_t cnt;
572
573
574 // Configure Trip Mechanism for the Motor control software
575 // -Cycle by cycle trip on CPU halt
576 // -One shot fault trip zone
577 // These trips need to be repeated for EPWM1 ,2 & 3
578 for(cnt=0;cnt<3;cnt++)
579 {
580 PWM_enableTripZoneSrc(obj->pwmHandle[cnt],PWM_TripZoneSrc_CycleByCycle_TZ6_NOT);
581
582 PWM_enableTripZoneSrc(obj->pwmHandle[cnt],PWM_TripZoneSrc_CycleByCycle_TZ3_NOT);
583
584 PWM_enableTripZoneSrc(obj->pwmHandle[cnt],PWM_TripZoneSrc_CycleByCycle_TZ2_NOT);
585
586 // What do we want the OST/CBC events to do?
587 // TZA events can force EPWMxA
588 // TZB events can force EPWMxB
589
590 PWM_setTripZoneState_TZA(obj->pwmHandle[cnt],PWM_TripZoneState_EPWM_Low);
591 PWM_setTripZoneState_TZB(obj->pwmHandle[cnt],PWM_TripZoneState_EPWM_Low);
592 }
593
594 return;
595 } // end of HAL_setupFaults() function
596
597
598 HAL_Handle HAL_init(void *pMemory,const size_t numBytes)
599 {
600 uint_least8_t cnt;
601 HAL_Handle handle;
602 HAL_Obj *obj;
603
604
605 if(numBytes < sizeof(HAL_Obj))
606 return((HAL_Handle)NULL);
607
608
609 // assign the handle
610 handle = (HAL_Handle)pMemory;
611
612
613 // assign the object
614 obj = (HAL_Obj *)handle;
615
616
617 // initialize the watchdog driver
618 obj->wdogHandle = WDOG_init((void *)WDOG_BASE_ADDR,sizeof(WDOG_Obj));
619
620
621 // disable watchdog
622 HAL_disableWdog(handle);
623
624
625 // initialize the ADC
626 obj->adcHandle = ADC_init((void *)ADC_BASE_ADDR,sizeof(ADC_Obj));
627
628
629 // initialize the clock handle
630 obj->clkHandle = CLK_init((void *)CLK_BASE_ADDR,sizeof(CLK_Obj));
631
632
633 // initialize the CPU handle
634 obj->cpuHandle = CPU_init(&cpu,sizeof(cpu));
635
636
637 // initialize the FLASH handle
638 obj->flashHandle = FLASH_init((void *)FLASH_BASE_ADDR,sizeof(FLASH_Obj));
639
640
641 // initialize the GPIO handle
642 obj->gpioHandle = GPIO_init((void *)GPIO_BASE_ADDR,sizeof(GPIO_Obj));
643
644
645 // initialize the current offset estimator handles
646 for(cnt=0;cnt<USER_NUM_CURRENT_SENSORS;cnt++)
647 {
648 obj->offsetHandle_I[cnt] = OFFSET_init(&obj->offset_I[cnt],sizeof(obj->offset_I[cnt]));
649 }
650
651
652 // initialize the voltage offset estimator handles
653 for(cnt=0;cnt<USER_NUM_VOLTAGE_SENSORS;cnt++)
654 {
655 obj->offsetHandle_V[cnt] = OFFSET_init(&obj->offset_V[cnt],sizeof(obj->offset_V[cnt]));
656 }
657
658
659 // initialize the oscillator handle
660 obj->oscHandle = OSC_init((void *)OSC_BASE_ADDR,sizeof(OSC_Obj));
661
662
663 // initialize the PIE handle
664 obj->pieHandle = PIE_init((void *)PIE_BASE_ADDR,sizeof(PIE_Obj));
665
666
667 // initialize the PLL handle
668 obj->pllHandle = PLL_init((void *)PLL_BASE_ADDR,sizeof(PLL_Obj));
669
670
671 // initialize the SPI handles
672 obj->spiAHandle = SPI_init((void *)SPIA_BASE_ADDR,sizeof(SPI_Obj));
673 obj->spiBHandle = SPI_init((void *)SPIB_BASE_ADDR,sizeof(SPI_Obj));
674
675
676 // initialize PWM handles
677 obj->pwmHandle[0] = PWM_init((void *)PWM_ePWM1_BASE_ADDR,sizeof(PWM_Obj));
678 obj->pwmHandle[1] = PWM_init((void *)PWM_ePWM2_BASE_ADDR,sizeof(PWM_Obj));
679 obj->pwmHandle[2] = PWM_init((void *)PWM_ePWM3_BASE_ADDR,sizeof(PWM_Obj));
680
681
682 // initialize PWM DAC handles
683 obj->pwmDacHandle[0] = PWMDAC_init((void *)PWM_ePWM6_BASE_ADDR,sizeof(PWM_Obj));
684 obj->pwmDacHandle[1] = PWMDAC_init((void *)PWM_ePWM5_BASE_ADDR,sizeof(PWM_Obj));
685 obj->pwmDacHandle[2] = PWMDAC_init((void *)PWM_ePWM4_BASE_ADDR,sizeof(PWM_Obj));
686
687
688 // initialize power handle
689 obj->pwrHandle = PWR_init((void *)PWR_BASE_ADDR,sizeof(PWR_Obj));
690
691
692 // initialize timer handles
693 obj->timerHandle[0] = TIMER_init((void *)TIMER0_BASE_ADDR,sizeof(TIMER_Obj));
694 obj->timerHandle[1] = TIMER_init((void *)TIMER1_BASE_ADDR,sizeof(TIMER_Obj));
695 obj->timerHandle[2] = TIMER_init((void *)TIMER2_BASE_ADDR,sizeof(TIMER_Obj));
696
697
698 // initialize drv8301 interface
699 obj->drv8301Handle = DRV8301_init(&obj->drv8301,sizeof(obj->drv8301));
700
701
702 #ifdef QEP
703 // initialize QEP driver
704 obj->qepHandle[0] = QEP_init((void*)QEP1_BASE_ADDR,sizeof(QEP_Obj));
705 #endif
706
707 return(handle);
708 } // end of HAL_init() function
709
710
711 void HAL_setParams(HAL_Handle handle,const USER_Params *pUserParams)
712 {
713 uint_least8_t cnt;
714 HAL_Obj *obj = (HAL_Obj *)handle;
715 _iq beta_lp_pu = _IQ(pUserParams->offsetPole_rps/(float_t)pUserParams->ctrlFreq_Hz);
716
717
718 HAL_setNumCurrentSensors(handle,pUserParams->numCurrentSensors);
719 HAL_setNumVoltageSensors(handle,pUserParams->numVoltageSensors);
720
721
722 for(cnt=0;cnt<HAL_getNumCurrentSensors(handle);cnt++)
723 {
724 HAL_setOffsetBeta_lp_pu(handle,HAL_SensorType_Current,cnt,beta_lp_pu);
725 HAL_setOffsetInitCond(handle,HAL_SensorType_Current,cnt,_IQ(0.0));
726 HAL_setOffsetValue(handle,HAL_SensorType_Current,cnt,_IQ(0.0));
727 }
728
729
730 for(cnt=0;cnt<HAL_getNumVoltageSensors(handle);cnt++)
731 {
732 HAL_setOffsetBeta_lp_pu(handle,HAL_SensorType_Voltage,cnt,beta_lp_pu);
733 HAL_setOffsetInitCond(handle,HAL_SensorType_Voltage,cnt,_IQ(0.0));
734 HAL_setOffsetValue(handle,HAL_SensorType_Voltage,cnt,_IQ(0.0));
735 }
736
737
738 // disable global interrupts
739 CPU_disableGlobalInts(obj->cpuHandle);
740
741
742 // disable cpu interrupts
743 CPU_disableInts(obj->cpuHandle);
744
745
746 // clear cpu interrupt flags
747 CPU_clearIntFlags(obj->cpuHandle);
748
749
750 // setup the clocks
751 HAL_setupClks(handle);
752
753
754 // Setup the PLL
755 HAL_setupPll(handle,PLL_ClkFreq_90_MHz);
756
757
758 // setup the PIE
759 HAL_setupPie(handle);
760
761
762 // run the device calibration
763 HAL_cal(handle);
764
765
766 // setup the peripheral clocks
767 HAL_setupPeripheralClks(handle);
768
769
770 // setup the GPIOs
771 HAL_setupGpios(handle);
772
773
774 // setup the flash
775 HAL_setupFlash(handle);
776
777
778 // setup the ADCs
779 HAL_setupAdcs(handle);
780
781
782 // setup the PWMs
783 HAL_setupPwms(handle,
784 (float_t)pUserParams->systemFreq_MHz,
785 pUserParams->pwmPeriod_usec,
786 USER_NUM_PWM_TICKS_PER_ISR_TICK);
787
788 #ifdef QEP
789 // setup the QEP
790 HAL_setupQEP(handle,HAL_Qep_QEP1);
791 #endif
792
793
794 // setup the spiA
795 HAL_setupSpiA(handle);
796
797
798 // setup the spiB
799 HAL_setupSpiB(handle);
800
801
802 // setup the PWM DACs
803 HAL_setupPwmDacs(handle);
804
805
806 // setup the timers
807 HAL_setupTimers(handle,
808 (float_t)pUserParams->systemFreq_MHz);
809
810
811 // setup the drv8301 interface
812 HAL_setupGate(handle);
813
814
815 // set the default current bias
816 {
817 uint_least8_t cnt;
818 _iq bias = _IQ12mpy(ADC_dataBias,_IQ(pUserParams->current_sf));
819
820 for(cnt=0;cnt<HAL_getNumCurrentSensors(handle);cnt++)
821 {
822 HAL_setBias(handle,HAL_SensorType_Current,cnt,bias);
823 }
824 }
825
826
827 // set the current scale factor
828 {
829 _iq current_sf = _IQ(pUserParams->current_sf);
830
831 HAL_setCurrentScaleFactor(handle,current_sf);
832 }
833
834
835 // set the default voltage bias
836 {
837 uint_least8_t cnt;
838 _iq bias = _IQ(0.0);
839
840 for(cnt=0;cnt<HAL_getNumVoltageSensors(handle);cnt++)
841 {
842 HAL_setBias(handle,HAL_SensorType_Voltage,cnt,bias);
843 }
844 }
845
846
847 // set the voltage scale factor
848 {
849 _iq voltage_sf = _IQ(pUserParams->voltage_sf);
850
851 HAL_setVoltageScaleFactor(handle,voltage_sf);
852 }
853
854 return;
855 } // end of HAL_setParams() function
856
857
858 void HAL_setupAdcs(HAL_Handle handle)
859 {
860 HAL_Obj *obj = (HAL_Obj *)handle;
861
862
863 // disable the ADCs
864 ADC_disable(obj->adcHandle);
865
866
867 // power up the bandgap circuit
868 ADC_enableBandGap(obj->adcHandle);
869
870
871 // set the ADC voltage reference source to internal
872 ADC_setVoltRefSrc(obj->adcHandle,ADC_VoltageRefSrc_Int);
873
874
875 // enable the ADC reference buffers
876 ADC_enableRefBuffers(obj->adcHandle);
877
878
879 // Set main clock scaling factor (max45MHz clock for the ADC module)
880 ADC_setDivideSelect(obj->adcHandle,ADC_DivideSelect_ClkIn_by_2);
881
882
883 // power up the ADCs
884 ADC_powerUp(obj->adcHandle);
885
886
887 // enable the ADCs
888 ADC_enable(obj->adcHandle);
889
890
891 // set the ADC interrupt pulse generation to prior
892 ADC_setIntPulseGenMode(obj->adcHandle,ADC_IntPulseGenMode_Prior);
893
894
895 // set the temperature sensor source to external
896 ADC_setTempSensorSrc(obj->adcHandle,ADC_TempSensorSrc_Ext);
897
898
899 // configure the interrupt sources
900 ADC_disableInt(obj->adcHandle,ADC_IntNumber_1);
901 ADC_setIntMode(obj->adcHandle,ADC_IntNumber_1,ADC_IntMode_ClearFlag);
902 ADC_setIntSrc(obj->adcHandle,ADC_IntNumber_1,ADC_IntSrc_EOC7);
903
904
905 //configure the SOCs for drv8301kit_revD
906 // EXT IA-FB
907 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_0,ADC_SocChanNumber_A6);
908 ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_0,ADC_SocTrigSrc_EPWM1_ADCSOCA);
909 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_0,ADC_SocSampleDelay_9_cycles);
910
911 // EXT IA-FB
912 // Duplicate conversion due to ADC Initial Conversion bug (SPRZ342)
913 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_1,ADC_SocChanNumber_A6);
914 ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_1,ADC_SocTrigSrc_EPWM1_ADCSOCA);
915 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_1,ADC_SocSampleDelay_9_cycles);
916
917 // EXT IB-FB
918 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_2,ADC_SocChanNumber_B6);
919 ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_2,ADC_SocTrigSrc_EPWM1_ADCSOCA);
920 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_2,ADC_SocSampleDelay_9_cycles);
921
922 // EXT IC-FB
923 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_3,ADC_SocChanNumber_A0);
924 ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_3,ADC_SocTrigSrc_EPWM1_ADCSOCA);
925 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_3,ADC_SocSampleDelay_9_cycles);
926
927 // ADC-Vhb1
928 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_4,ADC_SocChanNumber_B7);
929 ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_4,ADC_SocTrigSrc_EPWM1_ADCSOCA);
930 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_4,ADC_SocSampleDelay_9_cycles);
931
932 // ADC-Vhb2
933 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_5,ADC_SocChanNumber_A7);
934 ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_5,ADC_SocTrigSrc_EPWM1_ADCSOCA);
935 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_5,ADC_SocSampleDelay_9_cycles);
936
937 // ADC-Vhb3
938 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_6,ADC_SocChanNumber_B4);
939 ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_6,ADC_SocTrigSrc_EPWM1_ADCSOCA);
940 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_6,ADC_SocSampleDelay_9_cycles);
941
942 // VDCBUS
943 ADC_setSocChanNumber(obj->adcHandle,ADC_SocNumber_7,ADC_SocChanNumber_B2);
944 ADC_setSocTrigSrc(obj->adcHandle,ADC_SocNumber_7,ADC_SocTrigSrc_EPWM1_ADCSOCA);
945 ADC_setSocSampleDelay(obj->adcHandle,ADC_SocNumber_7,ADC_SocSampleDelay_9_cycles);
946
947 return;
948 } // end of HAL_setupAdcs() function
949
950
951 void HAL_setupClks(HAL_Handle handle)
952 {
953 HAL_Obj *obj = (HAL_Obj *)handle;
954
955
956 // enable internal oscillator 1
957 CLK_enableOsc1(obj->clkHandle);
958
959 // set the oscillator source
960 CLK_setOscSrc(obj->clkHandle,CLK_OscSrc_Internal);
961
962 // disable the external clock in
963 CLK_disableClkIn(obj->clkHandle);
964
965 // disable the crystal oscillator
966 CLK_disableCrystalOsc(obj->clkHandle);
967
968 // disable oscillator 2
969 CLK_disableOsc2(obj->clkHandle);
970
971 // set the low speed clock prescaler
972 CLK_setLowSpdPreScaler(obj->clkHandle,CLK_LowSpdPreScaler_SysClkOut_by_1);
973
974 // set the clock out prescaler
975 CLK_setClkOutPreScaler(obj->clkHandle,CLK_ClkOutPreScaler_SysClkOut_by_1);
976
977 return;
978 } // end of HAL_setupClks() function
979
980
981 void HAL_setupFlash(HAL_Handle handle)
982 {
983 HAL_Obj *obj = (HAL_Obj *)handle;
984
985
986 FLASH_enablePipelineMode(obj->flashHandle);
987
988 FLASH_setNumPagedReadWaitStates(obj->flashHandle,FLASH_NumPagedWaitStates_3);
989
990 FLASH_setNumRandomReadWaitStates(obj->flashHandle,FLASH_NumRandomWaitStates_3);
991
992 FLASH_setOtpWaitStates(obj->flashHandle,FLASH_NumOtpWaitStates_5);
993
994 FLASH_setStandbyWaitCount(obj->flashHandle,FLASH_STANDBY_WAIT_COUNT_DEFAULT);
995
996 FLASH_setActiveWaitCount(obj->flashHandle,FLASH_ACTIVE_WAIT_COUNT_DEFAULT);
997
998 return;
999 } // HAL_setupFlash() function
1000
1001
1002 void HAL_setupGate(HAL_Handle handle)
1003 {
1004 HAL_Obj *obj = (HAL_Obj *)handle;
1005
1006 DRV8301_setSpiHandle(obj->drv8301Handle,obj->spiBHandle);
1007 DRV8301_setGpioHandle(obj->drv8301Handle,obj->gpioHandle);
1008 DRV8301_setGpioNumber(obj->drv8301Handle,GPIO_Number_51);
1009
1010 return;
1011 } // HAL_setupGate() function
1012
1013
1014 void HAL_setupGpios(HAL_Handle handle)
1015 {
1016 HAL_Obj *obj = (HAL_Obj *)handle;
1017
1018
1019 // PWM1
1020 GPIO_setMode(obj->gpioHandle,GPIO_Number_0,GPIO_0_Mode_EPWM1A);
1021
1022 // PWM2
1023 GPIO_setMode(obj->gpioHandle,GPIO_Number_1,GPIO_1_Mode_EPWM1B);
1024
1025 // PWM3
1026 GPIO_setMode(obj->gpioHandle,GPIO_Number_2,GPIO_2_Mode_EPWM2A);
1027
1028 // PWM4
1029 GPIO_setMode(obj->gpioHandle,GPIO_Number_3,GPIO_3_Mode_EPWM2B);
1030
1031 // PWM5
1032 GPIO_setMode(obj->gpioHandle,GPIO_Number_4,GPIO_4_Mode_EPWM3A);
1033
1034 // PWM6
1035 GPIO_setMode(obj->gpioHandle,GPIO_Number_5,GPIO_5_Mode_EPWM3B);
1036
1037 // PWM-DAC4
1038 GPIO_setMode(obj->gpioHandle,GPIO_Number_6,GPIO_6_Mode_EPWM4A);
1039
1040 // Push Button SW2
1041 GPIO_setMode(obj->gpioHandle,GPIO_Number_7,GPIO_7_Mode_GeneralPurpose);
1042 GPIO_setDirection(obj->gpioHandle,GPIO_Number_7,GPIO_Direction_Input);
1043
1044 // ADCSOCAO_NOT or PWM-DAC3
1045 GPIO_setMode(obj->gpioHandle,GPIO_Number_8,GPIO_8_Mode_EPWM5A);
1046
1047 // Push Button SW1
1048 GPIO_setMode(obj->gpioHandle,GPIO_Number_9,GPIO_9_Mode_GeneralPurpose);
1049
1050 // PWM-DAC1
1051 GPIO_setMode(obj->gpioHandle,GPIO_Number_10,GPIO_10_Mode_EPWM6A);
1052
1053 // PWM-DAC2
1054 GPIO_setMode(obj->gpioHandle,GPIO_Number_11,GPIO_11_Mode_EPWM6B);
1055
1056 // DRV8301-LED1
1057 GPIO_setMode(obj->gpioHandle,GPIO_Number_12,GPIO_12_Mode_GeneralPurpose);
1058
1059 // OCTWn
1060 GPIO_setMode(obj->gpioHandle,GPIO_Number_13,GPIO_13_Mode_TZ2_NOT);
1061
1062 // FAULTn
1063 GPIO_setMode(obj->gpioHandle,GPIO_Number_14,GPIO_14_Mode_TZ3_NOT);
1064
1065 // LED2
1066 GPIO_setMode(obj->gpioHandle,GPIO_Number_15,GPIO_15_Mode_GeneralPurpose);
1067
1068 // Set Qualification Period for GPIO16-23, 22*2*(1/90MHz) = 0.48us
1069 GPIO_setQualificationPeriod(obj->gpioHandle,GPIO_Number_16,22);
1070
1071 // SPI-SIMO
1072 GPIO_setMode(obj->gpioHandle,GPIO_Number_16,GPIO_16_Mode_SPISIMOA);
1073 // GPIO_setPullup(obj->gpioHandle,GPIO_Number_16, GPIO_Pullup_Enable);
1074
1075 // SPI-SOMI
1076 GPIO_setMode(obj->gpioHandle,GPIO_Number_17,GPIO_17_Mode_SPISOMIA);
1077 // GPIO_setPullup(obj->gpioHandle,GPIO_Number_17, GPIO_Pullup_Enable);
1078
1079 // SPI-CLK
1080 GPIO_setMode(obj->gpioHandle,GPIO_Number_18,GPIO_18_Mode_SPICLKA);
1081 // GPIO_setPullup(obj->gpioHandle,GPIO_Number_18, GPIO_Pullup_Enable);
1082
1083 // SPI-STE
1084 GPIO_setMode(obj->gpioHandle,GPIO_Number_19,GPIO_19_Mode_SPISTEA_NOT);
1085 // GPIO_setPullup(obj->gpioHandle,GPIO_Number_19, GPIO_Pullup_Enable);
1086
1087 #ifdef QEP
1088 // EQEPA
1089 GPIO_setMode(obj->gpioHandle,GPIO_Number_20,GPIO_20_Mode_EQEP1A);
1090 GPIO_setQualification(obj->gpioHandle,GPIO_Number_20,GPIO_Qual_Sample_3);
1091
1092 // EQEPB
1093 GPIO_setMode(obj->gpioHandle,GPIO_Number_21,GPIO_21_Mode_EQEP1B);
1094 GPIO_setQualification(obj->gpioHandle,GPIO_Number_21,GPIO_Qual_Sample_3);
1095
1096 // STATUS
1097 GPIO_setMode(obj->gpioHandle,GPIO_Number_22,GPIO_22_Mode_GeneralPurpose);
1098
1099 // EQEP1I
1100 GPIO_setMode(obj->gpioHandle,GPIO_Number_23,GPIO_23_Mode_EQEP1I);
1101 GPIO_setQualification(obj->gpioHandle,GPIO_Number_23,GPIO_Qual_Sample_3);
1102 #else
1103 // EQEPA
1104 GPIO_setMode(obj->gpioHandle,GPIO_Number_20,GPIO_20_Mode_GeneralPurpose);
1105
1106 // EQEPB
1107 GPIO_setMode(obj->gpioHandle,GPIO_Number_21,GPIO_21_Mode_GeneralPurpose);
1108
1109 // STATUS
1110 GPIO_setMode(obj->gpioHandle,GPIO_Number_22,GPIO_22_Mode_GeneralPurpose);
1111
1112 // EQEP1I
1113 GPIO_setMode(obj->gpioHandle,GPIO_Number_23,GPIO_23_Mode_GeneralPurpose);
1114 #endif
1115
1116 // SPI SIMO B
1117 GPIO_setMode(obj->gpioHandle,GPIO_Number_24,GPIO_24_Mode_SPISIMOB);
1118
1119 // SPI SOMI B
1120 GPIO_setMode(obj->gpioHandle,GPIO_Number_25,GPIO_25_Mode_SPISOMIB);
1121
1122 // SPI CLK B
1123 GPIO_setMode(obj->gpioHandle,GPIO_Number_26,GPIO_26_Mode_SPICLKB);
1124
1125 // SPI CSn B
1126 GPIO_setMode(obj->gpioHandle,GPIO_Number_27,GPIO_27_Mode_SPISTEB_NOT);
1127
1128 // No Connection
1129 GPIO_setMode(obj->gpioHandle,GPIO_Number_28,GPIO_28_Mode_GeneralPurpose);
1130
1131 // No Connection
1132 GPIO_setMode(obj->gpioHandle,GPIO_Number_29,GPIO_29_Mode_GeneralPurpose);
1133
1134 // No Connection
1135 GPIO_setMode(obj->gpioHandle,GPIO_Number_30,GPIO_30_Mode_GeneralPurpose);
1136
1137 // ControlCARD LED2
1138 GPIO_setMode(obj->gpioHandle,GPIO_Number_31,GPIO_31_Mode_GeneralPurpose);
1139 GPIO_setLow(obj->gpioHandle,GPIO_Number_31);
1140 GPIO_setDirection(obj->gpioHandle,GPIO_Number_31,GPIO_Direction_Output);
1141
1142 // No Connection
1143 GPIO_setMode(obj->gpioHandle,GPIO_Number_32,GPIO_32_Mode_GeneralPurpose);
1144
1145 // No Connection
1146 GPIO_setMode(obj->gpioHandle,GPIO_Number_33,GPIO_33_Mode_GeneralPurpose);
1147
1148 // ControlCARD LED3
1149 GPIO_setMode(obj->gpioHandle,GPIO_Number_34,GPIO_34_Mode_GeneralPurpose);
1150 GPIO_setLow(obj->gpioHandle,GPIO_Number_34);
1151 GPIO_setDirection(obj->gpioHandle,GPIO_Number_34,GPIO_Direction_Output);
1152
1153 // JTAG
1154 GPIO_setMode(obj->gpioHandle,GPIO_Number_35,GPIO_35_Mode_JTAG_TDI);
1155 GPIO_setMode(obj->gpioHandle,GPIO_Number_36,GPIO_36_Mode_JTAG_TMS);
1156 GPIO_setMode(obj->gpioHandle,GPIO_Number_37,GPIO_37_Mode_JTAG_TDO);
1157 GPIO_setMode(obj->gpioHandle,GPIO_Number_38,GPIO_38_Mode_JTAG_TCK);
1158
1159 // DRV8301 Enable
1160 GPIO_setMode(obj->gpioHandle,GPIO_Number_39,GPIO_39_Mode_GeneralPurpose);
1161
1162 // CAP1
1163 GPIO_setMode(obj->gpioHandle,GPIO_Number_40,GPIO_40_Mode_GeneralPurpose);
1164
1165 // CAP2
1166 GPIO_setMode(obj->gpioHandle,GPIO_Number_41,GPIO_41_Mode_GeneralPurpose);
1167
1168 // CAP3
1169 GPIO_setMode(obj->gpioHandle,GPIO_Number_42,GPIO_42_Mode_GeneralPurpose);
1170
1171 // DC_CAL
1172 GPIO_setMode(obj->gpioHandle,GPIO_Number_43,GPIO_43_Mode_GeneralPurpose);
1173
1174 // No Connection
1175 GPIO_setMode(obj->gpioHandle,GPIO_Number_44,GPIO_44_Mode_GeneralPurpose);
1176
1177 // No Connection
1178 GPIO_setMode(obj->gpioHandle,GPIO_Number_50,GPIO_50_Mode_GeneralPurpose);
1179
1180 // DRV8301 Enable
1181 GPIO_setMode(obj->gpioHandle,GPIO_Number_51,GPIO_51_Mode_GeneralPurpose);
1182 GPIO_setLow(obj->gpioHandle,GPIO_Number_51);
1183 GPIO_setDirection(obj->gpioHandle,GPIO_Number_51,GPIO_Direction_Output);
1184
1185 // No Connection
1186 GPIO_setMode(obj->gpioHandle,GPIO_Number_52,GPIO_52_Mode_GeneralPurpose);
1187
1188 // No Connection
1189 GPIO_setMode(obj->gpioHandle,GPIO_Number_53,GPIO_53_Mode_GeneralPurpose);
1190
1191 // No Connection
1192 GPIO_setMode(obj->gpioHandle,GPIO_Number_54,GPIO_54_Mode_GeneralPurpose);
1193
1194 // No Connection
1195 GPIO_setMode(obj->gpioHandle,GPIO_Number_55,GPIO_55_Mode_GeneralPurpose);
1196
1197 // No Connection
1198 GPIO_setMode(obj->gpioHandle,GPIO_Number_56,GPIO_56_Mode_GeneralPurpose);
1199
1200 // No Connection
1201 GPIO_setMode(obj->gpioHandle,GPIO_Number_57,GPIO_57_Mode_GeneralPurpose);
1202
1203 // No Connection
1204 GPIO_setMode(obj->gpioHandle,GPIO_Number_58,GPIO_58_Mode_GeneralPurpose);
1205
1206 return;
1207 } // end of HAL_setupGpios() function
1208
1209
1210 void HAL_setupPie(HAL_Handle handle)
1211 {
1212 HAL_Obj *obj = (HAL_Obj *)handle;
1213
1214
1215 PIE_disable(obj->pieHandle);
1216
1217 PIE_disableAllInts(obj->pieHandle);
1218
1219 PIE_clearAllInts(obj->pieHandle);
1220
1221 PIE_clearAllFlags(obj->pieHandle);
1222
1223 PIE_setDefaultIntVectorTable(obj->pieHandle);
1224
1225 PIE_enable(obj->pieHandle);
1226
1227 return;
1228 } // end of HAL_setupPie() function
1229
1230
1231 void HAL_setupPeripheralClks(HAL_Handle handle)
1232 {
1233 HAL_Obj *obj = (HAL_Obj *)handle;
1234
1235
1236 CLK_enableAdcClock(obj->clkHandle);
1237
1238 CLK_enableCompClock(obj->clkHandle,CLK_CompNumber_1);
1239 CLK_enableCompClock(obj->clkHandle,CLK_CompNumber_2);
1240 CLK_enableCompClock(obj->clkHandle,CLK_CompNumber_3);
1241
1242 CLK_enableEcap1Clock(obj->clkHandle);
1243
1244 CLK_disableEcanaClock(obj->clkHandle);
1245
1246 #ifdef QEP
1247 CLK_enableEqep1Clock(obj->clkHandle);
1248 CLK_enableEqep2Clock(obj->clkHandle);
1249 #endif
1250
1251 CLK_enablePwmClock(obj->clkHandle,PWM_Number_1);
1252 CLK_enablePwmClock(obj->clkHandle,PWM_Number_2);
1253 CLK_enablePwmClock(obj->clkHandle,PWM_Number_3);
1254 CLK_enablePwmClock(obj->clkHandle,PWM_Number_4);
1255 CLK_enablePwmClock(obj->clkHandle,PWM_Number_5);
1256 CLK_enablePwmClock(obj->clkHandle,PWM_Number_6);
1257 CLK_enablePwmClock(obj->clkHandle,PWM_Number_7);
1258
1259 CLK_disableHrPwmClock(obj->clkHandle);
1260
1261 CLK_disableI2cClock(obj->clkHandle);
1262
1263 CLK_disableLinAClock(obj->clkHandle);
1264
1265 CLK_disableClaClock(obj->clkHandle);
1266
1267 CLK_enableSciaClock(obj->clkHandle);
1268
1269 CLK_enableSpiaClock(obj->clkHandle);
1270 CLK_enableSpibClock(obj->clkHandle);
1271
1272 CLK_enableTbClockSync(obj->clkHandle);
1273
1274 return;
1275 } // end of HAL_setupPeripheralClks() function
1276
1277
1278 void HAL_setupPll(HAL_Handle handle,const PLL_ClkFreq_e clkFreq)
1279 {
1280 HAL_Obj *obj = (HAL_Obj *)handle;
1281
1282
1283 // make sure PLL is not running in limp mode
1284 if(PLL_getClkStatus(obj->pllHandle) != PLL_ClkStatus_Normal)
1285 {
1286 // reset the clock detect
1287 PLL_resetClkDetect(obj->pllHandle);
1288
1289 // ???????
1290 asm(" ESTOP0");
1291 }
1292
1293
1294 // Divide Select must be ClkIn/4 before the clock rate can be changed
1295 if(PLL_getDivideSelect(obj->pllHandle) != PLL_DivideSelect_ClkIn_by_4)
1296 {
1297 PLL_setDivideSelect(obj->pllHandle,PLL_DivideSelect_ClkIn_by_4);
1298 }
1299
1300
1301 if(PLL_getClkFreq(obj->pllHandle) != clkFreq)
1302 {
1303 // disable the clock detect
1304 PLL_disableClkDetect(obj->pllHandle);
1305
1306 // set the clock rate
1307 PLL_setClkFreq(obj->pllHandle,clkFreq);
1308 }
1309
1310
1311 // wait until locked
1312 while(PLL_getLockStatus(obj->pllHandle) != PLL_LockStatus_Done) {}
1313
1314
1315 // enable the clock detect
1316 PLL_enableClkDetect(obj->pllHandle);
1317
1318
1319 // set divide select to ClkIn/2 to get desired clock rate
1320 // NOTE: clock must be locked before setting this register
1321 PLL_setDivideSelect(obj->pllHandle,PLL_DivideSelect_ClkIn_by_2);
1322
1323 return;
1324 } // end of HAL_setupPll() function
1325
1326
1327 void HAL_setupPwms(HAL_Handle handle,
1328 const float_t systemFreq_MHz,
1329 const float_t pwmPeriod_usec,
1330 const uint_least16_t numPwmTicksPerIsrTick)
1331 {
1332 HAL_Obj *obj = (HAL_Obj *)handle;
1333 uint16_t halfPeriod_cycles = (uint16_t)(systemFreq_MHz*pwmPeriod_usec) >> 1;
1334 uint_least8_t cnt;
1335
1336
1337 // turns off the outputs of the EPWM peripherals which will put the power switches
1338 // into a high impedance state.
1339 PWM_setOneShotTrip(obj->pwmHandle[PWM_Number_1]);
1340 PWM_setOneShotTrip(obj->pwmHandle[PWM_Number_2]);
1341 PWM_setOneShotTrip(obj->pwmHandle[PWM_Number_3]);
1342
1343 for(cnt=0;cnt<3;cnt++)
1344 {
1345 // setup the Time-Base Control Register (TBCTL)
1346 PWM_setCounterMode(obj->pwmHandle[cnt],PWM_CounterMode_UpDown);
1347 PWM_disableCounterLoad(obj->pwmHandle[cnt]);
1348 PWM_setPeriodLoad(obj->pwmHandle[cnt],PWM_PeriodLoad_Immediate);
1349 PWM_setSyncMode(obj->pwmHandle[cnt],PWM_SyncMode_EPWMxSYNC);
1350 PWM_setHighSpeedClkDiv(obj->pwmHandle[cnt],PWM_HspClkDiv_by_1);
1351 PWM_setClkDiv(obj->pwmHandle[cnt],PWM_ClkDiv_by_1);
1352 PWM_setPhaseDir(obj->pwmHandle[cnt],PWM_PhaseDir_CountUp);
1353 PWM_setRunMode(obj->pwmHandle[cnt],PWM_RunMode_FreeRun);
1354
1355 // setup the Timer-Based Phase Register (TBPHS)
1356 PWM_setPhase(obj->pwmHandle[cnt],0);
1357
1358 // setup the Time-Base Counter Register (TBCTR)
1359 PWM_setCount(obj->pwmHandle[cnt],0);
1360
1361 // setup the Time-Base Period Register (TBPRD)
1362 // set to zero initially
1363 PWM_setPeriod(obj->pwmHandle[cnt],0);
1364
1365 // setup the Counter-Compare Control Register (CMPCTL)
1366 PWM_setLoadMode_CmpA(obj->pwmHandle[cnt],PWM_LoadMode_Zero);
1367 PWM_setLoadMode_CmpB(obj->pwmHandle[cnt],PWM_LoadMode_Zero);
1368 PWM_setShadowMode_CmpA(obj->pwmHandle[cnt],PWM_ShadowMode_Shadow);
1369 PWM_setShadowMode_CmpB(obj->pwmHandle[cnt],PWM_ShadowMode_Immediate);
1370
1371 // setup the Action-Qualifier Output A Register (AQCTLA)
1372 PWM_setActionQual_CntUp_CmpA_PwmA(obj->pwmHandle[cnt],PWM_ActionQual_Set);
1373 PWM_setActionQual_CntDown_CmpA_PwmA(obj->pwmHandle[cnt],PWM_ActionQual_Clear);
1374
1375 // setup the Dead-Band Generator Control Register (DBCTL)
1376 PWM_setDeadBandOutputMode(obj->pwmHandle[cnt],PWM_DeadBandOutputMode_EPWMxA_Rising_EPWMxB_Falling);
1377 PWM_setDeadBandPolarity(obj->pwmHandle[cnt],PWM_DeadBandPolarity_EPWMxB_Inverted);
1378
1379 // setup the Dead-Band Rising Edge Delay Register (DBRED)
1380 PWM_setDeadBandRisingEdgeDelay(obj->pwmHandle[cnt],HAL_PWM_DBRED_CNT);
1381
1382 // setup the Dead-Band Falling Edge Delay Register (DBFED)
1383 PWM_setDeadBandFallingEdgeDelay(obj->pwmHandle[cnt],HAL_PWM_DBFED_CNT);
1384 // setup the PWM-Chopper Control Register (PCCTL)
1385 PWM_disableChopping(obj->pwmHandle[cnt]);
1386
1387 // setup the Trip Zone Select Register (TZSEL)
1388 PWM_disableTripZones(obj->pwmHandle[cnt]);
1389 }
1390
1391
1392 // setup the Event Trigger Selection Register (ETSEL)
1393 PWM_disableInt(obj->pwmHandle[PWM_Number_1]);
1394 PWM_setSocAPulseSrc(obj->pwmHandle[PWM_Number_1],PWM_SocPulseSrc_CounterEqualZero);
1395 PWM_enableSocAPulse(obj->pwmHandle[PWM_Number_1]);
1396
1397
1398 // setup the Event Trigger Prescale Register (ETPS)
1399 if(numPwmTicksPerIsrTick == 3)
1400 {
1401 PWM_setIntPeriod(obj->pwmHandle[PWM_Number_1],PWM_IntPeriod_ThirdEvent);
1402 PWM_setSocAPeriod(obj->pwmHandle[PWM_Number_1],PWM_SocPeriod_ThirdEvent);
1403 }
1404 else if(numPwmTicksPerIsrTick == 2)
1405 {
1406 PWM_setIntPeriod(obj->pwmHandle[PWM_Number_1],PWM_IntPeriod_SecondEvent);
1407 PWM_setSocAPeriod(obj->pwmHandle[PWM_Number_1],PWM_SocPeriod_SecondEvent);
1408 }
1409 else
1410 {
1411 PWM_setIntPeriod(obj->pwmHandle[PWM_Number_1],PWM_IntPeriod_FirstEvent);
1412 PWM_setSocAPeriod(obj->pwmHandle[PWM_Number_1],PWM_SocPeriod_FirstEvent);
1413 }
1414
1415
1416 // setup the Event Trigger Clear Register (ETCLR)
1417 PWM_clearIntFlag(obj->pwmHandle[PWM_Number_1]);
1418 PWM_clearSocAFlag(obj->pwmHandle[PWM_Number_1]);
1419
1420 // first step to synchronize the pwms
1421 CLK_disableTbClockSync(obj->clkHandle);
1422
1423 // since the PWM is configured as an up/down counter, the period register is set to one-half
1424 // of the desired PWM period
1425 PWM_setPeriod(obj->pwmHandle[PWM_Number_1],halfPeriod_cycles);
1426 PWM_setPeriod(obj->pwmHandle[PWM_Number_2],halfPeriod_cycles);
1427 PWM_setPeriod(obj->pwmHandle[PWM_Number_3],halfPeriod_cycles);
1428
1429 // last step to synchronize the pwms
1430 CLK_enableTbClockSync(obj->clkHandle);
1431
1432 return;
1433 } // end of HAL_setupPwms() function
1434
1435 #ifdef QEP
1436 void HAL_setupQEP(HAL_Handle handle,HAL_QepSelect_e qep)
1437 {
1438 HAL_Obj *obj = (HAL_Obj *)handle;
1439
1440
1441 // hold the counter in reset
1442 QEP_reset_counter(obj->qepHandle[qep]);
1443
1444 // set the QPOSINIT register
1445 QEP_set_posn_init_count(obj->qepHandle[qep], 0);
1446
1447 // disable all interrupts
1448 QEP_disable_all_interrupts(obj->qepHandle[qep]);
1449
1450 // clear the interrupt flags
1451 QEP_clear_all_interrupt_flags(obj->qepHandle[qep]);
1452
1453 // clear the position counter
1454 QEP_clear_posn_counter(obj->qepHandle[qep]);
1455
1456 // setup the max position
1457 QEP_set_max_posn_count(obj->qepHandle[qep], (4*USER_MOTOR_ENCODER_LINES)-1);
1458
1459 // setup the QDECCTL register
1460 QEP_set_QEP_source(obj->qepHandle[qep], QEP_Qsrc_Quad_Count_Mode);
1461 QEP_disable_sync_out(obj->qepHandle[qep]);
1462 QEP_set_swap_quad_inputs(obj->qepHandle[qep], QEP_Swap_Not_Swapped);
1463 QEP_disable_gate_index(obj->qepHandle[qep]);
1464 QEP_set_ext_clock_rate(obj->qepHandle[qep], QEP_Xcr_2x_Res);
1465 QEP_set_A_polarity(obj->qepHandle[qep], QEP_Qap_No_Effect);
1466 QEP_set_B_polarity(obj->qepHandle[qep], QEP_Qbp_No_Effect);
1467 QEP_set_index_polarity(obj->qepHandle[qep], QEP_Qip_No_Effect);
1468
1469 // setup the QEPCTL register
1470 QEP_set_emu_control(obj->qepHandle[qep], QEPCTL_Freesoft_Unaffected_Halt);
1471 QEP_set_posn_count_reset_mode(obj->qepHandle[qep], QEPCTL_Pcrm_Max_Reset);
1472 QEP_set_strobe_event_init(obj->qepHandle[qep], QEPCTL_Sei_Nothing);
1473 QEP_set_index_event_init(obj->qepHandle[qep], QEPCTL_Iei_Nothing);
1474 QEP_set_index_event_latch(obj->qepHandle[qep], QEPCTL_Iel_Rising_Edge);
1475 QEP_set_soft_init(obj->qepHandle[qep], QEPCTL_Swi_Nothing);
1476 QEP_disable_unit_timer(obj->qepHandle[qep]);
1477 QEP_disable_watchdog(obj->qepHandle[qep]);
1478
1479 // setup the QPOSCTL register
1480 QEP_disable_posn_compare(obj->qepHandle[qep]);
1481
1482 // setup the QCAPCTL register
1483 QEP_disable_capture(obj->qepHandle[qep]);
1484
1485 // renable the position counter
1486 QEP_enable_counter(obj->qepHandle[qep]);
1487
1488
1489 return;
1490 }
1491 #endif
1492
1493
1494 void HAL_setupSpiA(HAL_Handle handle)
1495 {
1496 HAL_Obj *obj = (HAL_Obj *)handle;
1497
1498 SPI_reset(obj->spiAHandle);
1499 SPI_setClkPolarity(obj->spiAHandle,SPI_ClkPolarity_OutputRisingEdge_InputFallingEdge);
1500 SPI_disableLoopBack(obj->spiAHandle);
1501 SPI_setCharLength(obj->spiAHandle,SPI_CharLength_16_Bits);
1502
1503 SPI_setMode(obj->spiAHandle,SPI_Mode_Slave);
1504 SPI_setClkPhase(obj->spiAHandle,SPI_ClkPhase_Delayed);
1505 SPI_enableTx(obj->spiAHandle);
1506
1507 SPI_enableChannels(obj->spiAHandle);
1508 SPI_enableTxFifoEnh(obj->spiAHandle);
1509 SPI_enableTxFifo(obj->spiAHandle);
1510 SPI_setTxDelay(obj->spiAHandle,0);
1511 SPI_clearTxFifoInt(obj->spiAHandle);
1512 SPI_enableRxFifo(obj->spiAHandle);
1513
1514 //not needed for slave mode SPI_setBaudRate(obj->spiAHandle,(SPI_BaudRate_e)(0x000d));
1515 SPI_setSuspend(obj->spiAHandle,SPI_TxSuspend_free);
1516 SPI_enable(obj->spiAHandle);
1517
1518 return;
1519 } // end of HAL_setupSpiA() function
1520
1521
1522 void HAL_setupSpiB(HAL_Handle handle)
1523 {
1524 HAL_Obj *obj = (HAL_Obj *)handle;
1525
1526 SPI_reset(obj->spiBHandle);
1527 SPI_setMode(obj->spiBHandle,SPI_Mode_Master);
1528 SPI_setClkPolarity(obj->spiBHandle,SPI_ClkPolarity_OutputRisingEdge_InputFallingEdge);
1529 SPI_enableTx(obj->spiBHandle);
1530 SPI_enableTxFifoEnh(obj->spiBHandle);
1531 SPI_enableTxFifo(obj->spiBHandle);
1532 SPI_setTxDelay(obj->spiBHandle,0x0018);
1533 SPI_setBaudRate(obj->spiBHandle,(SPI_BaudRate_e)(0x000d));
1534 SPI_setCharLength(obj->spiBHandle,SPI_CharLength_16_Bits);
1535 SPI_setSuspend(obj->spiBHandle,SPI_TxSuspend_free);
1536 SPI_enable(obj->spiBHandle);
1537
1538 return;
1539 } // end of HAL_setupSpiB() function
1540
1541
1542 void HAL_setupPwmDacs(HAL_Handle handle)
1543 {
1544 HAL_Obj *obj = (HAL_Obj *)handle;
1545 uint16_t halfPeriod_cycles = 512; // 3000->10kHz, 1500->20kHz, 1000-> 30kHz, 500->60kHz
1546 uint_least8_t cnt;
1547
1548
1549 for(cnt=0;cnt<3;cnt++)
1550 {
1551 // initialize the Time-Base Control Register (TBCTL)
1552 PWMDAC_setCounterMode(obj->pwmDacHandle[cnt],PWM_CounterMode_UpDown);
1553 PWMDAC_disableCounterLoad(obj->pwmDacHandle[cnt]);
1554 PWMDAC_setPeriodLoad(obj->pwmDacHandle[cnt],PWM_PeriodLoad_Immediate);
1555 PWMDAC_setSyncMode(obj->pwmDacHandle[cnt],PWM_SyncMode_EPWMxSYNC);
1556 PWMDAC_setHighSpeedClkDiv(obj->pwmDacHandle[cnt],PWM_HspClkDiv_by_1);
1557 PWMDAC_setClkDiv(obj->pwmDacHandle[cnt],PWM_ClkDiv_by_1);
1558 PWMDAC_setPhaseDir(obj->pwmDacHandle[cnt],PWM_PhaseDir_CountUp);
1559 PWMDAC_setRunMode(obj->pwmDacHandle[cnt],PWM_RunMode_FreeRun);
1560
1561 // initialize the Timer-Based Phase Register (TBPHS)
1562 PWMDAC_setPhase(obj->pwmDacHandle[cnt],0);
1563
1564 // setup the Time-Base Counter Register (TBCTR)
1565 PWMDAC_setCount(obj->pwmDacHandle[cnt],0);
1566
1567 // Initialize the Time-Base Period Register (TBPRD)
1568 // set to zero initially
1569 PWMDAC_setPeriod(obj->pwmDacHandle[cnt],0);
1570
1571 // initialize the Counter-Compare Control Register (CMPCTL)
1572 PWMDAC_setLoadMode_CmpA(obj->pwmDacHandle[cnt],PWM_LoadMode_Zero);
1573 PWMDAC_setLoadMode_CmpB(obj->pwmDacHandle[cnt],PWM_LoadMode_Zero);
1574 PWMDAC_setShadowMode_CmpA(obj->pwmDacHandle[cnt],PWM_ShadowMode_Shadow);
1575 PWMDAC_setShadowMode_CmpB(obj->pwmDacHandle[cnt],PWM_ShadowMode_Shadow);
1576
1577 // Initialize the Action-Qualifier Output A Register (AQCTLA)
1578 PWMDAC_setActionQual_CntUp_CmpA_PwmA(obj->pwmDacHandle[cnt],PWM_ActionQual_Clear);
1579 PWMDAC_setActionQual_CntDown_CmpA_PwmA(obj->pwmDacHandle[cnt],PWM_ActionQual_Set);
1580
1581 // account for EPWM6B
1582 if(cnt == 0)
1583 {
1584 PWMDAC_setActionQual_CntUp_CmpB_PwmB(obj->pwmDacHandle[cnt],PWM_ActionQual_Clear);
1585 PWMDAC_setActionQual_CntDown_CmpB_PwmB(obj->pwmDacHandle[cnt],PWM_ActionQual_Set);
1586 }
1587
1588 // Initialize the Dead-Band Control Register (DBCTL)
1589 PWMDAC_disableDeadBand(obj->pwmDacHandle[cnt]);
1590
1591 // Initialize the PWM-Chopper Control Register (PCCTL)
1592 PWMDAC_disableChopping(obj->pwmDacHandle[cnt]);
1593
1594 // Initialize the Trip-Zone Control Register (TZSEL)
1595 PWMDAC_disableTripZones(obj->pwmDacHandle[cnt]);
1596
1597 // Initialize the Trip-Zone Control Register (TZCTL)
1598 PWMDAC_setTripZoneState_TZA(obj->pwmDacHandle[cnt],PWM_TripZoneState_HighImp);
1599 PWMDAC_setTripZoneState_TZB(obj->pwmDacHandle[cnt],PWM_TripZoneState_HighImp);
1600 PWMDAC_setTripZoneState_DCAEVT1(obj->pwmDacHandle[cnt],PWM_TripZoneState_HighImp);
1601 PWMDAC_setTripZoneState_DCAEVT2(obj->pwmDacHandle[cnt],PWM_TripZoneState_HighImp);
1602 PWMDAC_setTripZoneState_DCBEVT1(obj->pwmDacHandle[cnt],PWM_TripZoneState_HighImp);
1603 }
1604
1605 // since the PWM is configured as an up/down counter, the period register is set to one-half
1606 // of the desired PWM period
1607 PWMDAC_setPeriod(obj->pwmDacHandle[PWMDAC_Number_1],halfPeriod_cycles); // Set period for both DAC1 and DAC2
1608 PWMDAC_setPeriod(obj->pwmDacHandle[PWMDAC_Number_2],halfPeriod_cycles);
1609 PWMDAC_setPeriod(obj->pwmDacHandle[PWMDAC_Number_3],halfPeriod_cycles);
1610
1611 return;
1612 } // end of HAL_setupPwmDacs() function
1613
1614
1615 void HAL_setupTimers(HAL_Handle handle,const float_t systemFreq_MHz)
1616 {
1617 HAL_Obj *obj = (HAL_Obj *)handle;
1618 uint32_t timerPeriod_cnts = (uint32_t)(systemFreq_MHz * (float_t)1000000.0) - 1;
1619
1620 // use timer 0 for frequency diagnostics
1621 TIMER_setDecimationFactor(obj->timerHandle[0],0);
1622 TIMER_setEmulationMode(obj->timerHandle[0],TIMER_EmulationMode_RunFree);
1623 TIMER_setPeriod(obj->timerHandle[0],timerPeriod_cnts);
1624 TIMER_setPreScaler(obj->timerHandle[0],0);
1625
1626 // use timer 1 for CPU usage diagnostics
1627 TIMER_setDecimationFactor(obj->timerHandle[1],0);
1628 TIMER_setEmulationMode(obj->timerHandle[1],TIMER_EmulationMode_RunFree);
1629 TIMER_setPeriod(obj->timerHandle[1],timerPeriod_cnts);
1630 TIMER_setPreScaler(obj->timerHandle[1],0);
1631
1632 return;
1633 } // end of HAL_setupTimers() function
1634
1635
1636 void HAL_writeDrvData(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
1637 {
1638 HAL_Obj *obj = (HAL_Obj *)handle;
1639
1640 DRV8301_writeData(obj->drv8301Handle,Spi_8301_Vars);
1641
1642 return;
1643 } // end of HAL_writeDrvData() function
1644
1645
1646 void HAL_readDrvData(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
1647 {
1648 HAL_Obj *obj = (HAL_Obj *)handle;
1649
1650 DRV8301_readData(obj->drv8301Handle,Spi_8301_Vars);
1651
1652 return;
1653 } // end of HAL_readDrvData() function
1654
1655
1656 void HAL_setupDrvSpi(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
1657 {
1658 HAL_Obj *obj = (HAL_Obj *)handle;
1659
1660 DRV8301_setupSpi(obj->drv8301Handle,Spi_8301_Vars);
1661
1662 return;
1663 } // end of HAL_setupDrvSpi() function
1664
1665
1666 // end of file
HAL_setNumVoltageSensors
static void HAL_setNumVoltageSensors(HAL_Handle handle, const uint_least8_t numVoltageSensors)
Sets the number of voltage sensors.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:852
FP_ROUND
#define FP_ROUND
Defines the quantity added to Q15 numbers before converting to integer to round the number...
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:79
_HAL_Obj_::offsetHandle_I
OFFSET_Handle offsetHandle_I[3]
the handles for the current offset estimators
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:140
HAL_setupQEP
void HAL_setupQEP(HAL_Handle handle, HAL_QepSelect_e qep)
Sets up the QEP peripheral.
HAL_enableGlobalInts
void HAL_enableGlobalInts(HAL_Handle handle)
Enables global interrupts.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:519
HAL_enableAdcInts
void HAL_enableAdcInts(HAL_Handle handle)
Enables the ADC interrupts.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:478
_HAL_Obj_::offset_V
OFFSET_Obj offset_V[3]
the voltage offset objects
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:144
HAL_disableGlobalInts
void HAL_disableGlobalInts(HAL_Handle handle)
Disables global interrupts.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:467
HAL_setCurrentScaleFactor
static void HAL_setCurrentScaleFactor(HAL_Handle handle, const _iq current_sf)
Sets the current scale factor in the hardware abstraction layer.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:824
getOsc2CoarseTrim
#define getOsc2CoarseTrim()
Defines the oscillator 2 coarse trim.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:106
_IQ
#define _IQ(A)
Definition: 32b/IQmathLib.h:319
OSC_POSTRIM_OFF
#define OSC_POSTRIM_OFF
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:85
getOsc1FineTrimSlope
#define getOsc1FineTrimSlope()
The following functions return reference values stored in OTP.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:90
_HAL_Obj_::pwmHandle
PWM_Handle pwmHandle[3]
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:152
HAL_PWM_DBFED_CNT
#define HAL_PWM_DBFED_CNT
Defines the PWM deadband falling edge delay count (system clocks)
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:113
_HAL_Obj_::spiBHandle
SPI_Handle spiBHandle
the SPI handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:172
HAL_OscTempComp
void HAL_OscTempComp(HAL_Handle handle)
Executes the oscillator 1 and 2 calibration functions.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:100
getOsc1FineTrimOffset
#define getOsc1FineTrimOffset()
Defines the oscillator 1 fine trim at high temp.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:93
HAL_setOffsetValue
static void HAL_setOffsetValue(HAL_Handle handle, const HAL_SensorType_e sensorType, const uint_least8_t sensorNumber, const _iq value)
Sets the initial offset value for offset estimation.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:918
_HAL_Obj_::clkHandle
CLK_Handle clkHandle
the clock handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:132
HAL_writeDrvData
void HAL_writeDrvData(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
Writes data to the driver.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:1636
_HAL_Obj_::drv8301
DRV8301_Obj drv8301
the drv8301 interface object
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:175
HAL_setOffsetInitCond
static void HAL_setOffsetInitCond(HAL_Handle handle, const HAL_SensorType_e sensorType, const uint_least8_t sensorNumber, const _iq initCond)
Sets the offset initial condition value for offset estimation.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:893
_USER_Params_::systemFreq_MHz
uint_least16_t systemFreq_MHz
Defines the system clock frequency, MHz.
Definition: fast/src/32b/userParams.h:220
_USER_Params_
Defines a structure for the user parameters.
Definition: fast/src/32b/userParams.h:193
_USER_Params_::numCurrentSensors
uint_least8_t numCurrentSensors
Defines the number of current sensors.
Definition: fast/src/32b/userParams.h:204
HAL_AdcCalChanSelect
void HAL_AdcCalChanSelect(HAL_Handle handle, const ADC_SocChanNumber_e chanNumber)
Selects the analog channel used for calibration.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:294
HAL_QepSelect_e
HAL_QepSelect_e
Enumeration for the QEP setup.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:142
getOsc2FineTrimOffset
#define getOsc2FineTrimOffset()
Defines the oscillator 2 fine trim at high temp.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:103
HAL_setupPeripheralClks
void HAL_setupPeripheralClks(HAL_Handle handle)
Sets up the peripheral clocks.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:1231
HAL_Qep_QEP1
Select QEP1.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:144
HAL_setupTimers
void HAL_setupTimers(HAL_Handle handle, const float_t systemFreq_MHz)
Sets up the timers.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:1615
_iq
long _iq
Definition: 32b/IQmathLib.h:223
HAL_osc2Comp
void HAL_osc2Comp(HAL_Handle handle, const int16_t sensorSample)
Executes the oscillator 2 calibration based on input sample.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:193
HAL_setupPll
void HAL_setupPll(HAL_Handle handle, const PLL_ClkFreq_e clkFreq)
Sets up the PLL (Phase Lock Loop)
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:1278
HAL_SensorType_Current
Enumeration for current sensor.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:162
_HAL_Obj_::flashHandle
FLASH_Handle flashHandle
the flash handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:136
_HAL_Obj_::pwmDacHandle
PWMDAC_Handle pwmDacHandle[3]
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:154
HAL_setupGpios
void HAL_setupGpios(HAL_Handle handle)
Sets up the GPIO (General Purpose I/O) pins.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:1014
HAL_setOffsetBeta_lp_pu
static void HAL_setOffsetBeta_lp_pu(HAL_Handle handle, const HAL_SensorType_e sensorType, const uint_least8_t sensorNumber, const _iq beta_lp_pu)
Sets the value used to set the low pass filter pole for offset estimation.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:868
HAL_setupFlash
void HAL_setupFlash(HAL_Handle handle)
Sets up the FLASH.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:981
HAL_enablePwmInt
void HAL_enablePwmInt(HAL_Handle handle)
Enables the PWM interrupt.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:530
hal.h
HAL_setupClks
void HAL_setupClks(HAL_Handle handle)
Sets up the clocks.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:951
HAL_PWM_DBRED_CNT
#define HAL_PWM_DBRED_CNT
Defines the PWM deadband rising edge delay count (system clocks)
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:118
HAL_setupFaults
void HAL_setupFaults(HAL_Handle handle)
Configures the fault protection logic.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:568
HAL_setVoltageScaleFactor
static void HAL_setVoltageScaleFactor(HAL_Handle handle, const _iq voltage_sf)
Sets the voltage scale factor in the hardware abstraction layer.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:941
_IQ12mpy
#define _IQ12mpy(A, B)
Definition: 32b/IQmathLib.h:828
HAL_Handle
struct _HAL_Obj_ * HAL_Handle
Defines the HAL handle.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:189
HAL_enableDrv
void HAL_enableDrv(HAL_Handle handle)
Enables the 8301 device.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:509
HAL_osc1Comp
void HAL_osc1Comp(HAL_Handle handle, const int16_t sensorSample)
Executes the oscillator 1 calibration based on input sample.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:166
_USER_Params_::voltage_sf
float_t voltage_sf
Defines the voltage scale factor for the system.
Definition: fast/src/32b/userParams.h:223
usDelay
void usDelay(const uint_least32_t delay_usec)
Provides a prescribes micro-second delay.
HAL_setupDrvSpi
void HAL_setupDrvSpi(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
Sets up the SPI interface for the driver.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:1656
_USER_Params_::numVoltageSensors
uint_least8_t numVoltageSensors
Defines the number of voltage sensors.
Definition: fast/src/32b/userParams.h:205
HAL_setupPwms
void HAL_setupPwms(HAL_Handle handle, const float_t systemFreq_MHz, const float_t pwmPeriod_usec, const uint_least16_t numPwmTicksPerIsrTick)
Sets up the PWMs (Pulse Width Modulators)
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:1327
HAL_setupPie
void HAL_setupPie(HAL_Handle handle)
Sets up the PIE (Peripheral Interrupt Expansion)
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:1210
HAL_enableDebugInt
void HAL_enableDebugInt(HAL_Handle handle)
Enables the debug interrupt.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:498
_HAL_Obj_::spiAHandle
SPI_Handle spiAHandle
the SPI handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:171
_USER_Params_::offsetPole_rps
float_t offsetPole_rps
Defines the pole location for the voltage and current offset estimation, rad/s.
Definition: fast/src/32b/userParams.h:207
getRefTempOffset
#define getRefTempOffset()
Defines the ADC reading of temperature sensor at reference temperature for compensation.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:109
HAL_setNumCurrentSensors
static void HAL_setNumCurrentSensors(HAL_Handle handle, const uint_least8_t numCurrentSensors)
Sets the number of current sensors.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:838
_USER_Params_::pwmPeriod_usec
float_t pwmPeriod_usec
Defines the Pulse Width Modulation (PWM) period, usec.
Definition: fast/src/32b/userParams.h:222
getOsc1CoarseTrim
#define getOsc1CoarseTrim()
Defines the oscillator 1 coarse trim.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:96
HAL_getNumVoltageSensors
static uint_least8_t HAL_getNumVoltageSensors(HAL_Handle handle)
Gets the number of voltage sensors.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:397
HAL_getNumCurrentSensors
static uint_least8_t HAL_getNumCurrentSensors(HAL_Handle handle)
Gets the number of current sensors.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:385
_USER_Params_::current_sf
float_t current_sf
Defines the current scale factor for the system.
Definition: fast/src/32b/userParams.h:224
HAL_setupSpiB
void HAL_setupSpiB(HAL_Handle handle)
Sets up the spiB peripheral.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:1522
_HAL_Obj_::wdogHandle
WDOG_Handle wdogHandle
the watchdog handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:160
HAL_AdcOffsetSelfCal
void HAL_AdcOffsetSelfCal(HAL_Handle handle)
Executes the offset calibration of the ADC.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:246
FP_SCALE
#define FP_SCALE
Defines used in oscillator calibration functions.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:76
_HAL_Obj_::oscHandle
OSC_Handle oscHandle
the oscillator handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:146
_HAL_Obj_::adcHandle
ADC_Handle adcHandle
the ADC handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:130
HAL_init
HAL_Handle HAL_init(void *pMemory, const size_t numBytes)
Initializes the hardware abstraction layer (HAL) object.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:598
_HAL_Obj_::pieHandle
PIE_Handle pieHandle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:148
_HAL_Obj_::cpuHandle
CPU_Handle cpuHandle
the CPU handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:134
_USER_Params_::ctrlFreq_Hz
uint_least32_t ctrlFreq_Hz
Defines the controller frequency, Hz.
Definition: fast/src/32b/userParams.h:253
HAL_cal
void HAL_cal(HAL_Handle handle)
Executes calibration routines.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:67
HAL_setupGate
void HAL_setupGate(HAL_Handle handle)
Sets up the GATE object.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:1002
hal
HAL_Obj hal
Defines the HAL object.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:61
hal_obj.h
_HAL_Obj_::timerHandle
TIMER_Handle timerHandle[3]
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:158
HAL_SensorType_Voltage
Enumeration for voltage sensor.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:163
HAL_AdcCalConversion
uint16_t HAL_AdcCalConversion(HAL_Handle handle)
Reads the converted value from the selected calibration channel.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:319
HAL_setupPwmDacs
void HAL_setupPwmDacs(HAL_Handle handle)
Sets up the PWM DACs (Pulse Width Modulator Digital to Analof Converters)
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:1542
HAL_setBias
static void HAL_setBias(HAL_Handle handle, const HAL_SensorType_e sensorType, uint_least8_t sensorNumber, const _iq bias)
Sets the ADC bias value.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:736
HAL_getOscTrimValue
uint16_t HAL_getOscTrimValue(int16_t coarse, int16_t fine)
Converts coarse and fine oscillator trim values into a single 16bit word value.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:220
_HAL_Obj_::offset_I
OFFSET_Obj offset_I[3]
the current offset objects
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:141
_HAL_Obj_::pwrHandle
PWR_Handle pwrHandle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:156
OFFSET_init
OFFSET_Handle OFFSET_init(void *pMemory, const size_t numBytes)
Initializes the offset.
Definition: 32b/offset.c:70
_HAL_Obj_::pllHandle
PLL_Handle pllHandle
the PLL handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:150
HAL_setupSpiA
void HAL_setupSpiA(HAL_Handle handle)
Sets up the spiA peripheral.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:1494
HAL_setParams
void HAL_setParams(HAL_Handle handle, const USER_Params *pUserParams)
Sets the hardware abstraction layer parameters.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:711
HAL_readDrvData
void HAL_readDrvData(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
Reads data from the driver.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:1646
_HAL_Obj_::drv8301Handle
DRV8301_Handle drv8301Handle
the drv8301 interface handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:174
HAL_setupAdcs
void HAL_setupAdcs(HAL_Handle handle)
Sets up the ADCs (Analog to Digital Converters)
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:858
HAL_enableTimer0Int
void HAL_enableTimer0Int(HAL_Handle handle)
Enables the Timer 0 interrupt.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:549
HAL_disableWdog
void HAL_disableWdog(HAL_Handle halHandle)
Disables the watch dog.
Definition: drv8301kit_revD/f28x/f2806x/src/hal.c:455
_HAL_Obj_::offsetHandle_V
OFFSET_Handle offsetHandle_V[3]
the handles for the voltage offset estimators
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:143
float_t
float float_t
Defines the portable data type for 32 bit, signed floating-point data.
Definition: types.h:121
_HAL_Obj_
Defines the hardware abstraction layer (HAL) data.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:128
_HAL_Obj_::gpioHandle
GPIO_Handle gpioHandle
the GPIO handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:138
OSC_POSTRIM
#define OSC_POSTRIM
Defines the amount to add to Q16.15 fixed point number to shift from a fine trim range of...
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:84
getOsc2FineTrimSlope
#define getOsc2FineTrimSlope()
Defines the slope used to compensate oscillator 2 (fine trim steps / ADC code). Stored.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:100