MSPM0G3519SensoredFOCMotorControlLibrary  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 /*!****************************************************************************
34  * @file hal.h
35  * @brief Hall Sensored Trap Motor Control Library HAL Module
36  * @defgroup HALL_SENSORED_TRAP__MSPM0G_HAL LP_MSPM0G3507 - \
37  * Hardware Abstraction Layer (HAL)
38  *
39  *
40  * @anchor hall_sensored_trap_lp_mpsm0g3507_hal_Overview
41  * # Overview
42  *
43  * The HAL module provides micro-controller agnostic set of application
44  * programming interfaces (APIs) to be used by other module's in the library
45  * as well as in the user's application code.
46  *
47  * <hr>
48  ******************************************************************************/
53 #ifndef _HAL_H
54 #define _HAL_H
55 
56 #include "ti_msp_dl_config.h"
57 #include <ti/iqmath/include/IQmathLib.h>
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
64 #define HAL_SYSTEM_FREQ_MHZ ((int32_t)80)
65 
66 
68 #define HAL_CAPTURE_TIMER_FREQ ((int32_t)100000)
69 
70 
72 typedef enum
73 {
79 
80 
82 typedef enum
83 {
95 
96 
98 typedef enum
99 {
107 
108 
110 typedef struct HAL_GPIO_Instance_
111 {
113  IOMUX_PINCM iomux;
115  GPIO_Regs * port;
117  uint32_t pin;
119  IRQn_Type IRQn;
125 
126 
128 typedef struct HAL_Timer_Instance_
129 {
131  GPTIMER_Regs *gptimer;
133  DL_TIMER_CC_INDEX ccIndex;
135  IRQn_Type IRQn;
137  uint32_t period;
139 
147 void HAL_init();
148 
153 void HAL_enableGPIOInterrupt(HAL_GPIO_IN pin);
154 
160 uint32_t HAL_getCaptureFrequency(HAL_CAPTURE_TIMER capture);
161 
167 uint32_t HAL_getCaptureValue(HAL_CAPTURE_TIMER capture);
168 
174 uint32_t HAL_getCaptureRunningValue(HAL_CAPTURE_TIMER capture);
175 
180 __STATIC_INLINE void HAL_delayMicroSeconds(uint32_t microSeconds)
181 {
182  delay_cycles(HAL_SYSTEM_FREQ_MHZ * microSeconds);
183  return;
184 }
190 __STATIC_INLINE uint32_t HAL_getTimerLoadValue(HAL_CAPTURE_TIMER capture)
191 {
192  return inputCapture[capture].period;
193 }
199 __STATIC_INLINE bool HAL_readGPIOPin(HAL_GPIO_IN pin)
200 {
201  return(DL_GPIO_readPins(gpioInputPin[pin].port, gpioInputPin[pin].pin));
202 }
203 
204 #ifdef __cplusplus
205 }
206 #endif
207 #endif /* _HAL_H */
208 
HAL_Timer_Instance inputCapture[HAL_CAPTURE_TIMER_MAX]
Array to store the capture instances.
Definition: hal.c:50
GPIO_Regs * port
GPIO port.
Definition: hal.h:115
GPTIMER_Regs * gptimer
Timer Register.
Definition: hal.h:131
void HAL_enableGPIOInterrupt(HAL_GPIO_IN pin)
Enables GPIO interrupts.
Definition: hal.c:83
DL_TIMER_CC_INDEX ccIndex
Timer ccIndex.
Definition: hal.h:133
HAL_GPIO_IN
HAL_GPIO_IN.
Definition: hal.h:82
uint32_t period
Definition: hal.h:137
HAL_GPIO_Instance gpioInputPin[HAL_GPIO_IN_MAX]
Array for storing the input GPIO pin instances.
Definition: hal.c:45
Index associated to input GPIO PIN 4.
Definition: hal.h:91
Index associated to input GPIO PIN 3.
Definition: hal.h:89
IRQn_Type IRQn
Timer IRQN.
Definition: hal.h:135
uint32_t HAL_getCaptureValue(HAL_CAPTURE_TIMER capture)
Capture the Timer Value.
Definition: hal.c:115
__STATIC_INLINE uint32_t HAL_getTimerLoadValue(HAL_CAPTURE_TIMER capture)
Timer Period Value.
Definition: hal.h:190
Total number of input captures.
Definition: hal.h:105
uint32_t pin
GPIO pin.
Definition: hal.h:117
IOMUX_PINCM iomux
IOMUX.
Definition: hal.h:113
uint32_t HAL_getCaptureRunningValue(HAL_CAPTURE_TIMER capture)
Capture the Timer Running Value.
Definition: hal.c:103
Total number of input GPIO pins.
Definition: hal.h:93
__STATIC_INLINE void HAL_delayMicroSeconds(uint32_t microSeconds)
Delays for specific time in microseconds.
Definition: hal.h:180
Defines a timer instance.
Definition: hal.h:128
GPIO set to low.
Definition: hal.h:75
__STATIC_INLINE bool HAL_readGPIOPin(HAL_GPIO_IN pin)
Reads a GPIOpin.
Definition: hal.h:199
void HAL_init()
Initializes the hal object.
Definition: hal.c:55
Index associated to input GPIO PIN 2.
Definition: hal.h:87
struct HAL_GPIO_Instance_ HAL_GPIO_Instance
Defines a GPIO instance.
Index associated to input capture 1.
Definition: hal.h:101
#define HAL_SYSTEM_FREQ_MHZ
Defines the system clock frequency, MHz.
Definition: hal.h:64
HAL_CAPTURE_TIMER
Definition: hal.h:98
uint32_t HAL_getCaptureFrequency(HAL_CAPTURE_TIMER capture)
Calculates the capture frequency.
Definition: hal.c:128
Index associated to input GPIO PIN 1.
Definition: hal.h:85
Defines a GPIO instance.
Definition: hal.h:110
struct HAL_Timer_Instance_ HAL_Timer_Instance
Defines a timer instance.
GPIO set to high.
Definition: hal.h:77
HAL_GPIO_STATE
HAL_GPIO_STATE.
Definition: hal.h:72
IRQn_Type IRQn
GPIO IRQN.
Definition: hal.h:119
Index associated to input capture 1.
Definition: hal.h:103
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale