Multi Half-Bridge 4.0.0
Library of Infineon's Multi Half-Bridge IC controllers family
 
Loading...
Searching...
No Matches
tle94112.hpp
Go to the documentation of this file.
1
10#ifndef TLE94112_HPP_
11#define TLE94112_HPP_
12
13#include <stdint.h>
14#include <stdlib.h>
15#include "timer.hpp"
16#include "gpio.hpp"
17#include "spic.hpp"
18
19using namespace tle94112;
20
31#define TLE94112_NUM_HB 13
32
38#define TLE94112_NUM_PWM 4
39
46#define TLE94112_NUM_CTRL_REGS 12
47
54#define TLE94112_NUM_STATUS_REGS 7
55
67{
68 public:
75
81
84 {
85 TLE_FLOATING = 0b00, TLE_LOW = 0b01, TLE_HIGH = 0b10
86 };
87
90 {
91 TLE_NONE = 0b00, TLE_LOWSIDE = 0b01, TLE_HIGHSIDE = 0b10
92 };
93
99
111
113 static const uint8_t TLE_STATUS_OK = 0U;
114
116 Tle94112();
117
120
122 ~Tle94112();
123
125 void begin(void);
126
128 void end(void);
129
140 void configHB(HalfBridge hb, HBState state, PWMChannel pwm);
141
154 void configHB(HalfBridge hb, HBState state, PWMChannel pwm, uint8_t activeFW);
155
165 void configPWM(PWMChannel pwm, PWMFreq freq, uint8_t dutyCycle);
166
177 uint8_t setLedMode(HalfBridge hb, uint8_t active);
178
184 uint8_t getSysDiagnosis();
185
195 uint8_t getSysDiagnosis(DiagFlag mask);
196
207 uint8_t getSysDiagnosis(uint8_t mask);
208
216 uint8_t getHBOverCurrent(HalfBridge hb);
217
225 uint8_t getHBOpenLoad(HalfBridge hb);
226
228 void clearErrors();
229
238 void directWriteReg(uint8_t reg, uint8_t data);
239
250 uint8_t readStatusReg(uint8_t reg);
251
252 SPIC *sBus; //<! \brief SPI cover class as representation of the SPI bus
253 GPIOC *cs; //<! \brief shield enable GPIO to switch chipselect on/off
254 GPIOC *en; //<! \brief shield enable GPIO to switch shield on/off
255 Timer *timer; //<! \brief timer for delay settings
256
257 protected:
258
275
287
289 typedef struct
290 {
291 uint8_t stateReg;
292 uint8_t stateMask;
293 uint8_t stateShift;
294 uint8_t pwmReg;
295 uint8_t pwmMask;
296 uint8_t pwmShift;
297 uint8_t fwReg;
298 uint8_t fwMask;
299 uint8_t fwShift;
300 uint8_t ocReg;
301 uint8_t ocMask;
302 uint8_t ocShift;
303 uint8_t olReg;
304 uint8_t olMask;
305 uint8_t olShift;
306 } HalfBridge_t;
307
309 typedef struct
310 {
311 uint8_t freqReg;
312 uint8_t freqMask;
313 uint8_t freqShift;
314 uint8_t dcReg;
315 uint8_t dcMask;
316 uint8_t dcShift;
317 } PWMchannel_t;
318
319
330
332 void init(void);
333
343 void _configHB(uint8_t hb, uint8_t state, uint8_t pwm, uint8_t activeFW);
344
352 void _configPWM(uint8_t pwm, uint8_t freq, uint8_t dutyCycle);
353
362 uint8_t _getHBOverCurrent(uint8_t hb);
363
372 uint8_t _getHBOpenLoad(uint8_t hb);
373
386 void writeReg(uint8_t reg, uint8_t mask, uint8_t shift, uint8_t data);
387
400 uint8_t readStatusReg(uint8_t reg, uint8_t mask, uint8_t shift);
401
410 void clearStatusReg(uint8_t reg);
411
412 uint8_t mEnabled; //<! \brief indicates if TLE94112LE is enabled
413
414};
415
418#endif
TLE94112 GPIO Platform Abstraction Layer.
Definition gpio.hpp:24
Definition spic.hpp:25
Definition timer.hpp:24
uint8_t dcShift
Definition tle94112.hpp:316
uint8_t _getHBOpenLoad(uint8_t hb)
gets the openload error flag bit for a specific halfbridge automatically called by the public version...
Definition tle94112.cpp:200
DiagFlag
enum for the flags in the register SYS_DIAG1
Definition tle94112.hpp:102
@ TLE_OVER_VOLTAGE
Definition tle94112.hpp:106
@ TLE_TEMP_SHUTDOWN
Definition tle94112.hpp:108
@ TLE_LOAD_ERROR
Definition tle94112.hpp:104
@ TLE_SPI_ERROR
Definition tle94112.hpp:103
@ TLE_UNDER_VOLTAGE
Definition tle94112.hpp:105
@ TLE_POWER_ON_RESET
Definition tle94112.hpp:107
@ TLE_TEMP_WARNING
Definition tle94112.hpp:109
uint8_t ocReg
Definition tle94112.hpp:300
HBState
enum for the output states of a halfbridge
Definition tle94112.hpp:84
@ TLE_LOW
Definition tle94112.hpp:85
@ TLE_FLOATING
Definition tle94112.hpp:85
@ TLE_HIGH
Definition tle94112.hpp:85
uint8_t fwShift
Definition tle94112.hpp:299
PWMFreq
enum for the frequencies of a PWM channel
Definition tle94112.hpp:96
@ TLE_FREQ80HZ
Definition tle94112.hpp:97
@ TLE_FREQ200HZ
Definition tle94112.hpp:97
@ TLE_FREQ100HZ
Definition tle94112.hpp:97
@ TLE_FREQOFF
Definition tle94112.hpp:97
uint8_t fwReg
Definition tle94112.hpp:297
uint8_t olMask
Definition tle94112.hpp:304
static const uint8_t TLE_STATUS_OK
Reference value of Status Register.
Definition tle94112.hpp:113
uint8_t getHBOpenLoad(HalfBridge hb)
gets the openload error flag bit for a specific halfbridge
Definition tle94112.cpp:195
uint8_t olShift
Definition tle94112.hpp:305
Tle94112()
standard constructor with default pin assignment
Definition tle94112.cpp:29
HBOCState
enum for the overcurrent states of a halfbridge
Definition tle94112.hpp:90
@ TLE_HIGHSIDE
Definition tle94112.hpp:91
@ TLE_LOWSIDE
Definition tle94112.hpp:91
@ TLE_NONE
Definition tle94112.hpp:91
uint8_t freqShift
Definition tle94112.hpp:313
uint8_t ocMask
Definition tle94112.hpp:301
Timer * timer
Definition tle94112.hpp:255
uint8_t dcReg
Definition tle94112.hpp:314
GPIOC * cs
Definition tle94112.hpp:253
SPIC * sBus
Definition tle94112.hpp:252
uint8_t readStatusReg(uint8_t reg)
reads one byte from a status register of the TLE94112
Definition tle94112.cpp:318
GPIOC * en
Definition tle94112.hpp:254
uint8_t pwmShift
Definition tle94112.hpp:296
PWMChannel
enum for the PWM channels of a halfbridge on TLE94112
Definition tle94112.hpp:78
@ TLE_PWM1
Definition tle94112.hpp:79
@ TLE_PWM2
Definition tle94112.hpp:79
@ TLE_PWM3
Definition tle94112.hpp:79
@ TLE_NOPWM
Definition tle94112.hpp:79
void writeReg(uint8_t reg, uint8_t mask, uint8_t shift, uint8_t data)
writes data bits to a control register of the TLE94112
Definition tle94112.cpp:298
StatusRegisters
enum for the status registers in a TLE94112
Definition tle94112.hpp:278
@ OP_ERROR_4_STAT
Definition tle94112.hpp:283
@ SYS_DIAG1
Definition tle94112.hpp:279
@ OP_ERROR_5_STAT
Definition tle94112.hpp:284
@ OP_ERROR_2_STAT
Definition tle94112.hpp:281
@ OP_ERROR_1_STAT
Definition tle94112.hpp:280
@ OP_ERROR_3_STAT
Definition tle94112.hpp:282
@ OP_ERROR_6_STAT
Definition tle94112.hpp:285
uint8_t mStatusRegAddresses[TLE94112_NUM_STATUS_REGS]
mapping array for status register addresses
Definition tle94112.hpp:329
void clearErrors()
clears all clearable error flags
Definition tle94112.cpp:207
HalfBridge_t mHalfBridges[TLE94112_NUM_HB]
array of register locations for halfbridges
Definition tle94112.hpp:321
HalfBridge
enum for the halfbridges on a TLE94112
Definition tle94112.hpp:71
@ TLE_HB3
Definition tle94112.hpp:72
@ TLE_HB2
Definition tle94112.hpp:72
@ TLE_HB6
Definition tle94112.hpp:72
@ TLE_HB1
Definition tle94112.hpp:72
@ TLE_NOHB
Definition tle94112.hpp:72
@ TLE_HB8
Definition tle94112.hpp:73
@ TLE_HB7
Definition tle94112.hpp:73
@ TLE_HB12
Definition tle94112.hpp:73
@ TLE_HB9
Definition tle94112.hpp:73
@ TLE_HB5
Definition tle94112.hpp:72
@ TLE_HB10
Definition tle94112.hpp:73
@ TLE_HB4
Definition tle94112.hpp:72
@ TLE_HB11
Definition tle94112.hpp:73
uint8_t freqMask
Definition tle94112.hpp:312
uint8_t freqReg
Definition tle94112.hpp:311
PWMchannel_t mPwmChannels[TLE94112_NUM_PWM]
array of register locations for PWM channels
Definition tle94112.hpp:323
uint8_t ocShift
Definition tle94112.hpp:302
uint8_t dcMask
Definition tle94112.hpp:315
uint8_t stateReg
Definition tle94112.hpp:291
uint8_t mCtrlRegData[TLE94112_NUM_CTRL_REGS]
mirror array for control register data
Definition tle94112.hpp:327
uint8_t stateMask
Definition tle94112.hpp:292
uint8_t _getHBOverCurrent(uint8_t hb)
gets the overcurrent error flag bit for a specific halfbridge automatically called by the public vers...
Definition tle94112.cpp:188
uint8_t mCtrlRegAddresses[TLE94112_NUM_CTRL_REGS]
mapping array for control register addresses
Definition tle94112.hpp:325
void init(void)
initializes this object, automatically called by begin()
Definition tle94112.cpp:220
uint8_t fwMask
Definition tle94112.hpp:298
uint8_t setLedMode(HalfBridge hb, uint8_t active)
sets LED mode on compatible half bridges (half bridge 1 or 2 of TLE94112)
Definition tle94112.cpp:147
uint8_t getSysDiagnosis()
returns a diagnosis value for error detection
Definition tle94112.cpp:162
uint8_t getHBOverCurrent(HalfBridge hb)
gets the overcurrent error flag bit for a specific halfbridge
Definition tle94112.cpp:183
void end(void)
deactivates all outputs and disables the TLE94112
Definition tle94112.cpp:84
void configHB(HalfBridge hb, HBState state, PWMChannel pwm)
sets the output state and the PWM channel for a halfbridge (only for passive freewheeling)
Definition tle94112.cpp:113
uint8_t pwmReg
Definition tle94112.hpp:294
uint8_t pwmMask
Definition tle94112.hpp:295
uint8_t mEnabled
Definition tle94112.hpp:412
void clearStatusReg(uint8_t reg)
clears a status register by writing 0x00 to it
Definition tle94112.cpp:343
void begin(void)
enables and initializes the TLE94112
Definition tle94112.cpp:51
void _configHB(uint8_t hb, uint8_t state, uint8_t pwm, uint8_t activeFW)
sets the output state and the PWM channel for a halfbridge automatically called by the public version...
Definition tle94112.cpp:123
void _configPWM(uint8_t pwm, uint8_t freq, uint8_t dutyCycle)
sets the frequency and duty cycle for a PWM channel automatically called by the public version of con...
Definition tle94112.cpp:138
void directWriteReg(uint8_t reg, uint8_t data)
writes data bits directly to a register of the TLE94112
Definition tle94112.cpp:283
void configPWM(PWMChannel pwm, PWMFreq freq, uint8_t dutyCycle)
sets the frequency and duty cycle for a PWM channel
Definition tle94112.cpp:133
~Tle94112()
standard destructor switches shield off
Definition tle94112.cpp:43
CtrlRegisters
enum for the control registers in a TLE94112
Definition tle94112.hpp:261
@ FW_OL_CTRL
Definition tle94112.hpp:272
@ HB_MODE_2_CTRL
Definition tle94112.hpp:266
@ PWM_CH_FREQ_CTRL
Definition tle94112.hpp:268
@ PWM3_DC_CTRL
Definition tle94112.hpp:271
@ FW_CTRL
Definition tle94112.hpp:273
@ HB_ACT_1_CTRL
Definition tle94112.hpp:262
@ HB_ACT_2_CTRL
Definition tle94112.hpp:263
@ PWM2_DC_CTRL
Definition tle94112.hpp:270
@ HB_ACT_3_CTRL
Definition tle94112.hpp:264
@ PWM1_DC_CTRL
Definition tle94112.hpp:269
@ HB_MODE_1_CTRL
Definition tle94112.hpp:265
@ HB_MODE_3_CTRL
Definition tle94112.hpp:267
uint8_t stateShift
Definition tle94112.hpp:293
uint8_t olReg
Definition tle94112.hpp:303
struct containing register locations for a single halfbridge
Definition tle94112.hpp:290
struct containing register locations for a single PWM channel
Definition tle94112.hpp:310
represents a basic TLE94112
Definition tle94112.hpp:67
#define TLE94112_NUM_HB
the number of halfbridges on a TLE94112 (including no halfbridge)
Definition tle94112.hpp:31
#define TLE94112_NUM_PWM
the number of pwm modes for a halfbridge (including no pwm)
Definition tle94112.hpp:38
#define TLE94112_NUM_STATUS_REGS
the number of status registers in a TLE94112
Definition tle94112.hpp:54
#define TLE94112_NUM_CTRL_REGS
the number of control registers in a TLE94112
Definition tle94112.hpp:46
Definition tle94112-types.hpp:14
TLE94112 SPI Platform Abstraction Layer.
TLE94112 Timer Platform Abstraction Layer.