SparkFun TMAG5273 Arduino Library  v1.0.3-44-g48e0e80
Library for the SparkFun TMAG5273 Arduino Library
Loading...
Searching...
No Matches
TMAG5273 Class Reference

#include <SparkFun_TMAG5273_Arduino_Library.h>

Public Member Functions

 TMAG5273 ()
 
int8_t begin (uint8_t sensorAddress=TMAG5273_I2C_ADDRESS_INITIAL, TwoWire &wirePort=Wire)
 Begin communication with the TMAG over I2C, initialize it, and and set the wire for the I2C communication. More...
 
int8_t isConnected ()
 This function will make sure the TMAG5273 acknowledges over I2C, along with checking the Device ID to ensure proper connection. More...
 
int8_t setupWakeUpAndSleep ()
 Write to the correct registers the correct values to enter wake up and sleep mode. See page 42 of the datasheet for more information on the values chosen. TMAG5273_REG_INT_CONFIG_1 TMAG5273_REG_DEVICE_CONFIG_2. More...
 
int8_t readWakeUpAndSleepData (float &xVal, float &yVal, float &zVal, float &temperature)
 Read the 16-bit magnetic reading for the X, Y, Z and temperature data during the wakeup and sleep mode. More...
 
int8_t setCRCMode (uint8_t crcMode)
 Sets the I2C CRC byte to be sent. More...
 
int8_t setMagTemp (uint8_t magTempMode)
 Sets the temperature coefficient of the magnet. More...
 
int8_t setConvAvg (uint8_t avgMode)
 Sets the additional sampling of the sensor data to reduce the noise effect (or to increase resolution) More...
 
int8_t setReadMode (uint8_t readMode)
 Defines the I2C read mode of the device. More...
 
int8_t setIntThreshold (uint8_t threshold)
 Sets the threshold for the interrupt function. More...
 
int8_t setLowPower (uint8_t lpLnMode)
 Sets the device to low power or low noise mode. More...
 
int8_t setGlitchFilter (uint8_t glitchMode)
 Sets the I2C glitch filter on and off. More...
 
int8_t setTriggerMode (uint8_t trigMode)
 Sets a condition which initiates a single conversion based off already configured registers. A running conversion completes before executing a trigger. Redundant triggers are ignored. TRIGGER_MODE is available only during the mode 'Stand-by mode' mentioned in OPERATING_MODE. More...
 
int8_t setOperatingMode (uint8_t opMode)
 Sets the operating mode from one of the 4 modes: stand-by mode, sleep mode, continuous measure mode, and wake-up and sleep mode. More...
 
int8_t setMagneticChannel (uint8_t channelMode)
 Sets the data acquisition from the following magnetic axis channels listed below. More...
 
int8_t setSleeptime (uint8_t sleepTime)
 Sets the time spent in low power mode between conversions when OPERATING_MODE = 11b. More...
 
int8_t setMagDir (uint8_t threshDir)
 Sets the direction of threshold check. This bit is ignored when THR_HYST > 001b. More...
 
int8_t setMagnitudeGain (uint8_t gainAdjust)
 Sets the axis for magnitude gain correction valued entered in MAG_GAIN_CONFIG register. More...
 
int8_t setMagneticGain (uint8_t magneticGain)
 This function sets an 8-bit gain value determined by a primary to adjust a Hall axis gain. The particular axis is selected based off the settings of MAG_GAIN_CH and ANGLE_EN register bits. The binary 8-bit input is interpreted as a fractional value between 0 and 1 based off the formula 'user entered value in decimal/256.' Gain value of 0 is interpreted by the device as 1. TMAG5273_REG_MAG_GAIN_CONFIG. More...
 
int8_t setMagneticOffset1 (int8_t offset1)
 This function will write an 8-bit, 2's complement offset value determined by a primary to adjust the first axis offset value. The range of possible offset valid entrees can be +/-128. The offset value is calculated by multiplying bit resolution with the entered value. TMAG5273_REG_MAG_OFFSET_CONFIG_1. More...
 
int8_t setMagneticOffset2 (int8_t offset2)
 This function will write an 8-bit, 2's complement offset value determined by a primary to adjust the first axis offset value. The range of possible offset valid entrees can be +/-128. The offset value is calculated by multiplying bit resolution with the entered value. TMAG5273_REG_MAG_OFFSET_CONFIG_2. More...
 
int8_t setAngleEn (uint8_t angleEnable)
 Sets the angle calculation, magnetic gain, and offset corrections between two selected magnetic channels. More...
 
int8_t setXYAxisRange (uint8_t xyAxisRange)
 Sets the X and Y axes magnetic range from 2 different options. More...
 
int8_t setZAxisRange (uint8_t zAxisRange)
 Sets the Z magnetic range from 2 different options. More...
 
int8_t setXThreshold (int8_t xThreshold)
 Sets an 8-bit, 2's complement X axis threshold code for limit check. The range of possible threshold entrees can be +/-128. The threshold value in mT is calculated as (40(1+X_Y_RANGE)/128)*X_THR_CONFIG, where X_THR_CONFIG is the value set by the user. Default 0h means no threshold comparison. More...
 
int8_t setYThreshold (int8_t yThreshold)
 Sets an 8-bit, 2's complement Y axis threshold code for limit check. The range of possible threshold entrees can be +/-128. The threshold value in mT is calculated as (40(1+X_Y_RANGE)/128)*Y_THR_CONFIG, where Y_THR_CONFIG is the value set by the user. Default 0h means no threshold comparison. More...
 
int8_t setZThreshold (int8_t zThresh)
 Sets an 8-bit, 2's complement Z axis threshold code for limit check. The range of possible threshold entrees can be +/-128. The threshold value in mT is calculated as (40(1+Z_RANGE)/128)*Z_THR_CONFIG, where Z_THR_CONFIG is the value set by the user. Default 0h means no threshold comparison. More...
 
int8_t setTemperatureThreshold (int8_t tempThresh)
 Sets the temperature threshold code entered by the user. The valid temperature threshold ranges are -41C to 170C with the threshold codes for -41C = 1Ah, and 170C = 34h. Resolution is 8 degree C/ LSB Default 0x0 means no threshold comparison. More...
 
int8_t setTemperatureEn (bool temperatureEnable)
 Sets the enable bit that determines the data acquisition of the temperature channel. More...
 
int8_t setInterruptResult (bool interruptEnable)
 Sets the enable interrupt response bit on conversion complete. More...
 
int8_t setThresholdEn (bool enableInterruptResponse)
 Configures the bit that enables interrupt response on a predefined threshold cross. More...
 
int8_t setIntPinState (bool interruptState)
 Enables the !INT interrupt if it is latched or pulsed. More...
 
int8_t setInterruptMode (uint8_t configurationMode)
 Configures the interrupt mode select. More...
 
int8_t setMaskInterrupt (bool interruptPinEnable)
 Configures the Mask !INT pin when !INT is connected to GND. More...
 
int8_t setI2CAddress (uint8_t address)
 This register is loaded with the default I2C address from OTP during first power up. Change these bits to a new setting if a new I2C address is required (at each power cycle these bits must be written again to avoid going back to default factory address). NOTE: To be able to use this function, make sure to enable the I2C Address Bit (see function setI2CAddressEN for more information). More...
 
int8_t setI2CAddressEN (bool addressEnable)
 Writes to the I2C_ADDRESS_UPDATE_EN bit to enable a new user defined I2C address. More...
 
int8_t setOscillatorError (bool oscError)
 This function clears the oscillator error flag when it is raised high by an error. More...
 
uint8_t getCRCMode ()
 Returns the I2C CRC byte to be sent 0X0 = CRC disabled 0X1 = CRC enabled TMAG5273_REG_DEVICE_CONFIG_1 - bit 7. More...
 
uint8_t getMagTemp ()
 Returns the temp coefficient of the magnet 0X0 = 0% (No temperature compensation) 0X1 = 0.12%/deg C (NdBFe) 0X2 = Reserved 0X3 = 0.2%/deg C (Ceramic) TMAG5273_REG_DEVICE_CONFIG_1 - bit 6-5. More...
 
uint8_t getConvAvg ()
 Returns the sampling of the sensor data to reduce the noise effect (or to increase resolution) 0X0 = 1x average, 10.0-kSPS (3-axes) or 20-kSPS (1 axis) 0X1 = 2x average, 5.7-kSPS (3-axes) or 13.3-kSPS (1 axis) 0X2 = 4x average, 3.1-kSPS (3-axes) or 8.0-kSPS (1 axis) 0X3 = 8x average, 1.6-kSPS (3-axes) or 4.4-kSPS (1 axis) 0X4 = 16x average, 0.8-kSPS (3-axes) or 2.4-kSPS (1 axis) 0X5 = 32x average, 0.4-kSPS (3-axes) or 1.2-kSPS (1 axis) TMAG5273_REG_DEVICE_CONFIG_1 - bit 4-2. More...
 
uint8_t getReadMode ()
 Returns the I2C read mode 0X0 = Standard I2C 3-byte read command 0X1 = 1-byte I2C read command for 16bit sensor data and conversion status 0X2 = 1-byte I2C read command for 8bit sensor MSB data and conversion status TMAG5273_REG_DEVICE_CONFIG_1 Bits 0-1. More...
 
uint8_t getIntThreshold ()
 Returns the threshold for the interrupt function. 0X0 = Takes the 2's complement value of each x_THR_CONFIG register to create a magnetic threshold of the corresponding axis 0X1 = Takes the 7LSB bits of the x_THR_CONFIG register to create two opposite magnetic thresholds (one north, and another south) of equal magnitude TMAG5273_REG_DEVICE_CONFIG_2 - bit 7-5. More...
 
uint8_t getLowPower ()
 Returns if the device is operating in low power or low noise mode. 0X0 = Low active current mode 0X1 = Low noise mode TMAG5273_REG_DEVICE_CONFIG_2 - bit 4. More...
 
uint8_t getGlitchFiler ()
 Returns if the I2C glitch filter is on or off 0x0 = Glitch filter ON 0X0 = Glitch filter OFF TMAG5273_REG_DEVICE_CONFIG_2 - bit 3. More...
 
uint8_t getTriggerMode ()
 Returns the condition which initiates a single conversion based off already configured registers. A running conversion completes before executing a trigger. Redundant triggers are ignored. TRIGGER_MODE is available only during the mode 'Stand- by Mode' mentioned in OPERATING_MODE. 0X0 = Conversion Start at I2C Command Bits, DEFAULT 0X1 = Conversion starts through trigger signal at !INT pin TMAG5273_REG_DEVICE_CONFIG_2 - bit 2. More...
 
uint8_t getOperatingMode ()
 Returns the operating mode from one of the 4 listed below: 0X0 = Stand-by mode (starts new conversion at trigger event) 0X1 = Sleep mode 0X2 = Continuous measure mode 0X3 = Wake-up and sleep mode (W&S Mode) TMAG5273_REG_DEVICE_CONFIG_2 - bit 1-0. More...
 
uint8_t getMagneticChannel ()
 Returns data acquisition from the following magnetic axis channels: 0X0 = All magnetic channels off, DEFAULT 0X1 = X Channel Enabled 0X2 = Y Channel Enabled 0X3 = X, Y Channel Enabled 0X4 = Z Channel Enabled 0X5 = Z, X Channel Enabled 0X6 = Y, Z Channel Enabled 0X7 = X, Y, Z Channel Enabled 0X8 = XYX Channel Enabled 0X9 = YXY Channel Enabled 0XA = YZY Channel Enabled 0XB = XZX Channel Enabled TMAG5273_REG_SENSOR_CONFIG_1 - bit 7-4. More...
 
uint8_t getSleeptime ()
 Returns the time spent in low power mode between conversions when OPERATING_MODE=11b. 0X0 = 1ms 0X1 = 5ms 0X2 = 10ms 0X3 = 15ms 0X4 = 20ms 0X5 = 30ms 0X6 = 50ms 0X7 = 100ms 0X8 = 500ms 0X9 = 1000ms 0XA = 2000ms 0XB = 5000ms 0XC = 20000ms TMAG5273_REG_SENSOR_CONFIG_1 - bit 3-0. More...
 
uint8_t getMagDir ()
 Returns the direction of threshold check. This bit is ignored when THR_HYST > 001b. 0X0 = sets interrupt for field above the threshold 0X1 = sets interrupt for field below the threshold TMAG5273_REG_SENSOR_CONFIG_2 - bit 5. More...
 
uint8_t getMagnitudeChannelSelect ()
 Returns the axis for magnitude gain correction value entered in MAG_GAIN_CONFIG register 0X0 = 1st channel is selected for gain adjustment 0X1 = 2nd channel is selected for gain adjustment TMAG5273_REG_SENSOR_CONFIG_2 - bit 4. More...
 
uint8_t getMagneticGain ()
 This function returns an 8-bit gain value determined by a primary to adjust a Hall axis gain. The particular axis is selected based off the settings of MAG_GAIN_CH and ANGLE_EN register bits. The binary 8-bit input is interpreted as a fractional value between 0 and 1 based off the formula 'user entered value in decimal/256.' Gain value of 0 is interpreted by the device as 1. TMAG5273_REG_MAG_GAIN_CONFIG. More...
 
int8_t getMagneticOffset1 ()
 This function will return an 8-bit, 2's complement offset value determined by a primary to adjust the first axis offset value. The range of possible offset valid entrees can be +/-128. The offset value is calculated by multiplying bit resolution with the entered value. TMAG5273_REG_MAG_OFFSET_CONFIG_1. More...
 
int8_t getMagneticOffset2 ()
 This function will return an 8-bit, 2's complement offset value determined by a primary to adjust the first axis offset value. The range of possible offset valid entrees can be +/-128. The offset value is calculated by multiplying bit resolution with the entered value. TMAG5273_REG_MAG_OFFSET_CONFIG_2. More...
 
uint8_t getAngleEn ()
 Returns angle calculation, magnetic gain, and offset corrections between two selected magnetic channels. 0X0 = No angle calculation, magnitude gain, and offset correction enabled 0X1 = X 1st, Y 2nd 0X2 = Y 1st, Z 2nd 0X3 = X 1st, Z 2nd TMAG5273_REG_SENSOR_CONFIG_2 - bit 3-2. More...
 
uint8_t getXYAxisRange ()
 Returns the X and Y axes magnetic range from the two following options: 0X0 = ±40mT, DEFAULT 0X1 = ±80mT TMAG5273_REG_SENSOR_CONFIG_2 - bit 1. More...
 
uint8_t getZAxisRange ()
 Returns the Z axis magnetic range from the two following options: 0X0 = ±40mT, DEFAULT 0X1 = ±80mT TMAG5273_REG_SENSOR_CONFIG_2 - bit 0. More...
 
int8_t getXThreshold ()
 Returns an 8-bit, 2's complement X axis threshold code for limit check. The range of possible threshold entrees can be +/-128. The threshold value in mT is calculated as (40(1+X_Y_RANGE)/128)*X_THR_CONFIG. The value of X_THR_CONFIG is returned by this method Default 0h means no threshold comparison. TMAG5273_REG_X_THR_CONFIG - bits 7-0. More...
 
int8_t getYThreshold ()
 Returns an 8-bit, 2's complement Y axis threshold code for limit check. The range of possible threshold entrees can be +/-128. The threshold value in mT is calculated as (40(1+X_Y_RANGE)/128)*Y_THR_CONFIG. The value of Y_THR_CONFIG is returned by this method Default 0h means no threshold comparison. TMAG5273_REG_Y_THR_CONFIG - bits 7-0. More...
 
int8_t getZThreshold ()
 Returns an 8-bit, 2's complement Z axis threshold code for limit check. The range of possible threshold entrees can be +/-128. The threshold value in mT is calculated as (40(1+Z_RANGE)/128)*Z_THR_CONFIG. The value of Z_THR_CONFIG is returned by this method Default 0h means no threshold comparison. TMAG5273_REG_Z_THR_CONFIG - bits 7-0. More...
 
uint8_t getTemperatureThreshold ()
 Returns the temperature threshold code entered by the user. The valid temperature threshold values are -41C to 170C with the threshold codes for -41C = 0x1A, and 170C = 0X34. Resolution is 8 degree C/LSB. Default 0x0 means no threshold comparison. TMAG5273_REG_T_CONFIG - bits 7-1. More...
 
uint8_t getTemperatureEN ()
 Returns the enable bit that determines the data acquisition of the temperature channel. 0x0 = Temp Channel Disabled 0x1 = Temp Channel Enabled TMAG5273_REG_T_CONFIG - bit 0. More...
 
uint8_t getInterruptResult ()
 Returns the enable interrupt response bit on conversion complete. 0X0 = Interrupt is NOT asserted when the configured set of conversions are complete 0X1 = Interrupt is asserted when the configured set of conversions are complete TMAG5273_REG_INT_CONFIG_1 - bit 7. More...
 
uint8_t getThresholdEn ()
 Returns the bit that enables the interrupt response on a predefined threshold cross. 0X0 = Interrupt is NOT asserted when a threshold is crossed 0X1 = Interrupt is asserted when a threshold is crossed TMAG5273_REG_INT_CONFIG_1 - bit 6. More...
 
uint8_t getIntPinState ()
 Returns the !INT interrupt if it is latched or pulsed. 0X0 = !INT interrupt latched until clear by a primary addressing the device 0X1 = !INT interrupt pulse for 10us TMAG5273_REG_INT_CONFIG_1 - bit 5. More...
 
uint8_t getInterruptMode ()
 Returns the configuration for the interrupt mode select 0X0 = No interrupt 0X1 = Interrupt through !INT 0X2 = Interrupt through !INT except when I2C bus is busy 0X3 = Interrupt through SCL 0X4 = Interrupt through SCL except when I2C bus is busy TMAG5273_REG_INT_CONFIG_1 - bit 4-2. More...
 
uint8_t getMaskInt ()
 Returns the Mask !INT pin when !INT is connected to GND 0X0 = !INT pin is enabled 0X1 = !INT pin is disabled (for wake-up and trigger functions) TMAG5273_REG_INT_CONFIG_1 - bit 0. More...
 
uint8_t getSetCount ()
 Returns the rolling count of conversion data sets TMAG5273_REG_CONV_STATUS - bit 7-5. More...
 
uint8_t getPOR ()
 Returns if the device is powered up, or experienced power- on-reset. Bit is cleared when the host writes back '1'. 0X0 = No POR 0X1 = POR occurred TMAG5273_REG_CONV_STATUS - bit 4. More...
 
uint8_t getDiagStatus ()
 Returns if there was a detection of any internal diagnostics fail which include VCC UV, internal memory CRC error, !INT pin error and internal clock error. Ignore this bit status if VCC < 2.3V. 0X0 = no diag fail 0X1 = diag fail detected TMAG5273_REG_CONV_STATUS - bit 1. More...
 
uint8_t getResultStatus ()
 Returns if the conversion data buffer is ready to be read. 0X0 = Conversion data not complete 0X1 = Conversion data complete TMAG5273_REG_CONV_STATUS - bit 0. More...
 
uint8_t getI2CAddress ()
 Returns the I2C address of the device. There is a 7-bit default factory address is loaded from OTP during first power up. Change these bits to a new setting if a new I2C address is required (at each power cycle these bits must be written again to avoid going back to default factory address). TMAG5273_REG_I2C_ADDRESS - bits 7-1. More...
 
uint8_t getDeviceID ()
 Returns the device version indicator. The reset value of the DEVICE_ID depends on the orderable part number 0X0 = Reserved 0X1 = ±40-mT and ±80-mT range 0X2 = ±133-mT and ±266-mT range 0X3 = Reserved DEVICE_ID. More...
 
uint16_t getManufacturerID ()
 Returns the 8-Bit Manufacturer ID. There are two registers, LSB and MSB. MANUFACTURER_ID_LSB MANUFACTURER_ID_MSB. More...
 
float getTemp ()
 Reads back the T-Channel data conversion results, combining the MSB and LSB registers. T_MSB_RESULT and T_LSB_RESULT. More...
 
float getXData ()
 Reads back the X-Channel data conversion results, the MSB 8-Bit and LSB 8-Bits. This reads from the following registers: X_MSB_RESULT and X_LSB_RESULT. More...
 
float getYData ()
 Reads back the Y-Channel data conversion results, the MSB 8-Bits and LSB 8-Bits. This reads from the following registers: Y_MSB_RESULT and Y_LSB_RESULT. More...
 
float getZData ()
 Reads back the Z-Channel data conversion results, the MSB 8-Bits and LSB 8-Bits. This reads from the following registers: Z_MSB_RESULT and Z_LSB_RESULT. More...
 
float getAngleResult ()
 Returns the angle measurement result in degree. The data displayed from 0 to 360 degree in 13 LSB bits after combining the MSB and LSB bits. The 4 LSB bits allocated for fraction of an angle in the format (xxx/16). TMAG5273_REG_ANGLE_RESULT_MSB TMAG5273_REG_ANGLE_RESULT_LSB. More...
 
float getMagnitudeResult ()
 Returns the resultant vector magnitude (during angle measurement) result. This value should be constant during 360 degree measurements. More...
 
uint8_t getInterruptPinStatus ()
 This function indicates the level that the device is reading back from the !INT pin. The reset value of DEVICE_STATUS depends on the status of the !INT pin at power-up. More...
 
uint8_t getDeviceStatus ()
 This function returns the device status register as its raw hex value. This value can be taken and compared to the main register as seen in the datasheet. The errors include an oscillator error, INT pin error detected, OTP CRC errors, or under voltage resistors. TMAG5273_REG_DEVICE_STATUS. More...
 
int8_t getError ()
 This function will return the error code, if there is any at the time when the function is called. If any of the Error pins are raised to 1 then there is an error. For more information on the specific error, checkout the getDeviceStatus() function and compare to the datasheet. More...
 

Constructor & Destructor Documentation

◆ TMAG5273()

TMAG5273::TMAG5273 ( )

Member Function Documentation

◆ begin()

int8_t TMAG5273::begin ( uint8_t  sensorAddress = TMAG5273_I2C_ADDRESS_INITIAL,
TwoWire &  wirePort = Wire 
)

Begin communication with the TMAG over I2C, initialize it, and and set the wire for the I2C communication.

Parameters
sensorAddressI2C address of the sensor
wirePortI2C port to use for communication, defaults to Wire
Returns
Error code (1 is success, 0 is failure, negative is warning)

◆ getAngleEn()

uint8_t TMAG5273::getAngleEn ( )

Returns angle calculation, magnetic gain, and offset corrections between two selected magnetic channels. 0X0 = No angle calculation, magnitude gain, and offset correction enabled 0X1 = X 1st, Y 2nd 0X2 = Y 1st, Z 2nd 0X3 = X 1st, Z 2nd TMAG5273_REG_SENSOR_CONFIG_2 - bit 3-2.

Returns
Angle calculation and associated channel order

◆ getAngleResult()

float TMAG5273::getAngleResult ( )

Returns the angle measurement result in degree. The data displayed from 0 to 360 degree in 13 LSB bits after combining the MSB and LSB bits. The 4 LSB bits allocated for fraction of an angle in the format (xxx/16). TMAG5273_REG_ANGLE_RESULT_MSB TMAG5273_REG_ANGLE_RESULT_LSB.

Returns
Angle measurement result in degrees (float value)

◆ getConvAvg()

uint8_t TMAG5273::getConvAvg ( )

Returns the sampling of the sensor data to reduce the noise effect (or to increase resolution) 0X0 = 1x average, 10.0-kSPS (3-axes) or 20-kSPS (1 axis) 0X1 = 2x average, 5.7-kSPS (3-axes) or 13.3-kSPS (1 axis) 0X2 = 4x average, 3.1-kSPS (3-axes) or 8.0-kSPS (1 axis) 0X3 = 8x average, 1.6-kSPS (3-axes) or 4.4-kSPS (1 axis) 0X4 = 16x average, 0.8-kSPS (3-axes) or 2.4-kSPS (1 axis) 0X5 = 32x average, 0.4-kSPS (3-axes) or 1.2-kSPS (1 axis) TMAG5273_REG_DEVICE_CONFIG_1 - bit 4-2.

Returns
Value of the sampling average of the sensor data

◆ getCRCMode()

uint8_t TMAG5273::getCRCMode ( )

Returns the I2C CRC byte to be sent 0X0 = CRC disabled 0X1 = CRC enabled TMAG5273_REG_DEVICE_CONFIG_1 - bit 7.

Returns
CRC disabled (0) or CRC enables (1), -1 for error

◆ getDeviceID()

uint8_t TMAG5273::getDeviceID ( )

Returns the device version indicator. The reset value of the DEVICE_ID depends on the orderable part number 0X0 = Reserved 0X1 = ±40-mT and ±80-mT range 0X2 = ±133-mT and ±266-mT range 0X3 = Reserved DEVICE_ID.

Returns
Version number code of the device

◆ getDeviceStatus()

uint8_t TMAG5273::getDeviceStatus ( )

This function returns the device status register as its raw hex value. This value can be taken and compared to the main register as seen in the datasheet. The errors include an oscillator error, INT pin error detected, OTP CRC errors, or under voltage resistors. TMAG5273_REG_DEVICE_STATUS.

Returns
Device Status Register as a raw value.

◆ getDiagStatus()

uint8_t TMAG5273::getDiagStatus ( )

Returns if there was a detection of any internal diagnostics fail which include VCC UV, internal memory CRC error, !INT pin error and internal clock error. Ignore this bit status if VCC < 2.3V. 0X0 = no diag fail 0X1 = diag fail detected TMAG5273_REG_CONV_STATUS - bit 1.

Returns
Detection of any internal diagnostics failure

◆ getError()

int8_t TMAG5273::getError ( )

This function will return the error code, if there is any at the time when the function is called. If any of the Error pins are raised to 1 then there is an error. For more information on the specific error, checkout the getDeviceStatus() function and compare to the datasheet.

Returns
Error code (0 is success, negative is failure, positive is warning)

◆ getGlitchFiler()

uint8_t TMAG5273::getGlitchFiler ( )

Returns if the I2C glitch filter is on or off 0x0 = Glitch filter ON 0X0 = Glitch filter OFF TMAG5273_REG_DEVICE_CONFIG_2 - bit 3.

Returns
I2C filter ON (0) or OFF (1)

◆ getI2CAddress()

uint8_t TMAG5273::getI2CAddress ( )

Returns the I2C address of the device. There is a 7-bit default factory address is loaded from OTP during first power up. Change these bits to a new setting if a new I2C address is required (at each power cycle these bits must be written again to avoid going back to default factory address). TMAG5273_REG_I2C_ADDRESS - bits 7-1.

Returns
I2C address of the device

◆ getInterruptMode()

uint8_t TMAG5273::getInterruptMode ( )

Returns the configuration for the interrupt mode select 0X0 = No interrupt 0X1 = Interrupt through !INT 0X2 = Interrupt through !INT except when I2C bus is busy 0X3 = Interrupt through SCL 0X4 = Interrupt through SCL except when I2C bus is busy TMAG5273_REG_INT_CONFIG_1 - bit 4-2.

Returns
Configuration for the interrupt mode select

◆ getInterruptPinStatus()

uint8_t TMAG5273::getInterruptPinStatus ( )

This function indicates the level that the device is reading back from the !INT pin. The reset value of DEVICE_STATUS depends on the status of the !INT pin at power-up.

Returns
Returns the following: 0X0 = !INT pin driven low 0X1 = !INT pin status high

◆ getInterruptResult()

uint8_t TMAG5273::getInterruptResult ( )

Returns the enable interrupt response bit on conversion complete. 0X0 = Interrupt is NOT asserted when the configured set of conversions are complete 0X1 = Interrupt is asserted when the configured set of conversions are complete TMAG5273_REG_INT_CONFIG_1 - bit 7.

Returns
Interrupt response bit for conversion complete.

◆ getIntPinState()

uint8_t TMAG5273::getIntPinState ( )

Returns the !INT interrupt if it is latched or pulsed. 0X0 = !INT interrupt latched until clear by a primary addressing the device 0X1 = !INT interrupt pulse for 10us TMAG5273_REG_INT_CONFIG_1 - bit 5.

Returns
Value if !INT interrupt is latched or pulsed

◆ getIntThreshold()

uint8_t TMAG5273::getIntThreshold ( )

Returns the threshold for the interrupt function. 0X0 = Takes the 2's complement value of each x_THR_CONFIG register to create a magnetic threshold of the corresponding axis 0X1 = Takes the 7LSB bits of the x_THR_CONFIG register to create two opposite magnetic thresholds (one north, and another south) of equal magnitude TMAG5273_REG_DEVICE_CONFIG_2 - bit 7-5.

Returns
Threshold for the interrupt function (0X0 - 0X1)

◆ getLowPower()

uint8_t TMAG5273::getLowPower ( )

Returns if the device is operating in low power or low noise mode. 0X0 = Low active current mode 0X1 = Low noise mode TMAG5273_REG_DEVICE_CONFIG_2 - bit 4.

Returns
Low power (0) or low noise (1) mode

◆ getMagDir()

uint8_t TMAG5273::getMagDir ( )

Returns the direction of threshold check. This bit is ignored when THR_HYST > 001b. 0X0 = sets interrupt for field above the threshold 0X1 = sets interrupt for field below the threshold TMAG5273_REG_SENSOR_CONFIG_2 - bit 5.

Returns
Direction of threshold check - 0 or 1

◆ getMagneticChannel()

uint8_t TMAG5273::getMagneticChannel ( )

Returns data acquisition from the following magnetic axis channels: 0X0 = All magnetic channels off, DEFAULT 0X1 = X Channel Enabled 0X2 = Y Channel Enabled 0X3 = X, Y Channel Enabled 0X4 = Z Channel Enabled 0X5 = Z, X Channel Enabled 0X6 = Y, Z Channel Enabled 0X7 = X, Y, Z Channel Enabled 0X8 = XYX Channel Enabled 0X9 = YXY Channel Enabled 0XA = YZY Channel Enabled 0XB = XZX Channel Enabled TMAG5273_REG_SENSOR_CONFIG_1 - bit 7-4.

Returns
Code for the magnetic channel axis being read

◆ getMagneticGain()

uint8_t TMAG5273::getMagneticGain ( )

This function returns an 8-bit gain value determined by a primary to adjust a Hall axis gain. The particular axis is selected based off the settings of MAG_GAIN_CH and ANGLE_EN register bits. The binary 8-bit input is interpreted as a fractional value between 0 and 1 based off the formula 'user entered value in decimal/256.' Gain value of 0 is interpreted by the device as 1. TMAG5273_REG_MAG_GAIN_CONFIG.

Returns
8-bit gain value

◆ getMagneticOffset1()

int8_t TMAG5273::getMagneticOffset1 ( )

This function will return an 8-bit, 2's complement offset value determined by a primary to adjust the first axis offset value. The range of possible offset valid entrees can be +/-128. The offset value is calculated by multiplying bit resolution with the entered value. TMAG5273_REG_MAG_OFFSET_CONFIG_1.

Returns
Magnetic offset value for the first axis

◆ getMagneticOffset2()

int8_t TMAG5273::getMagneticOffset2 ( )

This function will return an 8-bit, 2's complement offset value determined by a primary to adjust the first axis offset value. The range of possible offset valid entrees can be +/-128. The offset value is calculated by multiplying bit resolution with the entered value. TMAG5273_REG_MAG_OFFSET_CONFIG_2.

Returns
Magnetic offset value for the second axis

◆ getMagnitudeChannelSelect()

uint8_t TMAG5273::getMagnitudeChannelSelect ( )

Returns the axis for magnitude gain correction value entered in MAG_GAIN_CONFIG register 0X0 = 1st channel is selected for gain adjustment 0X1 = 2nd channel is selected for gain adjustment TMAG5273_REG_SENSOR_CONFIG_2 - bit 4.

Returns
First (0) or Second (0) channel selected for gain adjustment

◆ getMagnitudeResult()

float TMAG5273::getMagnitudeResult ( )

Returns the resultant vector magnitude (during angle measurement) result. This value should be constant during 360 degree measurements.

Returns
Vector magnitude during angle measurement

◆ getMagTemp()

uint8_t TMAG5273::getMagTemp ( )

Returns the temp coefficient of the magnet 0X0 = 0% (No temperature compensation) 0X1 = 0.12%/deg C (NdBFe) 0X2 = Reserved 0X3 = 0.2%/deg C (Ceramic) TMAG5273_REG_DEVICE_CONFIG_1 - bit 6-5.

Returns
Temperature coefficient of the magnet

◆ getManufacturerID()

uint16_t TMAG5273::getManufacturerID ( )

Returns the 8-Bit Manufacturer ID. There are two registers, LSB and MSB. MANUFACTURER_ID_LSB MANUFACTURER_ID_MSB.

Returns
16-Bit Manufacturer ID

◆ getMaskInt()

uint8_t TMAG5273::getMaskInt ( )

Returns the Mask !INT pin when !INT is connected to GND 0X0 = !INT pin is enabled 0X1 = !INT pin is disabled (for wake-up and trigger functions) TMAG5273_REG_INT_CONFIG_1 - bit 0.

Returns
!INT pin is enabled or disabled

◆ getOperatingMode()

uint8_t TMAG5273::getOperatingMode ( )

Returns the operating mode from one of the 4 listed below: 0X0 = Stand-by mode (starts new conversion at trigger event) 0X1 = Sleep mode 0X2 = Continuous measure mode 0X3 = Wake-up and sleep mode (W&S Mode) TMAG5273_REG_DEVICE_CONFIG_2 - bit 1-0.

Returns
Operating mode: stand-by, sleep, continuous, or wake-up and sleep

◆ getPOR()

uint8_t TMAG5273::getPOR ( )

Returns if the device is powered up, or experienced power- on-reset. Bit is cleared when the host writes back '1'. 0X0 = No POR 0X1 = POR occurred TMAG5273_REG_CONV_STATUS - bit 4.

Returns
Device is powered up or experienced POR.

◆ getReadMode()

uint8_t TMAG5273::getReadMode ( )

Returns the I2C read mode 0X0 = Standard I2C 3-byte read command 0X1 = 1-byte I2C read command for 16bit sensor data and conversion status 0X2 = 1-byte I2C read command for 8bit sensor MSB data and conversion status TMAG5273_REG_DEVICE_CONFIG_1 Bits 0-1.

Returns
I2C read mode (0-2)

◆ getResultStatus()

uint8_t TMAG5273::getResultStatus ( )

Returns if the conversion data buffer is ready to be read. 0X0 = Conversion data not complete 0X1 = Conversion data complete TMAG5273_REG_CONV_STATUS - bit 0.

Returns
Conversion data buffer status

◆ getSetCount()

uint8_t TMAG5273::getSetCount ( )

Returns the rolling count of conversion data sets TMAG5273_REG_CONV_STATUS - bit 7-5.

Returns
Rolling count of conversion data sets

◆ getSleeptime()

uint8_t TMAG5273::getSleeptime ( )

Returns the time spent in low power mode between conversions when OPERATING_MODE=11b. 0X0 = 1ms 0X1 = 5ms 0X2 = 10ms 0X3 = 15ms 0X4 = 20ms 0X5 = 30ms 0X6 = 50ms 0X7 = 100ms 0X8 = 500ms 0X9 = 1000ms 0XA = 2000ms 0XB = 5000ms 0XC = 20000ms TMAG5273_REG_SENSOR_CONFIG_1 - bit 3-0.

Returns
Code for the time spent in low power mode between conversions

◆ getTemp()

float TMAG5273::getTemp ( )

Reads back the T-Channel data conversion results, combining the MSB and LSB registers. T_MSB_RESULT and T_LSB_RESULT.

Returns
T-Channel data conversion results

◆ getTemperatureEN()

uint8_t TMAG5273::getTemperatureEN ( )

Returns the enable bit that determines the data acquisition of the temperature channel. 0x0 = Temp Channel Disabled 0x1 = Temp Channel Enabled TMAG5273_REG_T_CONFIG - bit 0.

Returns
Enable bit that determines if temp channel is enabled or disabled

◆ getTemperatureThreshold()

uint8_t TMAG5273::getTemperatureThreshold ( )

Returns the temperature threshold code entered by the user. The valid temperature threshold values are -41C to 170C with the threshold codes for -41C = 0x1A, and 170C = 0X34. Resolution is 8 degree C/LSB. Default 0x0 means no threshold comparison. TMAG5273_REG_T_CONFIG - bits 7-1.

Returns
Temperature threshold code entered by the user originally.

◆ getThresholdEn()

uint8_t TMAG5273::getThresholdEn ( )

Returns the bit that enables the interrupt response on a predefined threshold cross. 0X0 = Interrupt is NOT asserted when a threshold is crossed 0X1 = Interrupt is asserted when a threshold is crossed TMAG5273_REG_INT_CONFIG_1 - bit 6.

Returns
Enable bit for if the interrupt is or is not asserted

◆ getTriggerMode()

uint8_t TMAG5273::getTriggerMode ( )

Returns the condition which initiates a single conversion based off already configured registers. A running conversion completes before executing a trigger. Redundant triggers are ignored. TRIGGER_MODE is available only during the mode 'Stand- by Mode' mentioned in OPERATING_MODE. 0X0 = Conversion Start at I2C Command Bits, DEFAULT 0X1 = Conversion starts through trigger signal at !INT pin TMAG5273_REG_DEVICE_CONFIG_2 - bit 2.

Returns
Condition that initiates conversion thru I2C or INT

◆ getXData()

float TMAG5273::getXData ( )

Reads back the X-Channel data conversion results, the MSB 8-Bit and LSB 8-Bits. This reads from the following registers: X_MSB_RESULT and X_LSB_RESULT.

Returns
X-Channel data conversion results

◆ getXThreshold()

int8_t TMAG5273::getXThreshold ( )

Returns an 8-bit, 2's complement X axis threshold code for limit check. The range of possible threshold entrees can be +/-128. The threshold value in mT is calculated as (40(1+X_Y_RANGE)/128)*X_THR_CONFIG. The value of X_THR_CONFIG is returned by this method Default 0h means no threshold comparison. TMAG5273_REG_X_THR_CONFIG - bits 7-0.

Returns
Returns the X threshold code for limit check

◆ getXYAxisRange()

uint8_t TMAG5273::getXYAxisRange ( )

Returns the X and Y axes magnetic range from the two following options: 0X0 = ±40mT, DEFAULT 0X1 = ±80mT TMAG5273_REG_SENSOR_CONFIG_2 - bit 1.

Returns
X and Y axes magnetic range (0 or 1)

◆ getYData()

float TMAG5273::getYData ( )

Reads back the Y-Channel data conversion results, the MSB 8-Bits and LSB 8-Bits. This reads from the following registers: Y_MSB_RESULT and Y_LSB_RESULT.

Returns
Y-Channel data conversion results

◆ getYThreshold()

int8_t TMAG5273::getYThreshold ( )

Returns an 8-bit, 2's complement Y axis threshold code for limit check. The range of possible threshold entrees can be +/-128. The threshold value in mT is calculated as (40(1+X_Y_RANGE)/128)*Y_THR_CONFIG. The value of Y_THR_CONFIG is returned by this method Default 0h means no threshold comparison. TMAG5273_REG_Y_THR_CONFIG - bits 7-0.

Returns
Returns the Y threshold code for limit check

◆ getZAxisRange()

uint8_t TMAG5273::getZAxisRange ( )

Returns the Z axis magnetic range from the two following options: 0X0 = ±40mT, DEFAULT 0X1 = ±80mT TMAG5273_REG_SENSOR_CONFIG_2 - bit 0.

Returns
Z axis magnetic range from ±40mT or ±80mT

◆ getZData()

float TMAG5273::getZData ( )

Reads back the Z-Channel data conversion results, the MSB 8-Bits and LSB 8-Bits. This reads from the following registers: Z_MSB_RESULT and Z_LSB_RESULT.

Returns
Z-Channel data conversion results.

◆ getZThreshold()

int8_t TMAG5273::getZThreshold ( )

Returns an 8-bit, 2's complement Z axis threshold code for limit check. The range of possible threshold entrees can be +/-128. The threshold value in mT is calculated as (40(1+Z_RANGE)/128)*Z_THR_CONFIG. The value of Z_THR_CONFIG is returned by this method Default 0h means no threshold comparison. TMAG5273_REG_Z_THR_CONFIG - bits 7-0.

Returns
Returns the Z threshold code for limit check

◆ isConnected()

int8_t TMAG5273::isConnected ( )

This function will make sure the TMAG5273 acknowledges over I2C, along with checking the Device ID to ensure proper connection.

Returns
Error code (0 is success, negative is failure)

◆ readWakeUpAndSleepData()

int8_t TMAG5273::readWakeUpAndSleepData ( float &  xVal,
float &  yVal,
float &  zVal,
float &  temperature 
)

Read the 16-bit magnetic reading for the X, Y, Z and temperature data during the wakeup and sleep mode.

Parameters
xVal16-bit value for the X magnetic reading
yVal16-bit value for the Y magnetic reading
zVal16-bit value for the Z magnetic reading
temperature8-bit value for the temperature reading
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setAngleEn()

int8_t TMAG5273::setAngleEn ( uint8_t  angleEnable)

Sets the angle calculation, magnetic gain, and offset corrections between two selected magnetic channels.

Parameters
angleEnablevalue to write to the register for which angle calculation enabled 0X0 = No angle calculation, magnitude gain, and offset correction enabled 0X1 = X 1st, Y 2nd 0X2 = Y 1st, Z 2nd 0X3 = X 1st, Z 2nd TMAG5273_REG_SENSOR_CONFIG_2 - bit 3-2
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setConvAvg()

int8_t TMAG5273::setConvAvg ( uint8_t  avgMode)

Sets the additional sampling of the sensor data to reduce the noise effect (or to increase resolution)

Parameters
avgModevalue to set the conversion average 0X0 = 1x average, 10.0-kSPS (3-axes) or 20-kSPS (1 axis) 0X1 = 2x average, 5.7-kSPS (3-axes) or 13.3-kSPS (1 axis) 0X2 = 4x average, 3.1-kSPS (3-axes) or 8.0-kSPS (1 axis) 0X3 = 8x average, 1.6-kSPS (3-axes) or 4.4-kSPS (1 axis) 0X4 = 16x average, 0.8-kSPS (3-axes) or 2.4-kSPS (1 axis) 0X5 = 32x average, 0.4-kSPS (3-axes) or 1.2-kSPS (1 axis) TMAG5273_REG_DEVICE_CONFIG_1 - bit 4-2
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setCRCMode()

int8_t TMAG5273::setCRCMode ( uint8_t  crcMode)

Sets the I2C CRC byte to be sent.

Parameters
crcMode0b0-0b1 0X0 = CRC disabled 0X1 = CRC enabled TMAG5273_REG_DEVICE_CONFIG_1 - bit 7
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setGlitchFilter()

int8_t TMAG5273::setGlitchFilter ( uint8_t  glitchMode)

Sets the I2C glitch filter on and off.

Parameters
glitchModevalue to set the mode 0x0 = Glitch filter ON 0X0 = Glitch filter OFF TMAG5273_REG_DEVICE_CONFIG_2 - bit 3
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setI2CAddress()

int8_t TMAG5273::setI2CAddress ( uint8_t  address)

This register is loaded with the default I2C address from OTP during first power up. Change these bits to a new setting if a new I2C address is required (at each power cycle these bits must be written again to avoid going back to default factory address). NOTE: To be able to use this function, make sure to enable the I2C Address Bit (see function setI2CAddressEN for more information).

Parameters
addressAddress value to set device to TMAG5273_REG_I2C_ADDRESS - bits 7-1
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setI2CAddressEN()

int8_t TMAG5273::setI2CAddressEN ( bool  addressEnable)

Writes to the I2C_ADDRESS_UPDATE_EN bit to enable a new user defined I2C address.

Parameters
addressEnableValue to determine if the user can write a new address. 0X0 = Disable update of I2C address 0X1 = Enable update of I2C address with bits (7:1)
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setInterruptMode()

int8_t TMAG5273::setInterruptMode ( uint8_t  configurationMode)

Configures the interrupt mode select.

Parameters
config_modeValue to determine the int select 0X0 = No interrupt 0X1 = Interrupt through !INT 0X2 = Interrupt through !INT except when I2C bus is busy 0X3 = Interrupt through SCL 0X4 = Interrupt through SCL except when I2C bus is busy TMAG5273_REG_INT_CONFIG_1 - bit 4-2
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setInterruptResult()

int8_t TMAG5273::setInterruptResult ( bool  interruptEnable)

Sets the enable interrupt response bit on conversion complete.

Parameters
interruptEnableValue to determine if interrupt is or is not asserted 0X0 = Interrupt is NOT asserted when the configured set of conversions are complete 0X1 = Interrupt is asserted when the configured set of conversions are complete TMAG5273_REG_INT_CONFIG_1 - bit 7
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setIntPinState()

int8_t TMAG5273::setIntPinState ( bool  interruptState)

Enables the !INT interrupt if it is latched or pulsed.

Parameters
interruptStateValue to determine the interrupt state 0X0 = !INT interrupt latched until clear by a primary addressing the device 0X1 = !INT interrupt pulse for 10us TMAG5273_REG_INT_CONFIG_1 - bit 5
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setIntThreshold()

int8_t TMAG5273::setIntThreshold ( uint8_t  threshold)

Sets the threshold for the interrupt function.

Parameters
thresholdValue to set the threshold 0X0 = Takes the 2's complement value of each x_THR_CONFIG register to create a magnetic threshold of the corresponding axis 0X1 = Takes the 7LSB bits of the x_THR_CONFIG register to create two opposite magnetic thresholds (one north, and another south) of equal magnitude The rest of the bits are reserved (0x2 - 0x7) - DO NOT USE TMAG5273_REG_DEVICE_CONFIG_2 - bit 7-5
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setLowPower()

int8_t TMAG5273::setLowPower ( uint8_t  lpLnMode)

Sets the device to low power or low noise mode.

Parameters
lpLnModeValue to set the mode 0X0 = Low active current mode 0X1 = Low noise mode TMAG5273_REG_DEVICE_CONFIG_2 - bit 4
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setMagDir()

int8_t TMAG5273::setMagDir ( uint8_t  threshDir)

Sets the direction of threshold check. This bit is ignored when THR_HYST > 001b.

Parameters
threshDirvalue to set the direction of threshold 0X0 = sets interrupt for field above the threshold 0X1 = sets interrupt for field below the threshold TMAG5273_REG_SENSOR_CONFIG_2 - bit 5
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setMagneticChannel()

int8_t TMAG5273::setMagneticChannel ( uint8_t  channelMode)

Sets the data acquisition from the following magnetic axis channels listed below.

Parameters
channelModeValue that sets the channel for data acquisition 0X0 = All magnetic channels off, DEFAULT 0X1 = X Channel Enabled 0X2 = Y Channel Enabled 0X3 = X, Y Channel Enabled 0X4 = Z Channel Enabled 0X5 = Z, X Channel Enabled 0X6 = Y, Z Channel Enabled 0X7 = X, Y, Z Channel Enabled 0X8 = XYX Channel Enabled 0X9 = YXY Channel Enabled 0XA = YZY Channel Enabled 0XB = XZX Channel Enabled TMAG5273_REG_SENSOR_CONFIG_1 - bits 7-4
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setMagneticGain()

int8_t TMAG5273::setMagneticGain ( uint8_t  magneticGain)

This function sets an 8-bit gain value determined by a primary to adjust a Hall axis gain. The particular axis is selected based off the settings of MAG_GAIN_CH and ANGLE_EN register bits. The binary 8-bit input is interpreted as a fractional value between 0 and 1 based off the formula 'user entered value in decimal/256.' Gain value of 0 is interpreted by the device as 1. TMAG5273_REG_MAG_GAIN_CONFIG.

Parameters
magneticGain
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setMagneticOffset1()

int8_t TMAG5273::setMagneticOffset1 ( int8_t  offset1)

This function will write an 8-bit, 2's complement offset value determined by a primary to adjust the first axis offset value. The range of possible offset valid entrees can be +/-128. The offset value is calculated by multiplying bit resolution with the entered value. TMAG5273_REG_MAG_OFFSET_CONFIG_1.

Parameters
offset1Value within the range +/-128 in mT
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setMagneticOffset2()

int8_t TMAG5273::setMagneticOffset2 ( int8_t  offset2)

This function will write an 8-bit, 2's complement offset value determined by a primary to adjust the first axis offset value. The range of possible offset valid entrees can be +/-128. The offset value is calculated by multiplying bit resolution with the entered value. TMAG5273_REG_MAG_OFFSET_CONFIG_2.

Parameters
offset2Value within the range +/-128
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setMagnitudeGain()

int8_t TMAG5273::setMagnitudeGain ( uint8_t  gainAdjust)

Sets the axis for magnitude gain correction valued entered in MAG_GAIN_CONFIG register.

Parameters
gainAdjustValue to set the gain correction value 0X0 = 1st channel is selected for gain adjustment 0X1 = 2nd channel is selected for gain adjustment TMAG5273_REG_SENSOR_CONFIG_2 - bit 4
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setMagTemp()

int8_t TMAG5273::setMagTemp ( uint8_t  magTempMode)

Sets the temperature coefficient of the magnet.

Parameters
magTempModevalue to set the temp coefficient of the device 0x0 = 0% (No temperature compensation) 0x1 = 0.12%/deg C (NdBFe) 0x2 = Reserved 0x3 = 0.2%/deg C (Ceramic) TMAG5273_REG_DEVICE_CONFIG_1 - bit 6-5
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setMaskInterrupt()

int8_t TMAG5273::setMaskInterrupt ( bool  interruptPinEnable)

Configures the Mask !INT pin when !INT is connected to GND.

Parameters
interruptPinEnableValue to choose the INT enable or disable 0X0 = !INT pin is enabled 0X1 = !INT pin is disabled (for wake-up and trigger functions) TMAG5273_REG_INT_CONFIG_1 - bit 0
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setOperatingMode()

int8_t TMAG5273::setOperatingMode ( uint8_t  opMode)

Sets the operating mode from one of the 4 modes: stand-by mode, sleep mode, continuous measure mode, and wake-up and sleep mode.

Parameters
opModevalue to set the operating mode of the device 0X0 = Stand-by mode (starts new conversion at trigger event) 0X1 = Sleep mode 0X2 = Continuous measure mode 0X3 = Wake-up and sleep mode (W&S Mode) TMAG5273_REG_DEVICE_CONFIG_2 - bit 1-0
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setOscillatorError()

int8_t TMAG5273::setOscillatorError ( bool  oscError)

This function clears the oscillator error flag when it is raised high by an error.

Parameters
oscErrorWrite '1' to clear the error flag 0X0 = No oscillator error detected 0X1 = Oscillator error detected TMAG5273_REG_DEVICE_STATUS - bit 3
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setReadMode()

int8_t TMAG5273::setReadMode ( uint8_t  readMode)

Defines the I2C read mode of the device.

Parameters
readModeValue to set the read mode 0X0 = Standard I2C 3-byte read command 0X1 = 1-byte I2C read command for 16bit sensor data and conversion status 0X2 = 1-byte I2C read command for 8bit sensor MSB data and conversion status TMAG5273_REG_DEVICE_CONFIG_1 Bits 0-1
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setSleeptime()

int8_t TMAG5273::setSleeptime ( uint8_t  sleepTime)

Sets the time spent in low power mode between conversions when OPERATING_MODE = 11b.

Parameters
sleepTimeValue to set the time desired 0X0 = 1ms 0X1 = 5ms 0X2 = 10ms 0X3 = 15ms 0X4 = 20ms 0X5 = 30ms 0X6 = 50ms 0X7 = 100ms 0X8 = 500ms 0X9 = 1000ms 0XA = 2000ms 0XB = 5000ms 0XC = 20000ms TMAG5273_REG_SENSOR_CONFIG_1 - bit 3-0
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setTemperatureEn()

int8_t TMAG5273::setTemperatureEn ( bool  temperatureEnable)

Sets the enable bit that determines the data acquisition of the temperature channel.

Parameters
temperatureEnableValue to determine enable or disable 0x0 = Temp Channel Disabled 0x1 = Temp Channel Enabled TMAG5273_REG_T_CONFIG - bit 0
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setTemperatureThreshold()

int8_t TMAG5273::setTemperatureThreshold ( int8_t  tempThresh)

Sets the temperature threshold code entered by the user. The valid temperature threshold ranges are -41C to 170C with the threshold codes for -41C = 1Ah, and 170C = 34h. Resolution is 8 degree C/ LSB Default 0x0 means no threshold comparison.

Parameters
tempThresh8-bit value to set the threshold for the temperature limit TMAG5273_REG_T_CONFIG - bits 7-1
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setThresholdEn()

int8_t TMAG5273::setThresholdEn ( bool  enableInterruptResponse)

Configures the bit that enables interrupt response on a predefined threshold cross.

Parameters
enableInterruptResponseValue to determine if interrupt is or is not asserted 0X0 = Interrupt is NOT asserted when a threshold is crossed 0X1 = Interrupt is asserted when a threshold is crossed TMAG5273_REG_INT_CONFIG_1 - bit 6
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setTriggerMode()

int8_t TMAG5273::setTriggerMode ( uint8_t  trigMode)

Sets a condition which initiates a single conversion based off already configured registers. A running conversion completes before executing a trigger. Redundant triggers are ignored. TRIGGER_MODE is available only during the mode 'Stand-by mode' mentioned in OPERATING_MODE.

Parameters
trigModevalue to set the trigger mode of the device 0X0 = Conversion Start at I2C Command Bits, DEFAULT 0X1 = Conversion starts through trigger signal at !INT pin TMAG5273_REG_DEVICE_CONFIG_2 - bit 2
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setupWakeUpAndSleep()

int8_t TMAG5273::setupWakeUpAndSleep ( )

Write to the correct registers the correct values to enter wake up and sleep mode. See page 42 of the datasheet for more information on the values chosen. TMAG5273_REG_INT_CONFIG_1 TMAG5273_REG_DEVICE_CONFIG_2.

Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setXThreshold()

int8_t TMAG5273::setXThreshold ( int8_t  xThreshold)

Sets an 8-bit, 2's complement X axis threshold code for limit check. The range of possible threshold entrees can be +/-128. The threshold value in mT is calculated as (40(1+X_Y_RANGE)/128)*X_THR_CONFIG, where X_THR_CONFIG is the value set by the user. Default 0h means no threshold comparison.

Parameters
xThreshold8-bit value to set the threshold for the X limit TMAG5273_REG_X_THR_CONFIG - bits 7-0
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setXYAxisRange()

int8_t TMAG5273::setXYAxisRange ( uint8_t  xyAxisRange)

Sets the X and Y axes magnetic range from 2 different options.

Parameters
xyAxisRangeValue to choose the magnetic range 0X0 = ±40mT, DEFAULT 0X1 = ±80mT TMAG5273_REG_SENSOR_CONFIG_2 - bit 1
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setYThreshold()

int8_t TMAG5273::setYThreshold ( int8_t  yThreshold)

Sets an 8-bit, 2's complement Y axis threshold code for limit check. The range of possible threshold entrees can be +/-128. The threshold value in mT is calculated as (40(1+X_Y_RANGE)/128)*Y_THR_CONFIG, where Y_THR_CONFIG is the value set by the user. Default 0h means no threshold comparison.

Parameters
yThreshold8-bit value to set the threshold for the Y limit TMAG5273_REG_Y_THR_CONFIG - bits 7-0
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setZAxisRange()

int8_t TMAG5273::setZAxisRange ( uint8_t  zAxisRange)

Sets the Z magnetic range from 2 different options.

Parameters
zAxisRangeValue to set the range from either 40mT or 80mT 0X0 = ±40mT, DEFAULT 0X1 = ±80mT TMAG5273_REG_SENSOR_CONFIG_2 - bit 0
Returns
Error code (0 is success, negative is failure, positive is warning)

◆ setZThreshold()

int8_t TMAG5273::setZThreshold ( int8_t  zThreshold)

Sets an 8-bit, 2's complement Z axis threshold code for limit check. The range of possible threshold entrees can be +/-128. The threshold value in mT is calculated as (40(1+Z_RANGE)/128)*Z_THR_CONFIG, where Z_THR_CONFIG is the value set by the user. Default 0h means no threshold comparison.

Parameters
zThresh8-bit value to set the threshold for the Y limit TMAG5273_REG_Z_THR_CONFIG - bits 7-0
Returns
Error code (0 is success, negative is failure, positive is warning)

The documentation for this class was generated from the following files: