Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/machine/machine_rp2_adc.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ func ReadTemperature() (millicelsius int32) {
rp.ADC.CS.SetBits(rp.ADC_CS_TS_EN)

// T = 27 - (ADC_voltage - 0.706)/0.001721
return (27000<<16 - (int32(thermChan.getVoltage())-706<<16)*581) >> 16
// 1/0.001721 ≈ 581
return int32(((int64(27000) << 16) - ((int64(thermChan.getVoltage()) - (int64(706) << 16)) * 581)) >> 16)
}

// waitForReady spins waiting for the ADC peripheral to become ready.
Expand Down
Loading