MSPM0G3507HallSensoredTrapMotorControlLibrary  1.0
drv8323.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 drv8323.h
35  * @brief DRV8323_MODULE Module
36  *
37  * @anchor drv8323_h
38  * # Overview
39  *
40  * API's releated to DRV8323
41  *
42  * <hr>
43  ******************************************************************************/
48 #ifndef _DRV8323_H_
49 #define _DRV8323_H_
50 
51 #include "hal.h"
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
58 #define DRV8323_MAXIMUM_WAKEUP_TIME (2000)
59 
60 #define DRV8323_VOLTAGE_CONV_CONST _IQ20(17.433)
61 
62 #define DRV8323_CSA_REF_VOLTAGE (3300)
63 
64 #define DRV8323_CSAGAIN_5_IQ _IQ20(5)
65 
66 #define DRV8323_CSAGAIN_10_IQ _IQ20(10)
67 
68 #define DRV8323_CSAGAIN_20_IQ _IQ20(20)
69 
70 #define DRV8323_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;
160 
162 
168 __STATIC_INLINE void DRV8323_setnSleep(
169  DRV8323_Instance *drvHandle, DRV8323_DRV_NSLEEP_STAT value)
170 {
171  if(value == DRV8323_DRV_NSLEEP_AWAKE)
172  {
174  }
175  else if(value == DRV8323_DRV_NSLEEP_SLEEP)
176  {
178  }
179  else
180  {
181  /* This is expected to be empty */
182  }
183  /* tWake - Turnon time = 1ms
184  * tSleep - Turnoff time = 1ms
185  * So not matter what you set sleep pin to just wait 1 ms
186  */
188 }
189 
195 __STATIC_INLINE _iq20 DRV8323_getcsaVref(uint16_t vRef)
196 {
197  _iq13 temp = _IQ13div(_IQ13(vRef), _IQ13(1000));
198  return _IQ13toIQ20(temp);
199 }
200 
205 void DRV8323_init(DRV8323_Instance *drvHandle);
206 
211 void DRV8323_enable(DRV8323_Instance *drvHandle);
212 
220  DRV8323_CSAGAIN csa, uint16_t rSense);
221 
227 _iq20 DRV8323_getVoltage(HAL_ADC_CHAN chan);
228 
236 _iq20 DRV8323_getCurrent(
237  HAL_ADC_CHAN chan, DRV8323_Instance *drvHandle, _iq20 vRef);
238 
248  HAL_ADC_INT_VREF internalVRef, uint16_t externalVRef);
249 
250 #ifdef __cplusplus
251 }
252 #endif
253 #endif /* _DRV8323_H_ */
254 
Define DRV8323 CSA GAIN 5 Setting.
Definition: drv8323.h:76
DRV8323_DRVOFF_PIN_STAT
Definition: drv8323.h:86
_iq20 DRV8323_getCurrent(HAL_ADC_CHAN chan, DRV8323_Instance *drvHandle, _iq20 vRef)
Get current from adc channel.
Definition: drv8323.c:113
Defines drv8323 instance.
Definition: drv8323.h:106
_iq20 csaVRef
Definition: drv8323.h:127
HAL_ADC_CHAN VsenB
Definition: drv8323.h:139
HAL_ADC_CHAN
Definition: hal.h:88
HAL_GPIO_IN
Definition: hal.h:109
HAL_ADC_CHAN VsenA
Definition: drv8323.h:135
Definition: drv8323.h:91
void HAL_writeGPIOPin(HAL_GPIO_OUT pin, HAL_GPIO_STATE value)
Write to GPIOpin.
Definition: hal.c:221
HAL_GPIO_OUT nsleep
Definition: drv8323.h:111
Hall Sensored Trap Motor Control Library HAL Module.
HAL_GPIO_OUT led
Definition: drv8323.h:115
HAL_FAULT_INPUT faultIn
Definition: drv8323.h:159
HAL_ADC_INT_VREF
Definition: hal.h:201
HAL_ADC_CHAN Vsen
Definition: drv8323.h:131
void DRV8323_enable(DRV8323_Instance *drvHandle)
Enable DRV.
Definition: drv8323.c:54
void DRV8323_updateCSAScaleFactor(DRV8323_Instance *drvHandle, DRV8323_CSAGAIN csa, uint16_t rSense)
updates the current gain scale factor
Definition: drv8323.c:70
Define DRV8323 CSA GAIN 40 Setting.
Definition: drv8323.h:82
__STATIC_INLINE void HAL_delayMicroSeconds(uint32_t microSeconds)
Delays for specific time in microseconds.
Definition: hal.h:487
HAL_ADC_CHAN IsenB
Definition: drv8323.h:151
_iq20 DRV8323_getVoltage(HAL_ADC_CHAN chan)
Get voltage from adc channel.
Definition: drv8323.c:100
GPIO set to low.
Definition: hal.h:82
DRV8323_DRV_NSLEEP_STAT
Represents NSLEEP Pin State.
Definition: drv8323.h:97
Define NSLEEP PIN LOW.
Definition: drv8323.h:100
void DRV8323_init(DRV8323_Instance *drvHandle)
initialize the drv8323 module
Definition: drv8323.c:39
HAL_ADC_VREF
Definition: hal.h:190
HAL_ADC_CHAN IsenA
Definition: drv8323.h:147
Define DRV8323 CSA GAIN 10 Setting.
Definition: drv8323.h:78
__STATIC_INLINE void DRV8323_setnSleep(DRV8323_Instance *drvHandle, DRV8323_DRV_NSLEEP_STAT value)
set nSleep
Definition: drv8323.h:168
Define DRV8323 CSA GAIN 20 Setting.
Definition: drv8323.h:80
void DRV8323_ADCVRefSel(HAL_ADC_VREF adcRef, HAL_ADC_CHAN chan, HAL_ADC_INT_VREF internalVRef, uint16_t externalVRef)
updates the adc voltage reference
Definition: drv8323.c:128
_iq20 csa_sf
Definition: drv8323.h:123
Definition: drv8323.h:89
HAL_ADC_CHAN IsenC
Definition: drv8323.h:155
HAL_GPIO_OUT
Definition: hal.h:124
Define NSLEEP PIN HIGH.
Definition: drv8323.h:102
#define DRV8323_MAXIMUM_WAKEUP_TIME
Defines the time to wakeup the drv after reset.
Definition: drv8323.h:58
GPIO set to high.
Definition: hal.h:84
HAL_FAULT_INPUT
Definition: hal.h:159
__STATIC_INLINE _iq20 DRV8323_getcsaVref(uint16_t vRef)
get Current reference in IQ20
Definition: drv8323.h:195
HAL_ADC_CHAN VsenC
Definition: drv8323.h:143
DRV8323_CSAGAIN
Definition: drv8323.h:73
HAL_GPIO_IN nfault
Definition: drv8323.h:119
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale