MSPM0G3519SensoredFOCMotorControlLibrary  1.0
Macros | Enumerations | Functions
focHALInterface.h File Reference

Detailed Description

HAL interface for FOC Module.


Overview

HAL Apis used by FOC motor control


#include "ti_msp_dl_config.h"
#include <ti/iqmath/include/IQmathLib.h>
#include "IQmath_mathacl.h"
#include "focPeriphInit.h"
#include "gateDriver.h"
#include "stdint.h"
#include "measure.h"
#include "mcLib.h"
#include "main.h"
#include "iqNum.h"
#include "appInterface.h"
Include dependency graph for focHALInterface.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MIN_FLOAT_VOLTAGE   (0.1)
 Minimum floating voltage for phase in per unit.
 
#define MAX_FLOAT_VOLTAGE   (0.9)
 Maximum floating voltage for phase in per unit.
 
#define HAL_MCU_CLK_SPEED_HZ   (80000000)
 MCU clock frequency.
 
#define HAL_CYCLES_TO_1_US_DELAY   (HAL_MCU_CLK_SPEED_HZ/1000000)
 Cycles for 1 us delay.
 
#define HAL_GPIO_HIGH   (1)
 Gpio high state.
 
#define HAL_GPIO_LOW   (0)
 Gpio low state.
 

Enumerations

enum  VOLTAGE_VECTOR {
  VOLTAGE_VECTOR_AC = 0,
  VOLTAGE_VECTOR_CA,
  VOLTAGE_VECTOR_BC,
  VOLTAGE_VECTOR_CB,
  VOLTAGE_VECTOR_BA,
  VOLTAGE_VECTOR_AB,
  VOLTAGE_VECTOR_MAX
}
 VOLTAGE_VECTOR. More...
 

Functions

void HAL_ReadMotorInputs (HAL_MEASURE_MOTOR_INPUTS_T *pMotorInputs)
 Read Motor inputs. More...
 
void HAL_SetPhaseCurrentChannels (HAL_MEASURE_MOTOR_INPUTS_T *pMotorInputs)
 Set Phase current channels. More...
 
void HAL_setADCIdxChannel (ADC12_Regs *adc12, DL_ADC12_MEM_IDX idx, uint32_t chansel)
 Set ADC channel to index. More...
 
void HAL_ReadCurrents (HAL_MEASURE_MOTOR_INPUTS_T *pMotorInputs)
 Read phase currents. More...
 
void HAL_SelectShuntMeasure (HAL_MEASURE_MOTOR_INPUTS_T *pMotorInputs)
 Select two shunt if duty saturates in any phases. More...
 
void HAL_EnablePWM (void)
 Enable PWMs.
 
void HAL_DisablePWM (void)
 Disable PWMs and all outputs are forced low.
 
void HAL_EnableLowSideBrake (void)
 Turns all low side PWM outputs high.
 
void HAL_UpdateDuty (const MC_ABC_T *pABC, const int32_t FullDuty, MC_SECTOR_TYPES voltageSector, int32_t minDelta, int32_t blankingTime)
 Set PWM dutycycles. More...
 
void HAL_SetPWMFrequency (const int32_t pwmPeriod, const int32_t propagationDelay)
 Set PWM Frequency. More...
 
void HAL_SetADCSamplingFrequency (const ADC_SAMPLING_RATIO_TYPES samplingRatio)
 Set ADC sampling frequency. More...
 
void HAL_SetSystemFrequency (const int32_t systemPeriod)
 Set System timer frequency. More...
 
void HAL_ClearNFault (void)
 Sets Nfault pin low.
 
void HAL_SetNFault (void)
 Sets Nfault pin high.
 
uint32_t HAL_getRawHVdieFaultStatus (void)
 Gets the latched fault status. More...
 
uint32_t HAL_getRawFaultStatus (void)
 Gets the fault status. More...
 
void HAL_clearFaultStatus (void)
 Clears the fault status in pwm.
 
void HAL_setGateDriveOffsetCalib (void)
 Starts gate driver offset calibration.
 
void HAL_resetGateDriveOffsetCalib (void)
 Stops gate driver offset calibration.
 
void HAL_pwmCountZero (void)
 Set PWMs to zero.
 
void HAL_delayMicroSeconds (uint32_t num_us)
 Blocks for the specified delay time. More...
 
void HAL_DisableINT (void)
 Disables all the interrupts.
 
void HAL_resetPOR (void)
 Triggers a POR reset.
 
_Bool HAL_getDirPinStatus (void)
 Get the status of the Direction pin. More...
 
uint16_t HAL_Is_SingleShunt (void)
 Returns Shunt Config. More...
 
_Bool HAL_getBrakePinStatus (void)
 Get the status of the brake pin. More...
 
__STATIC_INLINE void HAL_TimerOverRideCCPOut (GPTIMER_Regs *gptimer, DL_TIMER_FORCE_OUT out, DL_TIMER_FORCE_CMPL_OUT outComp, DL_TIMER_CC_INDEX ccIndex)
 Overrides the timer CCP output. More...
 
__STATIC_INLINE void HAL_FGToggle (void)
 Toggle the GPIO to high and low for every sector change.
 
__STATIC_INLINE void HAL_PWMForceHigh (DL_TIMER_CC_INDEX CCIdx)
 Force the PWM out to high and complement out to low. More...
 
__STATIC_INLINE void HAL_PWMForceLow (DL_TIMER_CC_INDEX CCIdx)
 Force the PWM out to low and complement out to high. More...
 
__STATIC_INLINE void HAL_PWMForceDisable (DL_TIMER_CC_INDEX CCIdx)
 Disable forcing the PWM out and complement out. More...
 
__STATIC_INLINE void HAL_PWMAllForceDisable ()
 Disable forcing All PWM out and complement out.
 
__STATIC_INLINE void HAL_PWMAllForceLow ()
 Forcing low All PWM out and complement out.
 
__STATIC_INLINE void HAL_setCaptureCompareValue (GPTIMER_Regs *gptimer, uint32_t value, DL_TIMER_CC_INDEX ccIndex)
 Set the Capture Compare Value for Timer. More...
 

Enumeration Type Documentation

§ VOLTAGE_VECTOR

VOLTAGE_VECTOR.

Enumerator
VOLTAGE_VECTOR_AC 

IPD vector AC

VOLTAGE_VECTOR_CA 

IPD vector CA

VOLTAGE_VECTOR_BC 

IPD vector BC

VOLTAGE_VECTOR_CB 

IPD vector CB

VOLTAGE_VECTOR_BA 

IPD vector BA

VOLTAGE_VECTOR_AB 

IPD vector AB

VOLTAGE_VECTOR_MAX 

Max number of IPD vectors

Function Documentation

§ HAL_ReadMotorInputs()

void HAL_ReadMotorInputs ( HAL_MEASURE_MOTOR_INPUTS_T pMotorInputs)

§ HAL_SetPhaseCurrentChannels()

void HAL_SetPhaseCurrentChannels ( HAL_MEASURE_MOTOR_INPUTS_T pMotorInputs)

Set Phase current channels.

Parameters
[in]pMotorInputsPointer to motor input

References HAL_MEASURE_MOTOR_INPUTS_T::current, HAL_MEASURE_CURRENT_T::currentShunt, FOC_ADC0_INST, FOC_ADC1_INST, and HAL_GD_ConfigureCurrentChannels().

Referenced by HAL_SelectShuntMeasure(), loadRun(), and measureCurrentOffset().

§ HAL_setADCIdxChannel()

void HAL_setADCIdxChannel ( ADC12_Regs *  adc12,
DL_ADC12_MEM_IDX  idx,
uint32_t  chansel 
)

Set ADC channel to index.

Parameters
[in]adc12Pointer to ADC instance
[in]idxADC index
[in]chanselchannel to set in index

§ HAL_ReadCurrents()

void HAL_ReadCurrents ( HAL_MEASURE_MOTOR_INPUTS_T pMotorInputs)

§ HAL_SelectShuntMeasure()

void HAL_SelectShuntMeasure ( HAL_MEASURE_MOTOR_INPUTS_T pMotorInputs)

§ HAL_UpdateDuty()

void HAL_UpdateDuty ( const MC_ABC_T pABC,
const int32_t  FullDuty,
MC_SECTOR_TYPES  voltageSector,
int32_t  minDelta,
int32_t  blankingTime 
)

Set PWM dutycycles.

Parameters
[in]pABCPointer to dutycycle
[in]FullDutyFull dutycycle
[in]voltageSectorVoltage sector
[in]minDeltaminimum PWM delta
[in]blankingTimeBlanking time

§ HAL_SetPWMFrequency()

void HAL_SetPWMFrequency ( const int32_t  pwmPeriod,
const int32_t  propagationDelay 
)

Set PWM Frequency.

Parameters
[in]pwmPeriodPWM period to set
[in]propagationDelayPropagation delay

References ADC_PWM_TRIG_CH, FOC_PWMA0_ADC_TRIG_LOAD_EVENT, FOC_PWMA0_INST, FOC_TIMA1_INST, and HAL_setCaptureCompareValue().

Referenced by updateConfigurationParameters().

§ HAL_SetADCSamplingFrequency()

void HAL_SetADCSamplingFrequency ( const ADC_SAMPLING_RATIO_TYPES  samplingRatio)

Set ADC sampling frequency.

Parameters
[in]samplingRatioADC sampling ratio

References ADC_PWM_TRIG_CH, FOC_ADC0_INST, FOC_ADC1_INST, FOC_PWMA0_INST, FOC_TIMA1_INST, and HAL_setCaptureCompareValue().

Referenced by updateConfigurationParameters().

§ HAL_SetSystemFrequency()

void HAL_SetSystemFrequency ( const int32_t  systemPeriod)

Set System timer frequency.

Parameters
[in]systemPeriodTimer period

References FOC_TIMER_INST.

Referenced by updateConfigurationParameters().

§ HAL_getRawHVdieFaultStatus()

uint32_t HAL_getRawHVdieFaultStatus ( void  )

Gets the latched fault status.

Returns
Returns latched Fault status

References FOC_PWMA0_INST.

§ HAL_getRawFaultStatus()

uint32_t HAL_getRawFaultStatus ( void  )

Gets the fault status.

Returns
Returns Fault status

References FOC_PWMA0_INST.

Referenced by FOC_fault_Recovery().

§ HAL_getDirPinStatus()

_Bool HAL_getDirPinStatus ( void  )

Get the status of the Direction pin.

Returns
Returns GPIO state of Direction pin
Return values
trueDirection pin is high
falseDirection pin is low

References FOC_GPIO_DIR_PIN, FOC_GPIO_DIR_PORT, HAL_GPIO_HIGH, and HAL_GPIO_LOW.

Referenced by update_DirectionStatus().

§ HAL_Is_SingleShunt()

uint16_t HAL_Is_SingleShunt ( void  )

Returns Shunt Config.

Returns
Returns True for Single Shunt Config

References FALSE, and TRUE.

§ HAL_getBrakePinStatus()

_Bool HAL_getBrakePinStatus ( void  )

Get the status of the brake pin.

Returns
Returns GPIO state of brake pin
Return values
truebrake pin is high
falsebrake pin is low

References FOC_GPIO_BRAKE_PIN, FOC_GPIO_BRAKE_PORT, HAL_GPIO_HIGH, and HAL_GPIO_LOW.

Referenced by update_BrakeStatus().

§ HAL_TimerOverRideCCPOut()

__STATIC_INLINE void HAL_TimerOverRideCCPOut ( GPTIMER_Regs *  gptimer,
DL_TIMER_FORCE_OUT  out,
DL_TIMER_FORCE_CMPL_OUT  outComp,
DL_TIMER_CC_INDEX  ccIndex 
)

Overrides the timer CCP output.

Parameters
[in]gptimerPointer to timer instance.
[in]outSpecifies the CCP output state.
[in]outCompSpecifies the complementary output state.
[in]ccIndexCapture Compare Index.

Referenced by HAL_DisablePWM(), HAL_EnableLowSideBrake(), HAL_EnablePWM(), HAL_PWMForceDisable(), HAL_PWMForceHigh(), and HAL_PWMForceLow().

§ HAL_PWMForceHigh()

__STATIC_INLINE void HAL_PWMForceHigh ( DL_TIMER_CC_INDEX  CCIdx)

Force the PWM out to high and complement out to low.

Parameters
[in]CCIdxA PWM CC index.

References FOC_PWMA0_INST, and HAL_TimerOverRideCCPOut().

§ HAL_PWMForceLow()

__STATIC_INLINE void HAL_PWMForceLow ( DL_TIMER_CC_INDEX  CCIdx)

Force the PWM out to low and complement out to high.

Parameters
[in]CCIdxA PWM CC index.

References FOC_PWMA0_INST, and HAL_TimerOverRideCCPOut().

Referenced by HAL_EnableLowSideBrake(), and HAL_PWMAllForceLow().

§ HAL_PWMForceDisable()

__STATIC_INLINE void HAL_PWMForceDisable ( DL_TIMER_CC_INDEX  CCIdx)

Disable forcing the PWM out and complement out.

Parameters
[in]CCIdxA PWM CC index.

References FOC_PWMA0_INST, and HAL_TimerOverRideCCPOut().

Referenced by HAL_EnableLowSideBrake(), and HAL_PWMAllForceDisable().

§ HAL_setCaptureCompareValue()

__STATIC_INLINE void HAL_setCaptureCompareValue ( GPTIMER_Regs *  gptimer,
uint32_t  value,
DL_TIMER_CC_INDEX  ccIndex 
)

Set the Capture Compare Value for Timer.

Parameters
[in]gptimerPointer to timer instance.
[in]valueCompare Value.
[in]ccIndexCapture Compare Index.

Referenced by HAL_DisablePWM(), HAL_EnableLowSideBrake(), HAL_pwmCountZero(), HAL_SetADCSamplingFrequency(), and HAL_SetPWMFrequency().

© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale