Skip to content

Commit 26facd3

Browse files
committed
adds missing dma error flags
1 parent dabb372 commit 26facd3

File tree

3 files changed

+66
-9
lines changed

3 files changed

+66
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2020
`display-interface` driver and the `st7789` driver on a F413Discovery board [#302]
2121
- Derive `Eq`, `PartialEq`, `Copy` and `Clone` for error types
2222
- Added open-drain pin mode support for PWM output [#313]
23+
- Added missing error flags for dma streams [#318]
2324

2425
[#265]: https://github.com/stm32-rs/stm32f4xx-hal/pull/265
2526
[#297]: https://github.com/stm32-rs/stm32f4xx-hal/pull/297
2627
[#302]: https://github.com/stm32-rs/stm32f4xx-hal/pull/302
2728
[#313]: https://github.com/stm32-rs/stm32f4xx-hal/pull/313
29+
[#318]: https://github.com/stm32-rs/stm32f4xx-hal/pull/318
2830

2931
### Changed
3032

src/dma/mod.rs

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ impl<T: RccEnable> StreamsTuple<T> {
272272
// The implementation does the heavy lifting of mapping to the right fields on the stream
273273
macro_rules! dma_stream {
274274
($(($name:ident, $number:expr ,$ifcr:ident, $tcif:ident, $htif:ident, $teif:ident, $dmeif:ident,
275-
$feif:ident, $isr:ident, $tcisr:ident, $htisr:ident)),+ $(,)*) => {
275+
$feif:ident, $isr:ident, $tcisr:ident, $htisr:ident, $teisr:ident, $feisr:ident, $dmeisr:ident)),+
276+
$(,)*) => {
276277
$(
277278
impl<I: Instance> Stream for $name<I> {
278279

@@ -346,6 +347,27 @@ macro_rules! dma_stream {
346347
dma.$isr.read().$htisr().bit_is_set()
347348
}
348349

350+
#[inline(always)]
351+
fn get_transfer_error_flag() -> bool {
352+
//NOTE(unsafe) Atomic read with no side effects
353+
let dma = unsafe { &*I::ptr() };
354+
dma.$isr.read().$teisr().bit_is_set()
355+
}
356+
357+
#[inline(always)]
358+
fn get_fifo_error_flag() -> bool {
359+
//NOTE(unsafe) Atomic read with no side effects
360+
let dma = unsafe { &*I::ptr() };
361+
dma.$isr.read().$feisr().bit_is_set()
362+
}
363+
364+
#[inline(always)]
365+
fn get_direct_mode_error_flag() -> bool {
366+
//NOTE(unsafe) Atomic read with no side effects
367+
let dma = unsafe { &*I::ptr() };
368+
dma.$isr.read().$dmeisr().bit_is_set()
369+
}
370+
349371
#[inline(always)]
350372
fn set_peripheral_address(&mut self, value: u32) {
351373
//NOTE(unsafe) We only access the registers that belongs to the StreamX
@@ -598,14 +620,38 @@ macro_rules! dma_stream {
598620
}
599621

600622
dma_stream!(
601-
(Stream0, 0, lifcr, ctcif0, chtif0, cteif0, cdmeif0, cfeif0, lisr, tcif0, htif0),
602-
(Stream1, 1, lifcr, ctcif1, chtif1, cteif1, cdmeif1, cfeif1, lisr, tcif1, htif1),
603-
(Stream2, 2, lifcr, ctcif2, chtif2, cteif2, cdmeif2, cfeif2, lisr, tcif2, htif2),
604-
(Stream3, 3, lifcr, ctcif3, chtif3, cteif3, cdmeif3, cfeif3, lisr, tcif3, htif3),
605-
(Stream4, 4, hifcr, ctcif4, chtif4, cteif4, cdmeif4, cfeif4, hisr, tcif4, htif4),
606-
(Stream5, 5, hifcr, ctcif5, chtif5, cteif5, cdmeif5, cfeif5, hisr, tcif5, htif5),
607-
(Stream6, 6, hifcr, ctcif6, chtif6, cteif6, cdmeif6, cfeif6, hisr, tcif6, htif6),
608-
(Stream7, 7, hifcr, ctcif7, chtif7, cteif7, cdmeif7, cfeif7, hisr, tcif7, htif7),
623+
(
624+
Stream0, 0, lifcr, ctcif0, chtif0, cteif0, cdmeif0, cfeif0, lisr, tcif0, htif0, teif0,
625+
feif0, dmeif0
626+
),
627+
(
628+
Stream1, 1, lifcr, ctcif1, chtif1, cteif1, cdmeif1, cfeif1, lisr, tcif1, htif1, teif1,
629+
feif1, dmeif1
630+
),
631+
(
632+
Stream2, 2, lifcr, ctcif2, chtif2, cteif2, cdmeif2, cfeif2, lisr, tcif2, htif2, teif2,
633+
feif2, dmeif2
634+
),
635+
(
636+
Stream3, 3, lifcr, ctcif3, chtif3, cteif3, cdmeif3, cfeif3, lisr, tcif3, htif3, teif3,
637+
feif3, dmeif3
638+
),
639+
(
640+
Stream4, 4, hifcr, ctcif4, chtif4, cteif4, cdmeif4, cfeif4, hisr, tcif4, htif4, teif4,
641+
feif4, dmeif4
642+
),
643+
(
644+
Stream5, 5, hifcr, ctcif5, chtif5, cteif5, cdmeif5, cfeif5, hisr, tcif5, htif5, teif5,
645+
feif5, dmeif5
646+
),
647+
(
648+
Stream6, 6, hifcr, ctcif6, chtif6, cteif6, cdmeif6, cfeif6, hisr, tcif6, htif6, teif6,
649+
feif6, dmeif6
650+
),
651+
(
652+
Stream7, 7, hifcr, ctcif7, chtif7, cteif7, cdmeif7, cfeif7, hisr, tcif7, htif7, teif7,
653+
feif7, dmeif7
654+
),
609655
);
610656

611657
// Macro that defines a channel and it's conversion to u8

src/dma/traits.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ pub trait Stream: Sealed {
4646
/// Get half transfer flag.
4747
fn get_half_transfer_flag() -> bool;
4848

49+
/// Get transfer error flag
50+
fn get_transfer_error_flag() -> bool;
51+
52+
/// Get fifo error flag
53+
fn get_fifo_error_flag() -> bool;
54+
55+
/// Get direct mode error flag
56+
fn get_direct_mode_error_flag() -> bool;
57+
4958
/// Set the peripheral address (par) for the DMA stream.
5059
fn set_peripheral_address(&mut self, value: u32);
5160

0 commit comments

Comments
 (0)