Skip to content

Commit 3042c2c

Browse files
committed
dma: added more tock-registers
1 parent 7f5f790 commit 3042c2c

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

chips/stm32u5xx/src/dma.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ register_bitfields! [
4444
/// Request selection
4545
REQSEL OFFSET(0) NUMBITS(7) [],
4646
],
47+
pub DmaChannelBR1 [
48+
/// Block number of data bytes to transfer
49+
BNDT OFFSET(0) NUMBITS(16) []
50+
],
51+
pub DmaChannelSAR [
52+
/// Source address
53+
SAR OFFSET(0) NUMBITS(32) []
54+
],
55+
pub DmaChannelDAR [
56+
/// Destination address
57+
DAR OFFSET(0) NUMBITS(32) []
58+
],
4759
pub DmaChannelCR [
4860
/// Transfer complete interrupt enable
4961
TCIE OFFSET(8) NUMBITS(1) [],
@@ -120,11 +132,11 @@ register_structs! {
120132
/// Channel x transfer register 2 (Relative 0x44)
121133
(0x044 => pub t_r2: ReadWrite<u32, DmaChannelTR2::Register>),
122134
/// Channel x block register 1 (Relative 0x48)
123-
(0x048 => pub b_r1: ReadWrite<u32>),
135+
(0x048 => pub b_r1: ReadWrite<u32, DmaChannelBR1::Register>),
124136
/// Channel x source address register (Relative 0x4C)
125-
(0x04C => pub s_ar: ReadWrite<u32>),
137+
(0x04C => pub s_ar: ReadWrite<u32, DmaChannelSAR::Register>),
126138
/// Channel x destination address register (Relative 0x50)
127-
(0x050 => pub d_ar: ReadWrite<u32>),
139+
(0x050 => pub d_ar: ReadWrite<u32, DmaChannelDAR::Register>),
128140
(0x054 => _reserved2: [u32; 10]),
129141
/// Channel x linked-list address register (Relative 0x7C)
130142
(0x07C => pub l_lr: ReadWrite<u32>),
@@ -303,8 +315,8 @@ impl Dma {
303315
// Source request comes from destination peripheral
304316
ch.t_r2
305317
.write(DmaChannelTR2::REQSEL.val(reqsel) + DmaChannelTR2::DREQ::SET);
306-
ch.s_ar.set(buffer_addr);
307-
ch.d_ar.set(periph_addr);
318+
ch.s_ar.write(DmaChannelSAR::SAR.val(buffer_addr));
319+
ch.d_ar.write(DmaChannelDAR::DAR.val(periph_addr));
308320
}
309321
DmaDirection::PeripheralToMemory => {
310322
// Destination is memory (incrementing), Source is peripheral (fixed)
@@ -314,13 +326,13 @@ impl Dma {
314326
);
315327
// Source request comes from source peripheral
316328
ch.t_r2.write(DmaChannelTR2::REQSEL.val(reqsel));
317-
ch.s_ar.set(periph_addr);
318-
ch.d_ar.set(buffer_addr);
329+
ch.s_ar.write(DmaChannelSAR::SAR.val(periph_addr));
330+
ch.d_ar.write(DmaChannelDAR::DAR.val(buffer_addr));
319331
}
320332
}
321333

322334
// 5. Set Block Register 1 (BR1)
323-
ch.b_r1.set(length & 0xFFFF);
335+
ch.b_r1.write(DmaChannelBR1::BNDT.val(length & 0xFFFF));
324336

325337
// 6. Enable Transfer Complete Interrupt and start the channel
326338
ch.c_r

0 commit comments

Comments
 (0)