Skip to content

Commit b8a2969

Browse files
Adjusted code for correction from PR
Returned the readRegsiter functionality back to what is needed for this file.
1 parent 0014034 commit b8a2969

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/SparkFun_TMAG5273_Arduino_Library.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ int8_t TMAG5273::writeRegisters(uint8_t regAddress, uint8_t *dataBuffer, uint8_t
176176
uint8_t TMAG5273::readRegister(uint8_t regAddress)
177177
{
178178
uint8_t regVal = 0;
179-
readRegisters(regAddress, &regVal, 1);
179+
readRegisters(regAddress, &regVal, 2);
180180
return regVal;
181181
}
182182

@@ -2536,11 +2536,8 @@ float TMAG5273::getTemp()
25362536
/// @return X-Channel data conversion results
25372537
float TMAG5273::getXData()
25382538
{
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);
2539+
int8_t xLSB = readRegister(TMAG5273_REG_X_LSB_RESULT);
2540+
int8_t xMSB = readRegister(TMAG5273_REG_X_MSB_RESULT);
25442541

25452542
// Variable to store full X data
25462543
int16_t xData = 0;
@@ -2581,7 +2578,7 @@ float TMAG5273::getYData()
25812578
// Variable to store full Y data
25822579
int16_t yData = 0;
25832580
// Combines the two in one register where the MSB is shifted to the correct location
2584-
yData = yLSB + (yMSB << 8);
2581+
yData = yLSB + (yMSB << 8);
25852582

25862583
// Reads to see if the range is set to 40mT or 80mT
25872584
uint8_t rangeValXY = getXYAxisRange();
@@ -2617,7 +2614,7 @@ float TMAG5273::getZData()
26172614
// Variable to store full X data
26182615
int16_t zData = 0;
26192616
// Combines the two in one register where the MSB is shifted to the correct location
2620-
zData = zLSB + (zMSB << 8);
2617+
zData = zLSB + (zMSB << 8);
26212618

26222619
// Reads to see if the range is set to 40mT or 80mT
26232620
uint8_t rangeValZ = getZAxisRange();
@@ -2664,7 +2661,7 @@ float TMAG5273::getAngleResult()
26642661
float finalVal = 0;
26652662

26662663
// Combining the register value
2667-
angleReg = angleLSB + (angleMSB << 8);
2664+
angleReg = angleLSB + (angleMSB << 8);
26682665

26692666
// Removing the uneeded bits for the fraction value
26702667
decValue = float(angleLSB & 0b1111) / 16;

0 commit comments

Comments
 (0)