8 #ifndef TLI4971_H_INCLUDED 9 #define TLI4971_H_INCLUDED 28 enum OCDDEGLITCH {
D0,
D1,
D2,
D3,
D4,
D5,
D6,
D7,
D8,
D9,
D10,
D11,
D12,
D13,
D14,
D15 };
29 enum OCDTHR {
THR1_1,
THR1_2,
THR1_3,
THR1_4,
THR1_5,
THR1_6,
THR1_7,
THR1_8,
THR2_1,
THR2_2,
THR2_3,
THR2_4,
THR2_5,
THR2_6,
THR2_7,
THR2_8 };
32 TLI4971(
int aout,
int vref,
int pwr,
int sici,
int ocd1,
int ocd2,
int mux,
bool mc5V =
true);
40 void configAdc(
bool logicLevel5V,
int adcResolution = -1);
86 int adcResol = ADC_RESOLUTION
91 uint16_t configRegs[3];
93 double swOcdThreshold = 0;
94 double lastSwOcdValue = 0;
95 double swOcdCompHyst = 0;
96 bool swOcdTriggered =
false;
97 bool lastOcd1PinState = HIGH;
98 bool lastOcd2PinState = HIGH;
100 void (*_ocd1Function)(void);
101 void (*_ocd2Function)(void);
102 void (*_swOcdFunction)(void);
104 bool sendConfig(
void);
void configAdc(bool logicLevel5V, int adcResolution=-1)
Configurate ADC.
Definition: TLI4971.cpp:236
OCDDEGLITCH
Definition: TLI4971.h:28
bool setRatioGain(bool enable)
If this is enabled the sensitivity is ratio-metric to VDD respective to VREF in single-ended mode...
Definition: TLI4971.cpp:628
void ocdPolling(void)
If polling is used as OCD mode this function will perform the polling. Needs to be called repeatedly...
Definition: TLI4971.cpp:255
OCDTHR
Definition: TLI4971.h:29
bool setRatioOff(bool enable)
If this is enabled the ratio-metric offset behavior of the quiescent voltage is activated. Default is disabled.
Definition: TLI4971.cpp:653
bool setOpMode(int operatingMode)
Set operating mode of the sensor (refer to Programming guide).
Definition: TLI4971.cpp:427
double getLastSwOcdCurrent(void)
As soon as a Software OCD is triggered, the current value (> threshold) is stored. This function returns it.
Definition: TLI4971.cpp:305
OCDMODE
Definition: TLI4971.h:24
bool getOcd1State(void)
Reads state of ocd1-pin from sensor.
Definition: TLI4971.cpp:199
bool setVrefExt(int vrefExtVoltage)
Sets the reference voltage level. This can be used for Single Ended mode (setting needs to match exte...
Definition: TLI4971.cpp:602
VRefExt
Definition: TLI4971.h:30
bool registerSwOcdFunction(double currentLevel, void(*func)(void))
Register a handler, which shall be called when the sensor value exceeds a certain threshold...
Definition: TLI4971.cpp:378
TLI4971(int aout, int vref, int pwr, int sici, int ocd1, int ocd2, int mux, bool mc5V=true)
Current sensor instance constructor.
Definition: TLI4971.cpp:49
bool registerOcd2Function(int mode, void(*func)(void))
Register a handler which shall be called when the sensor triggeres OCD2.
Definition: TLI4971.cpp:350
bool setMeasRange(int measuringRange)
Sets the measurement Range of the sensor (refer to Programming Guide).
Definition: TLI4971.cpp:400
OPMODE
Definition: TLI4971.h:27
double read(void)
Reads sensor outputs and calculates current value. If Software OCD is used, this function can trigger...
Definition: TLI4971.cpp:171
void end(void)
Ends sensor library Turn off sensor supply.
Definition: TLI4971.cpp:159
bool registerOcd1Function(int mode, void(*func)(void))
Register a handler, which shall be called when the sensor triggeres OCD1.
Definition: TLI4971.cpp:321
bool getSwOcdState(void)
Get state of Software OCD.
Definition: TLI4971.cpp:223
bool setSwOcdCompHyst(double hysterese)
Set Hysteresis value for SW-OCD. Signal will be reset when current < threshold - hysteresis.
Definition: TLI4971.cpp:290
bool setOcdCompHyst(int threshold)
Sets the OCD hysteresis. OCD signals will reset if current < 20% of the provided threshold.
Definition: TLI4971.cpp:556
bool configOcd2(bool enable, int threshold=THR2_1, int deglitchTime=D0)
Configuration of OCD2.
Definition: TLI4971.cpp:506
~TLI4971(void)
Current sensor instance destructor . Reconfigurates pins to INPUT and ADC resolution to 8 Bit...
Definition: TLI4971.cpp:76
bool getOcd2State(void)
Reads state of ocd2-pin from sensor.
Definition: TLI4971.cpp:211
bool reset(void)
Resets sensor to factory settings.
Definition: TLI4971.cpp:147
bool configOcd1(bool enable, int threshold=THR1_1, int deglitchTime=D0)
Configuration of OCD1.
Definition: TLI4971.cpp:454
MEASRANGE
Definition: TLI4971.h:26
bool begin(void)
Turn on sensor supply, initialy reads sensor configuration and checks if sensor can be configurated...
Definition: TLI4971.cpp:91