MSPM0C1106HallSensoredTrapMotorControlLibrary  1.0
drv8353.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 drv8353.h
35  * @brief DRV8353_MODULE Module
36  *
37  * @anchor drv8353_h
38  * # Overview
39  *
40  * API's releated to DRV8353
41  *
42  * <hr>
43  ******************************************************************************/
48 #ifndef _DRV8353_H_
49 #define _DRV8353_H_
50 
51 //*****************************************************************************
52 // the includes
53 //*****************************************************************************
54 #include "hal.h"
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 
60 //*****************************************************************************
61 //defines
62 //*****************************************************************************
64 #define DRV8353_ADDR_MASK (0x7E00)
65 
67 #define DRV8353_DATA_MASK (0x00FF)
68 
70 #define DRV8353_DATA_TRANSMIT_TO_READ (0x00)
71 
73 #define DRV8353_INITIAL_PARITY (0x00)
74 
76 #define DRV8353_PARITY_CHECK (0x01)
77 
79 #define DRV8353_RIGHT_SHIFT_REGISTER (1)
80 
82 #define DRV8353_PARITY_BIT_POSITION (8)
83 
85 #define DRV8353_ADDR_BIT_POSITION (9)
86 
88 #define DRV8353_SPICMD_BIT_POSITION (15)
89 
91 #define DRV8353_CLEAR_BIT_MASK (0x01)
92 
94 #define DRV8353_MAXIMUM_RESET_TIME (40)
95 
97 #define DRV8353_MAXIMUM_WAKEUP_TIME (2000)
98 
100 #define DRV8353_VOLTAGE_CONV_CONST _IQ20(39.582)
101 
103 #define DRV8353_CSA_REF_VOLTAGE (3300)
104 
105 //*****************************************************************************
106 // typedefs
107 //*****************************************************************************
109 typedef enum
110 {
116 
118 typedef struct
119 {
135  _iq20 csa_sf;
139  _iq20 csaVRef;
172 
174 
175 //*****************************************************************************
176 // the function prototypes
177 //*****************************************************************************
183 __STATIC_INLINE void DRV8353_setnSleep(
184  DRV8353_Instance *drvHandle, DRV8353_DRV_NSLEEP_STAT value)
185 {
186  if(value == DRV8353_DRV_NSLEEP_AWAKE)
187  {
189  }
190  else if(value == DRV8353_DRV_NSLEEP_SLEEP)
191  {
193  }
194  else
195  {
196  /* This is expected to be empty */
197  }
198  /* tWake - Turnon time = 1ms
199  * tSleep - Turnoff time = 1ms
200  * So not matter what you set sleep pin to just wait 1 ms
201  */
203 }
204 
209 void DRV8353_init(DRV8353_Instance *drvHandle);
210 
215 void DRV8353_enable(DRV8353_Instance *drvHandle);
216 
223  DRV8353_Instance *drvHandle, uint16_t csa);
224 
230 _iq20 DRV8353_getVoltage(HAL_ADC_CHAN chan);
231 
240  DRV8353_Instance *drvHandle, _iq20 vRef);
241 
250  HAL_ADC_INT_VREF internalVRef, uint16_t externalVRef);
251 
257 __STATIC_INLINE _iq20 DRV8353_getcsaVref(uint16_t vRef)
258 {
259  _iq13 temp = _IQ13div(_IQ13(vRef),_IQ13(1000));
260  return _IQ13toIQ20(temp);
261 }
262 
263 #ifdef __cplusplus
264 }
265 #endif
266 #endif /* _DRV8353_H_ */
267 
Define NSLEEP PIN HIGH.
Definition: drv8353.h:114
HAL_ADC_CHAN VsenA
Definition: drv8353.h:147
_iq20 csaVRef
Definition: drv8353.h:139
HAL_ADC_CHAN VsenC
Definition: drv8353.h:155
__STATIC_INLINE _iq20 DRV8353_getcsaVref(uint16_t vRef)
get Current reference in IQ20
Definition: drv8353.h:257
HAL_FAULT_INPUT
Definition: hal.h:159
void DRV8353_ADCVRefSel(HAL_ADC_VREF adcRef, HAL_ADC_CHAN chan, HAL_ADC_INT_VREF internalVRef, uint16_t externalVRef)
updates the adc voltage reference
Definition: drv8353.c:112
Hall Sensored Trap Motor Control Library HAL Module.
HAL_ADC_VREF
Definition: hal.h:190
_iq20 DRV8353_getCurrent(HAL_ADC_CHAN chan, DRV8353_Instance *drvHandle, _iq20 vRef)
Get current from adc channel.
Definition: drv8353.c:97
_iq20 DRV8353_getVoltage(HAL_ADC_CHAN chan)
Get voltage from adc channel.
Definition: drv8353.c:84
GPIO set to high.
Definition: hal.h:84
HAL_ADC_CHAN IsenA
Definition: drv8353.h:159
HAL_ADC_CHAN
Definition: hal.h:88
HAL_GPIO_IN
Definition: hal.h:109
HAL_GPIO_OUT led
Definition: drv8353.h:127
HAL_ADC_CHAN IsenC
Definition: drv8353.h:167
Defines DRV8353 instance.
Definition: drv8353.h:118
#define DRV8353_MAXIMUM_WAKEUP_TIME
Defines the time to wakeup the drv after reset.
Definition: drv8353.h:97
HAL_ADC_INT_VREF
Definition: hal.h:201
__STATIC_INLINE void DRV8353_setnSleep(DRV8353_Instance *drvHandle, DRV8353_DRV_NSLEEP_STAT value)
set nSleep
Definition: drv8353.h:183
void DRV8353_init(DRV8353_Instance *drvHandle)
initialize the drv8353 module
Definition: drv8353.c:46
void DRV8353_enable(DRV8353_Instance *drvHandle)
Enable DRV.
Definition: drv8353.c:61
HAL_ADC_CHAN Vsen
Definition: drv8353.h:143
GPIO set to low.
Definition: hal.h:82
void DRV8353_updateCSAScaleFactor(DRV8353_Instance *drvHandle, uint16_t csa)
updates the current gain scale factor
Definition: drv8353.c:73
HAL_ADC_CHAN VsenB
Definition: drv8353.h:151
_iq20 csa_sf
Definition: drv8353.h:135
HAL_GPIO_OUT nsleep
Definition: drv8353.h:123
DRV8353_DRV_NSLEEP_STAT
Definition: drv8353.h:109
HAL_GPIO_IN nfault
Definition: drv8353.h:131
Define NSLEEP PIN LOW.
Definition: drv8353.h:112
HAL_FAULT_INPUT faultIn
Definition: drv8353.h:171
HAL_GPIO_OUT
Definition: hal.h:124
HAL_ADC_CHAN IsenB
Definition: drv8353.h:163
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