Skip to content

Commit ce54537

Browse files
committed
Update SparkFun_ADS1219.cpp
1 parent 4c238bd commit ce54537

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/SparkFun_ADS1219.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,14 @@ bool SfeADS1219Driver::readConversion()
129129
union {
130130
int32_t i32;
131131
uint32_t u32;
132-
} iu32;
132+
} iu32; // Use a union to avoid signed / unsigned ambiguity
133133
iu32.u32 = rawBytes[0];
134134
iu32.u32 = (iu32.u32 << 8) | rawBytes[1];
135135
iu32.u32 = (iu32.u32 << 8) | rawBytes[2];
136136
// Preserve the 2's complement.
137137
if (0x00100000 == (iu32.u32 & 0x00100000))
138138
iu32.u32 = iu32.u32 | 0xFF000000;
139-
_adcResult = iu32.i32; // Store the result
139+
_adcResult = iu32.i32; // Store the signed result
140140
}
141141
return result;
142142
}

0 commit comments

Comments
 (0)