![]() |
![]() |
|
MSPM0L1306HallSensoredTrapMotorControlLibrary
1.0
|
Data Structures | |
| struct | HAL_GPIO_Instance_ |
| Defines a GPIO instance. More... | |
| struct | HAL_ADC_instance_ |
| Defines a ADC instance. More... | |
| struct | HAL_Timer_Instance_ |
| Defines a timer instance. More... | |
| struct | HAL_fault_instance |
| Defines a fault instance. More... | |
Macros | |
| #define | HAL_SYSTEM_FREQ_MHZ ((int32_t)32) |
| Defines the system clock frequency, MHz. | |
| #define | HAL_PWM_TIMER_FREQ_MHZ ((int32_t)32) |
| Defines the pwm timer frequency in MHz. | |
| #define | HAL_CAPTURE_TIMER_FREQ ((int32_t)40000) |
| Defines the input capture timer frequency in Hz. | |
| #define | HAL_VDDA_REFVOLTAGE (3300) |
| Defines default ADC refernce voltage. | |
| #define | MAX_ADC_VALUE (4095) |
| Defines ADC max value. | |
Typedefs | |
| typedef struct HAL_GPIO_Instance_ | HAL_GPIO_Instance |
| Defines a GPIO instance. | |
| typedef struct HAL_ADC_instance_ | HAL_ADC_instance |
| Defines a ADC instance. | |
| typedef struct HAL_Timer_Instance_ | HAL_Timer_Instance |
| Defines a timer instance. | |
| typedef struct HAL_fault_instance | HAL_fault_Instance |
| Defines a fault instance. | |
Functions | |
| void | HAL_init () |
| Initializes the hal object. More... | |
| bool | HAL_readGPIOPin (HAL_GPIO_IN pin) |
| Reads a GPIOpin. More... | |
| void | HAL_writeGPIOPin (HAL_GPIO_OUT pin, HAL_GPIO_STATE value) |
| Write to GPIOpin. More... | |
| void | HAL_setDeadband (HAL_PWM pwm, uint16_t deadband) |
| Sets deadband for timer. More... | |
| void | HAL_setPWMFreq (HAL_PWM pwm, uint32_t PWMFreq) |
| Sets PWMfreq for all timers. More... | |
| void | HAL_writeSPI16 (HAL_SPI_CHAN chan, HAL_SPI_CS cs, uint16_t data) |
| Write data to spi. More... | |
| uint16_t | HAL_readSPI16 (HAL_SPI_CHAN chan, HAL_SPI_CS cs) |
| Read data from spi. More... | |
| void | HAL_setADCRefVoltage (HAL_ADC_CHAN chan, uint16_t voltage_mV) |
| Set ADC reference voltage. More... | |
| uint32_t | HAL_getmvFromADC (HAL_ADC_CHAN chan) |
| Get milli volts from ADC. More... | |
| _iq20 | HAL_getIQ20VoltageFromADC (HAL_ADC_CHAN chan) |
| Get volts from ADC in _IQ20. More... | |
| HAL_ADC_IIDX | HAL_processADCIRQ (ADC12_Regs *adcInst) |
| Read ADC values from results. More... | |
| void | HAL_enableADCInterrupt (HAL_ADC_CHAN chan) |
| Enables ADC interrupts. More... | |
| void | HAL_enableGPIOInterrupt (HAL_GPIO_IN pin) |
| Enables GPIO interrupts. More... | |
| void | HAL_enablePWMInterrupt (HAL_PWM PWM) |
| Enables PWM interrupts. More... | |
| void | HAL_enableCaptureInterrupt (HAL_CAPTURE_TIMER capture) |
| Enables capture interrupts. More... | |
| void | HAL_setADCVRefVDDA (HAL_ADC_CHAN chan) |
| Set ADC voltage reference to VDDA. More... | |
| void | HAL_setADCVRefInternal (HAL_ADC_CHAN chan, HAL_ADC_INT_VREF internalVRef) |
| Set ADC voltage reference to internal reference. More... | |
| void | HAL_setADCVRefExternal (HAL_ADC_CHAN chan, uint16_t externalVRef) |
| Set ADC voltage reference to external reference. More... | |
| bool | HAL_getTimerFaultStatus (HAL_FAULT_INPUT fault) |
| Read the PWM timer fault bit. More... | |
| uint32_t | HAL_getCaptureFrequency (HAL_CAPTURE_TIMER capture) |
| Calculates the capture frequency. More... | |
| void | HAL_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 void | HAL_delayMicroSeconds (uint32_t microSeconds) |
| Delays for specific time in microseconds. More... | |
| __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. More... | |
| __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. More... | |
| __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. More... | |
Variables | |
| HAL_Timer_Instance | PWMBase [HAL_PWM_MAX] |
| Array for storing the PWM instances. | |
| HAL_Timer_Instance | inputCapture [HAL_CAPTURE_TIMER_MAX] |
| Array to store the capture instances. | |
| HAL_ADC_instance | ADCChannel [HAL_ADC_CHAN_MAX] |
| Array for storing the ADC instances. | |
| HAL_fault_Instance | faultInput [HAL_FAULT_INPUT_MAX] |
| Array to store the fault instances. | |
The HAL module provides micro-controller agnostic set of application programming interfaces (APIs) to be used by other module's in the library as well as in the user's application code.
| enum HAL_GPIO_STATE |
| enum HAL_ADC_CHAN |
| enum HAL_GPIO_IN |
| enum HAL_GPIO_OUT |
| enum HAL_PWM |
| enum HAL_CAPTURE_TIMER |
| enum HAL_FAULT_INPUT |
| enum HAL_SPI_CHAN |
| enum HAL_SPI_CS |
| enum HAL_ADC_VREF |
| enum HAL_ADC_INT_VREF |
| enum HAL_ADC_IIDX |
| void HAL_init | ( | ) |
Initializes the hal object.
Initializes the hal object.
References HAL_Timer_Instance_::ccCompIndex, HAL_Timer_Instance_::ccIndex, HAL_Timer_Instance_::deadBand, HAL_ADC_instance_::endOfSeq, HAL_Timer_Instance_::gptimer, HAL_ADC_CHAN_0, HAL_ADC_CHAN_1, HAL_ADC_CHAN_MAX, HAL_ADC_IIDX_MEM1_RESULT_LOADED, HAL_CAPTURE_TIMER_01, HAL_FAULT_INPUT_1, HAL_GPIO_IN_01, HAL_GPIO_IN_02, HAL_GPIO_IN_03, HAL_GPIO_OUT_01, HAL_GPIO_OUT_02, HAL_PWM_01, HAL_PWM_02, HAL_PWM_03, HAL_SPI_CHAN_0, HAL_SPI_CS_0, HAL_SPI_CS_1, HAL_SPI_CS_2, HAL_SPI_CS_3, HAL_VDDA_REFVOLTAGE, HAL_ADC_instance_::inst, HAL_GPIO_Instance_::iomux, HAL_GPIO_Instance_::IRQn, HAL_ADC_instance_::IRQn, HAL_Timer_Instance_::IRQn, HAL_ADC_instance_::memIdx, HAL_GPIO_Instance_::pin, HAL_fault_instance::pin, HAL_GPIO_Instance_::port, HAL_fault_instance::port, HAL_ADC_instance_::refVoltagemV, and HAL_ADC_instance_::value.
| bool HAL_readGPIOPin | ( | HAL_GPIO_IN | pin | ) |
Reads a GPIOpin.
| [in] | pin | GPIOpin to be read |
Referenced by Halltrap_PWMUpdate().
| void HAL_writeGPIOPin | ( | HAL_GPIO_OUT | pin, |
| HAL_GPIO_STATE | value | ||
| ) |
Write to GPIOpin.
| [in] | pin | GPIOpin to write |
| [in] | value | Value to be written |
References HAL_GPIO_PIN_HIGH, and HAL_GPIO_PIN_LOW.
Referenced by drv8311_setDrvoff(), drv8311_setnSleep(), DRV8316_setDrvoff(), DRV8316_setnSleep(), drv8317_setDrvoff(), drv8317_setnSleep(), DRV8323_setnSleep(), drv8328_setDrvoff(), drv8328_setnSleep(), DRV8329_setDrvoff(), DRV8329_setnSleep(), and DRV8353_setnSleep().
| void HAL_setDeadband | ( | HAL_PWM | pwm, |
| uint16_t | deadband | ||
| ) |
Sets deadband for timer.
| [in] | pwm | PWM timer |
| [in] | deadband | Delay time in nanoseconds |
References HAL_Timer_Instance_::deadBand, and HAL_PWM_TIMER_FREQ_MHZ.
Referenced by Halltrap_setDeadband().
| void HAL_setPWMFreq | ( | HAL_PWM | pwm, |
| uint32_t | PWMFreq | ||
| ) |
Sets PWMfreq for all timers.
| [in] | pwm | PWM timer |
| [in] | PWMFreq | PWM frequency of the motor phase |
References HAL_Timer_Instance_::gptimer, and HAL_PWM_TIMER_FREQ_MHZ.
Referenced by Halltrap_setPWMFreq().
| void HAL_writeSPI16 | ( | HAL_SPI_CHAN | chan, |
| HAL_SPI_CS | cs, | ||
| uint16_t | data | ||
| ) |
Write data to spi.
| [in] | chan | The SPI channel |
| [in] | cs | Channel select pin |
| [in] | data | Data to write |
Referenced by DRV8316_init().
| uint16_t HAL_readSPI16 | ( | HAL_SPI_CHAN | chan, |
| HAL_SPI_CS | cs | ||
| ) |
Read data from spi.
| [in] | chan | The SPI channel |
| [in] | cs | Channel select pin |
Referenced by DRV8316_init().
| void HAL_setADCRefVoltage | ( | HAL_ADC_CHAN | chan, |
| uint16_t | voltage_mV | ||
| ) |
Set ADC reference voltage.
| [in] | chan | The ADC channel |
| [in] | voltage_mV | Reference voltage |
References HAL_ADC_instance_::refVoltagemV.
| uint32_t HAL_getmvFromADC | ( | HAL_ADC_CHAN | chan | ) |
Get milli volts from ADC.
| [in] | chan | The ADC channel |
References MAX_ADC_VALUE, HAL_ADC_instance_::refVoltagemV, and HAL_ADC_instance_::value.
Referenced by HAL_getIQ20VoltageFromADC().
| _iq20 HAL_getIQ20VoltageFromADC | ( | HAL_ADC_CHAN | chan | ) |
Get volts from ADC in _IQ20.
| [in] | chan | The ADC channel |
References HAL_getmvFromADC().
Referenced by DRV8300_getCurrent(), DRV8300_getVoltage(), drv8311_getCurrent(), drv8311_getVoltage(), DRV8316_getCurrent(), DRV8316_getVoltage(), drv8317_getCurrent(), drv8317_getVoltage(), DRV8323_getCurrent(), DRV8323_getVoltage(), drv8328_getCurrent(), drv8328_getVoltage(), DRV8329_getCurrent(), DRV8329_getVoltage(), DRV8353_getCurrent(), and DRV8353_getVoltage().
| HAL_ADC_IIDX HAL_processADCIRQ | ( | ADC12_Regs * | adcInst | ) |
Read ADC values from results.
| [in] | adcInst | ADC instances |
References HAL_ADC_CHAN_MAX, and HAL_ADC_instance_::value.
| void HAL_enableADCInterrupt | ( | HAL_ADC_CHAN | chan | ) |
Enables ADC interrupts.
| [in] | chan | The ADC channel |
References HAL_ADC_instance_::IRQn.
Referenced by DRV8300_init(), drv8311_init(), DRV8316_init(), drv8317_init(), DRV8323_init(), drv8328_init(), DRV8329_init(), and DRV8353_init().
| void HAL_enableGPIOInterrupt | ( | HAL_GPIO_IN | pin | ) |
Enables GPIO interrupts.
| [in] | pin | The GPIO pin |
References HAL_GPIO_Instance_::IRQn.
Referenced by Halltrap_Init().
| void HAL_enablePWMInterrupt | ( | HAL_PWM | pwm | ) |
| void HAL_enableCaptureInterrupt | ( | HAL_CAPTURE_TIMER | capture | ) |
Enables capture interrupts.
| [in] | capture | The capture channel |
References HAL_Timer_Instance_::IRQn.
Referenced by Halltrap_Init().
| void HAL_setADCVRefVDDA | ( | HAL_ADC_CHAN | chan | ) |
Set ADC voltage reference to VDDA.
| [in] | chan | The ADC channel |
References HAL_VDDA_REFVOLTAGE, HAL_ADC_instance_::inst, HAL_ADC_instance_::memIdx, and HAL_ADC_instance_::refVoltagemV.
Referenced by DRV8300_ADCVRefSel(), drv8311_ADCVRefSel(), DRV8316_ADCVRefSel(), drv8317_ADCVRefSel(), DRV8323_ADCVRefSel(), drv8328_ADCVRefSel(), DRV8329_ADCVRefSel(), DRV8353_ADCVRefSel(), and HAL_ADCVRefSel().
| void HAL_setADCVRefInternal | ( | HAL_ADC_CHAN | chan, |
| HAL_ADC_INT_VREF | internalVRef | ||
| ) |
Set ADC voltage reference to internal reference.
| [in] | chan | The ADC channel |
| [in] | internalVRef | Internal reference voltage |
References HAL_ADC_INT_VREF_1P4V, HAL_ADC_INT_VREF_2P5V, HAL_ADC_instance_::inst, HAL_ADC_instance_::memIdx, and HAL_ADC_instance_::refVoltagemV.
Referenced by DRV8300_ADCVRefSel(), drv8311_ADCVRefSel(), DRV8316_ADCVRefSel(), drv8317_ADCVRefSel(), DRV8323_ADCVRefSel(), drv8328_ADCVRefSel(), DRV8329_ADCVRefSel(), DRV8353_ADCVRefSel(), and HAL_ADCVRefSel().
| void HAL_setADCVRefExternal | ( | HAL_ADC_CHAN | chan, |
| uint16_t | externalVRef | ||
| ) |
Set ADC voltage reference to external reference.
| [in] | chan | The ADC channel |
| [in] | externalVRef | External reference voltage |
References HAL_ADC_instance_::inst, HAL_ADC_instance_::memIdx, and HAL_ADC_instance_::refVoltagemV.
Referenced by DRV8300_ADCVRefSel(), drv8311_ADCVRefSel(), DRV8316_ADCVRefSel(), drv8317_ADCVRefSel(), DRV8323_ADCVRefSel(), drv8328_ADCVRefSel(), DRV8329_ADCVRefSel(), DRV8353_ADCVRefSel(), and HAL_ADCVRefSel().
| bool HAL_getTimerFaultStatus | ( | HAL_FAULT_INPUT | fault | ) |
Read the PWM timer fault bit.
| [in] | fault | The fault input |
| uint32_t HAL_getCaptureFrequency | ( | HAL_CAPTURE_TIMER | capture | ) |
Calculates the capture frequency.
| [in] | capture | The capture channel |
References HAL_Timer_Instance_::ccIndex, HAL_Timer_Instance_::gptimer, and HAL_CAPTURE_TIMER_FREQ.
Referenced by Halltrap_calculateMotorSpeed().
| void HAL_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 | The 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().
| __STATIC_INLINE void HAL_delayMicroSeconds | ( | uint32_t | microSeconds | ) |
Delays for specific time in microseconds.
| [in] | microSeconds | Delayed time in microseconds |
References HAL_SYSTEM_FREQ_MHZ.
Referenced by drv8311_setnSleep(), DRV8316_setnSleep(), drv8317_setnSleep(), DRV8323_setnSleep(), drv8328_setnSleep(), DRV8329_setnSleep(), DRV8353_setnSleep(), and Halltrap_changeMotorDirection().
| __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.
| [in] | posPhase | phase whose output should be pwm |
| [in] | gndPhase | phase whose output should be ground |
| [in] | opnPhase | phase whose output should be open |
| [in] | PWMDuty | dutycycle of the pwm in percentage |
References HAL_Timer_Instance_::ccCompIndex, HAL_Timer_Instance_::ccIndex, HAL_Timer_Instance_::deadBand, and HAL_Timer_Instance_::gptimer.
Referenced by Halltrap_Init().
| __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.
| [in] | gndPhase_1 | phase whose output should be open |
| [in] | gndPhase_2 | phase whose output should be open |
| [in] | gndPhase_3 | phase whose output should be open |
References HAL_Timer_Instance_::ccCompIndex, HAL_Timer_Instance_::ccIndex, and HAL_Timer_Instance_::gptimer.
Referenced by Halltrap_changeMotorDirection(), Halltrap_disablePWM(), and Halltrap_stopMotor().
| __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.
| [in] | gndPhase_1 | phase whose output should be grounded |
| [in] | gndPhase_2 | phase whose output should be grounded |
| [in] | gndPhase_3 | phase whose output should be grounded |
References HAL_Timer_Instance_::ccCompIndex, HAL_Timer_Instance_::ccIndex, and HAL_Timer_Instance_::gptimer.
Referenced by Halltrap_stopMotor().