Add finish_dma function

This commit is contained in:
Grant Miller
2021-12-14 16:59:31 -06:00
parent a13a7a6616
commit 6597e67036
4 changed files with 33 additions and 81 deletions

View File

@ -451,6 +451,27 @@ fn spin_until_idle(regs: Regs) {
}
}
fn finish_dma(regs: Regs) {
spin_until_idle(regs);
unsafe {
regs.cr1().modify(|w| {
w.set_spe(false);
});
#[cfg(not(spi_v3))]
regs.cr2().modify(|reg| {
reg.set_txdmaen(false);
reg.set_rxdmaen(false);
});
#[cfg(spi_v3)]
regs.cfg1().modify(|reg| {
reg.set_txdmaen(false);
reg.set_rxdmaen(false);
});
}
}
trait Word {
const WORDSIZE: WordSize;
}