2019-11-24 22:09:52 +08:00
|
|
|
use super::pac;
|
2019-11-24 21:15:11 +08:00
|
|
|
|
2020-04-19 19:37:03 +08:00
|
|
|
pub fn dma1_setup(
|
2019-11-24 22:09:52 +08:00
|
|
|
dma1: &pac::DMA1,
|
|
|
|
dmamux1: &pac::DMAMUX1,
|
|
|
|
ma: usize,
|
|
|
|
pa0: usize,
|
|
|
|
pa1: usize,
|
|
|
|
) {
|
2019-11-24 21:15:11 +08:00
|
|
|
dma1.st[0].cr.modify(|_, w| w.en().clear_bit());
|
|
|
|
while dma1.st[0].cr.read().en().bit_is_set() {}
|
|
|
|
|
|
|
|
dma1.st[0].par.write(|w| unsafe { w.bits(pa0 as u32) });
|
|
|
|
dma1.st[0].m0ar.write(|w| unsafe { w.bits(ma as u32) });
|
2020-02-14 17:44:09 +08:00
|
|
|
dma1.st[0].ndtr.write(|w| w.ndt().bits(1));
|
2019-11-24 21:15:11 +08:00
|
|
|
dmamux1.ccr[0].modify(|_, w| w.dmareq_id().tim2_up());
|
2020-02-14 22:06:10 +08:00
|
|
|
dma1.st[0].cr.modify(|_, w| {
|
2019-11-24 22:09:52 +08:00
|
|
|
w.pl()
|
2020-02-14 19:26:16 +08:00
|
|
|
.medium()
|
2019-11-24 22:09:52 +08:00
|
|
|
.circ()
|
2020-02-14 19:26:16 +08:00
|
|
|
.enabled()
|
2019-11-24 22:09:52 +08:00
|
|
|
.msize()
|
2020-02-14 19:26:16 +08:00
|
|
|
.bits32()
|
2019-11-24 22:09:52 +08:00
|
|
|
.minc()
|
2020-02-14 19:26:16 +08:00
|
|
|
.fixed()
|
2019-11-24 22:09:52 +08:00
|
|
|
.mburst()
|
2020-02-14 19:26:16 +08:00
|
|
|
.single()
|
2019-11-24 22:09:52 +08:00
|
|
|
.psize()
|
2020-02-14 19:26:16 +08:00
|
|
|
.bits32()
|
2019-11-24 22:09:52 +08:00
|
|
|
.pinc()
|
2020-02-14 19:26:16 +08:00
|
|
|
.fixed()
|
2019-11-24 22:09:52 +08:00
|
|
|
.pburst()
|
2020-02-14 19:26:16 +08:00
|
|
|
.single()
|
2019-11-24 22:09:52 +08:00
|
|
|
.dbm()
|
2020-02-14 19:26:16 +08:00
|
|
|
.disabled()
|
2019-11-24 22:09:52 +08:00
|
|
|
.dir()
|
2020-02-14 19:26:16 +08:00
|
|
|
.memory_to_peripheral()
|
2019-11-24 22:09:52 +08:00
|
|
|
.pfctrl()
|
2020-02-14 19:26:16 +08:00
|
|
|
.dma()
|
2020-02-14 22:06:10 +08:00
|
|
|
});
|
2019-11-24 21:15:11 +08:00
|
|
|
dma1.st[0].fcr.modify(|_, w| w.dmdis().clear_bit());
|
|
|
|
dma1.st[0].cr.modify(|_, w| w.en().set_bit());
|
|
|
|
|
|
|
|
dma1.st[1].cr.modify(|_, w| w.en().clear_bit());
|
|
|
|
while dma1.st[1].cr.read().en().bit_is_set() {}
|
|
|
|
|
|
|
|
dma1.st[1].par.write(|w| unsafe { w.bits(pa1 as u32) });
|
|
|
|
dma1.st[1].m0ar.write(|w| unsafe { w.bits(ma as u32) });
|
2020-02-14 17:44:09 +08:00
|
|
|
dma1.st[1].ndtr.write(|w| w.ndt().bits(1));
|
2019-11-24 21:15:11 +08:00
|
|
|
dmamux1.ccr[1].modify(|_, w| w.dmareq_id().tim2_up());
|
2020-02-14 22:06:10 +08:00
|
|
|
dma1.st[1].cr.modify(|_, w| {
|
2019-11-24 22:09:52 +08:00
|
|
|
w.pl()
|
2020-02-14 19:26:16 +08:00
|
|
|
.medium()
|
2019-11-24 22:09:52 +08:00
|
|
|
.circ()
|
2020-02-14 19:26:16 +08:00
|
|
|
.enabled()
|
2019-11-24 22:09:52 +08:00
|
|
|
.msize()
|
2020-02-14 19:26:16 +08:00
|
|
|
.bits32()
|
2019-11-24 22:09:52 +08:00
|
|
|
.minc()
|
2020-02-14 19:26:16 +08:00
|
|
|
.fixed()
|
2019-11-24 22:09:52 +08:00
|
|
|
.mburst()
|
2020-02-14 19:26:16 +08:00
|
|
|
.single()
|
2019-11-24 22:09:52 +08:00
|
|
|
.psize()
|
2020-02-14 19:26:16 +08:00
|
|
|
.bits32()
|
2019-11-24 22:09:52 +08:00
|
|
|
.pinc()
|
2020-02-14 19:26:16 +08:00
|
|
|
.fixed()
|
2019-11-24 22:09:52 +08:00
|
|
|
.pburst()
|
2020-02-14 19:26:16 +08:00
|
|
|
.single()
|
2019-11-24 22:09:52 +08:00
|
|
|
.dbm()
|
2020-02-14 19:26:16 +08:00
|
|
|
.disabled()
|
2019-11-24 22:09:52 +08:00
|
|
|
.dir()
|
2020-02-14 19:26:16 +08:00
|
|
|
.memory_to_peripheral()
|
2019-11-24 22:09:52 +08:00
|
|
|
.pfctrl()
|
2020-02-14 19:26:16 +08:00
|
|
|
.dma()
|
2020-02-14 22:06:10 +08:00
|
|
|
});
|
2019-11-24 21:15:11 +08:00
|
|
|
dma1.st[1].fcr.modify(|_, w| w.dmdis().clear_bit());
|
|
|
|
dma1.st[1].cr.modify(|_, w| w.en().set_bit());
|
|
|
|
}
|