We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4c238bd commit ce54537Copy full SHA for ce54537
src/SparkFun_ADS1219.cpp
@@ -129,14 +129,14 @@ bool SfeADS1219Driver::readConversion()
129
union {
130
int32_t i32;
131
uint32_t u32;
132
- } iu32;
+ } iu32; // Use a union to avoid signed / unsigned ambiguity
133
iu32.u32 = rawBytes[0];
134
iu32.u32 = (iu32.u32 << 8) | rawBytes[1];
135
iu32.u32 = (iu32.u32 << 8) | rawBytes[2];
136
// Preserve the 2's complement.
137
if (0x00100000 == (iu32.u32 & 0x00100000))
138
iu32.u32 = iu32.u32 | 0xFF000000;
139
- _adcResult = iu32.i32; // Store the result
+ _adcResult = iu32.i32; // Store the signed result
140
}
141
return result;
142
0 commit comments