8000
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 536deaa commit c6b47feCopy full SHA for c6b47fe
src/machine/machine_rp2_adc.go
@@ -73,14 +73,15 @@ func (c ADCChannel) Configure(config ADCConfig) error {
73
func (c ADCChannel) getOnce() uint16 {
74
// Make it safe to sample multiple ADC channels in separate go routines.
75
adcLock.Lock()
76
- rp.ADC.CS.ReplaceBits(uint32(c), 0b111, rp.ADC_CS_AINSEL_Pos)
+ rp.ADC.CS.ReplaceBits(uint32(c)<<rp.ADC_CS_AINSEL_Pos, rp.ADC_CS_AINSEL_Msk, 0)
77
rp.ADC.CS.SetBits(rp.ADC_CS_START_ONCE)
78
79
waitForReady()
80
+ v := rp.ADC.RESULT.Get()
81
adcLock.Unlock()
82
83
// rp2040 is a 12-bit ADC, scale raw reading to 16-bits.
- return uint16(rp.ADC.RESULT.Get()) << 4
84
+ return uint16(v) << 4
85
}
86
87
// getVoltage does a one-shot sample and returns a millivolts reading.
0 commit comments