MSPM0C1106HallSensoredTrapMotorControlLibrary  1.0
drv8328.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 drv8328.h
35  * @brief drv8328_MODULE Module
36  *
37  * @anchor drv8328_h
38  * # Overview
39  *
40  * API's releated to drv8328
41  *
42  * <hr>
43  ******************************************************************************/
48 #ifndef _drv8328_H_
49 #define _drv8328_H_
50 
51 #include "hal.h"
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
58 #define drv8328_MAXIMUM_WAKEUP_TIME (2000)
59 
60 #define drv8328_VOLTAGE_CONV_CONST _IQ20(23.044)
61 
62 #define drv8328_CSA_REF_VOLTAGE (3300)
63 
65 typedef enum
66 {
72 
76 typedef enum
77 {
83 
85 typedef struct
86 {
102  _iq20 csa_sf;
127 
129 
130 //*****************************************************************************
131 // the function prototypes
132 //*****************************************************************************
138 __STATIC_INLINE void drv8328_setDrvoff(
139  drv8328_Instance *drvHandle, drv8328_DRVOFF_PIN_STAT value)
140 {
141  if(value == drv8328_DRVOFF_PIN_HIGH)
142  {
144  }
145  else if(value == drv8328_DRVOFF_PIN_LOW)
146  {
148  }
149  else
150  {
151  /* This is expected to be empty */
152  }
153 }
154 
160 __STATIC_INLINE void drv8328_setnSleep(
161  drv8328_Instance *drvHandle, drv8328_DRV_NSLEEP_STAT value)
162 {
163  if(value == drv8328_DRV_NSLEEP_AWAKE)
164  {
166  }
167  else if(value == drv8328_DRV_NSLEEP_SLEEP)
168  {
170  }
171  else
172  {
173  /* This is expected to be empty */
174  }
175  /* tWake - Turnon time = 1ms
176  * tSleep - Turnoff time = 1ms
177  * So not matter what you set sleep pin to just wait 1 ms
178  */
180 }
181 
187 __STATIC_INLINE _iq20 drv8328_getcsaVref(uint16_t vRef)
188 {
189  _iq13 temp = _IQ13div(_IQ13(vRef), _IQ13(1000));
190  return _IQ13toIQ20(temp);
191 }
192 
197 void drv8328_init(drv8328_Instance *drvHandle);
198 
203 void drv8328_enable(drv8328_Instance *drvHandle);
204 
211  uint16_t csa);
212 
218 _iq20 drv8328_getVoltage(HAL_ADC_CHAN chan);
219 
226 _iq20 drv8328_getCurrent(HAL_ADC_CHAN chan, drv8328_Instance *drvHandle);
227 
237  HAL_ADC_INT_VREF internalVRef, uint16_t externalVRef);
238 
239 #ifdef __cplusplus
240 }
241 #endif
242 #endif /* _drv8328_H_ */
243 
drv8328_DRV_NSLEEP_STAT
Represents NSLEEP Pin State.
Definition: drv8328.h:76
__STATIC_INLINE _iq20 drv8328_getcsaVref(uint16_t vRef)
get Current reference in IQ20
Definition: drv8328.h:187
void drv8328_init(drv8328_Instance *drvHandle)
initialize the drv8328 module
Definition: drv8328.c:39
void drv8328_enable(drv8328_Instance *drvHandle)
Enable DRV.
Definition: drv8328.c:52
HAL_FAULT_INPUT
Definition: hal.h:159
Definition: drv8328.h:68
__STATIC_INLINE void drv8328_setDrvoff(drv8328_Instance *drvHandle, drv8328_DRVOFF_PIN_STAT value)
set drvoff
Definition: drv8328.h:138
HAL_GPIO_OUT drvoff
Definition: drv8328.h:94
#define drv8328_MAXIMUM_WAKEUP_TIME
Defines the time to wakeup the drv after reset.
Definition: drv8328.h:58
Hall Sensored Trap Motor Control Library HAL Module.
HAL_ADC_VREF
Definition: hal.h:190
__STATIC_INLINE void drv8328_setnSleep(drv8328_Instance *drvHandle, drv8328_DRV_NSLEEP_STAT value)
set nSleep
Definition: drv8328.h:160
GPIO set to high.
Definition: hal.h:84
HAL_ADC_CHAN
Definition: hal.h:88
HAL_GPIO_IN
Definition: hal.h:109
_iq20 drv8328_getVoltage(HAL_ADC_CHAN chan)
Get voltage from adc channel.
Definition: drv8328.c:78
Definition: drv8328.h:70
HAL_ADC_CHAN Isen
Definition: drv8328.h:122
Define NSLEEP PIN LOW.
Definition: drv8328.h:79
HAL_ADC_INT_VREF
Definition: hal.h:201
drv8328_DRVOFF_PIN_STAT
Definition: drv8328.h:65
HAL_FAULT_INPUT faultIn
Definition: drv8328.h:126
Define NSLEEP PIN HIGH.
Definition: drv8328.h:81
_iq20 csa_sf
Definition: drv8328.h:102
void drv8328_ADCVRefSel(HAL_ADC_VREF adcRef, HAL_ADC_CHAN chan, HAL_ADC_INT_VREF internalVRef, uint16_t externalVRef)
updates the adc voltage reference
Definition: drv8328.c:103
Defines drv8328 instance.
Definition: drv8328.h:85
GPIO set to low.
Definition: hal.h:82
_iq20 drv8328_getCurrent(HAL_ADC_CHAN chan, drv8328_Instance *drvHandle)
Get current from adc channel.
Definition: drv8328.c:90
HAL_GPIO_OUT nsleep
Definition: drv8328.h:90
HAL_ADC_CHAN VsenB
Definition: drv8328.h:114
HAL_ADC_CHAN VsenA
Definition: drv8328.h:110
HAL_GPIO_IN nfault
Definition: drv8328.h:98
HAL_ADC_CHAN Vsen
Definition: drv8328.h:106
HAL_ADC_CHAN VsenC
Definition: drv8328.h:118
HAL_GPIO_OUT
Definition: hal.h:124
void HAL_writeGPIOPin(HAL_GPIO_OUT pin, HAL_GPIO_STATE value)
Write to GPIOpin.
Definition: hal.c:193
__STATIC_INLINE void HAL_delayMicroSeconds(uint32_t microSeconds)
Delays for specific time in microseconds.
Definition: hal.h:487
void drv8328_updateCSAScaleFactor(drv8328_Instance *drvHandle, uint16_t csa)
updates the current gain scale factor
Definition: drv8328.c:67
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale