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);
bool registerOcd2Function(int mode, void(*func)(void))
Register a handler which shall be called when the sensor triggeres OCD2.
Definition TLI4971.cpp:353
bool registerOcd1Function(int mode, void(*func)(void))
Register a handler, which shall be called when the sensor triggeres OCD1.
Definition TLI4971.cpp:324
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:605
double read(void)
Reads sensor outputs and calculates current value. If Software OCD is used, this function can trigger...
Definition TLI4971.cpp:174
OCDDEGLITCH
Definition TLI4971.h:28
@ D6
Definition TLI4971.h:28
@ D1
Definition TLI4971.h:28
@ D2
Definition TLI4971.h:28
@ D3
Definition TLI4971.h:28
@ D7
Definition TLI4971.h:28
@ D10
Definition TLI4971.h:28
@ D4
Definition TLI4971.h:28
@ D15
Definition TLI4971.h:28
@ D13
Definition TLI4971.h:28
@ D8
Definition TLI4971.h:28
@ D12
Definition TLI4971.h:28
@ D9
Definition TLI4971.h:28
@ D0
Definition TLI4971.h:28
@ D11
Definition TLI4971.h:28
@ D14
Definition TLI4971.h:28
@ D5
Definition TLI4971.h:28
~TLI4971(void)
Current sensor instance destructor . Reconfigurates pins to INPUT and ADC resolution to 8 Bit
Definition TLI4971.cpp:79
OPMODE
Definition TLI4971.h:27
@ S_ENDED
Definition TLI4971.h:27
@ SD_UNI
Definition TLI4971.h:27
@ SD_BID
Definition TLI4971.h:27
@ FD
Definition TLI4971.h:27
double getLastSwOcdCurrent(void)
As soon as a Software OCD is triggered, the current value (> threshold) is stored....
Definition TLI4971.cpp:308
bool configOcd1(bool enable, int threshold=THR1_1, int deglitchTime=D0)
Configuration of OCD1.
Definition TLI4971.cpp:457
void end(void)
Ends sensor library Turn off sensor supply.
Definition TLI4971.cpp:162
bool reset(void)
Resets sensor to factory settings.
Definition TLI4971.cpp:150
bool setOcdCompHyst(int threshold)
Sets the OCD hysteresis. OCD signals will reset if current < 20% of the provided threshold.
Definition TLI4971.cpp:559
bool begin(void)
Turn on sensor supply, initialy reads sensor configuration and checks if sensor can be configurated.
Definition TLI4971.cpp:94
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:631
MEASRANGE
Definition TLI4971.h:26
@ FSR75
Definition TLI4971.h:26
@ FSR100
Definition TLI4971.h:26
@ FSR25
Definition TLI4971.h:26
@ FSR120
Definition TLI4971.h:26
@ FSR37_5
Definition TLI4971.h:26
@ FSR50
Definition TLI4971.h:26
void configAdc(bool logicLevel5V, int adcResolution=-1)
Configurate ADC.
Definition TLI4971.cpp:239
bool getOcd2State(void)
Reads state of ocd2-pin from sensor.
Definition TLI4971.cpp:214
bool getSwOcdState(void)
Get state of Software OCD.
Definition TLI4971.cpp:226
bool setSwOcdCompHyst(double hysterese)
Set Hysteresis value for SW-OCD. Signal will be reset when current < threshold - hysteresis.
Definition TLI4971.cpp:293
VRefExt
Definition TLI4971.h:30
@ V1_2
Definition TLI4971.h:30
@ V2_5
Definition TLI4971.h:30
@ V1_8
Definition TLI4971.h:30
@ V1_65
Definition TLI4971.h:30
@ V1_5
Definition TLI4971.h:30
bool setRatioOff(bool enable)
If this is enabled the ratio-metric offset behavior of the quiescent voltage is activated....
Definition TLI4971.cpp:656
OCDMODE
Definition TLI4971.h:24
@ POLLING
Definition TLI4971.h:24
@ NONE
Definition TLI4971.h:24
@ INTERRUPT
Definition TLI4971.h:24
bool configOcd2(bool enable, int threshold=THR2_1, int deglitchTime=D0)
Configuration of OCD2.
Definition TLI4971.cpp:509
void ocdPolling(void)
If polling is used as OCD mode this function will perform the polling. Needs to be called repeatedly,...
Definition TLI4971.cpp:258
OCDTHR
Definition TLI4971.h:29
@ THR2_7
Definition TLI4971.h:29
@ THR2_8
Definition TLI4971.h:29
@ THR2_5
Definition TLI4971.h:29
@ THR2_2
Definition TLI4971.h:29
@ THR2_3
Definition TLI4971.h:29
@ THR1_7
Definition TLI4971.h:29
@ THR1_6
Definition TLI4971.h:29
@ THR1_4
Definition TLI4971.h:29
@ THR1_3
Definition TLI4971.h:29
@ THR2_6
Definition TLI4971.h:29
@ THR1_2
Definition TLI4971.h:29
@ THR1_5
Definition TLI4971.h:29
@ THR1_1
Definition TLI4971.h:29
@ THR2_4
Definition TLI4971.h:29
@ THR1_8
Definition TLI4971.h:29
@ THR2_1
Definition TLI4971.h:29
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:381
bool setOpMode(int operatingMode)
Set operating mode of the sensor (refer to Programming guide).
Definition TLI4971.cpp:430
bool setMeasRange(int measuringRange)
Sets the measurement Range of the sensor (refer to Programming Guide).
Definition TLI4971.cpp:403
bool getOcd1State(void)
Reads state of ocd1-pin from sensor.
Definition TLI4971.cpp:202