@@ -176,7 +176,7 @@ int8_t TMAG5273::writeRegisters(uint8_t regAddress, uint8_t *dataBuffer, uint8_t
176
176
uint8_t TMAG5273::readRegister (uint8_t regAddress)
177
177
{
178
178
uint8_t regVal = 0 ;
179
- readRegisters (regAddress, ®Val, 2 );
179
+ readRegisters (regAddress, ®Val, 1 );
180
180
return regVal;
181
181
}
182
182
@@ -2536,13 +2536,16 @@ float TMAG5273::getTemp()
2536
2536
// / @return X-Channel data conversion results
2537
2537
float TMAG5273::getXData ()
2538
2538
{
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);
2541
2544
2542
2545
// Variable to store full X data
2543
2546
int16_t xData = 0 ;
2544
2547
// 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 );
2546
2549
2547
2550
// Reads to see if the range is set to 40mT or 80mT
2548
2551
uint8_t rangeValXY = getXYAxisRange ();
@@ -2577,7 +2580,8 @@ float TMAG5273::getYData()
2577
2580
2578
2581
// Variable to store full Y data
2579
2582
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 );
2581
2585
2582
2586
// Reads to see if the range is set to 40mT or 80mT
2583
2587
uint8_t rangeValXY = getXYAxisRange ();
@@ -2613,7 +2617,7 @@ float TMAG5273::getZData()
2613
2617
// Variable to store full X data
2614
2618
int16_t zData = 0 ;
2615
2619
// 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 );
2617
2621
2618
2622
// Reads to see if the range is set to 40mT or 80mT
2619
2623
uint8_t rangeValZ = getZAxisRange ();
@@ -2660,7 +2664,7 @@ float TMAG5273::getAngleResult()
2660
2664
float finalVal = 0 ;
2661
2665
2662
2666
// Combining the register value
2663
- angleReg = (angleMSB << 8 ) | angleLSB ;
2667
+ angleReg = angleLSB + (angleMSB << 8 );
2664
2668
2665
2669
// Removing the uneeded bits for the fraction value
2666
2670
decValue = float (angleLSB & 0b1111 ) / 16 ;
0 commit comments