Fix adc giving wrong values on sequential reads of multiple channels

This commit is contained in:
Jonathan Nilsson 2021-09-09 21:08:46 +02:00 committed by 9names
parent db11231f49
commit 0e5d582363

View file

@ -138,15 +138,17 @@ where
self.device.cs.modify(|_, w| w.ts_en().set_bit())
}
if self.device.cs.read().ready().bit_is_set() {
self.device
.cs
.modify(|_, w| unsafe { w.ainsel().bits(chan).start_once().set_bit() });
};
if !self.device.cs.read().ready().bit_is_set() {
// Can't return WouldBlock here since that would take to long and next call conversion would be over
while !self.device.cs.read().ready().bit_is_set() {
cortex_m::asm::nop();
};
}
self.device
.cs
.modify(|_, w| unsafe { w.ainsel().bits(chan).start_once().set_bit() });
while !self.device.cs.read().ready().bit_is_set() {
cortex_m::asm::nop();
}
Ok(self.device.result.read().result().bits().into())
}