MSPM0C1106HallSensoredTrapMotorControlLibrary  1.0
drv8300.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 drv8300.h
35  * @brief DRV8300_MODULE Module
36  *
37  * @anchor drv8300_h
38  * # Overview
39  *
40  * API's releated to DRV8300
41  *
42  * <hr>
43  ******************************************************************************/
48 #ifndef _DRV8300_H_
49 #define _DRV8300_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 //*****************************************************************************
63 
65 #define DRV8300_VOLTAGE_CONV_CONST _IQ20(33.425)
66 
68 #define DRV8300_CSA_REF_VOLTAGE (3300)
69 
70 //*****************************************************************************
71 // typedefs
72 //*****************************************************************************
73 
75 typedef struct
76 {
84  _iq20 csa_sf;
88  _iq20 csaVRef;
117 
119 
120 //*****************************************************************************
121 // the function prototypes
122 //*****************************************************************************
127 void DRV8300_init(DRV8300_Instance *drvHandle);
128 
133 void DRV8300_enable(DRV8300_Instance *drvHandle);
134 
141  DRV8300_Instance *drvHandle, uint16_t csa);
142 
148 _iq20 DRV8300_getVoltage(HAL_ADC_CHAN chan);
149 
158  DRV8300_Instance *drvHandle, _iq20 vRef);
159 
168  HAL_ADC_INT_VREF internalVRef, uint16_t externalVRef);
169 
175 __STATIC_INLINE _iq20 DRV8300_getcsaVref(uint16_t vRef)
176 {
177  _iq13 temp = _IQ13div(_IQ13(vRef),_IQ13(1000));
178  return _IQ13toIQ20(temp);
179 }
180 
181 #ifdef __cplusplus
182 }
183 #endif
184 #endif /* _DRV8300_H_ */
185 
_iq20 csa_sf
Definition: drv8300.h:84
Hall Sensored Trap Motor Control Library HAL Module.
HAL_ADC_VREF
Definition: hal.h:190
_iq20 DRV8300_getVoltage(HAL_ADC_CHAN chan)
Get voltage from adc channel.
Definition: drv8300.c:73
HAL_ADC_CHAN VsenB
Definition: drv8300.h:100
HAL_ADC_CHAN
Definition: hal.h:88
void DRV8300_init(DRV8300_Instance *drvHandle)
initialize the drv8300 module
Definition: drv8300.c:46
void DRV8300_updateCSAScaleFactor(DRV8300_Instance *drvHandle, uint16_t csa)
updates the current gain scale factor
Definition: drv8300.c:62
HAL_ADC_INT_VREF
Definition: hal.h:201
HAL_ADC_CHAN Vsen
Definition: drv8300.h:92
HAL_ADC_CHAN VsenA
Definition: drv8300.h:96
void DRV8300_enable(DRV8300_Instance *drvHandle)
Enable DRV.
HAL_ADC_CHAN IsenC
Definition: drv8300.h:116
HAL_ADC_CHAN VsenC
Definition: drv8300.h:104
void DRV8300_ADCVRefSel(HAL_ADC_VREF adcRef, HAL_ADC_CHAN chan, HAL_ADC_INT_VREF internalVRef, uint16_t externalVRef)
updates the adc voltage reference
Definition: drv8300.c:101
_iq20 csaVRef
Definition: drv8300.h:88
_iq20 DRV8300_getCurrent(HAL_ADC_CHAN chan, DRV8300_Instance *drvHandle, _iq20 vRef)
Get current from adc channel.
Definition: drv8300.c:86
__STATIC_INLINE _iq20 DRV8300_getcsaVref(uint16_t vRef)
get Current reference in IQ20
Definition: drv8300.h:175
HAL_ADC_CHAN IsenA
Definition: drv8300.h:108
Defines DRV8300 instance.
Definition: drv8300.h:75
HAL_ADC_CHAN IsenB
Definition: drv8300.h:112
HAL_GPIO_OUT led
Definition: drv8300.h:80
HAL_GPIO_OUT
Definition: hal.h:124
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale