56 #include "ti_msp_dl_config.h" 57 #include <ti/iqmath/include/IQmathLib.h> 64 #define HAL_SYSTEM_FREQ_MHZ ((int32_t)32) 67 #define HAL_PWM_TIMER_FREQ_MHZ ((int32_t)32) 70 #define HAL_CAPTURE_TIMER_FREQ ((int32_t)100000) 73 #define HAL_VDDA_REFVOLTAGE (3300) 76 #define MAX_ADC_VALUE (4095) 371 void HAL_writeSPI16(HAL_SPI_CHAN chan, HAL_SPI_CS cs, uint16_t data);
481 HAL_ADC_INT_VREF internalVRef, uint16_t externalVRef);
501 const HAL_PWM gndPhase,
502 const HAL_PWM opnPhase,
503 const uint16_t PWMDuty)
510 uint16_t PWMPeriod = DL_TimerA_getLoadValue(positivePhase->
gptimer);
512 uint16_t posPhase_cmpValue = PWMPeriod - (PWMPeriod * PWMDuty)/100;
515 DL_TimerA_setCaptureCompareValue(positivePhase->
gptimer,
519 DL_Timer_overrideCCPOut(positivePhase->
gptimer, DL_TIMER_FORCE_OUT_DISABLED,
520 DL_TIMER_FORCE_CMPL_OUT_DISABLED, positivePhase->
ccIndex);
522 DL_Timer_overrideCCPOut(groundPhase->
gptimer, DL_TIMER_FORCE_OUT_LOW,
523 DL_TIMER_FORCE_CMPL_OUT_HIGH, groundPhase->
ccIndex);
525 DL_Timer_overrideCCPOut(openPhase->
gptimer, DL_TIMER_FORCE_OUT_LOW,
526 DL_TIMER_FORCE_CMPL_OUT_LOW, openPhase->
ccIndex);
537 const HAL_PWM gndPhase_2,
538 const HAL_PWM gndPhase_3)
544 DL_Timer_overrideCCPOut(groundPhase01->
gptimer, DL_TIMER_FORCE_OUT_LOW,
545 DL_TIMER_FORCE_CMPL_OUT_LOW, groundPhase01->
ccIndex);
547 DL_Timer_overrideCCPOut(groundPhase02->
gptimer, DL_TIMER_FORCE_OUT_LOW,
548 DL_TIMER_FORCE_CMPL_OUT_LOW, groundPhase02->
ccIndex);
550 DL_Timer_overrideCCPOut(groundPhase03->
gptimer, DL_TIMER_FORCE_OUT_LOW,
551 DL_TIMER_FORCE_CMPL_OUT_LOW, groundPhase03->
ccIndex);
561 const HAL_PWM gndPhase_2,
562 const HAL_PWM gndPhase_3)
568 DL_Timer_overrideCCPOut(groundPhase01->
gptimer, DL_TIMER_FORCE_OUT_LOW,
569 DL_TIMER_FORCE_CMPL_OUT_HIGH, groundPhase01->
ccIndex);
571 DL_Timer_overrideCCPOut(groundPhase02->
gptimer, DL_TIMER_FORCE_OUT_LOW,
572 DL_TIMER_FORCE_CMPL_OUT_HIGH, groundPhase02->
ccIndex);
574 DL_Timer_overrideCCPOut(groundPhase03->
gptimer, DL_TIMER_FORCE_OUT_LOW,
575 DL_TIMER_FORCE_CMPL_OUT_HIGH, groundPhase03->
ccIndex);
GPIO_Regs * port
GPIO port.
Definition: hal.h:278
DL_ADC12_MEM_IDX memIdx
ADC memory IDX.
Definition: hal.h:299
GPTIMER_Regs * gptimer
Timer Register.
Definition: hal.h:306
ADC12 interrupt index for MEM6 result loaded interrupt.
Definition: hal.h:254
GPIO_Regs * port
GPIO port.
Definition: hal.h:319
Index associated to output GPIO PIN 2.
Definition: hal.h:129
DL_TIMER_CC_INDEX ccIndex
Timer ccIndex.
Definition: hal.h:308
HAL_FAULT_INPUT
Definition: hal.h:159
void HAL_ADCVRefSel(HAL_ADC_VREF adcRef, HAL_ADC_CHAN chan, HAL_ADC_INT_VREF internalVRef, uint16_t externalVRef)
updates the adc voltage reference
Definition: hal.c:499
HAL_ADC_IIDX HAL_processADCIRQ(ADC12_Regs *adcInst)
Read ADC values from results.
Definition: hal.c:317
uint16_t HAL_readSPI16(HAL_SPI_CHAN chan, HAL_SPI_CS cs)
Read data from spi.
Definition: hal.c:259
struct HAL_GPIO_Instance_ HAL_GPIO_Instance
Defines a GPIO instance.
Index associated to chip select 0.
Definition: hal.h:182
void HAL_enableADCInterrupt(HAL_ADC_CHAN chan)
Enables ADC interrupts.
Definition: hal.c:337
Total number of input captures.
Definition: hal.h:155
Index associated to ADC Channel 2.
Definition: hal.h:95
Index associated to ADC Channel 0.
Definition: hal.h:91
Total number of SPI channels.
Definition: hal.h:172
void HAL_setPWMFreq(HAL_PWM pwm, uint32_t PWMFreq)
Sets PWMfreq for all timers.
Definition: hal.c:227
ADC Reference VDDA.
Definition: hal.h:193
Index associated to ADC Channel 5.
Definition: hal.h:101
void HAL_setADCRefVoltage(HAL_ADC_CHAN chan, uint16_t voltage_mV)
Set ADC reference voltage.
Definition: hal.c:275
IRQn_Type IRQn
Timer IRQN.
Definition: hal.h:310
ADC12 interrupt index for MEMRESx result lower than window comparator low threshold.
Definition: hal.h:224
ADC12 interrupt index for MEM2 result loaded interrupt.
Definition: hal.h:242
HAL_ADC_VREF
Definition: hal.h:190
Index associated to PWM channel 2.
Definition: hal.h:142
ADC External Reference.
Definition: hal.h:197
ADC12 interrupt index for DMA done.
Definition: hal.h:230
Index associated to chip select 0.
Definition: hal.h:184
__STATIC_INLINE void HAL_PWMOutputLow(const HAL_PWM gndPhase_1, const HAL_PWM gndPhase_2, const HAL_PWM gndPhase_3)
Set all PWM outputs low.
Definition: hal.h:536
Total number of faults.
Definition: hal.h:164
__STATIC_INLINE void HAL_PWMOutputHigh(const HAL_PWM gndPhase_1, const HAL_PWM gndPhase_2, const HAL_PWM gndPhase_3)
Set complementary PWM outputs high.
Definition: hal.h:560
Index associated to SPI channel 0.
Definition: hal.h:170
Index associated to PWM channel 3.
Definition: hal.h:144
GPIO set to high.
Definition: hal.h:84
void HAL_enablePWMInterrupt(HAL_PWM PWM)
Enables PWM interrupts.
Definition: hal.c:357
ADC Internal Reference 2.5V.
Definition: hal.h:204
void HAL_setADCVRefVDDA(HAL_ADC_CHAN chan)
Set ADC voltage reference to VDDA.
Definition: hal.c:377
HAL_ADC_IIDX
Definition: hal.h:210
HAL_ADC_CHAN
Definition: hal.h:88
Index associated to input GPIO PIN 2.
Definition: hal.h:114
Defines a fault instance.
Definition: hal.h:314
uint32_t pin
GPIO pin.
Definition: hal.h:280
Total number of chip select pins.
Definition: hal.h:186
HAL_GPIO_IN
Definition: hal.h:109
HAL_SPI_CS
Definition: hal.h:176
ADC12 interrupt index for MEM7 result loaded interrupt.
Definition: hal.h:257
uint16_t value
ADC result.
Definition: hal.h:295
Index associated to chip select 0.
Definition: hal.h:180
Index associated to ADC Channel 1.
Definition: hal.h:93
ADC12 interrupt index for MEMRESX overflow.
Definition: hal.h:213
HAL_Timer_Instance PWMBase[HAL_PWM_MAX]
Array for storing the PWM instances.
Definition: hal.c:69
Index associated to ADC Channel 3.
Definition: hal.h:97
IOMUX_PINCM iomux
IOMUX.
Definition: hal.h:276
Index associated to input GPIO PIN 1.
Definition: hal.h:112
Index associated to ADC Channel 4.
Definition: hal.h:99
ADC12 interrupt index for MEM10 result loaded interrupt.
Definition: hal.h:269
__STATIC_INLINE void HAL_updatePWM(const HAL_PWM posPhase, const HAL_PWM gndPhase, const HAL_PWM opnPhase, const uint16_t PWMDuty)
Writes the pwm to the pinouts.
Definition: hal.h:500
uint16_t refVoltagemV
ADC reference voltage.
Definition: hal.h:297
Defines a timer instance.
Definition: hal.h:303
ADC12 interrupt index for MEM1 result loaded interrupt.
Definition: hal.h:239
HAL_fault_instance faultInput[HAL_FAULT_INPUT_MAX]
Array to store the fault instances.
Definition: hal.c:79
#define HAL_SYSTEM_FREQ_MHZ
Defines the system clock frequency, MHz.
Definition: hal.h:64
ADC12 interrupt index for MEM9 result loaded interrupt.
Definition: hal.h:263
HAL_ADC_INT_VREF
Definition: hal.h:201
struct HAL_ADC_instance_ HAL_ADC_instance
Defines a ADC instance.
ADC12 interrupt index for sequence conversion trigger overflow.
Definition: hal.h:216
ADC12 interrupt index for MEM10 result loaded interrupt.
Definition: hal.h:266
uint32_t HAL_getmvFromADC(HAL_ADC_CHAN chan)
Get milli volts from ADC.
Definition: hal.c:285
ADC12 interrupt index for MEM4 result loaded interrupt.
Definition: hal.h:248
ADC12 interrupt index for MEMRESX underflow.
Definition: hal.h:233
Index associated to output GPIO PIN 1.
Definition: hal.h:127
ADC12 interrupt index for MEMRESx result higher than window comparator high threshold.
Definition: hal.h:220
ADC12 interrupt index for MEM8 result loaded interrupt.
Definition: hal.h:260
void HAL_setDeadband(HAL_PWM pwm, uint16_t deadband)
Sets deadband for timer.
Definition: hal.c:214
HAL_SPI_CHAN
Definition: hal.h:168
Total number of input GPIO pins.
Definition: hal.h:120
HAL_Timer_Instance inputCapture[HAL_CAPTURE_TIMER_MAX]
Array to store the capture instances.
Definition: hal.c:74
void HAL_setADCVRefExternal(HAL_ADC_CHAN chan, uint16_t externalVRef)
Set ADC voltage reference to external reference.
Definition: hal.c:424
Defines a ADC instance.
Definition: hal.h:286
ADC12 interrupt index for MEM3 result loaded interrupt.
Definition: hal.h:245
Total number of PWM channels.
Definition: hal.h:146
void HAL_enableCaptureInterrupt(HAL_CAPTURE_TIMER capture)
Enables capture interrupts.
Definition: hal.c:367
Index associated to output GPIO PIN 3.
Definition: hal.h:131
HAL_ADC_IIDX endOfSeq
ADC end of sequence.
Definition: hal.h:291
GPIO set to low.
Definition: hal.h:82
ADC Internal Reference.
Definition: hal.h:195
struct HAL_Timer_Instance_ HAL_Timer_Instance
Defines a timer instance.
ADC12 interrupt index for MEM5 result loaded interrupt.
Definition: hal.h:251
HAL_GPIO_STATE
Definition: hal.h:79
_iq20 HAL_getIQ20VoltageFromADC(HAL_ADC_CHAN chan)
Get volts from ADC in _IQ20.
Definition: hal.c:297
void HAL_setADCVRefInternal(HAL_ADC_CHAN chan, HAL_ADC_INT_VREF internalVRef)
Set ADC voltage reference to internal reference.
Definition: hal.c:394
ADC Internal Reference 1.4V.
Definition: hal.h:206
Index associated to ADC Channel 6.
Definition: hal.h:103
Total number of ADC channels.
Definition: hal.h:105
GPTIMER_Regs * gptimer
Timer Register.
Definition: hal.h:317
Index associated to input GPIO PIN 4.
Definition: hal.h:118
HAL_PWM
Definition: hal.h:137
Index associated to input GPIO PIN 3.
Definition: hal.h:116
HAL_ADC_instance ADCChannel[HAL_ADC_CHAN_MAX]
Array for storing the ADC instances.
Definition: hal.c:64
Total number of output GPIO pins.
Definition: hal.h:133
ADC12 interrupt index for MEM0 result loaded interrupt.
Definition: hal.h:236
Defines a GPIO instance.
Definition: hal.h:273
ADC12 interrupt index for result in range.
Definition: hal.h:227
uint32_t pin
GPIO pin.
Definition: hal.h:321
bool HAL_getTimerFaultStatus(HAL_FAULT_INPUT fault)
Read the PWM timer fault bit.
Definition: hal.c:453
Index associated to PWM channel 1.
Definition: hal.h:140
void HAL_writeSPI16(HAL_SPI_CHAN chan, HAL_SPI_CS cs, uint16_t data)
Write data to spi.
Definition: hal.c:240
void HAL_clearTimerFault(HAL_FAULT_INPUT fault)
Clear the PWM timer fault bit.
Definition: hal.c:442
void HAL_enableGPIOInterrupt(HAL_GPIO_IN pin)
Enables GPIO interrupts.
Definition: hal.c:347
struct HAL_fault_instance HAL_fault_instance
Defines a fault instance.
ADC12_Regs * inst
ADC register.
Definition: hal.h:289
IRQn_Type IRQn
GPIO IRQN.
Definition: hal.h:282
IRQn_Type IRQn
ADC IRQN.
Definition: hal.h:293
HAL_CAPTURE_TIMER
Definition: hal.h:150
Index associated to fault 1.
Definition: hal.h:162
void HAL_init()
Initializes the hal object.
Definition: hal.c:84
Index associated to chip select 0.
Definition: hal.h:178
Index associated to input capture 1.
Definition: hal.h:153
HAL_GPIO_OUT
Definition: hal.h:124
uint32_t HAL_getCaptureFrequency(HAL_CAPTURE_TIMER capture)
Calculates the capture frequency.
Definition: hal.c:465
void HAL_writeGPIOPin(HAL_GPIO_OUT pin, HAL_GPIO_STATE value)
Write to GPIOpin.
Definition: hal.c:193
__STATIC_INLINE void HAL_delayMicroSeconds(uint32_t microSeconds)
Delays for specific time in microseconds.
Definition: hal.h:487
bool HAL_readGPIOPin(HAL_GPIO_IN pin)
Reads a GPIOpin.
Definition: hal.c:183