MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

boostxldrv8301_revB/f28x/f2806x/src/hal.h
Go to the documentation of this file.
1 #ifndef _HAL_H_
2 #define _HAL_H_
3 /* --COPYRIGHT--,BSD
4 * Copyright (c) 2012, Texas Instruments Incorporated
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
26 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
32 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * --/COPYRIGHT--*/
34
40
41
42 // **************************************************************************
43 // the includes
44
45
46 // modules
47
48
49 // platforms
50 #include "hal_obj.h"
51 #include "sw/modules/svgen/src/32b/svgen_current.h"
52
53
58
59
60
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64
65
66 // **************************************************************************
67 // the defines
68
70 #define DRV8301_SPI
71
72 #define Device_cal (void (*)(void))0x3D7C80
73
76 #define FP_SCALE 32768
77
79 #define FP_ROUND FP_SCALE/2
80
84 #define OSC_POSTRIM 32
85 #define OSC_POSTRIM_OFF FP_SCALE*OSC_POSTRIM
86
88
90 #define getOsc1FineTrimSlope() (*(int16_t (*)(void))0x3D7E90)()
91
93 #define getOsc1FineTrimOffset() (*(int16_t (*)(void))0x3D7E93)()
94
96 #define getOsc1CoarseTrim() (*(int16_t (*)(void))0x3D7E96)()
97
100 #define getOsc2FineTrimSlope() (*(int16_t (*)(void))0x3D7E99)()
101
103 #define getOsc2FineTrimOffset() (*(int16_t (*)(void))0x3D7E9C)()
104
106 #define getOsc2CoarseTrim() (*(int16_t (*)(void))0x3D7E9F)()
107
109 #define getRefTempOffset() (*(int16_t (*)(void))0x3D7EA2)()
110
113 #define HAL_PWM_DBFED_CNT 1
114
115
118 #define HAL_PWM_DBRED_CNT 1
119
120
123 #define HAL_turnLedOff HAL_setGpioLow
124
125
128 #define HAL_turnLedOn HAL_setGpioHigh
129
130
133 #define HAL_toggleLed HAL_toggleGpio
134
135
136 // **************************************************************************
137 // the typedefs
138
139
142 typedef enum
143 {
144 HAL_Qep_QEP1=0,
145 HAL_Qep_QEP2=1
146 } HAL_QepSelect_e;
147
148
151 typedef enum
152 {
153 HAL_Gpio_LED2=GPIO_Number_34,
154 HAL_Gpio_LED3=GPIO_Number_39
155 } HAL_LedNumber_e;
156
157
160 typedef enum
161 {
162 HAL_SensorType_Current=0,
163 HAL_SensorType_Voltage
164 } HAL_SensorType_e;
165
166
167 // **************************************************************************
168 // the globals
169
170 extern interrupt void mainISR(void);
171
172
173 // **************************************************************************
174 // the function prototypes
175
176
181 static inline void HAL_acqAdcInt(HAL_Handle handle,const ADC_IntNumber_e intNumber)
182 {
183 HAL_Obj *obj = (HAL_Obj *)handle;
184
185
186 // clear the ADC interrupt flag
187 ADC_clearIntFlag(obj->adcHandle,intNumber);
188
189
190 // Acknowledge interrupt from PIE group 10
191 PIE_clearInt(obj->pieHandle,PIE_GroupNumber_10);
192
193 return;
194 } // end of HAL_acqAdcInt() function
195
196
201 static inline void HAL_acqPwmInt(HAL_Handle handle,const PWM_Number_e pwmNumber)
202 {
203 HAL_Obj *obj = (HAL_Obj *)handle;
204
205
206 // clear the PWM interrupt flag
207 PWM_clearIntFlag(obj->pwmHandle[pwmNumber]);
208
209
210 // clear the SOCA flag
211 PWM_clearSocAFlag(obj->pwmHandle[pwmNumber]);
212
213
214 // Acknowledge interrupt from PIE group 3
215 PIE_clearInt(obj->pieHandle,PIE_GroupNumber_3);
216
217 return;
218 } // end of HAL_acqPwmInt() function
219
220
224 static inline void HAL_acqTimer0Int(HAL_Handle handle)
225 {
226 HAL_Obj *obj = (HAL_Obj *)handle;
227
228
229 // clear the Timer 0 interrupt flag
230 TIMER_clearFlag(obj->timerHandle[0]);
231
232
233 // Acknowledge interrupt from PIE group 1
234 PIE_clearInt(obj->pieHandle,PIE_GroupNumber_1);
235
236 return;
237 } // end of HAL_acqTimer0Int() function
238
239
245 extern void HAL_cal(HAL_Handle handle);
246
247
250 extern void HAL_disableGlobalInts(HAL_Handle handle);
251
252
255 extern void HAL_disableWdog(HAL_Handle handle);
256
257
262 static inline void HAL_disablePwm(HAL_Handle handle)
263 {
264 HAL_Obj *obj = (HAL_Obj *)handle;
265
266 PWM_setOneShotTrip(obj->pwmHandle[PWM_Number_1]);
267 PWM_setOneShotTrip(obj->pwmHandle[PWM_Number_2]);
268 PWM_setOneShotTrip(obj->pwmHandle[PWM_Number_3]);
269
270 return;
271 } // end of HAL_disablePwm() function
272
273
278 extern void HAL_enableAdcInts(HAL_Handle handle);
279
280
286 extern void HAL_enableDebugInt(HAL_Handle handle);
287
288
291 extern void HAL_enableGlobalInts(HAL_Handle handle);
292
293
297 extern void HAL_enableDrv(HAL_Handle handle);
298
299
304 static inline void HAL_enablePwm(HAL_Handle handle)
305 {
306 HAL_Obj *obj = (HAL_Obj *)handle;
307
308 PWM_clearOneShotTrip(obj->pwmHandle[PWM_Number_1]);
309 PWM_clearOneShotTrip(obj->pwmHandle[PWM_Number_2]);
310 PWM_clearOneShotTrip(obj->pwmHandle[PWM_Number_3]);
311
312 return;
313 } // end of HAL_enablePwm() function
314
315
318 extern void HAL_enablePwmInt(HAL_Handle handle);
319
320
323 extern void HAL_enableTimer0Int(HAL_Handle handle);
324
325
330 static inline ADC_SocSampleDelay_e HAL_getAdcSocSampleDelay(HAL_Handle handle,
331 const ADC_SocNumber_e socNumber)
332 {
333 HAL_Obj *obj = (HAL_Obj *)handle;
334
335 return(ADC_getSocSampleDelay(obj->adcHandle,socNumber));
336 } // end of HAL_getAdcSocSampleDelay() function
337
338
347 static inline _iq HAL_getBias(HAL_Handle handle,
348 const HAL_SensorType_e sensorType,
349 uint_least8_t sensorNumber)
350 {
351 HAL_Obj *obj = (HAL_Obj *)handle;
352 _iq bias = _IQ(0.0);
353
354 if(sensorType == HAL_SensorType_Current)
355 {
356 bias = obj->adcBias.I.value[sensorNumber];
357 }
358 else if(sensorType == HAL_SensorType_Voltage)
359 {
360 bias = obj->adcBias.V.value[sensorNumber];
361 }
362
363 return(bias);
364 } // end of HAL_getBias() function
365
366
374 static inline _iq HAL_getCurrentScaleFactor(HAL_Handle handle)
375 {
376 HAL_Obj *obj = (HAL_Obj *)handle;
377
378 return(obj->current_sf);
379 } // end of HAL_getCurrentScaleFactor() function
380
381
385 static inline uint_least8_t HAL_getNumCurrentSensors(HAL_Handle handle)
386 {
387 HAL_Obj *obj = (HAL_Obj *)handle;
388
389
390 return(obj->numCurrentSensors);
391 } // end of HAL_getNumCurrentSensors() function
392
393
397 static inline uint_least8_t HAL_getNumVoltageSensors(HAL_Handle handle)
398 {
399 HAL_Obj *obj = (HAL_Obj *)handle;
400
401
402 return(obj->numVoltageSensors);
403 } // end of HAL_getNumVoltageSensors() function
404
405
413 static inline _iq HAL_getOffsetBeta_lp_pu(HAL_Handle handle,
414 const HAL_SensorType_e sensorType,
415 const uint_least8_t sensorNumber)
416 {
417 HAL_Obj *obj = (HAL_Obj *)handle;
418
419 _iq beta_lp_pu = _IQ(0.0);
420
421 if(sensorType == HAL_SensorType_Current)
422 {
423 beta_lp_pu = OFFSET_getBeta(obj->offsetHandle_I[sensorNumber]);
424 }
425 else if(sensorType == HAL_SensorType_Voltage)
426 {
427 beta_lp_pu = OFFSET_getBeta(obj->offsetHandle_V[sensorNumber]);
428 }
429
430 return(beta_lp_pu);
431 } // end of HAL_getOffsetBeta_lp_pu() function
432
433
441 static inline _iq HAL_getOffsetValue(HAL_Handle handle,
442 const HAL_SensorType_e sensorType,
443 const uint_least8_t sensorNumber)
444 {
445 HAL_Obj *obj = (HAL_Obj *)handle;
446
447 _iq offset = _IQ(0.0);
448
449 if(sensorType == HAL_SensorType_Current)
450 {
451 offset = OFFSET_getOffset(obj->offsetHandle_I[sensorNumber]);
452 }
453 else if(sensorType == HAL_SensorType_Voltage)
454 {
455 offset = OFFSET_getOffset(obj->offsetHandle_V[sensorNumber]);
456 }
457
458 return(offset);
459 } // end of HAL_getOffsetValue() function
460
461
469 static inline _iq HAL_getVoltageScaleFactor(HAL_Handle handle)
470 {
471 HAL_Obj *obj = (HAL_Obj *)handle;
472
473 return(obj->voltage_sf);
474 } // end of HAL_getVoltageScaleFactor() function
475
476
483 extern void HAL_setupFaults(HAL_Handle handle);
484
485
492 extern HAL_Handle HAL_init(void *pMemory,const size_t numBytes);
493
494
498 static inline void HAL_initIntVectorTable(HAL_Handle handle)
499 {
500 HAL_Obj *obj = (HAL_Obj *)handle;
501 PIE_Obj *pie = (PIE_Obj *)obj->pieHandle;
502
503
504 ENABLE_PROTECTED_REGISTER_WRITE_MODE;
505
506 pie->ADCINT1 = &mainISR;
507
508 DISABLE_PROTECTED_REGISTER_WRITE_MODE;
509
510 return;
511 } // end of HAL_initIntVectorTable() function
512
513
521 static inline void HAL_readAdcData(HAL_Handle handle,HAL_AdcData_t *pAdcData)
522 {
523 HAL_Obj *obj = (HAL_Obj *)handle;
524
525 _iq value;
526 _iq current_sf = HAL_getCurrentScaleFactor(handle);
527 _iq voltage_sf = HAL_getVoltageScaleFactor(handle);
528
529
530 // convert current A
531 // sample the first sample twice due to errata sprz342f, ignore the first sample
532 value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_1);
533 value = _IQ12mpy(value,current_sf) - obj->adcBias.I.value[0]; // divide by 2^numAdcBits = 2^12
534 pAdcData->I.value[0] = value;
535
536 // convert current B
537 value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_2);
538 value = _IQ12mpy(value,current_sf) - obj->adcBias.I.value[1]; // divide by 2^numAdcBits = 2^12
539 pAdcData->I.value[1] = value;
540
541 // convert current C
542 value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_3);
543 value = _IQ12mpy(value,current_sf) - obj->adcBias.I.value[2]; // divide by 2^numAdcBits = 2^12
544 pAdcData->I.value[2] = value;
545
546 // convert voltage A
547 value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_4);
548 value = _IQ12mpy(value,voltage_sf) - obj->adcBias.V.value[0]; // divide by 2^numAdcBits = 2^12
549 pAdcData->V.value[0] = value;
550
551 // convert voltage B
552 value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_5);
553 value = _IQ12mpy(value,voltage_sf) - obj->adcBias.V.value[1]; // divide by 2^numAdcBits = 2^12
554 pAdcData->V.value[1] = value;
555
556 // convert voltage C
557 value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_6);
558 value = _IQ12mpy(value,voltage_sf) - obj->adcBias.V.value[2]; // divide by 2^numAdcBits = 2^12
559 pAdcData->V.value[2] = value;
560
561 // read the dcBus voltage value
562 value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_7); // divide by 2^numAdcBits = 2^12
563 value = _IQ12mpy(value,voltage_sf);
564 pAdcData->dcBus = value;
565
566 return;
567 } // end of HAL_readAdcData() function
568
569
577 static inline void HAL_readAdcDataWithOffsets(HAL_Handle handle,HAL_AdcData_t *pAdcData)
578 {
579 HAL_Obj *obj = (HAL_Obj *)handle;
580
581 _iq value;
582 _iq current_sf = HAL_getCurrentScaleFactor(handle);
583 _iq voltage_sf = HAL_getVoltageScaleFactor(handle);
584
585
586 // convert current A
587 // sample the first sample twice due to errata sprz342f, ignore the first sample
588 value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_1);
589 value = _IQ12mpy(value,current_sf);
590 pAdcData->I.value[0] = value;
591
592 // convert current B
593 value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_2);
594 value = _IQ12mpy(value,current_sf);
595 pAdcData->I.value[1] = value;
596
597 // convert current C
598 value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_3);
599 value = _IQ12mpy(value,current_sf);
600 pAdcData->I.value[2] = value;
601
602 // convert voltage A
603 value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_4);
604 value = _IQ12mpy(value,voltage_sf);
605 pAdcData->V.value[0] = value;
606
607 // convert voltage B
608 value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_5);
609 value = _IQ12mpy(value,voltage_sf);
610 pAdcData->V.value[1] = value;
611
612 // convert voltage C
613 value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_6);
614 value = _IQ12mpy(value,voltage_sf);
615 pAdcData->V.value[2] = value;
616
617 // read the dcBus voltage value
618 value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_7);
619 value = _IQ12mpy(value,voltage_sf);
620 pAdcData->dcBus = value;
621
622 return;
623 } // end of HAL_readAdcDataWithOffsets() function
624
625
630 static inline uint32_t HAL_readTimerCnt(HAL_Handle handle,const uint_least8_t timerNumber)
631 {
632 HAL_Obj *obj = (HAL_Obj *)handle;
633 uint32_t timerCnt = TIMER_getCount(obj->timerHandle[timerNumber]);
634
635 return(timerCnt);
636 } // end of HAL_readTimerCnt() function
637
638
642 static inline void HAL_reloadTimer(HAL_Handle handle,const uint_least8_t timerNumber)
643 {
644 HAL_Obj *obj = (HAL_Obj *)handle;
645
646 // reload the specified timer
647 TIMER_reload(obj->timerHandle[timerNumber]);
648
649 return;
650 } // end of HAL_reloadTimer() function
651
652
655 void HAL_setupGate(HAL_Handle handle);
656
657
661 static inline void HAL_startTimer(HAL_Handle handle,const uint_least8_t timerNumber)
662 {
663 HAL_Obj *obj = (HAL_Obj *)handle;
664
665 // start the specified timer
666 TIMER_start(obj->timerHandle[timerNumber]);
667
668 return;
669 } // end of HAL_startTimer() function
670
671
675 static inline void HAL_stopTimer(HAL_Handle handle,const uint_least8_t timerNumber)
676 {
677 HAL_Obj *obj = (HAL_Obj *)handle;
678
679 // stop the specified timer
680 TIMER_stop(obj->timerHandle[timerNumber]);
681
682 return;
683 } // end of HAL_stopTimer() function
684
685
690 static inline void HAL_setTimerPeriod(HAL_Handle handle,const uint_least8_t timerNumber, const uint32_t period)
691 {
692 HAL_Obj *obj = (HAL_Obj *)handle;
693
694 // set the period
695 TIMER_setPeriod(obj->timerHandle[timerNumber], period);
696
697 return;
698 } // end of HAL_setTimerPeriod() function
699
700
705 static inline uint32_t HAL_getTimerPeriod(HAL_Handle handle,const uint_least8_t timerNumber)
706 {
707 HAL_Obj *obj = (HAL_Obj *)handle;
708
709 uint32_t timerPeriod = TIMER_getPeriod(obj->timerHandle[timerNumber]);
710
711 return(timerPeriod);
712 } // end of HAL_getTimerPeriod() function
713
714
719 static inline void HAL_setAdcSocSampleDelay(HAL_Handle handle,
720 const ADC_SocNumber_e socNumber,
721 const ADC_SocSampleDelay_e sampleDelay)
722 {
723 HAL_Obj *obj = (HAL_Obj *)handle;
724
725 ADC_setSocSampleDelay(obj->adcHandle,socNumber,sampleDelay);
726
727 return;
728 } // end of HAL_setAdcSocSampleDelay() function
729
730
736 static inline void HAL_setBias(HAL_Handle handle,
737 const HAL_SensorType_e sensorType,
738 uint_least8_t sensorNumber,
739 const _iq bias)
740 {
741 HAL_Obj *obj = (HAL_Obj *)handle;
742
743
744 if(sensorType == HAL_SensorType_Current)
745 {
746 obj->adcBias.I.value[sensorNumber] = bias;
747 }
748 else if(sensorType == HAL_SensorType_Voltage)
749 {
750 obj->adcBias.V.value[sensorNumber] = bias;
751 }
752
753 return;
754 } // end of HAL_setBias() function
755
756
762 static inline void HAL_setGpioHigh(HAL_Handle handle,const GPIO_Number_e gpioNumber)
763 {
764 HAL_Obj *obj = (HAL_Obj *)handle;
765
766
767 // set GPIO high
768 GPIO_setHigh(obj->gpioHandle,gpioNumber);
769
770 return;
771 } // end of HAL_setGpioHigh() function
772
773
778 static inline bool HAL_readGpio(HAL_Handle handle,const GPIO_Number_e gpioNumber)
779 {
780 HAL_Obj *obj = (HAL_Obj *)handle;
781
782 // read GPIO
783 return(GPIO_read(obj->gpioHandle,gpioNumber));
784 } // end of HAL_readGpio() function
785
786
792 static inline void HAL_toggleGpio(HAL_Handle handle,const GPIO_Number_e gpioNumber)
793 {
794 HAL_Obj *obj = (HAL_Obj *)handle;
795
796
797 // set GPIO high
798 GPIO_toggle(obj->gpioHandle,gpioNumber);
799
800 return;
801 } // end of HAL_setGpioHigh() function
802
803
809 static inline void HAL_setGpioLow(HAL_Handle handle,const GPIO_Number_e gpioNumber)
810 {
811 HAL_Obj *obj = (HAL_Obj *)handle;
812
813
814 // set GPIO low
815 GPIO_setLow(obj->gpioHandle,gpioNumber);
816
817 return;
818 } // end of HAL_setGpioLow() function
819
820
824 static inline void HAL_setCurrentScaleFactor(HAL_Handle handle,const _iq current_sf)
825 {
826 HAL_Obj *obj = (HAL_Obj *)handle;
827
828
829 obj->current_sf = current_sf;
830
831 return;
832 } // end of HAL_setCurrentScaleFactor() function
833
834
838 static inline void HAL_setNumCurrentSensors(HAL_Handle handle,const uint_least8_t numCurrentSensors)
839 {
840 HAL_Obj *obj = (HAL_Obj *)handle;
841
842
843 obj->numCurrentSensors = numCurrentSensors;
844
845 return;
846 } // end of HAL_setNumCurrentSensors() function
847
848
852 static inline void HAL_setNumVoltageSensors(HAL_Handle handle,const uint_least8_t numVoltageSensors)
853 {
854 HAL_Obj *obj = (HAL_Obj *)handle;
855
856
857 obj->numVoltageSensors = numVoltageSensors;
858
859 return;
860 } // end of HAL_setNumVoltageSensors() function
861
862
868 static inline void HAL_setOffsetBeta_lp_pu(HAL_Handle handle,
869 const HAL_SensorType_e sensorType,
870 const uint_least8_t sensorNumber,
871 const _iq beta_lp_pu)
872 {
873 HAL_Obj *obj = (HAL_Obj *)handle;
874
875 if(sensorType == HAL_SensorType_Current)
876 {
877 OFFSET_setBeta(obj->offsetHandle_I[sensorNumber],beta_lp_pu);
878 }
879 else if(sensorType == HAL_SensorType_Voltage)
880 {
881 OFFSET_setBeta(obj->offsetHandle_V[sensorNumber],beta_lp_pu);
882 }
883
884 return;
885 } // end of HAL_setOffsetBeta_lp_pu() function
886
887
893 static inline void HAL_setOffsetInitCond(HAL_Handle handle,
894 const HAL_SensorType_e sensorType,
895 const uint_least8_t sensorNumber,
896 const _iq initCond)
897 {
898 HAL_Obj *obj = (HAL_Obj *)handle;
899
900 if(sensorType == HAL_SensorType_Current)
901 {
902 OFFSET_setInitCond(obj->offsetHandle_I[sensorNumber],initCond);
903 }
904 else if(sensorType == HAL_SensorType_Voltage)
905 {
906 OFFSET_setInitCond(obj->offsetHandle_V[sensorNumber],initCond);
907 }
908
909 return;
910 } // end of HAL_setOffsetInitCond() function
911
912
918 static inline void HAL_setOffsetValue(HAL_Handle handle,
919 const HAL_SensorType_e sensorType,
920 const uint_least8_t sensorNumber,
921 const _iq value)
922 {
923 HAL_Obj *obj = (HAL_Obj *)handle;
924
925 if(sensorType == HAL_SensorType_Current)
926 {
927 OFFSET_setOffset(obj->offsetHandle_I[sensorNumber],value);
928 }
929 else if(sensorType == HAL_SensorType_Voltage)
930 {
931 OFFSET_setOffset(obj->offsetHandle_V[sensorNumber],value);
932 }
933
934 return;
935 } // end of HAL_setOffsetValue() function
936
937
941 static inline void HAL_setVoltageScaleFactor(HAL_Handle handle,const _iq voltage_sf)
942 {
943 HAL_Obj *obj = (HAL_Obj *)handle;
944
945 obj->voltage_sf = voltage_sf;
946
947 return;
948 } // end of HAL_setVoltageScaleFactor() function
949
950
957 extern void HAL_setParams(HAL_Handle handle,const USER_Params *pUserParams);
958
959
962 extern void HAL_setupAdcs(HAL_Handle handle);
963
964
968 extern void HAL_setupClks(HAL_Handle handle);
969
970
973 extern void HAL_setupFlash(HAL_Handle handle);
974
975
978 extern void HAL_setupGpios(HAL_Handle handle);
979
980
983 extern void HAL_setupPeripheralClks(HAL_Handle handle);
984
985
988 extern void HAL_setupPie(HAL_Handle handle);
989
990
994 extern void HAL_setupPll(HAL_Handle handle,const PLL_ClkFreq_e clkFreq);
995
996
1002 extern void HAL_setupPwms(HAL_Handle handle,
1003 const float_t systemFreq_MHz,
1004 const float_t pwmPeriod_usec,
1005 const uint_least16_t numPwmTicksPerIsrTick);
1006
1007
1010 extern void HAL_setupPwmDacs(HAL_Handle handle);
1011
1012
1015 extern void HAL_setupQEP(HAL_Handle handle,HAL_QepSelect_e qep);
1016
1017
1020 extern void HAL_setupSpiA(HAL_Handle handle);
1021
1022
1025 extern void HAL_setupSpiB(HAL_Handle handle);
1026
1027
1031 void HAL_setupTimers(HAL_Handle handle,const float_t systemFreq_MHz);
1032
1033
1038 static inline void HAL_updateAdcBias(HAL_Handle handle)
1039 {
1040 uint_least8_t cnt;
1041 HAL_Obj *obj = (HAL_Obj *)handle;
1042 _iq bias;
1043
1044
1045 // update the current bias
1046 for(cnt=0;cnt<HAL_getNumCurrentSensors(handle);cnt++)
1047 {
1048 bias = HAL_getBias(handle,HAL_SensorType_Current,cnt);
1049
1050 bias += OFFSET_getOffset(obj->offsetHandle_I[cnt]);
1051
1052 HAL_setBias(handle,HAL_SensorType_Current,cnt,bias);
1053 }
1054
1055
1056 // update the voltage bias
1057 for(cnt=0;cnt<HAL_getNumVoltageSensors(handle);cnt++)
1058 {
1059 bias = HAL_getBias(handle,HAL_SensorType_Voltage,cnt);
1060
1061 bias += OFFSET_getOffset(obj->offsetHandle_V[cnt]);
1062
1063 HAL_setBias(handle,HAL_SensorType_Voltage,cnt,bias);
1064 }
1065
1066 return;
1067 } // end of HAL_updateAdcBias() function
1068
1069
1073 static inline void HAL_writeDacData(HAL_Handle handle,HAL_DacData_t *pDacData)
1074 {
1075 HAL_Obj *obj = (HAL_Obj *)handle;
1076
1077 // convert values from _IQ to _IQ15
1078 int16_t dacValue_1 = (int16_t)_IQtoIQ15(pDacData->value[0]);
1079 int16_t dacValue_2 = (int16_t)_IQtoIQ15(pDacData->value[1]);
1080 int16_t dacValue_3 = (int16_t)_IQtoIQ15(pDacData->value[2]);
1081 int16_t dacValue_4 = (int16_t)_IQtoIQ15(pDacData->value[3]);
1082
1083 // write the DAC data
1084 PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_1],dacValue_1);
1085 PWMDAC_write_CmpB(obj->pwmDacHandle[PWMDAC_Number_1],dacValue_2);
1086 PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_2],dacValue_3);
1087 PWMDAC_write_CmpB(obj->pwmDacHandle[PWMDAC_Number_2],dacValue_4);
1088
1089 return;
1090 } // end of HAL_writeDacData() function
1091
1092
1096 static inline void HAL_writePwmData(HAL_Handle handle,HAL_PwmData_t *pPwmData)
1097 {
1098 uint_least8_t cnt;
1099 HAL_Obj *obj = (HAL_Obj *)handle;
1100 PWM_Obj *pwm;
1101 _iq period;
1102 _iq pwmData_neg;
1103 _iq pwmData_sat;
1104 _iq pwmData_sat_dc;
1105 _iq value;
1106 uint16_t value_sat;
1107
1108 for(cnt=0;cnt<3;cnt++)
1109 {
1110 pwm = (PWM_Obj *)obj->pwmHandle[cnt];
1111 period = (_iq)pwm->TBPRD;
1112 pwmData_neg = _IQmpy(pPwmData->Tabc.value[cnt],_IQ(-1.0));
1113 pwmData_sat = _IQsat(pwmData_neg,_IQ(0.5),_IQ(-0.5));
1114 pwmData_sat_dc = pwmData_sat + _IQ(0.5);
1115 value = _IQmpy(pwmData_sat_dc, period);
1116 value_sat = (uint16_t)_IQsat(value, period, _IQ(0.0));
1117
1118 // write the PWM data
1119 PWM_write_CmpA(obj->pwmHandle[cnt],value_sat);
1120 }
1121
1122 return;
1123 } // end of HAL_writePwmData() function
1124
1125
1130 static inline uint16_t HAL_readPwmCmpA(HAL_Handle handle,const PWM_Number_e pwmNumber)
1131 {
1132 HAL_Obj *obj = (HAL_Obj *)handle;
1133
1134 // the compare value to be returned
1135 uint16_t pwmValue;
1136
1137 pwmValue = PWM_get_CmpA(obj->pwmHandle[pwmNumber]);
1138
1139 return(pwmValue);
1140 } // end of HAL_readPwmCmpA() function
1141
1142
1147 static inline uint16_t HAL_readPwmCmpAM(HAL_Handle handle,const PWM_Number_e pwmNumber)
1148 {
1149 HAL_Obj *obj = (HAL_Obj *)handle;
1150
1151 // the compare value to be returned
1152 uint16_t pwmValue;
1153
1154 pwmValue = PWM_get_CmpAM(obj->pwmHandle[pwmNumber]);
1155
1156 return(pwmValue);
1157 } // end of HAL_readPwmCmpAM() function
1158
1159
1164 static inline uint16_t HAL_readPwmCmpB(HAL_Handle handle,const PWM_Number_e pwmNumber)
1165 {
1166 HAL_Obj *obj = (HAL_Obj *)handle;
1167
1168 // the compare value to be returned
1169 uint16_t pwmValue;
1170
1171 pwmValue = PWM_get_CmpB(obj->pwmHandle[pwmNumber]);
1172
1173 return(pwmValue);
1174 } // end of HAL_readPwmCmpB() function
1175
1176
1181 static inline uint16_t HAL_readPwmPeriod(HAL_Handle handle,const PWM_Number_e pwmNumber)
1182 {
1183 HAL_Obj *obj = (HAL_Obj *)handle;
1184
1185 // the period value to be returned
1186 uint16_t pwmPeriodValue;
1187
1188 pwmPeriodValue = PWM_getPeriod(obj->pwmHandle[pwmNumber]);
1189
1190 return(pwmPeriodValue);
1191 } // end of HAL_readPwmPeriod() function
1192
1193
1194 static inline void HAL_setTrigger(HAL_Handle handle,const SVGENCURRENT_IgnoreShunt_e ignoreShunt,const int16_t minwidth, const int16_t cmpOffset)
1195 {
1196 HAL_Obj *obj = (HAL_Obj *)handle;
1197
1198 PWM_Obj *pwm1 = (PWM_Obj *)obj->pwmHandle[PWM_Number_1];
1199 PWM_Obj *pwm2 = (PWM_Obj *)obj->pwmHandle[PWM_Number_2];
1200 PWM_Obj *pwm3 = (PWM_Obj *)obj->pwmHandle[PWM_Number_3];
1201 PWM_Obj *pwm;
1202
1203 uint16_t nextPulse1 = (pwm1->CMPA + pwm1->CMPAM) / 2;
1204 uint16_t nextPulse2 = (pwm2->CMPA + pwm2->CMPAM) / 2;
1205 uint16_t nextPulse3 = (pwm3->CMPA + pwm3->CMPAM) / 2;
1206 uint16_t pwmCMPA1 = pwm1->CMPA;
1207 uint16_t pwmCMPA2 = pwm2->CMPA;
1208 uint16_t pwmCMPA3 = pwm3->CMPA;
1209
1210 int16_t offset;
1211
1212 if(ignoreShunt == use_all)
1213 {
1214 if((nextPulse1 <= nextPulse2) && (nextPulse1 <= nextPulse3))
1215 {
1216 pwm = pwm1;
1217 }
1218 else if((nextPulse2 <= nextPulse1) && (nextPulse2 <= nextPulse3))
1219 {
1220 pwm = pwm2;
1221 }
1222 else
1223 {
1224 pwm = pwm3;
1225 }
1226 }
1227 else if(ignoreShunt == ignore_a)
1228 {
1229 offset = pwmCMPA1 + cmpOffset;
1230 }
1231 else if(ignoreShunt == ignore_b)
1232 {
1233 offset = pwmCMPA2 + cmpOffset;
1234 }
1235 else if(ignoreShunt == ignore_c)
1236 {
1237 offset = pwmCMPA3 + cmpOffset;
1238 }
1239 else if(ignoreShunt == ignore_ab)
1240 {
1241 if(pwmCMPA1 > pwmCMPA2)
1242 {
1243 offset = pwmCMPA1 + cmpOffset;
1244 }
1245 else
1246 {
1247 offset = pwmCMPA2 + cmpOffset;
1248 }
1249 }
1250 else if(ignoreShunt == ignore_ac)
1251 {
1252 if(pwmCMPA1 > pwmCMPA3)
1253 {
1254 offset = pwmCMPA1 + cmpOffset;
1255 }
1256 else
1257 {
1258 offset = pwmCMPA3 + cmpOffset;
1259 }
1260 }
1261 else // when ignoreShunt == ignore_bc
1262 {
1263 if(pwmCMPA2 > pwmCMPA3)
1264 {
1265 offset = pwmCMPA2 + cmpOffset;
1266 }
1267 else
1268 {
1269 offset = pwmCMPA3 + cmpOffset;
1270 }
1271 }
1272
1273
1274 if(ignoreShunt == use_all)
1275 {
1276 if(pwm->CMPAM >= (pwm->CMPA + pwm->DBFED))
1277 {
1278 pwm1->CMPB = (pwm->CMPAM - (pwm->CMPA + pwm->DBFED)) / 2 + 1;
1279 PWM_setSocAPulseSrc(obj->pwmHandle[PWM_Number_1],PWM_SocPulseSrc_CounterEqualCmpBDecr);
1280 }
1281 else
1282 {
1283 pwm1->CMPB = ((pwm->CMPA + pwm->DBFED) - pwm->CMPAM ) / 2 + 1;
1284 PWM_setSocAPulseSrc(obj->pwmHandle[PWM_Number_1],PWM_SocPulseSrc_CounterEqualCmpBIncr);
1285 }
1286 }
1287 else
1288 {
1289 pwm1->CMPB = offset;
1290 PWM_setSocAPulseSrc(obj->pwmHandle[PWM_Number_1],PWM_SocPulseSrc_CounterEqualCmpBIncr);
1291 }
1292
1293 return;
1294 } // end of HAL_setTrigger() function
1295
1296 #ifdef QEP
1297 static inline uint32_t HAL_getQepPosnCounts(HAL_Handle handle)
1301 {
1302 HAL_Obj *obj = (HAL_Obj *)handle;
1303 #ifdef J5
1304 QEP_Obj *qep = (QEP_Obj *)obj->qepHandle[1];
1305 #else
1306 QEP_Obj *qep = (QEP_Obj *)obj->qepHandle[0];
1307 #endif
1308
1309 return qep->QPOSCNT;
1310 }
1311
1312
1316 static inline uint32_t HAL_getQepPosnMaximum(HAL_Handle handle)
1317 {
1318 HAL_Obj *obj = (HAL_Obj *)handle;
1319 #ifdef J5
1320 QEP_Obj *qep = (QEP_Obj *)obj->qepHandle[1];
1321 #else
1322 QEP_Obj *qep = (QEP_Obj *)obj->qepHandle[0];
1323 #endif
1324
1325 return qep->QPOSMAX;
1326 }
1327 #endif
1328
1332 void HAL_AdcCalChanSelect(HAL_Handle handle, const ADC_SocChanNumber_e chanNumber);
1333
1334
1338 uint16_t HAL_AdcCalConversion(HAL_Handle handle);
1339
1340
1343 void HAL_AdcOffsetSelfCal(HAL_Handle handle);
1344
1345
1351 uint16_t HAL_getOscTrimValue(int16_t coarse, int16_t fine);
1352
1353
1356 void HAL_OscTempComp(HAL_Handle handle);
1357
1358
1361 void HAL_osc1Comp(HAL_Handle handle, const int16_t sensorSample);
1362
1363
1366 void HAL_osc2Comp(HAL_Handle handle, const int16_t sensorSample);
1367
1368
1372 void HAL_writeDrvData(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars);
1373
1374
1378 void HAL_readDrvData(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars);
1379
1380
1384 void HAL_setupDrvSpi(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars);
1385
1386
1387 #ifdef __cplusplus
1388 }
1389 #endif // extern "C"
1390
1392 #endif // end of _HAL_H_ definition
1393
1394
HAL_getAdcSocSampleDelay
static ADC_SocSampleDelay_e HAL_getAdcSocSampleDelay(HAL_Handle handle, const ADC_SocNumber_e socNumber)
Gets the ADC delay value.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:330
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
HAL_getOffsetValue
static _iq HAL_getOffsetValue(HAL_Handle handle, const HAL_SensorType_e sensorType, const uint_least8_t sensorNumber)
Gets the offset value.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:441
_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: boostxldrv8301_revB/f28x/f2806x/src/hal.c:519
HAL_enableAdcInts
void HAL_enableAdcInts(HAL_Handle handle)
Enables the ADC interrupts.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:478
HAL_setTimerPeriod
static void HAL_setTimerPeriod(HAL_Handle handle, const uint_least8_t timerNumber, const uint32_t period)
Sets the timer period.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:690
HAL_disableGlobalInts
void HAL_disableGlobalInts(HAL_Handle handle)
Disables global interrupts.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:467
_IQtoIQ15
#define _IQtoIQ15(A)
Definition: 32b/IQmathLib.h:631
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
HAL_reloadTimer
static void HAL_reloadTimer(HAL_Handle handle, const uint_least8_t timerNumber)
Reloads the timer.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:642
HAL_readAdcDataWithOffsets
static void HAL_readAdcDataWithOffsets(HAL_Handle handle, HAL_AdcData_t *pAdcData)
Reads the ADC data.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:577
_IQ
#define _IQ(A)
Definition: 32b/IQmathLib.h:319
_HAL_Obj_::pwmHandle
PWM_Handle pwmHandle[3]
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:152
HAL_readPwmCmpAM
static uint16_t HAL_readPwmCmpAM(HAL_Handle handle, const PWM_Number_e pwmNumber)
Reads PWM compare mirror register A.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:1147
HAL_Qep_QEP2
Select QEP2.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:145
HAL_getTimerPeriod
static uint32_t HAL_getTimerPeriod(HAL_Handle handle, const uint_least8_t timerNumber)
Gets the timer period.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:705
HAL_OscTempComp
void HAL_OscTempComp(HAL_Handle handle)
Executes the oscillator 1 and 2 calibration functions.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:100
ignore_b
Ignore the B phase shunt measurement.
Definition: svgen_current.h:72
HAL_writePwmData
static void HAL_writePwmData(HAL_Handle handle, HAL_PwmData_t *pPwmData)
Writes PWM data to the PWM comparators for motor control.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:1096
_MATH_vec3_::value
_iq value[3]
Definition: 32b/math.h:261
mainISR
interrupt void mainISR(void)
ignore_ac
Ignore the AC phase shunt measurement.
Definition: svgen_current.h:75
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_writeDrvData
void HAL_writeDrvData(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
Writes data to the driver.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:1701
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
HAL_Gpio_LED3
GPIO pin number for LaunchPad LED D10.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:154
HAL_acqAdcInt
static void HAL_acqAdcInt(HAL_Handle handle, const ADC_IntNumber_e intNumber)
Acknowledges an interrupt from the ADC so that another ADC interrupt can happen again.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:181
_USER_Params_
Defines a structure for the user parameters.
Definition: fast/src/32b/userParams.h:193
ignore_a
Ignore the A phase shunt measurement.
Definition: svgen_current.h:71
HAL_AdcCalChanSelect
void HAL_AdcCalChanSelect(HAL_Handle handle, const ADC_SocChanNumber_e chanNumber)
Selects the analog channel used for calibration.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:294
_HAL_Obj_::current_sf
_iq current_sf
the current scale factor, amps_pu/cnt
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:164
HAL_QepSelect_e
HAL_QepSelect_e
Enumeration for the QEP setup.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:142
HAL_setupPeripheralClks
void HAL_setupPeripheralClks(HAL_Handle handle)
Sets up the peripheral clocks.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:1309
HAL_SensorType_e
HAL_SensorType_e
Enumeration for the sensor types.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:160
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: boostxldrv8301_revB/f28x/f2806x/src/hal.c:1680
HAL_osc2Comp
void HAL_osc2Comp(HAL_Handle handle, const int16_t sensorSample)
Executes the oscillator 2 calibration based on input sample.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:193
_iq
long _iq
Definition: 32b/IQmathLib.h:223
HAL_setupPll
void HAL_setupPll(HAL_Handle handle, const PLL_ClkFreq_e clkFreq)
Sets up the PLL (Phase Lock Loop)
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:1358
_HAL_Obj_::adcBias
HAL_AdcData_t adcBias
the ADC bias
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:162
HAL_setAdcSocSampleDelay
static void HAL_setAdcSocSampleDelay(HAL_Handle handle, const ADC_SocNumber_e socNumber, const ADC_SocSampleDelay_e sampleDelay)
Sets the ADC SOC sample delay value.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:719
HAL_SensorType_Current
Enumeration for current sensor.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:162
HAL_setGpioLow
static void HAL_setGpioLow(HAL_Handle handle, const GPIO_Number_e gpioNumber)
Sets the GPIO pin low.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:809
_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: boostxldrv8301_revB/f28x/f2806x/src/hal.c:1071
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: boostxldrv8301_revB/f28x/f2806x/src/hal.c:1033
ignore_ab
Ignore the AB phase shunt measurement.
Definition: svgen_current.h:74
OFFSET_setInitCond
void OFFSET_setInitCond(OFFSET_Handle handle, const _iq initCond)
Set the initial condition of the integrator or the value of y[n-1].
Definition: 32b/offset.c:102
_HAL_PwmData_t_
Defines the PWM data.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:116
HAL_enablePwmInt
void HAL_enablePwmInt(HAL_Handle handle)
Enables the PWM interrupt.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:530
HAL_setupClks
void HAL_setupClks(HAL_Handle handle)
Sets up the clocks.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:1003
HAL_setupFaults
void HAL_setupFaults(HAL_Handle handle)
Configures the fault protection logic.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:572
_HAL_PwmData_t_::Tabc
MATH_vec3 Tabc
the PWM time-durations for each motor phase
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:118
HAL_enablePwm
static void HAL_enablePwm(HAL_Handle handle)
Enables the PWM devices.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:304
HAL_startTimer
static void HAL_startTimer(HAL_Handle handle, const uint_least8_t timerNumber)
Starts the timer.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:661
HAL_stopTimer
static void HAL_stopTimer(HAL_Handle handle, const uint_least8_t timerNumber)
Stops the timer.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:675
_IQmpy
#define _IQmpy(A, B)
Definition: 32b/IQmathLib.h:809
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_enableDrv
void HAL_enableDrv(HAL_Handle handle)
Enables the 8301 device.
Definition: boostxldrv8301_revB/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: boostxldrv8301_revB/f28x/f2806x/src/hal.c:166
HAL_getVoltageScaleFactor
static _iq HAL_getVoltageScaleFactor(HAL_Handle handle)
Gets the voltage scale factor.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:469
OFFSET_setOffset
void OFFSET_setOffset(OFFSET_Handle handle, _iq offsetValue)
Sets the offset value.
Definition: 32b/offset.c:113
svgen_current.h
Contains the public interface to the Svgen Current module routines.
_HAL_Obj_::numCurrentSensors
uint_least8_t numCurrentSensors
the number of current sensors
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:168
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: boostxldrv8301_revB/f28x/f2806x/src/hal.c:1721
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: boostxldrv8301_revB/f28x/f2806x/src/hal.c:1407
HAL_setupPie
void HAL_setupPie(HAL_Handle handle)
Sets up the PIE (Peripheral Interrupt Expansion)
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:1288
HAL_enableDebugInt
void HAL_enableDebugInt(HAL_Handle handle)
Enables the debug interrupt.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:498
SVGENCURRENT_IgnoreShunt_e
SVGENCURRENT_IgnoreShunt_e
Definition: svgen_current.h:68
HAL_readGpio
static bool HAL_readGpio(HAL_Handle handle, const GPIO_Number_e gpioNumber)
Reads the specified GPIO pin.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:778
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
_HAL_Obj_::voltage_sf
_iq voltage_sf
the voltage scale factor, volts_pu/cnt
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:166
HAL_acqTimer0Int
static void HAL_acqTimer0Int(HAL_Handle handle)
Acknowledges an interrupt from Timer 0 so that another Timer 0 interrupt can happen again...
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:224
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
HAL_setupSpiB
void HAL_setupSpiB(HAL_Handle handle)
Sets up the spiB peripheral.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:1593
HAL_readTimerCnt
static uint32_t HAL_readTimerCnt(HAL_Handle handle, const uint_least8_t timerNumber)
Reads the timer count.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:630
use_all
Use all shunt measurements.
Definition: svgen_current.h:70
_HAL_DacData_t_
Defines the DAC data.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:103
HAL_AdcOffsetSelfCal
void HAL_AdcOffsetSelfCal(HAL_Handle handle)
Executes the offset calibration of the ADC.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:246
hal_obj.h
HAL_disablePwm
static void HAL_disablePwm(HAL_Handle handle)
Disables the PWM device.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:262
OFFSET_setBeta
void OFFSET_setBeta(OFFSET_Handle handle, const _iq beta)
Sets the beta offset filter coefficient.
Definition: 32b/offset.c:88
_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: boostxldrv8301_revB/f28x/f2806x/src/hal.c:602
_HAL_Obj_::pieHandle
PIE_Handle pieHandle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:148
HAL_readPwmCmpA
static uint16_t HAL_readPwmCmpA(HAL_Handle handle, const PWM_Number_e pwmNumber)
Reads PWM compare register A.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:1130
_HAL_AdcData_t_::dcBus
_iq dcBus
the dcBus value
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:94
HAL_cal
void HAL_cal(HAL_Handle handle)
Executes calibration routines.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:67
HAL_setupGate
void HAL_setupGate(HAL_Handle handle)
Sets up the GATE object.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:1054
HAL_readAdcData
static void HAL_readAdcData(HAL_Handle handle, HAL_AdcData_t *pAdcData)
Reads the ADC data.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:521
HAL_setTrigger
static void HAL_setTrigger(HAL_Handle handle, const SVGENCURRENT_IgnoreShunt_e ignoreShunt, const int16_t minwidth, const int16_t cmpOffset)
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:1194
OFFSET_getBeta
_iq OFFSET_getBeta(OFFSET_Handle handle)
Gets the beta offset filter coefficient.
Definition: 32b/offset.c:58
_HAL_DacData_t_::value
_iq value[4]
the DAC data
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:105
_HAL_Obj_::timerHandle
TIMER_Handle timerHandle[3]
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:158
HAL_getOffsetBeta_lp_pu
static _iq HAL_getOffsetBeta_lp_pu(HAL_Handle handle, const HAL_SensorType_e sensorType, const uint_least8_t sensorNumber)
Gets the value used to set the low pass filter pole for offset estimation.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:413
HAL_SensorType_Voltage
Enumeration for voltage sensor.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:163
HAL_toggleGpio
static void HAL_toggleGpio(HAL_Handle handle, const GPIO_Number_e gpioNumber)
Toggles the GPIO pin.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:792
HAL_AdcCalConversion
uint16_t HAL_AdcCalConversion(HAL_Handle handle)
Reads the converted value from the selected calibration channel.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:319
HAL_getBias
static _iq HAL_getBias(HAL_Handle handle, const HAL_SensorType_e sensorType, uint_least8_t sensorNumber)
Gets the ADC bias value.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:347
_HAL_AdcData_t_::V
MATH_vec3 V
the voltage values
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:92
HAL_getCurrentScaleFactor
static _iq HAL_getCurrentScaleFactor(HAL_Handle handle)
Gets the current scale factor.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:374
HAL_setupPwmDacs
void HAL_setupPwmDacs(HAL_Handle handle)
Sets up the PWM DACs (Pulse Width Modulator Digital to Analof Converters)
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:1613
HAL_setGpioHigh
static void HAL_setGpioHigh(HAL_Handle handle, const GPIO_Number_e gpioNumber)
Sets the GPIO pin high.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:762
_HAL_AdcData_t_
Defines the ADC data.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:88
HAL_Gpio_LED2
GPIO pin number for LaunchPad LED D9.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:153
_HAL_AdcData_t_::I
MATH_vec3 I
the current values
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:90
HAL_initIntVectorTable
static void HAL_initIntVectorTable(HAL_Handle handle)
Initializes the interrupt vector table.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:498
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: boostxldrv8301_revB/f28x/f2806x/src/hal.c:220
HAL_updateAdcBias
static void HAL_updateAdcBias(HAL_Handle handle)
Updates the ADC bias values.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:1038
HAL_readPwmPeriod
static uint16_t HAL_readPwmPeriod(HAL_Handle handle, const PWM_Number_e pwmNumber)
Reads PWM period register.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:1181
_IQsat
#define _IQsat(A, Pos, Neg)
Definition: 32b/IQmathLib.h:513
HAL_setupSpiA
void HAL_setupSpiA(HAL_Handle handle)
Sets up the spiA peripheral.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:1573
HAL_readPwmCmpB
static uint16_t HAL_readPwmCmpB(HAL_Handle handle, const PWM_Number_e pwmNumber)
Reads PWM compare register B.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:1164
HAL_setParams
void HAL_setParams(HAL_Handle handle, const USER_Params *pUserParams)
Sets the hardware abstraction layer parameters.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:721
HAL_readDrvData
void HAL_readDrvData(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
Reads data from the driver.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:1711
HAL_setupAdcs
void HAL_setupAdcs(HAL_Handle handle)
Sets up the ADCs (Analog to Digital Converters)
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:868
_HAL_Obj_::numVoltageSensors
uint_least8_t numVoltageSensors
the number of voltage sensors
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:169
HAL_writeDacData
static void HAL_writeDacData(HAL_Handle handle, HAL_DacData_t *pDacData)
Writes DAC data to the PWM comparators for DAC (digital-to-analog conversion) output.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:1073
HAL_enableTimer0Int
void HAL_enableTimer0Int(HAL_Handle handle)
Enables the Timer 0 interrupt.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:553
HAL_LedNumber_e
HAL_LedNumber_e
Enumeration for the LED numbers.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:151
HAL_disableWdog
void HAL_disableWdog(HAL_Handle handle)
Disables the watch dog.
Definition: boostxldrv8301_revB/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
OFFSET_getOffset
static _iq OFFSET_getOffset(OFFSET_Handle handle)
Gets the offset value.
Definition: 32b/offset.h:115
ignore_c
Ignore the C phase shunt measurement.
Definition: svgen_current.h:73
HAL_acqPwmInt
static void HAL_acqPwmInt(HAL_Handle handle, const PWM_Number_e pwmNumber)
Acknowledges an interrupt from the PWM so that another PWM interrupt can happen again.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.h:201
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