MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

hal_obj_both.h
Go to the documentation of this file.
1 #ifndef _HAL_OBJ_H_
2 #define _HAL_OBJ_H_
3 /* --COPYRIGHT--,BSD
4 * Copyright (c) 2012, Texas Instruments Incorporated
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
26 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
32 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * --/COPYRIGHT--*/
34
39
40
41 // drivers
42 #include "sw/drivers/adc/src/32b/f28x/f2806x/adc.h"
43 #include "sw/drivers/clk/src/32b/f28x/f2806x/clk.h"
44 #include "sw/drivers/cpu/src/32b/f28x/f2806x/cpu.h"
45 #include "sw/drivers/flash/src/32b/f28x/f2806x/flash.h"
46 #include "sw/drivers/gpio/src/32b/f28x/f2806x/gpio.h"
47 #include "sw/drivers/osc/src/32b/f28x/f2806x/osc.h"
48 #include "sw/drivers/pie/src/32b/f28x/f2806x/pie.h"
49 #include "sw/drivers/pll/src/32b/f28x/f2806x/pll.h"
50 #include "sw/drivers/pwm/src/32b/f28x/f2806x/pwm.h"
51 #include "sw/drivers/pwmdac/src/32b/f28x/f2806x/pwmdac.h"
52 #include "sw/drivers/pwr/src/32b/f28x/f2806x/pwr.h"
53 #include "sw/drivers/spi/src/32b/f28x/f2806x/spi.h"
54 #include "sw/drivers/timer/src/32b/f28x/f2806x/timer.h"
55 #include "sw/drivers/wdog/src/32b/f28x/f2806x/wdog.h"
56 #include "sw/drivers/drvic/drv8301/src/32b/f28x/f2806x/drv8301.h"
57
58
59 #ifdef QEP
60 #include "sw/drivers/qep/src/32b/f28x/f2806x/qep.h"
61 #endif
62
63 // modules
64 #include "sw/modules/offset/src/32b/offset.h"
65 #include "sw/modules/types/src/types.h"
66 #include "sw/modules/usDelay/src/32b/usDelay.h"
67
68
69 // platforms
70 #include "user.h"
71
72
77
78
79
80 #ifdef __cplusplus
81 extern "C" {
82 #endif
83 typedef struct _HAL_AdcData_t_
89 {
90 MATH_vec3 I;
91
92 MATH_vec3 V;
93
94 _iq dcBus;
95
96 } HAL_AdcData_t;
97
98
103 typedef struct _HAL_DacData_t_
104 {
105 _iq value[4];
106
107 } HAL_DacData_t;
108
109
116 typedef struct _HAL_PwmData_t_
117 {
118 MATH_vec3 Tabc;
119
120 } HAL_PwmData_t;
121
122
128 typedef struct _HAL_Obj_
129 {
130 ADC_Handle adcHandle;
131
132 CLK_Handle clkHandle;
133
134 CPU_Handle cpuHandle;
135
136 FLASH_Handle flashHandle;
137
138 GPIO_Handle gpioHandle;
139 #error fix these for 2 motor
140 OFFSET_Handle offsetHandle_I[3];
141 OFFSET_Obj offset_I[3];
142
143 OFFSET_Handle offsetHandle_V[3];
144 OFFSET_Obj offset_V[3];
145
146 OSC_Handle oscHandle;
147
148 PIE_Handle pieHandle; //<! the PIE handle
149
150 PLL_Handle pllHandle;
151
152 PWM_Handle pwmHandle[6]; //<! the PWM handles
153
154 PWMDAC_Handle pwmDacHandle[2]; //<! the PWMDAC handles
155
156 PWR_Handle pwrHandle; //<! the power handle
157
158 TIMER_Handle timerHandle[3]; //<! the timer handles
159
160 WDOG_Handle wdogHandle;
161
162 HAL_AdcData_t adcBias;
163
164 _iq current_sf;
165
166 _iq voltage_sf;
167
168 uint_least8_t numCurrentSensors;
169 uint_least8_t numVoltageSensors;
170
171 SPI_Handle spiAHandle;
172 SPI_Obj spiA;
173
174 SPI_Handle spiBHandle;
175 SPI_Obj spiB;
176
177 DRV8301_Handle drv8301Handle[2];
178 DRV8301_Obj drv8301[2];
179
180 #ifdef QEP
181 QEP_Handle qepHandle[2];
182 #endif
183
184 } HAL_Obj;
185
186
192 typedef struct _HAL_Obj_ *HAL_Handle;
193
194
197 extern HAL_Obj hal;
198
199
205 inline void HAL_runOffsetEst(HAL_Handle handle,const HAL_AdcData_t *pAdcData)
206 {
207 uint_least8_t cnt;
208 HAL_Obj *obj = (HAL_Obj *)handle;
209
210
211 // estimate the current offsets
212 for(cnt=0;cnt<obj->numCurrentSensors;cnt++)
213 {
214 OFFSET_run(obj->offsetHandle_I[cnt],pAdcData->I.value[cnt]);
215 }
216
217
218 // estimate the voltage offsets
219 for(cnt=0;cnt<obj->numVoltageSensors;cnt++)
220 {
221 OFFSET_run(obj->offsetHandle_V[cnt],pAdcData->V.value[cnt]);
222 }
223
224 return;
225 } // end of HAL_runOffsetEst() function
226
227
228 #ifdef __cplusplus
229 }
230 #endif // extern "C"
231
233 #endif // end of _HAL_OBJ_H_ definition
234
_HAL_Obj_::offsetHandle_I
OFFSET_Handle offsetHandle_I[3]
the handles for the current offset estimators
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:140
_HAL_Obj_::offset_V
OFFSET_Obj offset_V[3]
the voltage offset objects
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:144
types.h
Contains the public interface to the types definitions.
_HAL_Obj_::pwmHandle
PWM_Handle pwmHandle[3]
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:152
_HAL_Obj_::spiBHandle
SPI_Handle spiBHandle
the SPI handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:172
offset.h
Contains the public interface to the offset (OFFSET) module routines.
_MATH_vec3_::value
_iq value[3]
Definition: 32b/math.h:261
_HAL_Obj_::clkHandle
CLK_Handle clkHandle
the clock handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:132
_HAL_Obj_::drv8301
DRV8301_Obj drv8301
the drv8301 interface object
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:175
_HAL_Obj_::current_sf
_iq current_sf
the current scale factor, amps_pu/cnt
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:164
_HAL_Obj_::spiB
SPI_Obj spiB
the SPIB object
Definition: hal_obj_both.h:175
_iq
long _iq
Definition: 32b/IQmathLib.h:223
_HAL_Obj_::adcBias
HAL_AdcData_t adcBias
the ADC bias
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:162
_HAL_Obj_::flashHandle
FLASH_Handle flashHandle
the flash handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:136
_HAL_Obj_::pwmDacHandle
PWMDAC_Handle pwmDacHandle[3]
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:154
usDelay.h
Contains public interface to the micro-second delay function.
_HAL_PwmData_t_
Defines the PWM data.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:116
_HAL_PwmData_t_::Tabc
MATH_vec3 Tabc
the PWM time-durations for each motor phase
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:118
HAL_Handle
struct _HAL_Obj_ * HAL_Handle
Defines the HAL handle.
Definition: hal_obj_both.h:192
_MATH_vec3_
Defines a three element vector.
Definition: 32b/math.h:258
HAL_runOffsetEst
void HAL_runOffsetEst(HAL_Handle handle, const HAL_AdcData_t *pAdcData)
Runs offset estimation.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:202
HAL_DacData_t
struct _HAL_DacData_t_ HAL_DacData_t
Defines the DAC data.
_HAL_Obj_::numCurrentSensors
uint_least8_t numCurrentSensors
the number of current sensors
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:168
OFFSET_Handle
struct _OFFSET_Obj_ * OFFSET_Handle
Defines the OFFSET handle.
Definition: 32b/offset.h:95
_HAL_Obj_::spiAHandle
SPI_Handle spiAHandle
the SPI handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:171
_HAL_Obj_::voltage_sf
_iq voltage_sf
the voltage scale factor, volts_pu/cnt
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:166
_HAL_Obj_::spiA
SPI_Obj spiA
the SPIA object
Definition: hal_obj_both.h:172
_HAL_Obj_::wdogHandle
WDOG_Handle wdogHandle
the watchdog handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:160
HAL_PwmData_t
struct _HAL_PwmData_t_ HAL_PwmData_t
Defines the PWM data.
_HAL_DacData_t_
Defines the DAC data.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:103
HAL_AdcData_t
struct _HAL_AdcData_t_ HAL_AdcData_t
Defines the ADC data.
_HAL_Obj_::oscHandle
OSC_Handle oscHandle
the oscillator handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:146
_HAL_Obj_::adcHandle
ADC_Handle adcHandle
the ADC handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:130
_HAL_Obj_::pieHandle
PIE_Handle pieHandle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:148
_HAL_AdcData_t_::dcBus
_iq dcBus
the dcBus value
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:94
_HAL_Obj_::cpuHandle
CPU_Handle cpuHandle
the CPU handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:134
HAL_Obj
struct _HAL_Obj_ HAL_Obj
Defines the hardware abstraction layer (HAL) data.
hal
HAL_Obj hal
Defines the HAL object.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal.c:61
_HAL_DacData_t_::value
_iq value[4]
the DAC data
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:105
_HAL_Obj_::timerHandle
TIMER_Handle timerHandle[3]
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:158
_HAL_AdcData_t_::V
MATH_vec3 V
the voltage values
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:92
_HAL_AdcData_t_
Defines the ADC data.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:88
_HAL_AdcData_t_::I
MATH_vec3 I
the current values
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:90
_HAL_Obj_::offset_I
OFFSET_Obj offset_I[3]
the current offset objects
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:141
_HAL_Obj_::pwrHandle
PWR_Handle pwrHandle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:156
_HAL_Obj_::pllHandle
PLL_Handle pllHandle
the PLL handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:150
_HAL_Obj_::drv8301Handle
DRV8301_Handle drv8301Handle
the drv8301 interface handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:174
_HAL_Obj_::numVoltageSensors
uint_least8_t numVoltageSensors
the number of voltage sensors
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:169
OFFSET_run
static void OFFSET_run(OFFSET_Handle handle, const _iq inputValue)
Runs an offset filter of the form y[n] = beta*(x[n]+bias) + (1 - beta)*y[n-1] y -> The DC offset x ->...
Definition: 32b/offset.h:137
_HAL_Obj_::offsetHandle_V
OFFSET_Handle offsetHandle_V[3]
the handles for the voltage offset estimators
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:143
_HAL_Obj_
Defines the hardware abstraction layer (HAL) data.
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:128
_HAL_Obj_::gpioHandle
GPIO_Handle gpioHandle
the GPIO handle
Definition: boostxldrv8301_revB/f28x/f2806x/src/hal_obj.h:138
_OFFSET_
Defines the offset (OFFSET) object.
Definition: 32b/offset.h:82