Skip to content

Commit b7fcf6a

Browse files
ysoldakdeadprogram
authored andcommitted
nrf: fix adc read near zero
1 parent 7417c14 commit b7fcf6a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/machine/machine_nrf52xxx.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,12 @@ func (a *ADC) Get() uint16 {
183183
resolutionAdjustment = 4 // 12bit
184184
}
185185

186-
return rawValue.Get() << resolutionAdjustment
186+
value := int16(rawValue.Get())
187+
if value < 0 {
188+
value = 0
189+
}
190+
191+
return uint16(value << resolutionAdjustment)
187192
}
188193

189194
// SPI on the NRF.

0 commit comments

Comments
 (0)