#include <Tli493d.h>
Public Types | |
enum | TypeAddress_e { TLI493D_A0 = 0x35, TLI493D_A1 = 0x22, TLI493D_A2 = 0x78, TLI493D_A3 = 0x44 } |
enum | AccessMode_e { LOWPOWERMODE = 0, MASTERCONTROLLEDMODE = 1, FASTMODE = 3 } |
enum | Range_e { FULL = 0, SHORT = 1, EXTRASHORT = 3 } |
Public Member Functions | |
Tli493d (AccessMode_e mode=MASTERCONTROLLEDMODE, TypeAddress_e productType=TLI493D_A0, int resetPin=NO_POWER_PIN, bool powerLevel=HIGH) | |
Constructor of the sensor class. More... | |
Tli493d (int resetPin, bool powerLevel=HIGH, AccessMode_e mode=MASTERCONTROLLEDMODE, TypeAddress_e productType=TLI493D_A0) | |
Constructor of the sensor class. More... | |
~Tli493d (void) | |
Destructor. More... | |
void | begin (void) |
Starts the sensor. More... | |
void | begin (bool) |
Starts the sensor. More... | |
void | begin (TwoWire &bus, TypeAddress_e slaveAddress, bool reset, uint8_t oneByteRead) |
Starts the sensor. More... | |
bool | setAccessMode (AccessMode_e mode) |
Sets the operating mode of the sensor. More... | |
void | setTrigger (uint8_t trigger) |
Sets when new measurements are triggered in MASTERCONTROLLEDMODE. If invalid argument or sensor mode is LOWPOWERMODE this function returns without having any effect. More... | |
void | enableTemp (void) |
Enables temperature measurement; by default already enabled. More... | |
void | disableTemp (void) |
Disables temperature measurement to reduce power consumption. More... | |
void | enableBz (void) |
Enables BZ measurement; by default already enabled. More... | |
void | disableBz (void) |
Disables Bz measurement to reduce power consumption. This only works, when temperature measurement is disabled as well. More... | |
bool | setWakeUpThreshold (float xh, float xl, float yh, float yl, float zh, float zl) |
The Wake Up threshold range disabling /INT pulses between upper threshold and lower threshold is limited to a window of the half output range. Here the adjustable range can be set with a ratio of size [-1,1] When all the measurement values Bx, By and Bz are within this range INT is disabled. If the arguments are out of range or any upper threshold is smaller than the lower one, the function returns false without taking effect. If any of the ranges xh-xl, yh-yl or zh-zl is greater than half output range, false will be returned even thought the values are written to the wake-up regeisters. More... | |
bool | setWakeUpThresholdLSB (int16_t xh, int16_t xl, int16_t yh, int16_t yl, int16_t zh, int16_t zl) |
The Wake Up threshold range disabling /INT pulses between upper threshold and lower threshold is limited to a window of the half output range. Here the adjustable range can be set in LSB [-2048,2047]. When all the measurement values Bx, By and Bz are within this range INT is disabled. If the arguments are out of range or any upper threshold is smaller than the lower one, the function returns false without taking effect. If any of the ranges xh-xl, yh-yl or zh-zl is greater than half output range, false will be returned, even thought the values are written to the wake-up regeisters. More... | |
bool | setWakeUpThresholdMT (float xh, float xl, float yh, float yl, float zh, float zl) |
The Wake Up threshold range disabling /INT pulses between upper threshold and lower threshold is limited to a window of the half output range. Here the adjustable range can be set in mT. When all the measurement values Bx, By and Bz are within this range INT is disabled. If the arguments are out of range or any upper threshold is smaller than the lower one, the function returns false without taking effect. If any of the ranges xh-xl, yh-yl or zh-zl is greater than half output range, false will be returned, even thought the values are written to the wake-up regeisters. More... | |
bool | wakeUpEnabled (void) |
Checks if WA bit is set. When not interrupt configuration is as specified by the CA and INT bits. More... | |
void | enableWakeUp (void) |
Enables the Wake Up functionality of the sensor. Following conditions must be fulfilled: More... | |
void | disableWakeUp (void) |
Disables the Wake Up functionality of the sensor. More... | |
void | setUpdateRate (uint8_t updateRate) |
Sets the update rate in low power mode. More... | |
bool | setMeasurementRange (Range_e range) |
Sets the magnetic range that can be measured. The smaller the range, the higher the sensitivity. Please note: The EXTRASHORT-range enables the T-Bit in Register 0x06 and therefore cannot be used together with the WakeUp-feature. Before setting the range to EXTRASHORT, the WakeUp needs to be disabled via disableWakeUp(). Otherwise this function will return false without taking effect. More... | |
Tli493d_Error | updateData (void) |
Reads measurement results from sensor. More... | |
float | getX (void) |
float | getY (void) |
float | getZ (void) |
float | getNorm (void) |
float | getAzimuth (void) |
float | getPolar (void) |
float | getTemp (void) |
void | resetSensor (void) |
Resets the sensor. More... | |
void | readDiagnosis (uint8_t(&diag)[7]) |
void | enableInterrupt (void) |
Enables interrupts. More... | |
void | disableInterrupt (void) |
Disables interrupts; When Collision Avoidance is activated, Sensor read-outs are suppressed during ongoing ADC conversion (clock stretching) More... | |
void | enableCollisionAvoidance (void) |
Enables collision avoidance. When Interrupt is deactivated, clock stretching is active. For clock stretching: SCL and INT pins must be shorted. More... | |
void | disableCollisionAvoidance (void) |
Disables collision avoidance; readouts may collide with ADC conversion. More... | |
Protected Member Functions | |
void | setRegBits (uint8_t regMaskIndex, uint8_t data) |
Stores new values into the bus interface; for this function to take effect the function writeOut() should be called afterwards. More... | |
uint8_t | getRegBits (uint8_t regMaskIndex) |
Returns the value of a register field. More... | |
Protected Attributes | |
tli493d::BusInterface_t | mInterface |
Enumerates the three available modes; number 2 is reserved In low power mode cyclic measurements and ADC-conversions are carried out with a update rate; the wake-up function is already configured for this mode, so that the sensor can continue making magnetic field measurements. With this configuration the microcontroller will only consume power and access the sensor if relevant measurement data is available. In master controlled mode the sensor powered down if when it is not triggered. This library configures to ADC start before sending first MSB of data registers In fast mode the measurements and ADC-conversions are running continuously.
Enumerator | |
---|---|
LOWPOWERMODE | |
MASTERCONTROLLEDMODE | |
FASTMODE |
enum Tli493d::Range_e |
Enumerates the three available ranges; number 2 is reserved The full range is from -160mT to 160mT with a sensitivity of 7.7 LSB/mT. The short range is from -100mT to 100mT with a sensitivity of 15.4 LSB/mT. The extra short range is from -50mT to 50mT with a sensitivity of 30.8 LSB/mT. This is a special feature of the W2BW type.
Enumerator | |
---|---|
FULL | |
SHORT | |
EXTRASHORT |
Tli493d::Tli493d | ( | AccessMode_e | mode = MASTERCONTROLLEDMODE , |
TypeAddress_e | productType = TLI493D_A0 , |
||
int | resetPin = NO_POWER_PIN , |
||
bool | powerLevel = HIGH |
||
) |
Constructor of the sensor class.
mode | Operating mode of the sensor; default is the master controlled mode |
productType | The library supports product types from A0 to A3; default is type A0 |
Tli493d::Tli493d | ( | int | resetPin, |
bool | powerLevel = HIGH , |
||
AccessMode_e | mode = MASTERCONTROLLEDMODE , |
||
TypeAddress_e | productType = TLI493D_A0 |
||
) |
Constructor of the sensor class.
mode | Operating mode of the sensor; default is the master controlled mode |
productType | The library supports product types from A0 to A3; default is type A0 |
Tli493d::~Tli493d | ( | void | ) |
Destructor.
void Tli493d::begin | ( | void | ) |
Starts the sensor.
void Tli493d::begin | ( | bool | reset | ) |
Starts the sensor.
void Tli493d::begin | ( | TwoWire & | bus, |
TypeAddress_e | slaveAddress, | ||
bool | reset, | ||
uint8_t | oneByteRead | ||
) |
Starts the sensor.
bus | The I2C bus |
slaveAddress | The 7-bit slave address as defined in Tli493d_Type |
reset | If a reset should be initiated before starting the sensor |
oneByteRead | If one-byte read protocol should be used. Otherwise the two-byte protocol is available |
bool Tli493d::setAccessMode | ( | AccessMode_e | mode | ) |
Sets the operating mode of the sensor.
mode | MASTERCONTROLLEDMODE,LOWPOWERMODE or FASTMODE, default is MASTERCONTROLLEDMODE |
void Tli493d::setTrigger | ( | uint8_t | trigger | ) |
Sets when new measurements are triggered in MASTERCONTROLLEDMODE. If invalid argument or sensor mode is LOWPOWERMODE this function returns without having any effect.
trigger | 0 = no measurements, 1 = measurements on read before first MSB, 2 = measurements on read after register 0x05 |
void Tli493d::enableTemp | ( | void | ) |
Enables temperature measurement; by default already enabled.
void Tli493d::disableTemp | ( | void | ) |
Disables temperature measurement to reduce power consumption.
void Tli493d::enableBz | ( | void | ) |
Enables BZ measurement; by default already enabled.
void Tli493d::disableBz | ( | void | ) |
Disables Bz measurement to reduce power consumption. This only works, when temperature measurement is disabled as well.
bool Tli493d::setWakeUpThreshold | ( | float | xh, |
float | xl, | ||
float | yh, | ||
float | yl, | ||
float | zh, | ||
float | zl | ||
) |
The Wake Up threshold range disabling /INT pulses between upper threshold and lower threshold is limited to a window of the half output range. Here the adjustable range can be set with a ratio of size [-1,1] When all the measurement values Bx, By and Bz are within this range INT is disabled. If the arguments are out of range or any upper threshold is smaller than the lower one, the function returns false without taking effect. If any of the ranges xh-xl, yh-yl or zh-zl is greater than half output range, false will be returned even thought the values are written to the wake-up regeisters.
xh | Upper threshold in x direction [-1,1] |
xl | Lower threshold in x direction [-1,1] |
yh | Upper threshold in y direction [-1,1] |
yl | Lower threshold in y direction [-1,1] |
zh | Upper threshold in z direction [-1,1] |
zl | Lower threshold in z direction [-1,1] |
bool Tli493d::setWakeUpThresholdLSB | ( | int16_t | xh, |
int16_t | xl, | ||
int16_t | yh, | ||
int16_t | yl, | ||
int16_t | zh, | ||
int16_t | zl | ||
) |
The Wake Up threshold range disabling /INT pulses between upper threshold and lower threshold is limited to a window of the half output range. Here the adjustable range can be set in LSB [-2048,2047]. When all the measurement values Bx, By and Bz are within this range INT is disabled. If the arguments are out of range or any upper threshold is smaller than the lower one, the function returns false without taking effect. If any of the ranges xh-xl, yh-yl or zh-zl is greater than half output range, false will be returned, even thought the values are written to the wake-up regeisters.
xh | Upper threshold in x direction [-2048,2047] |
xl | Lower threshold in x direction [-2048,2047] |
yh | Upper threshold in y direction [-2048,2047] |
yl | Lower threshold in y direction [-2048,2047] |
zh | Upper threshold in z direction [-2048,2047] |
zl | Lower threshold in z direction [-2048,2047] |
bool Tli493d::setWakeUpThresholdMT | ( | float | xh, |
float | xl, | ||
float | yh, | ||
float | yl, | ||
float | zh, | ||
float | zl | ||
) |
The Wake Up threshold range disabling /INT pulses between upper threshold and lower threshold is limited to a window of the half output range. Here the adjustable range can be set in mT. When all the measurement values Bx, By and Bz are within this range INT is disabled. If the arguments are out of range or any upper threshold is smaller than the lower one, the function returns false without taking effect. If any of the ranges xh-xl, yh-yl or zh-zl is greater than half output range, false will be returned, even thought the values are written to the wake-up regeisters.
xh | Upper threshold in x direction in mT |
xl | Lower threshold in x direction in mT |
yh | Upper threshold in y direction in mT |
yl | Lower threshold in y direction in mT |
zh | Upper threshold in z direction in mT |
zl | Lower threshold in z direction in mT |
bool Tli493d::wakeUpEnabled | ( | void | ) |
Checks if WA bit is set. When not interrupt configuration is as specified by the CA and INT bits.
void Tli493d::enableWakeUp | ( | void | ) |
Enables the Wake Up functionality of the sensor. Following conditions must be fulfilled:
CP parity bit must be odd
void Tli493d::disableWakeUp | ( | void | ) |
Disables the Wake Up functionality of the sensor.
void Tli493d::setUpdateRate | ( | uint8_t | updateRate | ) |
Sets the update rate in low power mode.
updateRate | Update rate which is an unsigned integer from the 0 (the fastest) to 7 (the highest) |
bool Tli493d::setMeasurementRange | ( | Range_e | range | ) |
Sets the magnetic range that can be measured. The smaller the range, the higher the sensitivity. Please note: The EXTRASHORT-range enables the T-Bit in Register 0x06 and therefore cannot be used together with the WakeUp-feature. Before setting the range to EXTRASHORT, the WakeUp needs to be disabled via disableWakeUp(). Otherwise this function will return false without taking effect.
range | FULL, SHORT or EXTRASHORT, default is FULL. |
Tli493d_Error_t Tli493d::updateData | ( | void | ) |
Reads measurement results from sensor.
float Tli493d::getX | ( | void | ) |
float Tli493d::getY | ( | void | ) |
float Tli493d::getZ | ( | void | ) |
float Tli493d::getNorm | ( | void | ) |
float Tli493d::getAzimuth | ( | void | ) |
float Tli493d::getPolar | ( | void | ) |
float Tli493d::getTemp | ( | void | ) |
void Tli493d::resetSensor | ( | void | ) |
Resets the sensor.
void Tli493d::readDiagnosis | ( | uint8_t(&) | diag[7] | ) |
void Tli493d::enableInterrupt | ( | void | ) |
Enables interrupts.
void Tli493d::disableInterrupt | ( | void | ) |
Disables interrupts; When Collision Avoidance is activated, Sensor read-outs are suppressed during ongoing ADC conversion (clock stretching)
void Tli493d::enableCollisionAvoidance | ( | void | ) |
Enables collision avoidance. When Interrupt is deactivated, clock stretching is active. For clock stretching: SCL and INT pins must be shorted.
void Tli493d::disableCollisionAvoidance | ( | void | ) |
Disables collision avoidance; readouts may collide with ADC conversion.
|
protected |
Stores new values into the bus interface; for this function to take effect the function writeOut() should be called afterwards.
Register | mask index as defined in Registers_e |
Value | to be written into the register field specified by the register index |
|
protected |
Returns the value of a register field.
Register | mask index as defined in Registers_e |
|
protected |