Skip to content

Commit 8cf2404

Browse files
committed
back to original - this is the right path forward when making the int16 value
1 parent 3dbef09 commit 8cf2404

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/SparkFun_TMAG5273_Arduino_Library.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2579,8 +2579,7 @@ float TMAG5273::getXData()
25792579

25802580
// Combines the two in one register where the MSB is shifted to the correct location
25812581
// convert the uint16_t to int16_t
2582-
uint16_t tmpData = (xMSB << 8) + xLSB;
2583-
int16_t xData = *(int16_t *)&tmpData;
2582+
int16_t xData = (xMSB << 8) + xLSB;
25842583

25852584
// Reads to see if the range is set to 40mT or 80mT
25862585
uint8_t rangeValXY = getXYAxisRange();
@@ -2617,8 +2616,7 @@ float TMAG5273::getYData()
26172616

26182617
// Combines the two in one register where the MSB is shifted to the correct location
26192618
// convert the uint16_t to int16_t
2620-
uint16_t tmpData = (yMSB << 8) + yLSB;
2621-
int16_t yData = *(int16_t *)&tmpData;
2619+
int16_t yData = (yMSB << 8) + yLSB;
26222620

26232621
// Reads to see if the range is set to 40mT or 80mT
26242622
uint8_t rangeValXY = getXYAxisRange();
@@ -2656,8 +2654,7 @@ float TMAG5273::getZData()
26562654

26572655
// Combines the two in one register where the MSB is shifted to the correct location
26582656
// convert the uint16_t to int16_t
2659-
uint16_t tmpData = (zMSB << 8) + zLSB;
2660-
int16_t zData = *(int16_t *)&tmpData;
2657+
int16_t zData = (zMSB << 8) + zLSB;
26612658

26622659
// Reads to see if the range is set to 40mT or 80mT
26632660
uint8_t rangeValZ = getZAxisRange();

0 commit comments

Comments
 (0)