MSPM0C1106HallSensoredTrapMotorControlLibrary  1.0
drv8329.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 drv8329.h
35  * @brief DRV8329_MODULE Module
36  *
37  * @anchor drv8329_h
38  * # Overview
39  *
40  * API's releated to DRV8329
41  *
42  * <hr>
43  ******************************************************************************/
48 #ifndef _DRV8329_H_
49 #define _DRV8329_H_
50 
51 #include "hal.h"
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
58 #define DRV8329_MAXIMUM_WAKEUP_TIME (2000)
59 
60 #define DRV8329_VOLTAGE_CONV_CONST _IQ20(23.044)
61 
62 #define DRV8329_CSA_REF_VOLTAGE (3300)
63 
64 #define DRV8329_CSAGAIN_5_IQ _IQ20(5)
65 
66 #define DRV8329_CSAGAIN_10_IQ _IQ20(10)
67 
68 #define DRV8329_CSAGAIN_20_IQ _IQ20(20)
69 
70 #define DRV8329_CSAGAIN_40_IQ _IQ20(40)
71 
73 typedef enum
74 {
84 
86 typedef enum
87 {
93 
97 typedef enum
98 {
104 
106 typedef struct
107 {
123  _iq20 csa_sf;
127  _iq20 csaVRef;
152 
154 
155 //*****************************************************************************
156 // the function prototypes
157 //*****************************************************************************
163 __STATIC_INLINE void DRV8329_setDrvoff(
164  DRV8329_Instance *drvHandle, DRV8329_DRVOFF_PIN_STAT value)
165 {
166  if(value == DRV8329_DRVOFF_PIN_HIGH)
167  {
169  }
170  else if(value == DRV8329_DRVOFF_PIN_LOW)
171  {
173  }
174  else
175  {
176  /* This is expected to be empty */
177  }
178 }
179 
185 __STATIC_INLINE void DRV8329_setnSleep(
186  DRV8329_Instance *drvHandle, DRV8329_DRV_NSLEEP_STAT value)
187 {
188  if(value == DRV8329_DRV_NSLEEP_AWAKE)
189  {
191  }
192  else if(value == DRV8329_DRV_NSLEEP_SLEEP)
193  {
195  }
196  else
197  {
198  /* This is expected to be empty */
199  }
200  /* tWake - Turnon time = 1ms
201  * tSleep - Turnoff time = 1ms
202  * So not matter what you set sleep pin to just wait 1 ms
203  */
205 }
206 
212 __STATIC_INLINE _iq20 DRV8329_getcsaVref(uint16_t vRef)
213 {
214  _iq13 temp = _IQ13div(_IQ13(vRef), _IQ13(1000));
215  return _IQ13toIQ20(temp);
216 }
217 
222 void DRV8329_init(DRV8329_Instance *drvHandle);
223 
228 void DRV8329_enable(DRV8329_Instance *drvHandle);
229 
237  DRV8329_CSAGAIN csa, uint16_t rSense);
238 
244 _iq20 DRV8329_getVoltage(HAL_ADC_CHAN chan);
245 
253 _iq20 DRV8329_getCurrent(
254  HAL_ADC_CHAN chan, DRV8329_Instance *drvHandle, _iq20 vRef);
255 
265  HAL_ADC_INT_VREF internalVRef, uint16_t externalVRef);
266 
267 #ifdef __cplusplus
268 }
269 #endif
270 #endif /* _DRV8329_H_ */
271 
_iq20 csaVRef
Definition: drv8329.h:127
Definition: drv8329.h:89
HAL_FAULT_INPUT
Definition: hal.h:159
HAL_ADC_CHAN Vsen
Definition: drv8329.h:131
Define NSLEEP PIN LOW.
Definition: drv8329.h:100
_iq20 DRV8329_getCurrent(HAL_ADC_CHAN chan, DRV8329_Instance *drvHandle, _iq20 vRef)
Get current from adc channel.
Definition: drv8329.c:111
Defines drv8329 instance.
Definition: drv8329.h:106
void DRV8329_updateCSAScaleFactor(DRV8329_Instance *drvHandle, DRV8329_CSAGAIN csa, uint16_t rSense)
updates the current gain scale factor
Definition: drv8329.c:68
Hall Sensored Trap Motor Control Library HAL Module.
void DRV8329_init(DRV8329_Instance *drvHandle)
initialize the drv8329 module
Definition: drv8329.c:39
HAL_ADC_VREF
Definition: hal.h:190
void DRV8329_ADCVRefSel(HAL_ADC_VREF adcRef, HAL_ADC_CHAN chan, HAL_ADC_INT_VREF internalVRef, uint16_t externalVRef)
updates the adc voltage reference
Definition: drv8329.c:126
GPIO set to high.
Definition: hal.h:84
#define DRV8329_MAXIMUM_WAKEUP_TIME
Defines the time to wakeup the drv after reset.
Definition: drv8329.h:58
HAL_ADC_CHAN
Definition: hal.h:88
HAL_ADC_CHAN VsenA
Definition: drv8329.h:135
HAL_GPIO_IN
Definition: hal.h:109
Define DRV8329 CSA GAIN 5 Setting.
Definition: drv8329.h:76
Definition: drv8329.h:91
DRV8329_DRV_NSLEEP_STAT
Represents NSLEEP Pin State.
Definition: drv8329.h:97
Define NSLEEP PIN HIGH.
Definition: drv8329.h:102
HAL_ADC_CHAN VsenC
Definition: drv8329.h:143
__STATIC_INLINE _iq20 DRV8329_getcsaVref(uint16_t vRef)
get Current reference in IQ20
Definition: drv8329.h:212
_iq20 DRV8329_getVoltage(HAL_ADC_CHAN chan)
Get voltage from adc channel.
Definition: drv8329.c:98
HAL_ADC_INT_VREF
Definition: hal.h:201
void DRV8329_enable(DRV8329_Instance *drvHandle)
Enable DRV.
Definition: drv8329.c:52
HAL_FAULT_INPUT faultIn
Definition: drv8329.h:151
DRV8329_CSAGAIN
Definition: drv8329.h:73
HAL_ADC_CHAN Isen
Definition: drv8329.h:147
GPIO set to low.
Definition: hal.h:82
Define DRV8329 CSA GAIN 20 Setting.
Definition: drv8329.h:80
Define DRV8329 CSA GAIN 10 Setting.
Definition: drv8329.h:78
HAL_GPIO_OUT drvoff
Definition: drv8329.h:115
__STATIC_INLINE void DRV8329_setnSleep(DRV8329_Instance *drvHandle, DRV8329_DRV_NSLEEP_STAT value)
set nSleep
Definition: drv8329.h:185
__STATIC_INLINE void DRV8329_setDrvoff(DRV8329_Instance *drvHandle, DRV8329_DRVOFF_PIN_STAT value)
set drvoff
Definition: drv8329.h:163
HAL_GPIO_OUT nsleep
Definition: drv8329.h:111
DRV8329_DRVOFF_PIN_STAT
Definition: drv8329.h:86
Define DRV8329 CSA GAIN 40 Setting.
Definition: drv8329.h:82
HAL_GPIO_IN nfault
Definition: drv8329.h:119
HAL_ADC_CHAN VsenB
Definition: drv8329.h:139
_iq20 csa_sf
Definition: drv8329.h:123
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
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale