MSPM0C1106BrushedMotorControlLibrary  1.0
Macros | Enumerations | Functions
LP_MSPM0C1106 - Hardware Abstraction Layer (HAL)

Macros

#define HIGH   (PIN_MODE_OUTPUT_HIGH)
 Set GPIO output to high.
 
#define LOW   (PIN_MODE_OUTPUT_LOW)
 Set GPIO output to low.
 

Enumerations

enum  PIN_MODE {
  PIN_MODE_OUTPUT_LOW = 0,
  PIN_MODE_OUTPUT_HIGH,
  PIN_MODE_INPUT_PU,
  PIN_MODE_INPUT_PD,
  PIN_MODE_INPUT_HZ,
  PIN_MODE_PERIPHERAL,
  PIN_MODE_MAX
}
 
enum  PWM_CHANNELS {
  PWM_CHANNEL_0 = 0,
  PWM_CHANNEL_1,
  PWM_CHANNELS_MAX
}
 Channels described here simply references individual PWM output pins. This means a micro-controller can have a single peripheral such as a timer that can be used to generate 1 or more different PWM signals. Each of those PWM signals are considered seperate PWM channels. More...
 
enum  SPI_CHANNELS {
  SPI_CHANNEL_0 = 0,
  SPI_CHANNELS_MAX
}
 Channels described usually references individual SPI peripheral instances ie ( SCLK, PICO and POCI). More...
 
enum  SPI_CS {
  SPI_CS_0 = 0,
  SPI_CS_1,
  SPI_CS_2,
  SPI_CS_3,
  SPI_CS_MAX
}
 The chip select number here has no relationship with the physical chip select that the SPI peripheral instance has. For example, SPI_CS_0 can be mapped to the peripheral's CS2 or even a GPIO pin that is being used as a chip select. More...
 
enum  GPIO_OUTPUT_PINS {
  GPIO_OUTPUT_PIN_0 = 0,
  GPIO_OUTPUT_PIN_1,
  GPIO_OUTPUT_PIN_2,
  GPIO_OUTPUT_PIN_3,
  GPIO_OUTPUT_PIN_4,
  GPIO_OUTPUT_PINS_MAX
}
 
enum  GPIO_INPUT_PINS {
  GPIO_INPUT_PIN_0 = 0,
  GPIO_INPUT_PINS_MAX
}
 
enum  ADC_CHANS {
  ADC_CHAN_0 = 0,
  ADC_CHAN_1,
  ADC_CHANS_MAX
}
 

Functions

void HAL_setDutyCycle (PWM_CHANNELS pwmChan, uint8_t targetDutyCycle)
 Sets the PWM duty cycle for a specific channel. More...
 
void HAL_setPWMFreq (PWM_CHANNELS pwmChan, uint32_t targetFreq)
 Sets the PWM frequency for a specific channel. More...
 
void HAL_configurePWMPin (PWM_CHANNELS pwmChan, PIN_MODE mode)
 Sets the PWM pin to specified pin mode. More...
 
void HAL_writeSPI8withTimeout (SPI_CHANNELS spi_chan, SPI_CS cs_chan, uint8_t data, uint32_t timeout)
 Performs a 8-bit SPI write with timeout. More...
 
uint8_t HAL_readSPI8withTimeout (SPI_CHANNELS spi_chan, SPI_CS cs_chan, uint32_t timeout)
 Performs a 8-bit SPI read with timeout. More...
 
void HAL_writeSPI16withTimeout (SPI_CHANNELS spi_chan, SPI_CS cs_chan, uint16_t data, int32_t timeout)
 Performs a 16-bit SPI write with timeout. More...
 
uint16_t HAL_readSPI16withTimeout (SPI_CHANNELS spi_chan, SPI_CS cs_chan, int32_t timeout)
 Performs a 16-bit SPI write with timeout. More...
 
void HAL_delayMicroSeconds (uint32_t num_us)
 Delay function in microseconds. More...
 
void HAL_delayMilliSeconds (uint32_t num_us)
 Delay function in milliseconds. More...
 
bool HAL_readGPIOInput (GPIO_INPUT_PINS pin)
 Read GPIO input pin value. More...
 
void HAL_setGPIOOutput (GPIO_OUTPUT_PINS pin, PIN_MODE mode)
 Set output pin's value. More...
 
void HAL_Init ()
 Function called to run initialization code needed by the HAL.
 
void HAL_setADCRefVoltage (ADC_CHANS adcChan, uint16_t voltage_mV)
 Set the reference voltage that specified ADC channel is using. The software doesn't know what reference voltage is associated with the ADC channel so this needs to be manually configured. More...
 
uint16_t HAL_getRawADCValue (ADC_CHANS adcChan)
 Return the latest raw ADC value from the specified ADC channel. More...
 
uint32_t HAL_getmVfromADC (ADC_CHANS adcChan)
 Returns the voltage in mV read from the specified ADC channel. Important This function depends on the correct ADC reference voltage being set HAL_setADCRefVoltage. More...
 
_iq20 HAL_getIQ20VoltageFromADC (ADC_CHANS adcChan)
 Returns the voltage in mV in IQ20 format read from the specified ADC channel Important This function depends on the correct ADC reference voltage being set HAL_setADCRefVoltage. More...
 
DL_ADC12_IIDX HAL_processADCIRQ (ADC12_Regs *adcInst)
 Function to process ADC interrupts and read converted ADC values. Should only be used in ADC irqs. More...
 

Detailed Description

Overview

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.


Enumeration Type Documentation

§ PIN_MODE

enum PIN_MODE
Enumerator
PIN_MODE_OUTPUT_LOW 

Pin to be configured as a low gpio output

PIN_MODE_OUTPUT_HIGH 

Pin to be configured as a high gpio output

PIN_MODE_INPUT_PU 

Pin to be configured as a gpio input with an internal pullup

PIN_MODE_INPUT_PD 

Pin to be configured as a gpio input with an internal pulldown

PIN_MODE_INPUT_HZ 

Pin to be configured as a gpio input with no internal pullup or pulldown.

PIN_MODE_PERIPHERAL 

Indicates you want pin set to the peripheral mode

PIN_MODE_MAX 

Indicates the max amount of pin mode's supported

§ PWM_CHANNELS

Channels described here simply references individual PWM output pins. This means a micro-controller can have a single peripheral such as a timer that can be used to generate 1 or more different PWM signals. Each of those PWM signals are considered seperate PWM channels.

Enumerator
PWM_CHANNEL_0 

Reference the 1st generic PWM output

PWM_CHANNEL_1 

Reference the 2nd generic PWM output

PWM_CHANNELS_MAX 

Indicates the max amount of PWM outputs

§ SPI_CHANNELS

Channels described usually references individual SPI peripheral instances ie ( SCLK, PICO and POCI).

Enumerator
SPI_CHANNEL_0 

Reference the 1st generic SPI channel

SPI_CHANNELS_MAX 

Indicates the max amount of SPI channels

§ SPI_CS

enum SPI_CS

The chip select number here has no relationship with the physical chip select that the SPI peripheral instance has. For example, SPI_CS_0 can be mapped to the peripheral's CS2 or even a GPIO pin that is being used as a chip select.

Enumerator
SPI_CS_0 

Reference the 1st generic SPI chip select

SPI_CS_1 

Reference the 2nd generic SPI chip select

SPI_CS_2 

Reference the 3rd generic SPI chip select

SPI_CS_3 

Reference the 4th generic SPI chip select

SPI_CS_MAX 

Indicates the max amount of SPI chip selects

§ GPIO_OUTPUT_PINS

Enumerator
GPIO_OUTPUT_PIN_0 

Reference the 1st generic gpio output pin

GPIO_OUTPUT_PIN_1 

Reference the 2nd generic gpio output pin

GPIO_OUTPUT_PIN_2 

Reference the 3rd generic gpio output pin

GPIO_OUTPUT_PIN_3 

Reference the 4th generic gpio output pin

GPIO_OUTPUT_PIN_4 

Reference the 5th generic gpio output pin

GPIO_OUTPUT_PINS_MAX 

Indicates the max amount of gpio output pins

§ GPIO_INPUT_PINS

Enumerator
GPIO_INPUT_PIN_0 

Reference the 1st generic gpio input pin

GPIO_INPUT_PINS_MAX 

Indicates the max amount of gpio input pins

§ ADC_CHANS

enum ADC_CHANS
Enumerator
ADC_CHAN_0 

Reference the 1st generic adc channel

ADC_CHAN_1 

Reference the 2nd generic adc channel

ADC_CHANS_MAX 

Indicates the max amount of adc channels

Function Documentation

§ HAL_setDutyCycle()

void HAL_setDutyCycle ( PWM_CHANNELS  pwmChan,
uint8_t  targetDutyCycle 
)

Sets the PWM duty cycle for a specific channel.

Parameters
[in]pwmChanThe targetted PWM channel
[in]targetDutyCycleThe duty cycle you want the PWM channel to be set to.

Referenced by DRV8706Q1_init(), and HAL_setPWMFreq().

§ HAL_setPWMFreq()

void HAL_setPWMFreq ( PWM_CHANNELS  pwmChan,
uint32_t  targetFreq 
)

Sets the PWM frequency for a specific channel.

Parameters
[in]pwmChanThe targetted PWM channel
[in]targetFreqFrequency you want to set PWM channel to.

References HAL_setDutyCycle(), PWM_CHANNEL_0, and PWM_CHANNEL_1.

Referenced by DRV8706Q1_init().

§ HAL_configurePWMPin()

void HAL_configurePWMPin ( PWM_CHANNELS  pwmChan,
PIN_MODE  mode 
)

Sets the PWM pin to specified pin mode.

Parameters
[in]pwmChanThe targetted PWM channel
[in]modePin mode you want to configure pin to. Should only use the output or peripheral modes. Other modes may result in unexpected behavior.

References PIN_MODE_PERIPHERAL.

Referenced by DRV8706Q1_changeHalfBridgeDrive(), DRV8706Q1_changeHBridgeDrive(), DRV8706Q1_changePhaseDrive(), and DRV8706Q1_changeSolenoidDrive().

§ HAL_writeSPI8withTimeout()

void HAL_writeSPI8withTimeout ( SPI_CHANNELS  spi_chan,
SPI_CS  cs_chan,
uint8_t  data,
uint32_t  timeout 
)

Performs a 8-bit SPI write with timeout.

Parameters
[in]spi_chanThe targetted SPI channel
[in]cs_chanThe targetted SPI chip select
[in]dataData to send
[in]timeout(Not currently used)

§ HAL_readSPI8withTimeout()

uint8_t HAL_readSPI8withTimeout ( SPI_CHANNELS  spi_chan,
SPI_CS  cs_chan,
uint32_t  timeout 
)

Performs a 8-bit SPI read with timeout.

Parameters
[in]spi_chanThe targetted SPI channel
[in]cs_chanThe targetted SPI chip select
[in]timeout(Not currently used)
Returns
8-bit data read back.

§ HAL_writeSPI16withTimeout()

void HAL_writeSPI16withTimeout ( SPI_CHANNELS  spi_chan,
SPI_CS  cs_chan,
uint16_t  data,
int32_t  timeout 
)

Performs a 16-bit SPI write with timeout.

Parameters
[in]spi_chanThe targetted SPI channel
[in]cs_chanThe targetted SPI chip select
[in]dataData to send
[in]timeout(Not currently used)

Referenced by DRV8706Q1_switchToSolenoidDrive().

§ HAL_readSPI16withTimeout()

uint16_t HAL_readSPI16withTimeout ( SPI_CHANNELS  spi_chan,
SPI_CS  cs_chan,
int32_t  timeout 
)

Performs a 16-bit SPI write with timeout.

Parameters
[in]spi_chanThe targetted SPI channel
[in]cs_chanThe targetted SPI chip select
[in]timeout(Not currently used)
Returns
16-bit data read back

Referenced by DRV8706Q1_switchToSolenoidDrive().

§ HAL_delayMicroSeconds()

void HAL_delayMicroSeconds ( uint32_t  num_us)

Delay function in microseconds.

Parameters
[in]num_usThe number of microseconds you want to delay for

§ HAL_delayMilliSeconds()

void HAL_delayMilliSeconds ( uint32_t  num_us)

Delay function in milliseconds.

Parameters
[in]num_usThe number of milliseconds you want to delay for

Referenced by DRV8706Q1_reset(), and DRV8706Q1_setNSleep().

§ HAL_readGPIOInput()

bool HAL_readGPIOInput ( GPIO_INPUT_PINS  pin)

Read GPIO input pin value.

Parameters
[in]pinThe targetted pin you want to read
Returns
True if the input pin is high and false if input pin is low

References PIN_MODE_INPUT_HZ, PIN_MODE_INPUT_PD, PIN_MODE_INPUT_PU, PIN_MODE_OUTPUT_HIGH, and PIN_MODE_OUTPUT_LOW.

§ HAL_setGPIOOutput()

void HAL_setGPIOOutput ( GPIO_OUTPUT_PINS  pin,
PIN_MODE  mode 
)

Set output pin's value.

Parameters
[in]pinThe targetted pin whose output value you want to set
[in]modePin mode you want to configure the pin to. Should only use one of the output modes

References PIN_MODE_OUTPUT_HIGH, and PIN_MODE_OUTPUT_LOW.

Referenced by DRV8706Q1_changeHalfBridgeDrive(), DRV8706Q1_changeSolenoidDrive(), DRV8706Q1_setDrvOff(), DRV8706Q1_setNHiZ1(), DRV8706Q1_setNHiZ2(), and DRV8706Q1_setNSleep().

§ HAL_setADCRefVoltage()

void HAL_setADCRefVoltage ( ADC_CHANS  adcChan,
uint16_t  voltage_mV 
)

Set the reference voltage that specified ADC channel is using. The software doesn't know what reference voltage is associated with the ADC channel so this needs to be manually configured.

Parameters
adcChanThe targetted adc channel
voltage_mVThe reference voltage in mV ie 1.32V = 1320mV

§ HAL_getRawADCValue()

uint16_t HAL_getRawADCValue ( ADC_CHANS  adcChan)

Return the latest raw ADC value from the specified ADC channel.

Parameters
adcChanThe targetted adc channel
Returns
unsigned 16-bit value

§ HAL_getmVfromADC()

uint32_t HAL_getmVfromADC ( ADC_CHANS  adcChan)

Returns the voltage in mV read from the specified ADC channel. Important This function depends on the correct ADC reference voltage being set HAL_setADCRefVoltage.

Parameters
adcChanThe targetted adc channel
Returns
Converted ADC channel voltage in mV

Referenced by HAL_getIQ20VoltageFromADC().

§ HAL_getIQ20VoltageFromADC()

_iq20 HAL_getIQ20VoltageFromADC ( ADC_CHANS  adcChan)

Returns the voltage in mV in IQ20 format read from the specified ADC channel Important This function depends on the correct ADC reference voltage being set HAL_setADCRefVoltage.

Parameters
adcChanThe ADC channel to get the voltage from.
Returns
Converted ADC channel voltage in mV using the IQ20 format

References HAL_getmVfromADC().

Referenced by DRV8706Q1_getCurrent().

§ HAL_processADCIRQ()

DL_ADC12_IIDX HAL_processADCIRQ ( ADC12_Regs *  adcInst)

Function to process ADC interrupts and read converted ADC values. Should only be used in ADC irqs.

Parameters
adcInstMSPM0 ADC Driverlib instance that the IRQ was for
Returns
DL_ADC12_IIDX returns interrupt information that caused the IRQ to fire.

References ADC_CHANS_MAX.

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