stm32/dma: solve overlapping impl on DmaCtrl on stm32h7

This commit is contained in:
Dario Nieuwenhuis
2023-05-01 19:10:00 +02:00
parent 96e8a7ddb9
commit 00cde67abe
3 changed files with 19 additions and 15 deletions

View File

@ -609,18 +609,20 @@ impl<'a, C: Channel, W: Word> Drop for DoubleBuffered<'a, C, W> {
// ==============================
impl<C: Channel> DmaCtrl for C {
struct DmaCtrlImpl<'a, C: Channel>(PeripheralRef<'a, C>);
impl<'a, C: Channel> DmaCtrl for DmaCtrlImpl<'a, C> {
fn ndtr(&self) -> usize {
let ch = self.regs().st(self.num());
let ch = self.0.regs().st(self.0.num());
unsafe { ch.ndtr().read() }.ndt() as usize
}
fn get_complete_count(&self) -> usize {
STATE.complete_count[self.index()].load(Ordering::Acquire)
STATE.complete_count[self.0.index()].load(Ordering::Acquire)
}
fn reset_complete_count(&mut self) -> usize {
STATE.complete_count[self.index()].swap(0, Ordering::AcqRel)
STATE.complete_count[self.0.index()].swap(0, Ordering::AcqRel)
}
}
@ -707,13 +709,13 @@ impl<'a, C: Channel, W: Word> RingBuffer<'a, C, W> {
}
pub fn clear(&mut self) {
self.ringbuf.clear(&mut *self.channel);
self.ringbuf.clear(DmaCtrlImpl(self.channel.reborrow()));
}
/// Read bytes from the ring buffer
/// OverrunError is returned if the portion to be read was overwritten by the DMA controller.
pub fn read(&mut self, buf: &mut [W]) -> Result<usize, OverrunError> {
self.ringbuf.read(&mut *self.channel, buf)
self.ringbuf.read(DmaCtrlImpl(self.channel.reborrow()), buf)
}
pub fn is_empty(&self) -> bool {