Skip to content

Commit 41f04e8

Browse files
committed
dma: Add support for configuring circular mode
1 parent f3b3e82 commit 41f04e8

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

src/aes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ impl<Target, Channel, Buffer> Transfer<Target, Channel, Buffer, dma::Ready>
614614
address,
615615
priority,
616616
dir,
617+
false,
617618
);
618619

619620
Self {

src/dma.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ impl<T, C, B> Transfer<T, C, B, Ready>
112112
address: u32,
113113
priority: Priority,
114114
dir: Direction,
115+
circular: bool,
115116
)
116117
-> Self
117118
where
@@ -127,7 +128,7 @@ impl<T, C, B> Transfer<T, C, B, Ready>
127128
channel.set_peripheral_address(handle, address);
128129
channel.set_memory_address(handle, buffer.as_ptr() as u32);
129130
channel.set_transfer_len(handle, num_words as u16);
130-
channel.configure::<Word>(handle, priority.0, dir.0);
131+
channel.configure::<Word>(handle, priority.0, dir.0, circular);
131132

132133
Transfer {
133134
res: TransferResources {
@@ -270,6 +271,7 @@ pub trait Channel: Sized {
270271
_: &mut Handle,
271272
priority: cr::PL_A,
272273
dir: cr::DIR_A,
274+
circular: bool,
273275
)
274276
where Word: SupportedWordSize;
275277
fn enable_interrupts(&self, interrupts: Interrupts);
@@ -337,6 +339,7 @@ macro_rules! impl_channel {
337339
handle: &mut Handle,
338340
priority: cr::PL_A,
339341
dir: cr::DIR_A,
342+
circular: bool,
340343
)
341344
where Word: SupportedWordSize
342345
{
@@ -354,8 +357,8 @@ macro_rules! impl_channel {
354357
.minc().enabled()
355358
// Don't increment peripheral pointer
356359
.pinc().disabled()
357-
// Circular mode disabled
358-
.circ().disabled()
360+
// Circular mode
361+
.circ().bit(circular)
359362
// Data transfer direction
360363
.dir().variant(dir)
361364
// Disable interrupts

src/i2c.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ where
273273
address,
274274
dma::Priority::high(),
275275
dma::Direction::memory_to_peripheral(),
276+
false,
276277
)
277278
};
278279

@@ -337,6 +338,7 @@ where
337338
address,
338339
dma::Priority::high(),
339340
dma::Direction::peripheral_to_memory(),
341+
false,
340342
)
341343
};
342344

src/serial.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ macro_rules! usart {
498498
address,
499499
dma::Priority::high(),
500500
dma::Direction::peripheral_to_memory(),
501+
false,
501502
)
502503
}
503504
}
@@ -609,6 +610,7 @@ macro_rules! usart {
609610
address,
610611
dma::Priority::high(),
611612
dma::Direction::memory_to_peripheral(),
613+
false,
612614
)
613615
}
614616
}

0 commit comments

Comments
 (0)