@@ -176,7 +176,7 @@ int8_t TMAG5273::writeRegisters(uint8_t regAddress, uint8_t *dataBuffer, uint8_t
176176uint8_t TMAG5273::readRegister (uint8_t regAddress)
177177{
178178 uint8_t regVal = 0 ;
179- readRegisters (regAddress, ®Val, 2 );
179+ readRegisters (regAddress, ®Val, 1 );
180180 return regVal;
181181}
182182
@@ -2536,13 +2536,16 @@ float TMAG5273::getTemp()
25362536// / @return X-Channel data conversion results
25372537float TMAG5273::getXData ()
25382538{
2539- int8_t xLSB = readRegister (TMAG5273_REG_X_LSB_RESULT);
2540- int8_t xMSB = readRegister (TMAG5273_REG_X_MSB_RESULT);
2539+ int8_t xLSB = 0 ;
2540+ int8_t xMSB = 0 ;
2541+
2542+ xLSB = readRegister (TMAG5273_REG_X_LSB_RESULT);
2543+ xMSB = readRegister (TMAG5273_REG_X_MSB_RESULT);
25412544
25422545 // Variable to store full X data
25432546 int16_t xData = 0 ;
25442547 // Combines the two in one register where the MSB is shifted to the correct location
2545- xData = - (xMSB << 8 ) | xLSB ;
2548+ xData = xLSB + (xMSB << 8 );
25462549
25472550 // Reads to see if the range is set to 40mT or 80mT
25482551 uint8_t rangeValXY = getXYAxisRange ();
@@ -2577,7 +2580,8 @@ float TMAG5273::getYData()
25772580
25782581 // Variable to store full Y data
25792582 int16_t yData = 0 ;
2580- yData = -(yMSB << 8 ) | (yLSB); // Combines the two in one register where the MSB is shifted to the correct location
2583+ // Combines the two in one register where the MSB is shifted to the correct location
2584+ yData = yLSB + (yMSB << 8 );
25812585
25822586 // Reads to see if the range is set to 40mT or 80mT
25832587 uint8_t rangeValXY = getXYAxisRange ();
@@ -2613,7 +2617,7 @@ float TMAG5273::getZData()
26132617 // Variable to store full X data
26142618 int16_t zData = 0 ;
26152619 // Combines the two in one register where the MSB is shifted to the correct location
2616- zData = - (zMSB << 8 ) | (zLSB );
2620+ zData = zLSB + (zMSB << 8 );
26172621
26182622 // Reads to see if the range is set to 40mT or 80mT
26192623 uint8_t rangeValZ = getZAxisRange ();
@@ -2660,7 +2664,7 @@ float TMAG5273::getAngleResult()
26602664 float finalVal = 0 ;
26612665
26622666 // Combining the register value
2663- angleReg = (angleMSB << 8 ) | angleLSB ;
2667+ angleReg = angleLSB + (angleMSB << 8 );
26642668
26652669 // Removing the uneeded bits for the fraction value
26662670 decValue = float (angleLSB & 0b1111 ) / 16 ;
0 commit comments