MotorWare f2806x Module API Documentation
drv8301kit_revD/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"
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 
73 #define Device_cal (void (*)(void))0x3D7C80
74 
77 #define FP_SCALE 32768
78 
80 #define FP_ROUND FP_SCALE/2
81 
85 #define OSC_POSTRIM 32
86 #define OSC_POSTRIM_OFF FP_SCALE*OSC_POSTRIM
87 
89 
91 #define getOsc1FineTrimSlope() (*(int16_t (*)(void))0x3D7E90)()
92 
94 #define getOsc1FineTrimOffset() (*(int16_t (*)(void))0x3D7E93)()
95 
97 #define getOsc1CoarseTrim() (*(int16_t (*)(void))0x3D7E96)()
98 
101 #define getOsc2FineTrimSlope() (*(int16_t (*)(void))0x3D7E99)()
102 
104 #define getOsc2FineTrimOffset() (*(int16_t (*)(void))0x3D7E9C)()
105 
107 #define getOsc2CoarseTrim() (*(int16_t (*)(void))0x3D7E9F)()
108 
110 #define getRefTempOffset() (*(int16_t (*)(void))0x3D7EA2)()
111 
114 #define HAL_PWM_DBFED_CNT 1
115 
116 
119 #define HAL_PWM_DBRED_CNT 1
120 
121 
124 #define HAL_turnLedOff HAL_setGpioLow
125 
126 
129 #define HAL_turnLedOn HAL_setGpioHigh
130 
131 
134 #define HAL_toggleLed HAL_toggleGpio
135 
136 
139 #define HAL_GPIO_SW1 GPIO_Number_9
140 
141 
144 #define HAL_GPIO_SW2 GPIO_Number_7
145 
146 // **************************************************************************
147 // the typedefs
148 
149 
152 typedef enum
153 {
157 
158 
161 typedef enum
162 {
163  HAL_Gpio_LED2=GPIO_Number_31,
164  HAL_Gpio_LED3=GPIO_Number_34
166 
167 
170 typedef enum
171 {
175 
176 
177 // **************************************************************************
178 // the globals
179 
180 extern interrupt void mainISR(void);
181 
182 
183 // **************************************************************************
184 // the function prototypes
185 
186 
191 static inline void HAL_acqAdcInt(HAL_Handle handle,const ADC_IntNumber_e intNumber)
192 {
193  HAL_Obj *obj = (HAL_Obj *)handle;
194 
195 
196  // clear the ADC interrupt flag
197  ADC_clearIntFlag(obj->adcHandle,intNumber);
198 
199 
200  // Acknowledge interrupt from PIE group 10
201  PIE_clearInt(obj->pieHandle,PIE_GroupNumber_10);
202 
203  return;
204 } // end of HAL_acqAdcInt() function
205 
206 
211 static inline void HAL_acqPwmInt(HAL_Handle handle,const PWM_Number_e pwmNumber)
212 {
213  HAL_Obj *obj = (HAL_Obj *)handle;
214 
215 
216  // clear the PWM interrupt flag
217  PWM_clearIntFlag(obj->pwmHandle[pwmNumber]);
218 
219 
220  // clear the SOCA flag
221  PWM_clearSocAFlag(obj->pwmHandle[pwmNumber]);
222 
223 
224  // Acknowledge interrupt from PIE group 3
225  PIE_clearInt(obj->pieHandle,PIE_GroupNumber_3);
226 
227  return;
228 } // end of HAL_acqPwmInt() function
229 
230 
234 static inline void HAL_acqTimer0Int(HAL_Handle handle)
235 {
236  HAL_Obj *obj = (HAL_Obj *)handle;
237 
238 
239  // clear the Timer 0 interrupt flag
240  TIMER_clearFlag(obj->timerHandle[0]);
241 
242 
243  // Acknowledge interrupt from PIE group 1
244  PIE_clearInt(obj->pieHandle,PIE_GroupNumber_1);
245 
246  return;
247 } // end of HAL_acqTimer0Int() function
248 
249 
255 extern void HAL_cal(HAL_Handle handle);
256 
257 
260 extern void HAL_disableGlobalInts(HAL_Handle handle);
261 
262 
265 extern void HAL_disableWdog(HAL_Handle handle);
266 
267 
272 static inline void HAL_disablePwm(HAL_Handle handle)
273 {
274  HAL_Obj *obj = (HAL_Obj *)handle;
275 
276  PWM_setOneShotTrip(obj->pwmHandle[PWM_Number_1]);
277  PWM_setOneShotTrip(obj->pwmHandle[PWM_Number_2]);
278  PWM_setOneShotTrip(obj->pwmHandle[PWM_Number_3]);
279 
280  return;
281 } // end of HAL_disablePwm() function
282 
283 
288 extern void HAL_enableAdcInts(HAL_Handle handle);
289 
290 
296 extern void HAL_enableDebugInt(HAL_Handle handle);
297 
298 
301 extern void HAL_enableGlobalInts(HAL_Handle handle);
302 
303 
307 extern void HAL_enableDrv(HAL_Handle handle);
308 
309 
314 static inline void HAL_enablePwm(HAL_Handle handle)
315 {
316  HAL_Obj *obj = (HAL_Obj *)handle;
317 
318  PWM_clearOneShotTrip(obj->pwmHandle[PWM_Number_1]);
319  PWM_clearOneShotTrip(obj->pwmHandle[PWM_Number_2]);
320  PWM_clearOneShotTrip(obj->pwmHandle[PWM_Number_3]);
321 
322  return;
323 } // end of HAL_enablePwm() function
324 
325 
328 extern void HAL_enablePwmInt(HAL_Handle handle);
329 
330 
333 extern void HAL_enableTimer0Int(HAL_Handle handle);
334 
335 
340 static inline ADC_SocSampleDelay_e HAL_getAdcSocSampleDelay(HAL_Handle handle,
341  const ADC_SocNumber_e socNumber)
342 {
343  HAL_Obj *obj = (HAL_Obj *)handle;
344 
345  return(ADC_getSocSampleDelay(obj->adcHandle,socNumber));
346 } // end of HAL_getAdcSocSampleDelay() function
347 
348 
357 static inline _iq HAL_getBias(HAL_Handle handle,
358  const HAL_SensorType_e sensorType,
359  uint_least8_t sensorNumber)
360 {
361  HAL_Obj *obj = (HAL_Obj *)handle;
362  _iq bias = _IQ(0.0);
363 
364  if(sensorType == HAL_SensorType_Current)
365  {
366  bias = obj->adcBias.I.value[sensorNumber];
367  }
368  else if(sensorType == HAL_SensorType_Voltage)
369  {
370  bias = obj->adcBias.V.value[sensorNumber];
371  }
372 
373  return(bias);
374 } // end of HAL_getBias() function
375 
376 
385 {
386  HAL_Obj *obj = (HAL_Obj *)handle;
387 
388  return(obj->current_sf);
389 } // end of HAL_getCurrentScaleFactor() function
390 
391 
395 static inline uint_least8_t HAL_getNumCurrentSensors(HAL_Handle handle)
396 {
397  HAL_Obj *obj = (HAL_Obj *)handle;
398 
399 
400  return(obj->numCurrentSensors);
401 } // end of HAL_getNumCurrentSensors() function
402 
403 
407 static inline uint_least8_t HAL_getNumVoltageSensors(HAL_Handle handle)
408 {
409  HAL_Obj *obj = (HAL_Obj *)handle;
410 
411 
412  return(obj->numVoltageSensors);
413 } // end of HAL_getNumVoltageSensors() function
414 
415 
424  const HAL_SensorType_e sensorType,
425  const uint_least8_t sensorNumber)
426 {
427  HAL_Obj *obj = (HAL_Obj *)handle;
428 
429  _iq beta_lp_pu = _IQ(0.0);
430 
431  if(sensorType == HAL_SensorType_Current)
432  {
433  beta_lp_pu = OFFSET_getBeta(obj->offsetHandle_I[sensorNumber]);
434  }
435  else if(sensorType == HAL_SensorType_Voltage)
436  {
437  beta_lp_pu = OFFSET_getBeta(obj->offsetHandle_V[sensorNumber]);
438  }
439 
440  return(beta_lp_pu);
441 } // end of HAL_getOffsetBeta_lp_pu() function
442 
443 
451 static inline _iq HAL_getOffsetValue(HAL_Handle handle,
452  const HAL_SensorType_e sensorType,
453  const uint_least8_t sensorNumber)
454 {
455  HAL_Obj *obj = (HAL_Obj *)handle;
456 
457  _iq offset = _IQ(0.0);
458 
459  if(sensorType == HAL_SensorType_Current)
460  {
461  offset = OFFSET_getOffset(obj->offsetHandle_I[sensorNumber]);
462  }
463  else if(sensorType == HAL_SensorType_Voltage)
464  {
465  offset = OFFSET_getOffset(obj->offsetHandle_V[sensorNumber]);
466  }
467 
468  return(offset);
469 } // end of HAL_getOffsetValue() function
470 
471 
480 {
481  HAL_Obj *obj = (HAL_Obj *)handle;
482 
483  return(obj->voltage_sf);
484 } // end of HAL_getVoltageScaleFactor() function
485 
486 
493 extern void HAL_setupFaults(HAL_Handle handle);
494 
495 
502 extern HAL_Handle HAL_init(void *pMemory,const size_t numBytes);
503 
504 
508 static inline void HAL_initIntVectorTable(HAL_Handle handle)
509  {
510  HAL_Obj *obj = (HAL_Obj *)handle;
511  PIE_Obj *pie = (PIE_Obj *)obj->pieHandle;
512 
513 
514  ENABLE_PROTECTED_REGISTER_WRITE_MODE;
515 
516  pie->ADCINT1 = &mainISR;
517 
518  DISABLE_PROTECTED_REGISTER_WRITE_MODE;
519 
520  return;
521  } // end of HAL_initIntVectorTable() function
522 
523 
531 static inline void HAL_readAdcData(HAL_Handle handle,HAL_AdcData_t *pAdcData)
532 {
533  HAL_Obj *obj = (HAL_Obj *)handle;
534 
535  _iq value;
536  _iq current_sf = HAL_getCurrentScaleFactor(handle);
537  _iq voltage_sf = HAL_getVoltageScaleFactor(handle);
538 
539 
540  // convert current A
541  // sample the first sample twice due to errata sprz342f, ignore the first sample
542  value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_1);
543  value = _IQ12mpy(value,current_sf) - obj->adcBias.I.value[0]; // divide by 2^numAdcBits = 2^12
544  pAdcData->I.value[0] = value;
545 
546  // convert current B
547  value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_2);
548  value = _IQ12mpy(value,current_sf) - obj->adcBias.I.value[1]; // divide by 2^numAdcBits = 2^12
549  pAdcData->I.value[1] = value;
550 
551  // convert current C
552  value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_3);
553  value = _IQ12mpy(value,current_sf) - obj->adcBias.I.value[2]; // divide by 2^numAdcBits = 2^12
554  pAdcData->I.value[2] = value;
555 
556  // convert voltage A
557  value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_4);
558  value = _IQ12mpy(value,voltage_sf) - obj->adcBias.V.value[0]; // divide by 2^numAdcBits = 2^12
559  pAdcData->V.value[0] = value;
560 
561  // convert voltage B
562  value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_5);
563  value = _IQ12mpy(value,voltage_sf) - obj->adcBias.V.value[1]; // divide by 2^numAdcBits = 2^12
564  pAdcData->V.value[1] = value;
565 
566  // convert voltage C
567  value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_6);
568  value = _IQ12mpy(value,voltage_sf) - obj->adcBias.V.value[2]; // divide by 2^numAdcBits = 2^12
569  pAdcData->V.value[2] = value;
570 
571  // read the dcBus voltage value
572  value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_7); // divide by 2^numAdcBits = 2^12
573  value = _IQ12mpy(value,voltage_sf);
574  pAdcData->dcBus = value;
575 
576  return;
577 } // end of HAL_readAdcData() function
578 
579 
587 static inline void HAL_readAdcDataWithOffsets(HAL_Handle handle,HAL_AdcData_t *pAdcData)
588 {
589  HAL_Obj *obj = (HAL_Obj *)handle;
590 
591  _iq value;
592  _iq current_sf = HAL_getCurrentScaleFactor(handle);
593  _iq voltage_sf = HAL_getVoltageScaleFactor(handle);
594 
595 
596  // convert current A
597  // sample the first sample twice due to errata sprz342f, ignore the first sample
598  value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_1);
599  value = _IQ12mpy(value,current_sf);
600  pAdcData->I.value[0] = value;
601 
602  // convert current B
603  value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_2);
604  value = _IQ12mpy(value,current_sf);
605  pAdcData->I.value[1] = value;
606 
607  // convert current C
608  value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_3);
609  value = _IQ12mpy(value,current_sf);
610  pAdcData->I.value[2] = value;
611 
612  // convert voltage A
613  value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_4);
614  value = _IQ12mpy(value,voltage_sf);
615  pAdcData->V.value[0] = value;
616 
617  // convert voltage B
618  value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_5);
619  value = _IQ12mpy(value,voltage_sf);
620  pAdcData->V.value[1] = value;
621 
622  // convert voltage C
623  value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_6);
624  value = _IQ12mpy(value,voltage_sf);
625  pAdcData->V.value[2] = value;
626 
627  // read the dcBus voltage value
628  value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_7);
629  value = _IQ12mpy(value,voltage_sf);
630  pAdcData->dcBus = value;
631 
632  return;
633 } // end of HAL_readAdcDataWithOffsets() function
634 
635 
640 static inline uint32_t HAL_readTimerCnt(HAL_Handle handle,const uint_least8_t timerNumber)
641 {
642  HAL_Obj *obj = (HAL_Obj *)handle;
643  uint32_t timerCnt = TIMER_getCount(obj->timerHandle[timerNumber]);
644 
645  return(timerCnt);
646 } // end of HAL_readTimerCnt() function
647 
648 
652 static inline void HAL_reloadTimer(HAL_Handle handle,const uint_least8_t timerNumber)
653 {
654  HAL_Obj *obj = (HAL_Obj *)handle;
655 
656  // reload the specified timer
657  TIMER_reload(obj->timerHandle[timerNumber]);
658 
659  return;
660 } // end of HAL_reloadTimer() function
661 
662 
665 void HAL_setupGate(HAL_Handle handle);
666 
667 
671 static inline void HAL_startTimer(HAL_Handle handle,const uint_least8_t timerNumber)
672 {
673  HAL_Obj *obj = (HAL_Obj *)handle;
674 
675  // start the specified timer
676  TIMER_start(obj->timerHandle[timerNumber]);
677 
678  return;
679 } // end of HAL_startTimer() function
680 
681 
685 static inline void HAL_stopTimer(HAL_Handle handle,const uint_least8_t timerNumber)
686 {
687  HAL_Obj *obj = (HAL_Obj *)handle;
688 
689  // stop the specified timer
690  TIMER_stop(obj->timerHandle[timerNumber]);
691 
692  return;
693 } // end of HAL_stopTimer() function
694 
695 
700 static inline void HAL_setTimerPeriod(HAL_Handle handle,const uint_least8_t timerNumber, const uint32_t period)
701 {
702  HAL_Obj *obj = (HAL_Obj *)handle;
703 
704  // set the period
705  TIMER_setPeriod(obj->timerHandle[timerNumber], period);
706 
707  return;
708 } // end of HAL_setTimerPeriod() function
709 
710 
715 static inline uint32_t HAL_getTimerPeriod(HAL_Handle handle,const uint_least8_t timerNumber)
716 {
717  HAL_Obj *obj = (HAL_Obj *)handle;
718 
719  uint32_t timerPeriod = TIMER_getPeriod(obj->timerHandle[timerNumber]);
720 
721  return(timerPeriod);
722 } // end of HAL_getTimerPeriod() function
723 
724 
729 static inline void HAL_setAdcSocSampleDelay(HAL_Handle handle,
730  const ADC_SocNumber_e socNumber,
731  const ADC_SocSampleDelay_e sampleDelay)
732 {
733  HAL_Obj *obj = (HAL_Obj *)handle;
734 
735  ADC_setSocSampleDelay(obj->adcHandle,socNumber,sampleDelay);
736 
737  return;
738 } // end of HAL_setAdcSocSampleDelay() function
739 
740 
746 static inline void HAL_setBias(HAL_Handle handle,
747  const HAL_SensorType_e sensorType,
748  uint_least8_t sensorNumber,
749  const _iq bias)
750 {
751  HAL_Obj *obj = (HAL_Obj *)handle;
752 
753 
754  if(sensorType == HAL_SensorType_Current)
755  {
756  obj->adcBias.I.value[sensorNumber] = bias;
757  }
758  else if(sensorType == HAL_SensorType_Voltage)
759  {
760  obj->adcBias.V.value[sensorNumber] = bias;
761  }
762 
763  return;
764 } // end of HAL_setBias() function
765 
766 
772 static inline void HAL_setGpioHigh(HAL_Handle handle,const GPIO_Number_e gpioNumber)
773 {
774  HAL_Obj *obj = (HAL_Obj *)handle;
775 
776 
777  // set GPIO high
778  GPIO_setHigh(obj->gpioHandle,gpioNumber);
779 
780  return;
781 } // end of HAL_setGpioHigh() function
782 
783 
788 static inline bool HAL_readGpio(HAL_Handle handle,const GPIO_Number_e gpioNumber)
789 {
790  HAL_Obj *obj = (HAL_Obj *)handle;
791 
792  // read GPIO
793  return(GPIO_read(obj->gpioHandle,gpioNumber));
794 } // end of HAL_readGpio() function
795 
796 
802 static inline void HAL_toggleGpio(HAL_Handle handle,const GPIO_Number_e gpioNumber)
803 {
804  HAL_Obj *obj = (HAL_Obj *)handle;
805 
806 
807  // set GPIO high
808  GPIO_toggle(obj->gpioHandle,gpioNumber);
809 
810  return;
811 } // end of HAL_setGpioHigh() function
812 
813 
819 static inline void HAL_setGpioLow(HAL_Handle handle,const GPIO_Number_e gpioNumber)
820 {
821  HAL_Obj *obj = (HAL_Obj *)handle;
822 
823 
824  // set GPIO low
825  GPIO_setLow(obj->gpioHandle,gpioNumber);
826 
827  return;
828 } // end of HAL_setGpioLow() function
829 
830 
834 static inline void HAL_setCurrentScaleFactor(HAL_Handle handle,const _iq current_sf)
835 {
836  HAL_Obj *obj = (HAL_Obj *)handle;
837 
838 
839  obj->current_sf = current_sf;
840 
841  return;
842 } // end of HAL_setCurrentScaleFactor() function
843 
844 
848 static inline void HAL_setNumCurrentSensors(HAL_Handle handle,const uint_least8_t numCurrentSensors)
849 {
850  HAL_Obj *obj = (HAL_Obj *)handle;
851 
852 
853  obj->numCurrentSensors = numCurrentSensors;
854 
855  return;
856 } // end of HAL_setNumCurrentSensors() function
857 
858 
862 static inline void HAL_setNumVoltageSensors(HAL_Handle handle,const uint_least8_t numVoltageSensors)
863 {
864  HAL_Obj *obj = (HAL_Obj *)handle;
865 
866 
867  obj->numVoltageSensors = numVoltageSensors;
868 
869  return;
870 } // end of HAL_setNumVoltageSensors() function
871 
872 
878 static inline void HAL_setOffsetBeta_lp_pu(HAL_Handle handle,
879  const HAL_SensorType_e sensorType,
880  const uint_least8_t sensorNumber,
881  const _iq beta_lp_pu)
882 {
883  HAL_Obj *obj = (HAL_Obj *)handle;
884 
885  if(sensorType == HAL_SensorType_Current)
886  {
887  OFFSET_setBeta(obj->offsetHandle_I[sensorNumber],beta_lp_pu);
888  }
889  else if(sensorType == HAL_SensorType_Voltage)
890  {
891  OFFSET_setBeta(obj->offsetHandle_V[sensorNumber],beta_lp_pu);
892  }
893 
894  return;
895 } // end of HAL_setOffsetBeta_lp_pu() function
896 
897 
903 static inline void HAL_setOffsetInitCond(HAL_Handle handle,
904  const HAL_SensorType_e sensorType,
905  const uint_least8_t sensorNumber,
906  const _iq initCond)
907 {
908  HAL_Obj *obj = (HAL_Obj *)handle;
909 
910  if(sensorType == HAL_SensorType_Current)
911  {
912  OFFSET_setInitCond(obj->offsetHandle_I[sensorNumber],initCond);
913  }
914  else if(sensorType == HAL_SensorType_Voltage)
915  {
916  OFFSET_setInitCond(obj->offsetHandle_V[sensorNumber],initCond);
917  }
918 
919  return;
920 } // end of HAL_setOffsetInitCond() function
921 
922 
928 static inline void HAL_setOffsetValue(HAL_Handle handle,
929  const HAL_SensorType_e sensorType,
930  const uint_least8_t sensorNumber,
931  const _iq value)
932 {
933  HAL_Obj *obj = (HAL_Obj *)handle;
934 
935  if(sensorType == HAL_SensorType_Current)
936  {
937  OFFSET_setOffset(obj->offsetHandle_I[sensorNumber],value);
938  }
939  else if(sensorType == HAL_SensorType_Voltage)
940  {
941  OFFSET_setOffset(obj->offsetHandle_V[sensorNumber],value);
942  }
943 
944  return;
945 } // end of HAL_setOffsetValue() function
946 
947 
951 static inline void HAL_setVoltageScaleFactor(HAL_Handle handle,const _iq voltage_sf)
952 {
953  HAL_Obj *obj = (HAL_Obj *)handle;
954 
955  obj->voltage_sf = voltage_sf;
956 
957  return;
958 } // end of HAL_setVoltageScaleFactor() function
959 
960 
967 extern void HAL_setParams(HAL_Handle handle,const USER_Params *pUserParams);
968 
969 
972 extern void HAL_setupAdcs(HAL_Handle handle);
973 
974 
978 extern void HAL_setupClks(HAL_Handle handle);
979 
980 
983 extern void HAL_setupFlash(HAL_Handle handle);
984 
985 
988 extern void HAL_setupGpios(HAL_Handle handle);
989 
990 
993 extern void HAL_setupPeripheralClks(HAL_Handle handle);
994 
995 
998 extern void HAL_setupPie(HAL_Handle handle);
999 
1000 
1004 extern void HAL_setupPll(HAL_Handle handle,const PLL_ClkFreq_e clkFreq);
1005 
1006 
1012 extern void HAL_setupPwms(HAL_Handle handle,
1013  const float_t systemFreq_MHz,
1014  const float_t pwmPeriod_usec,
1015  const uint_least16_t numPwmTicksPerIsrTick);
1016 
1017 
1020 extern void HAL_setupPwmDacs(HAL_Handle handle);
1021 
1022 
1025 extern void HAL_setupQEP(HAL_Handle handle,HAL_QepSelect_e qep);
1026 
1027 
1028 
1029 
1032 extern void HAL_setupSpiA(HAL_Handle handle);
1033 
1034 
1037 extern void HAL_setupSpiB(HAL_Handle handle);
1038 
1039 
1043 void HAL_setupTimers(HAL_Handle handle,const float_t systemFreq_MHz);
1044 
1045 
1050 static inline void HAL_updateAdcBias(HAL_Handle handle)
1051 {
1052  uint_least8_t cnt;
1053  HAL_Obj *obj = (HAL_Obj *)handle;
1054  _iq bias;
1055 
1056 
1057  // update the current bias
1058  for(cnt=0;cnt<HAL_getNumCurrentSensors(handle);cnt++)
1059  {
1060  bias = HAL_getBias(handle,HAL_SensorType_Current,cnt);
1061 
1062  bias += OFFSET_getOffset(obj->offsetHandle_I[cnt]);
1063 
1064  HAL_setBias(handle,HAL_SensorType_Current,cnt,bias);
1065  }
1066 
1067 
1068  // update the voltage bias
1069  for(cnt=0;cnt<HAL_getNumVoltageSensors(handle);cnt++)
1070  {
1071  bias = HAL_getBias(handle,HAL_SensorType_Voltage,cnt);
1072 
1073  bias += OFFSET_getOffset(obj->offsetHandle_V[cnt]);
1074 
1075  HAL_setBias(handle,HAL_SensorType_Voltage,cnt,bias);
1076  }
1077 
1078  return;
1079 } // end of HAL_updateAdcBias() function
1080 
1081 
1085 static inline void HAL_writeDacData(HAL_Handle handle,HAL_DacData_t *pDacData)
1086 {
1087  HAL_Obj *obj = (HAL_Obj *)handle;
1088  PWM_Obj *pwm = (PWM_Obj *)obj->pwmDacHandle[PWMDAC_Number_1];
1089  _iq period = (_iq)pwm->TBPRD;
1090  _iq pwmData_sat, pwmData_sat_dc, value;
1091  uint16_t value_sat[4];
1092  uint_least8_t cnt;
1093 
1094 
1095  for(cnt=0;cnt<4;cnt++)
1096  {
1097  pwmData_sat = _IQsat(pDacData->value[cnt],_IQ(0.5),_IQ(-0.5));
1098  pwmData_sat_dc = pwmData_sat + _IQ(0.5);
1099  value = _IQmpy(pwmData_sat_dc, period);
1100  value_sat[cnt] = (uint16_t)_IQsat(value, period, _IQ(0.0));
1101  }
1102 
1103 
1104  // write the DAC data
1105  PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_1],value_sat[0]);
1106  PWMDAC_write_CmpB(obj->pwmDacHandle[PWMDAC_Number_1],value_sat[1]);
1107  PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_2],value_sat[2]);
1108  PWMDAC_write_CmpA(obj->pwmDacHandle[PWMDAC_Number_3],value_sat[3]);
1109 
1110  return;
1111 } // end of HAL_writeDacData() function
1112 
1113 
1117 static inline void HAL_writePwmData(HAL_Handle handle,HAL_PwmData_t *pPwmData)
1118 {
1119  uint_least8_t cnt;
1120  HAL_Obj *obj = (HAL_Obj *)handle;
1121  PWM_Obj *pwm;
1122  _iq period;
1123  _iq pwmData_neg;
1124  _iq pwmData_sat;
1125  _iq pwmData_sat_dc;
1126  _iq value;
1127  uint16_t value_sat;
1128 
1129  for(cnt=0;cnt<3;cnt++)
1130  {
1131  pwm = (PWM_Obj *)obj->pwmHandle[cnt];
1132  period = (_iq)pwm->TBPRD;
1133  pwmData_neg = _IQmpy(pPwmData->Tabc.value[cnt],_IQ(-1.0));
1134  pwmData_sat = _IQsat(pwmData_neg,_IQ(0.5),_IQ(-0.5));
1135  pwmData_sat_dc = pwmData_sat + _IQ(0.5);
1136  value = _IQmpy(pwmData_sat_dc, period);
1137  value_sat = (uint16_t)_IQsat(value, period, _IQ(0.0));
1138 
1139  // write the PWM data
1140  PWM_write_CmpA(obj->pwmHandle[cnt],value_sat);
1141  }
1142 
1143  return;
1144 } // end of HAL_writePwmData() function
1145 
1146 
1151 static inline uint16_t HAL_readPwmCmpA(HAL_Handle handle,const PWM_Number_e pwmNumber)
1152 {
1153  HAL_Obj *obj = (HAL_Obj *)handle;
1154 
1155  // the compare value to be returned
1156  uint16_t pwmValue;
1157 
1158  pwmValue = PWM_get_CmpA(obj->pwmHandle[pwmNumber]);
1159 
1160  return(pwmValue);
1161 } // end of HAL_readPwmCmpA() function
1162 
1163 
1168 static inline uint16_t HAL_readPwmCmpAM(HAL_Handle handle,const PWM_Number_e pwmNumber)
1169 {
1170  HAL_Obj *obj = (HAL_Obj *)handle;
1171 
1172  // the compare value to be returned
1173  uint16_t pwmValue;
1174 
1175  pwmValue = PWM_get_CmpAM(obj->pwmHandle[pwmNumber]);
1176 
1177  return(pwmValue);
1178 } // end of HAL_readPwmCmpAM() function
1179 
1180 
1185 static inline uint16_t HAL_readPwmCmpB(HAL_Handle handle,const PWM_Number_e pwmNumber)
1186 {
1187  HAL_Obj *obj = (HAL_Obj *)handle;
1188 
1189  // the compare value to be returned
1190  uint16_t pwmValue;
1191 
1192  pwmValue = PWM_get_CmpB(obj->pwmHandle[pwmNumber]);
1193 
1194  return(pwmValue);
1195 } // end of HAL_readPwmCmpB() function
1196 
1197 
1202 static inline uint16_t HAL_readPwmPeriod(HAL_Handle handle,const PWM_Number_e pwmNumber)
1203 {
1204  HAL_Obj *obj = (HAL_Obj *)handle;
1205 
1206  // the period value to be returned
1207  uint16_t pwmPeriodValue;
1208 
1209  pwmPeriodValue = PWM_getPeriod(obj->pwmHandle[pwmNumber]);
1210 
1211  return(pwmPeriodValue);
1212 } // end of HAL_readPwmPeriod() function
1213 
1214 
1215 static inline void HAL_setTrigger(HAL_Handle handle,const SVGENCURRENT_IgnoreShunt_e ignoreShunt,const int16_t minwidth, const int16_t cmpOffset)
1216 {
1217  HAL_Obj *obj = (HAL_Obj *)handle;
1218 
1219  PWM_Obj *pwm1 = (PWM_Obj *)obj->pwmHandle[PWM_Number_1];
1220  PWM_Obj *pwm2 = (PWM_Obj *)obj->pwmHandle[PWM_Number_2];
1221  PWM_Obj *pwm3 = (PWM_Obj *)obj->pwmHandle[PWM_Number_3];
1222  PWM_Obj *pwm;
1223 
1224  uint16_t nextPulse1 = (pwm1->CMPA + pwm1->CMPAM) / 2;
1225  uint16_t nextPulse2 = (pwm2->CMPA + pwm2->CMPAM) / 2;
1226  uint16_t nextPulse3 = (pwm3->CMPA + pwm3->CMPAM) / 2;
1227  uint16_t pwmCMPA1 = pwm1->CMPA;
1228  uint16_t pwmCMPA2 = pwm2->CMPA;
1229  uint16_t pwmCMPA3 = pwm3->CMPA;
1230 
1231  int16_t offset;
1232 
1233  if(ignoreShunt == use_all)
1234  {
1235  if((nextPulse1 <= nextPulse2) && (nextPulse1 <= nextPulse3))
1236  {
1237  pwm = pwm1;
1238  }
1239  else if((nextPulse2 <= nextPulse1) && (nextPulse2 <= nextPulse3))
1240  {
1241  pwm = pwm2;
1242  }
1243  else
1244  {
1245  pwm = pwm3;
1246  }
1247  }
1248  else if(ignoreShunt == ignore_a)
1249  {
1250  offset = pwmCMPA1 + cmpOffset;
1251  }
1252  else if(ignoreShunt == ignore_b)
1253  {
1254  offset = pwmCMPA2 + cmpOffset;
1255  }
1256  else if(ignoreShunt == ignore_c)
1257  {
1258  offset = pwmCMPA3 + cmpOffset;
1259  }
1260  else if(ignoreShunt == ignore_ab)
1261  {
1262  if(pwmCMPA1 > pwmCMPA2)
1263  {
1264  offset = pwmCMPA1 + cmpOffset;
1265  }
1266  else
1267  {
1268  offset = pwmCMPA2 + cmpOffset;
1269  }
1270  }
1271  else if(ignoreShunt == ignore_ac)
1272  {
1273  if(pwmCMPA1 > pwmCMPA3)
1274  {
1275  offset = pwmCMPA1 + cmpOffset;
1276  }
1277  else
1278  {
1279  offset = pwmCMPA3 + cmpOffset;
1280  }
1281  }
1282  else // when ignoreShunt == ignore_bc
1283  {
1284  if(pwmCMPA2 > pwmCMPA3)
1285  {
1286  offset = pwmCMPA2 + cmpOffset;
1287  }
1288  else
1289  {
1290  offset = pwmCMPA3 + cmpOffset;
1291  }
1292  }
1293 
1294 
1295  if(ignoreShunt == use_all)
1296  {
1297  if(pwm->CMPAM >= (pwm->CMPA + pwm->DBFED))
1298  {
1299  pwm1->CMPB = (pwm->CMPAM - (pwm->CMPA + pwm->DBFED)) / 2 + 1;
1300  PWM_setSocAPulseSrc(obj->pwmHandle[PWM_Number_1],PWM_SocPulseSrc_CounterEqualCmpBDecr);
1301  }
1302  else
1303  {
1304  pwm1->CMPB = ((pwm->CMPA + pwm->DBFED) - pwm->CMPAM ) / 2 + 1;
1305  PWM_setSocAPulseSrc(obj->pwmHandle[PWM_Number_1],PWM_SocPulseSrc_CounterEqualCmpBIncr);
1306  }
1307  }
1308  else
1309  {
1310  pwm1->CMPB = offset;
1311  PWM_setSocAPulseSrc(obj->pwmHandle[PWM_Number_1],PWM_SocPulseSrc_CounterEqualCmpBIncr);
1312  }
1313 
1314  return;
1315 } // end of HAL_setTrigger() function
1316 
1317 #ifdef QEP
1318 static inline uint32_t HAL_getQepPosnCounts(HAL_Handle handle)
1322 {
1323  HAL_Obj *obj = (HAL_Obj *)handle;
1324  QEP_Obj *qep = (QEP_Obj *)obj->qepHandle[0];
1325 
1326  return qep->QPOSCNT;
1327 }
1328 
1329 
1333 static inline uint32_t HAL_getQepPosnMaximum(HAL_Handle handle)
1334 {
1335  HAL_Obj *obj = (HAL_Obj *)handle;
1336  QEP_Obj *qep = (QEP_Obj *)obj->qepHandle[0];
1337 
1338  return qep->QPOSMAX;
1339 }
1340 #endif
1341 
1345 void HAL_AdcCalChanSelect(HAL_Handle handle, const ADC_SocChanNumber_e chanNumber);
1346 
1347 
1351 uint16_t HAL_AdcCalConversion(HAL_Handle handle);
1352 
1353 
1356 void HAL_AdcOffsetSelfCal(HAL_Handle handle);
1357 
1358 
1364 uint16_t HAL_getOscTrimValue(int16_t coarse, int16_t fine);
1365 
1366 
1369 void HAL_OscTempComp(HAL_Handle handle);
1370 
1371 
1374 void HAL_osc1Comp(HAL_Handle handle, const int16_t sensorSample);
1375 
1376 
1379 void HAL_osc2Comp(HAL_Handle handle, const int16_t sensorSample);
1380 
1381 
1385 void HAL_writeDrvData(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars);
1386 
1387 
1391 void HAL_readDrvData(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars);
1392 
1393 
1397 void HAL_setupDrvSpi(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars);
1398 
1399 
1400 #ifdef __cplusplus
1401 }
1402 #endif // extern "C"
1403 
1405 #endif // end of _HAL_H_ definition
1406 
1407 
OFFSET_Handle offsetHandle_I[3]
the handles for the current offset estimators
static uint32_t HAL_readTimerCnt(HAL_Handle handle, const uint_least8_t timerNumber)
Reads the timer count.
void HAL_setupQEP(HAL_Handle handle, HAL_QepSelect_e qep)
Sets up the QEP peripheral.
static void HAL_initIntVectorTable(HAL_Handle handle)
Initializes the interrupt vector table.
void HAL_enableGlobalInts(HAL_Handle handle)
Enables global interrupts.
void HAL_enableAdcInts(HAL_Handle handle)
Enables the ADC interrupts.
static void HAL_setBias(HAL_Handle handle, const HAL_SensorType_e sensorType, uint_least8_t sensorNumber, const _iq bias)
Sets the ADC bias value.
static void HAL_setTimerPeriod(HAL_Handle handle, const uint_least8_t timerNumber, const uint32_t period)
Sets the timer period.
void HAL_disableGlobalInts(HAL_Handle handle)
Disables global interrupts.
static void HAL_setGpioLow(HAL_Handle handle, const GPIO_Number_e gpioNumber)
Sets the GPIO pin low.
#define _IQ(A)
static uint16_t HAL_readPwmCmpAM(HAL_Handle handle, const PWM_Number_e pwmNumber)
Reads PWM compare mirror register A.
static uint_least8_t HAL_getNumVoltageSensors(HAL_Handle handle)
Gets the number of voltage sensors.
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.
void HAL_OscTempComp(HAL_Handle handle)
Executes the oscillator 1 and 2 calibration functions.
Ignore the B phase shunt measurement.
Definition: svgen_current.h:72
_iq value[3]
Definition: 32b/math.h:261
static void HAL_toggleGpio(HAL_Handle handle, const GPIO_Number_e gpioNumber)
Toggles the GPIO pin.
interrupt void mainISR(void)
Ignore the AC phase shunt measurement.
Definition: svgen_current.h:75
void HAL_writeDrvData(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
Writes data to the driver.
GPIO pin number for ControlCARD LED 3.
static uint32_t HAL_getTimerPeriod(HAL_Handle handle, const uint_least8_t timerNumber)
Gets the timer period.
static _iq HAL_getCurrentScaleFactor(HAL_Handle handle)
Gets the current scale factor.
Defines a structure for the user parameters.
Ignore the A phase shunt measurement.
Definition: svgen_current.h:71
void HAL_AdcCalChanSelect(HAL_Handle handle, const ADC_SocChanNumber_e chanNumber)
Selects the analog channel used for calibration.
_iq current_sf
the current scale factor, amps_pu/cnt
HAL_QepSelect_e
Enumeration for the QEP setup.
void HAL_setupPeripheralClks(HAL_Handle handle)
Sets up the peripheral clocks.
HAL_SensorType_e
Enumeration for the sensor types.
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.
void HAL_setupTimers(HAL_Handle handle, const float_t systemFreq_MHz)
Sets up the timers.
void HAL_osc2Comp(HAL_Handle handle, const int16_t sensorSample)
Executes the oscillator 2 calibration based on input sample.
long _iq
void HAL_setupPll(HAL_Handle handle, const PLL_ClkFreq_e clkFreq)
Sets up the PLL (Phase Lock Loop)
HAL_AdcData_t adcBias
the ADC bias
Enumeration for current sensor.
void HAL_setupGpios(HAL_Handle handle)
Sets up the GPIO (General Purpose I/O) pins.
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.
static uint16_t HAL_readPwmCmpB(HAL_Handle handle, const PWM_Number_e pwmNumber)
Reads PWM compare register B.
void HAL_setupFlash(HAL_Handle handle)
Sets up the FLASH.
Ignore the AB phase shunt measurement.
Definition: svgen_current.h:74
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
static void HAL_acqTimer0Int(HAL_Handle handle)
Acknowledges an interrupt from Timer 0 so that another Timer 0 interrupt can happen again...
void HAL_enablePwmInt(HAL_Handle handle)
Enables the PWM interrupt.
void HAL_setupClks(HAL_Handle handle)
Sets up the clocks.
void HAL_setupFaults(HAL_Handle handle)
Configures the fault protection logic.
MATH_vec3 Tabc
the PWM time-durations for each motor phase
static void HAL_stopTimer(HAL_Handle handle, const uint_least8_t timerNumber)
Stops the timer.
#define _IQmpy(A, B)
static void HAL_setGpioHigh(HAL_Handle handle, const GPIO_Number_e gpioNumber)
Sets the GPIO pin high.
static uint_least8_t HAL_getNumCurrentSensors(HAL_Handle handle)
Gets the number of current sensors.
static void HAL_updateAdcBias(HAL_Handle handle)
Updates the ADC bias values.
#define _IQ12mpy(A, B)
void HAL_enableDrv(HAL_Handle handle)
Enables the 8301 device.
void HAL_osc1Comp(HAL_Handle handle, const int16_t sensorSample)
Executes the oscillator 1 calibration based on input sample.
static _iq HAL_getOffsetValue(HAL_Handle handle, const HAL_SensorType_e sensorType, const uint_least8_t sensorNumber)
Gets the offset value.
static void HAL_setVoltageScaleFactor(HAL_Handle handle, const _iq voltage_sf)
Sets the voltage scale factor in the hardware abstraction layer.
void OFFSET_setOffset(OFFSET_Handle handle, _iq offsetValue)
Sets the offset value.
Definition: 32b/offset.c:113
Contains the public interface to the Svgen Current module routines.
static void HAL_readAdcDataWithOffsets(HAL_Handle handle, HAL_AdcData_t *pAdcData)
Reads the ADC data.
uint_least8_t numCurrentSensors
the number of current sensors
void HAL_setupDrvSpi(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
Sets up the SPI interface for the driver.
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)
void HAL_setupPie(HAL_Handle handle)
Sets up the PIE (Peripheral Interrupt Expansion)
void HAL_enableDebugInt(HAL_Handle handle)
Enables the debug interrupt.
SVGENCURRENT_IgnoreShunt_e
Definition: svgen_current.h:68
static void HAL_setAdcSocSampleDelay(HAL_Handle handle, const ADC_SocNumber_e socNumber, const ADC_SocSampleDelay_e sampleDelay)
Sets the ADC SOC sample delay value.
_iq voltage_sf
the voltage scale factor, volts_pu/cnt
static void HAL_setNumVoltageSensors(HAL_Handle handle, const uint_least8_t numVoltageSensors)
Sets the number of voltage sensors.
static uint16_t HAL_readPwmCmpA(HAL_Handle handle, const PWM_Number_e pwmNumber)
Reads PWM compare register A.
static void HAL_readAdcData(HAL_Handle handle, HAL_AdcData_t *pAdcData)
Reads the ADC data.
static ADC_SocSampleDelay_e HAL_getAdcSocSampleDelay(HAL_Handle handle, const ADC_SocNumber_e socNumber)
Gets the ADC delay value.
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.
void HAL_setupSpiB(HAL_Handle handle)
Sets up the spiB peripheral.
Use all shunt measurements.
Definition: svgen_current.h:70
void HAL_AdcOffsetSelfCal(HAL_Handle handle)
Executes the offset calibration of the ADC.
static void HAL_disablePwm(HAL_Handle handle)
Disables the PWM device.
static uint16_t HAL_readPwmPeriod(HAL_Handle handle, const PWM_Number_e pwmNumber)
Reads PWM period register.
static void HAL_reloadTimer(HAL_Handle handle, const uint_least8_t timerNumber)
Reloads the timer.
static _iq HAL_getVoltageScaleFactor(HAL_Handle handle)
Gets the voltage scale factor.
void OFFSET_setBeta(OFFSET_Handle handle, const _iq beta)
Sets the beta offset filter coefficient.
Definition: 32b/offset.c:88
static bool HAL_readGpio(HAL_Handle handle, const GPIO_Number_e gpioNumber)
Reads the specified GPIO pin.
ADC_Handle adcHandle
the ADC handle
HAL_Handle HAL_init(void *pMemory, const size_t numBytes)
Initializes the hardware abstraction layer (HAL) object.
static void HAL_setTrigger(HAL_Handle handle, const SVGENCURRENT_IgnoreShunt_e ignoreShunt, const int16_t minwidth, const int16_t cmpOffset)
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.
static void HAL_enablePwm(HAL_Handle handle)
Enables the PWM devices.
void HAL_cal(HAL_Handle handle)
Executes calibration routines.
void HAL_setupGate(HAL_Handle handle)
Sets up the GATE object.
static void HAL_startTimer(HAL_Handle handle, const uint_least8_t timerNumber)
Starts the timer.
_iq OFFSET_getBeta(OFFSET_Handle handle)
Gets the beta offset filter coefficient.
Definition: 32b/offset.c:58
Enumeration for voltage sensor.
uint16_t HAL_AdcCalConversion(HAL_Handle handle)
Reads the converted value from the selected calibration channel.
void HAL_setupPwmDacs(HAL_Handle handle)
Sets up the PWM DACs (Pulse Width Modulator Digital to Analof Converters)
static _iq HAL_getBias(HAL_Handle handle, const HAL_SensorType_e sensorType, uint_least8_t sensorNumber)
Gets the ADC bias value.
GPIO pin number for ControlCARD LED 2.
uint16_t HAL_getOscTrimValue(int16_t coarse, int16_t fine)
Converts coarse and fine oscillator trim values into a single 16bit word value.
#define _IQsat(A, Pos, Neg)
void HAL_setupSpiA(HAL_Handle handle)
Sets up the spiA peripheral.
void HAL_setParams(HAL_Handle handle, const USER_Params *pUserParams)
Sets the hardware abstraction layer parameters.
static void HAL_setCurrentScaleFactor(HAL_Handle handle, const _iq current_sf)
Sets the current scale factor in the hardware abstraction layer.
void HAL_readDrvData(HAL_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
Reads data from the driver.
void HAL_setupAdcs(HAL_Handle handle)
Sets up the ADCs (Analog to Digital Converters)
uint_least8_t numVoltageSensors
the number of voltage sensors
void HAL_enableTimer0Int(HAL_Handle handle)
Enables the Timer 0 interrupt.
static void HAL_setNumCurrentSensors(HAL_Handle handle, const uint_least8_t numCurrentSensors)
Sets the number of current sensors.
HAL_LedNumber_e
Enumeration for the LED numbers.
void HAL_disableWdog(HAL_Handle halHandle)
Disables the watch dog.
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.
OFFSET_Handle offsetHandle_V[3]
the handles for the voltage offset estimators
static _iq OFFSET_getOffset(OFFSET_Handle handle)
Gets the offset value.
Definition: 32b/offset.h:115
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.
Ignore the C phase shunt measurement.
Definition: svgen_current.h:73
static void HAL_writePwmData(HAL_Handle handle, HAL_PwmData_t *pPwmData)
Writes PWM data to the PWM comparators for motor control.
float float_t
Defines the portable data type for 32 bit, signed floating-point data.
Definition: types.h:121
Defines the hardware abstraction layer (HAL) data.
GPIO_Handle gpioHandle
the GPIO handle