![]() |
![]() |
MSPM0C1106HallSensoredTrapMotorControlLibrary
1.0
|
Data Structures | |
struct | drv8311_Instance |
Defines drv8311 instance. More... | |
Macros | |
#define | drv8311_MAXIMUM_RESET_TIME (40) |
Defines the time to clear the nSLEEP pin to reset faults. | |
#define | drv8311_MAXIMUM_WAKEUP_TIME (2000) |
Defines the time to wakeup the drv after reset. | |
#define | drv8311_VOLTAGE_CONV_CONST _IQ20(8.143) |
Defines voltage conversion constant. | |
#define | drv8311_CSA_REF_VOLTAGE (3000) |
Defines CSA reference voltage. | |
#define | drv8311_CSAGAIN_0P25VA_IQ _IQ20(0.25) |
Defines CSA gains 0.25 in IQ20. | |
#define | drv8311_CSAGAIN_0P5VA_IQ _IQ20(0.5) |
Defines CSA gains 0.5 in IQ20. | |
#define | drv8311_CSAGAIN_1P0VA_IQ _IQ20(1.0) |
Defines CSA gains 1.0 in IQ20. | |
#define | drv8311_CSAGAIN_2P0VA_IQ _IQ20(2.0) |
Defines CSA gains 2.0 in IQ20. | |
Enumerations | |
enum | drv8311_CSAGAIN { drv8311_CSAGAIN_0P25VA = 0x00 << 0, drv8311_CSAGAIN_0P5VA = 0x01 << 0, drv8311_CSAGAIN_1P0VA = 0x02 << 0, drv8311_CSAGAIN_2P0VA = 0x03 << 0 } |
enum | drv8311_DRVOFF_PIN_STAT { drv8311_DRVOFF_PIN_LOW = HAL_GPIO_PIN_LOW, drv8311_DRVOFF_PIN_HIGH = HAL_GPIO_PIN_HIGH } |
enum | drv8311_DRV_NSLEEP_STAT { drv8311_DRV_NSLEEP_SLEEP = HAL_GPIO_PIN_LOW, drv8311_DRV_NSLEEP_AWAKE = HAL_GPIO_PIN_HIGH } |
Functions | |
__STATIC_INLINE void | drv8311_setDrvoff (drv8311_Instance *drvHandle, drv8311_DRVOFF_PIN_STAT value) |
set drvoff More... | |
__STATIC_INLINE void | drv8311_setnSleep (drv8311_Instance *drvHandle, drv8311_DRV_NSLEEP_STAT value) |
set nSleep More... | |
void | drv8311_init (drv8311_Instance *drvHandle) |
initialize the drv8311 module More... | |
void | drv8311_enable (drv8311_Instance *drvHandle) |
Enable DRV. More... | |
void | drv8311_updateCSAScaleFactor (drv8311_Instance *drvHandle, drv8311_CSAGAIN csa) |
updates the current gain scale factor More... | |
_iq20 | drv8311_getVoltage (HAL_ADC_CHAN chan) |
Get voltage from adc channel. More... | |
_iq20 | drv8311_getCurrent (HAL_ADC_CHAN chan, drv8311_Instance *drvHandle, _iq20 vRef) |
Get current from adc channel. More... | |
void | drv8311_ADCVRefSel (HAL_ADC_VREF adcRef, HAL_ADC_CHAN chan, HAL_ADC_INT_VREF internalVRef, uint16_t externalVRef) |
updates the adc voltage reference More... | |
__STATIC_INLINE _iq20 | drv8311_getcsaVref (uint16_t vRef) |
get Current reference in IQ20 More... | |
enum drv8311_CSAGAIN |
__STATIC_INLINE void drv8311_setDrvoff | ( | drv8311_Instance * | drvHandle, |
drv8311_DRVOFF_PIN_STAT | value | ||
) |
set drvoff
[in] | drvHandle | The drv instance |
[in] | value | drvoff value |
References drv8311_DRVOFF_PIN_HIGH, drv8311_DRVOFF_PIN_LOW, drv8311_Instance::drvoff, HAL_GPIO_PIN_HIGH, HAL_GPIO_PIN_LOW, and HAL_writeGPIOPin().
Referenced by drv8311_enable().
__STATIC_INLINE void drv8311_setnSleep | ( | drv8311_Instance * | drvHandle, |
drv8311_DRV_NSLEEP_STAT | value | ||
) |
set nSleep
[in] | drvHandle | The drv instance |
[in] | value | nSleep value |
References drv8311_ADCVRefSel(), drv8311_DRV_NSLEEP_AWAKE, drv8311_DRV_NSLEEP_SLEEP, drv8311_enable(), drv8311_getCurrent(), drv8311_getVoltage(), drv8311_init(), drv8311_MAXIMUM_WAKEUP_TIME, drv8311_updateCSAScaleFactor(), HAL_delayMicroSeconds(), HAL_GPIO_PIN_HIGH, HAL_GPIO_PIN_LOW, HAL_writeGPIOPin(), and drv8311_Instance::nsleep.
Referenced by drv8311_enable().
void drv8311_init | ( | drv8311_Instance * | drvHandle | ) |
initialize the drv8311 module
[in] | drvHandle | The drv instance |
References HAL_enableADCInterrupt(), drv8311_Instance::IsenA, drv8311_Instance::IsenB, drv8311_Instance::IsenC, drv8311_Instance::Vsen, drv8311_Instance::VsenA, drv8311_Instance::VsenB, and drv8311_Instance::VsenC.
Referenced by drv8311_setnSleep().
void drv8311_enable | ( | drv8311_Instance * | drvHandle | ) |
Enable DRV.
[in] | drvHandle | The drv instance |
References drv8311_DRV_NSLEEP_AWAKE, drv8311_DRV_NSLEEP_SLEEP, drv8311_DRVOFF_PIN_LOW, drv8311_setDrvoff(), and drv8311_setnSleep().
Referenced by drv8311_setnSleep().
void drv8311_updateCSAScaleFactor | ( | drv8311_Instance * | drvHandle, |
drv8311_CSAGAIN | csa | ||
) |
updates the current gain scale factor
[in] | drvHandle | The drv instance |
[in] | csa | drv8311 CSA gain value |
References drv8311_Instance::csa_sf, drv8311_CSAGAIN_0P25VA, drv8311_CSAGAIN_0P25VA_IQ, drv8311_CSAGAIN_0P5VA, drv8311_CSAGAIN_0P5VA_IQ, drv8311_CSAGAIN_1P0VA, drv8311_CSAGAIN_1P0VA_IQ, drv8311_CSAGAIN_2P0VA, and drv8311_CSAGAIN_2P0VA_IQ.
Referenced by drv8311_setnSleep().
_iq20 drv8311_getVoltage | ( | HAL_ADC_CHAN | chan | ) |
Get voltage from adc channel.
[in] | chan | The ADC channel name |
References drv8311_VOLTAGE_CONV_CONST, and HAL_getIQ20VoltageFromADC().
Referenced by drv8311_setnSleep().
_iq20 drv8311_getCurrent | ( | HAL_ADC_CHAN | chan, |
drv8311_Instance * | drvHandle, | ||
_iq20 | vRef | ||
) |
Get current from adc channel.
[in] | chan | The ADC channel name |
[in] | drvHandle | The drv instance |
[in] | vRef | voltage reference for current |
References drv8311_Instance::csa_sf, and HAL_getIQ20VoltageFromADC().
Referenced by drv8311_setnSleep().
void drv8311_ADCVRefSel | ( | HAL_ADC_VREF | adcRef, |
HAL_ADC_CHAN | chan, | ||
HAL_ADC_INT_VREF | internalVRef, | ||
uint16_t | externalVRef | ||
) |
updates the adc voltage reference
[in] | adcRef | ADC voltage reference |
[in] | chan | ADC channel name |
[in] | internalVRef | Internal reference voltage |
[in] | externalVRef | External reference voltage |
References HAL_ADC_VREF_EXTERNAL, HAL_ADC_VREF_INTERNAL, HAL_ADC_VREF_VDDA, HAL_setADCVRefExternal(), HAL_setADCVRefInternal(), and HAL_setADCVRefVDDA().
Referenced by drv8311_setnSleep().
__STATIC_INLINE _iq20 drv8311_getcsaVref | ( | uint16_t | vRef | ) |
get Current reference in IQ20
[in] | vRef | CSA reference voltage in milli volts |