MSPM0C1106BrushedMotorControlLibrary  1.0
hal.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*!****************************************************************************
33  * @file hal.h
34  * @brief Brushed Motor Driver Library HAL Module
35  * @defgroup BSM__MSPM0C_HAL LP_MSPM0C1106 - Hardware Abstraction Layer (HAL)
36  *
37  *
38  * @anchor bsm_lp_mpsm0c1106_hal_Overview
39  * # Overview
40  *
41  * The HAL module provides micro-controller agnostic set of application
42  * programming interfaces (APIs) to be used by other module's in the library
43  * as well as in the user's application code.
44  *
45  * <hr>
46  ******************************************************************************/
50 #ifndef bsm_lp_mpsm0c1106_hal_h
51 #define bsm_lp_mpsm0c1106_hal_h
52 
53 #include "ti_msp_dl_config.h"
54 #include <ti/iqmath/include/IQmathLib.h>
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 
63 #define HIGH (PIN_MODE_OUTPUT_HIGH)
64 
68 #define LOW (PIN_MODE_OUTPUT_LOW)
69 
71 typedef enum {
88 } PIN_MODE;
89 
97 typedef enum {
104 } PWM_CHANNELS;
105 
110 typedef enum {
115 } SPI_CHANNELS;
116 
123 typedef enum {
125  SPI_CS_0 = 0,
134 } SPI_CS;
135 
137 typedef enum {
151 
153 typedef enum {
159 
161 typedef enum {
168 } ADC_CHANS;
169 
178 void HAL_setDutyCycle(PWM_CHANNELS pwmChan,uint8_t targetDutyCycle);
179 
186 void HAL_setPWMFreq(PWM_CHANNELS pwmChan, uint32_t targetFreq);
187 
196 void HAL_configurePWMPin(PWM_CHANNELS pwmChan,PIN_MODE mode);
197 
207 void HAL_writeSPI8withTimeout(SPI_CHANNELS spi_chan,
208  SPI_CS cs_chan,
209  uint8_t data,
210  uint32_t timeout);
211 
222 uint8_t HAL_readSPI8withTimeout(SPI_CHANNELS spi_chan,
223  SPI_CS cs_chan,
224  uint32_t timeout);
225 
235 void HAL_writeSPI16withTimeout(SPI_CHANNELS spi_chan,
236  SPI_CS cs_chan,
237  uint16_t data,
238  int32_t timeout);
239 
250 uint16_t HAL_readSPI16withTimeout(SPI_CHANNELS spi_chan,
251  SPI_CS cs_chan,
252  int32_t timeout);
253 
259 void HAL_delayMicroSeconds(uint32_t num_us);
260 
266 void HAL_delayMilliSeconds(uint32_t num_us);
267 
275 bool HAL_readGPIOInput(GPIO_INPUT_PINS pin);
276 
284 void HAL_setGPIOOutput(GPIO_OUTPUT_PINS pin,PIN_MODE mode);
285 
290 void HAL_Init();
291 
300 void HAL_setADCRefVoltage(ADC_CHANS adcChan, uint16_t voltage_mV);
301 
308 uint16_t HAL_getRawADCValue(ADC_CHANS adcChan);
309 
319 uint32_t HAL_getmVfromADC(ADC_CHANS adcChan);
320 
331 _iq20 HAL_getIQ20VoltageFromADC(ADC_CHANS adcChan);
332 
341 DL_ADC12_IIDX HAL_processADCIRQ(ADC12_Regs *adcInst);
342 
343 #ifdef __cplusplus
344 }
345 #endif
346 
347 #endif
348 
GPIO_INPUT_PINS
Definition: hal.h:153
Definition: hal.h:75
Definition: hal.h:129
Definition: hal.h:114
Definition: hal.h:133
Definition: hal.h:103
Definition: hal.h:163
Definition: hal.h:155
PWM_CHANNELS
Channels described here simply references individual PWM output pins. This means a micro-controller c...
Definition: hal.h:97
bool HAL_readGPIOInput(GPIO_INPUT_PINS pin)
Read GPIO input pin value.
Definition: hal.c:220
void HAL_configurePWMPin(PWM_CHANNELS pwmChan, PIN_MODE mode)
Sets the PWM pin to specified pin mode.
Definition: hal.c:198
Definition: hal.h:157
Definition: hal.h:145
Definition: hal.h:85
SPI_CS
The chip select number here has no relationship with the physical chip select that the SPI peripheral...
Definition: hal.h:123
_iq20 HAL_getIQ20VoltageFromADC(ADC_CHANS adcChan)
Returns the voltage in mV in IQ20 format read from the specified ADC channel Important This function ...
Definition: hal.c:346
Definition: hal.h:87
Definition: hal.h:141
Definition: hal.h:167
Definition: hal.h:127
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.
Definition: hal.c:297
uint8_t HAL_readSPI8withTimeout(SPI_CHANNELS spi_chan, SPI_CS cs_chan, uint32_t timeout)
Performs a 8-bit SPI read with timeout.
Definition: hal.c:285
void HAL_setPWMFreq(PWM_CHANNELS pwmChan, uint32_t targetFreq)
Sets the PWM frequency for a specific channel.
Definition: hal.c:161
uint16_t HAL_getRawADCValue(ADC_CHANS adcChan)
Return the latest raw ADC value from the specified ADC channel.
Definition: hal.c:337
Definition: hal.h:149
Definition: hal.h:139
Definition: hal.h:79
Definition: hal.h:165
Definition: hal.h:125
GPIO_OUTPUT_PINS
Definition: hal.h:137
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.
Definition: hal.c:273
Definition: hal.h:101
SPI_CHANNELS
Channels described usually references individual SPI peripheral instances ie ( SCLK, PICO and POCI).
Definition: hal.h:110
ADC_CHANS
Definition: hal.h:161
void HAL_setGPIOOutput(GPIO_OUTPUT_PINS pin, PIN_MODE mode)
Set output pin&#39;s value.
Definition: hal.c:210
Definition: hal.h:147
uint16_t HAL_readSPI16withTimeout(SPI_CHANNELS spi_chan, SPI_CS cs_chan, int32_t timeout)
Performs a 16-bit SPI write with timeout.
Definition: hal.c:309
void HAL_setADCRefVoltage(ADC_CHANS adcChan, uint16_t voltage_mV)
Set the reference voltage that specified ADC channel is using. The software doesn&#39;t know what referen...
Definition: hal.c:334
Definition: hal.h:99
PIN_MODE
Definition: hal.h:71
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...
Definition: hal.c:360
Definition: hal.h:73
Definition: hal.h:143
Definition: hal.h:77
void HAL_setDutyCycle(PWM_CHANNELS pwmChan, uint8_t targetDutyCycle)
Sets the PWM duty cycle for a specific channel.
Definition: hal.c:256
Definition: hal.h:131
void HAL_delayMicroSeconds(uint32_t num_us)
Delay function in microseconds.
Definition: hal.c:320
void HAL_Init()
Function called to run initialization code needed by the HAL.
Definition: hal.c:152
Definition: hal.h:83
void HAL_delayMilliSeconds(uint32_t num_us)
Delay function in milliseconds.
Definition: hal.c:327
uint32_t HAL_getmVfromADC(ADC_CHANS adcChan)
Returns the voltage in mV read from the specified ADC channel. Important This function depends on the...
Definition: hal.c:341
Definition: hal.h:112
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale