![]() |
SparkFun TMAG5273 Arduino Library
v1.0.3-44-g48e0e80
Library for the SparkFun TMAG5273 Arduino Library
|
#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... | |
| TMAG5273::TMAG5273 | ( | ) |
| 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.
| sensorAddress | I2C address of the sensor |
| wirePort | I2C port to use for communication, defaults to Wire |
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| float TMAG5273::getMagnitudeResult | ( | ) |
Returns the resultant vector magnitude (during angle measurement) result. This value should be constant during 360 degree measurements.
| 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.
| uint16_t TMAG5273::getManufacturerID | ( | ) |
Returns the 8-Bit Manufacturer ID. There are two registers, LSB and MSB. MANUFACTURER_ID_LSB MANUFACTURER_ID_MSB.
| 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.
| 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.
| 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.
| 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.
| 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.
| uint8_t TMAG5273::getSetCount | ( | ) |
Returns the rolling count of conversion data sets TMAG5273_REG_CONV_STATUS - bit 7-5.
| 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.
| float TMAG5273::getTemp | ( | ) |
Reads back the T-Channel data conversion results, combining the MSB and LSB registers. T_MSB_RESULT and T_LSB_RESULT.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| 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.
| int8_t TMAG5273::isConnected | ( | ) |
This function will make sure the TMAG5273 acknowledges over I2C, along with checking the Device ID to ensure proper connection.
| 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.
| xVal | 16-bit value for the X magnetic reading |
| yVal | 16-bit value for the Y magnetic reading |
| zVal | 16-bit value for the Z magnetic reading |
| temperature | 8-bit value for the temperature reading |
| int8_t TMAG5273::setAngleEn | ( | uint8_t | angleEnable | ) |
Sets the angle calculation, magnetic gain, and offset corrections between two selected magnetic channels.
| angleEnable | value 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 |
| int8_t TMAG5273::setConvAvg | ( | uint8_t | avgMode | ) |
Sets the additional sampling of the sensor data to reduce the noise effect (or to increase resolution)
| avgMode | value 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 |
| int8_t TMAG5273::setCRCMode | ( | uint8_t | crcMode | ) |
Sets the I2C CRC byte to be sent.
| crcMode | 0b0-0b1 0X0 = CRC disabled 0X1 = CRC enabled TMAG5273_REG_DEVICE_CONFIG_1 - bit 7 |
| int8_t TMAG5273::setGlitchFilter | ( | uint8_t | glitchMode | ) |
Sets the I2C glitch filter on and off.
| glitchMode | value to set the mode 0x0 = Glitch filter ON 0X0 = Glitch filter OFF TMAG5273_REG_DEVICE_CONFIG_2 - bit 3 |
| 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).
| address | Address value to set device to TMAG5273_REG_I2C_ADDRESS - bits 7-1 |
| int8_t TMAG5273::setI2CAddressEN | ( | bool | addressEnable | ) |
Writes to the I2C_ADDRESS_UPDATE_EN bit to enable a new user defined I2C address.
| addressEnable | Value 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) |
| int8_t TMAG5273::setInterruptMode | ( | uint8_t | configurationMode | ) |
Configures the interrupt mode select.
| config_mode | Value 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 |
| int8_t TMAG5273::setInterruptResult | ( | bool | interruptEnable | ) |
Sets the enable interrupt response bit on conversion complete.
| interruptEnable | Value 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 |
| int8_t TMAG5273::setIntPinState | ( | bool | interruptState | ) |
Enables the !INT interrupt if it is latched or pulsed.
| interruptState | Value 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 |
| int8_t TMAG5273::setIntThreshold | ( | uint8_t | threshold | ) |
Sets the threshold for the interrupt function.
| threshold | Value 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 |
| int8_t TMAG5273::setLowPower | ( | uint8_t | lpLnMode | ) |
Sets the device to low power or low noise mode.
| lpLnMode | Value to set the mode 0X0 = Low active current mode 0X1 = Low noise mode TMAG5273_REG_DEVICE_CONFIG_2 - bit 4 |
| int8_t TMAG5273::setMagDir | ( | uint8_t | threshDir | ) |
Sets the direction of threshold check. This bit is ignored when THR_HYST > 001b.
| threshDir | value 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 |
| int8_t TMAG5273::setMagneticChannel | ( | uint8_t | channelMode | ) |
Sets the data acquisition from the following magnetic axis channels listed below.
| channelMode | Value 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 |
| 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.
| magneticGain |
| 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.
| offset1 | Value within the range +/-128 in mT |
| 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.
| offset2 | Value within the range +/-128 |
| int8_t TMAG5273::setMagnitudeGain | ( | uint8_t | gainAdjust | ) |
Sets the axis for magnitude gain correction valued entered in MAG_GAIN_CONFIG register.
| gainAdjust | Value 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 |
| int8_t TMAG5273::setMagTemp | ( | uint8_t | magTempMode | ) |
Sets the temperature coefficient of the magnet.
| magTempMode | value 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 |
| int8_t TMAG5273::setMaskInterrupt | ( | bool | interruptPinEnable | ) |
Configures the Mask !INT pin when !INT is connected to GND.
| interruptPinEnable | Value 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 |
| 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.
| opMode | value 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 |
| int8_t TMAG5273::setOscillatorError | ( | bool | oscError | ) |
This function clears the oscillator error flag when it is raised high by an error.
| oscError | Write '1' to clear the error flag 0X0 = No oscillator error detected 0X1 = Oscillator error detected TMAG5273_REG_DEVICE_STATUS - bit 3 |
| int8_t TMAG5273::setReadMode | ( | uint8_t | readMode | ) |
Defines the I2C read mode of the device.
| readMode | Value 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 |
| int8_t TMAG5273::setSleeptime | ( | uint8_t | sleepTime | ) |
Sets the time spent in low power mode between conversions when OPERATING_MODE = 11b.
| sleepTime | Value 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 |
| int8_t TMAG5273::setTemperatureEn | ( | bool | temperatureEnable | ) |
Sets the enable bit that determines the data acquisition of the temperature channel.
| temperatureEnable | Value to determine enable or disable 0x0 = Temp Channel Disabled 0x1 = Temp Channel Enabled TMAG5273_REG_T_CONFIG - bit 0 |
| 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.
| tempThresh | 8-bit value to set the threshold for the temperature limit TMAG5273_REG_T_CONFIG - bits 7-1 |
| int8_t TMAG5273::setThresholdEn | ( | bool | enableInterruptResponse | ) |
Configures the bit that enables interrupt response on a predefined threshold cross.
| enableInterruptResponse | Value 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 |
| 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.
| trigMode | value 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 |
| 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.
| 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.
| xThreshold | 8-bit value to set the threshold for the X limit TMAG5273_REG_X_THR_CONFIG - bits 7-0 |
| int8_t TMAG5273::setXYAxisRange | ( | uint8_t | xyAxisRange | ) |
Sets the X and Y axes magnetic range from 2 different options.
| xyAxisRange | Value to choose the magnetic range 0X0 = ±40mT, DEFAULT 0X1 = ±80mT TMAG5273_REG_SENSOR_CONFIG_2 - bit 1 |
| 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.
| yThreshold | 8-bit value to set the threshold for the Y limit TMAG5273_REG_Y_THR_CONFIG - bits 7-0 |
| int8_t TMAG5273::setZAxisRange | ( | uint8_t | zAxisRange | ) |
Sets the Z magnetic range from 2 different options.
| zAxisRange | Value to set the range from either 40mT or 80mT 0X0 = ±40mT, DEFAULT 0X1 = ±80mT TMAG5273_REG_SENSOR_CONFIG_2 - bit 0 |
| 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.
| zThresh | 8-bit value to set the threshold for the Y limit TMAG5273_REG_Z_THR_CONFIG - bits 7-0 |