Skip to content

Commit 9875ba8

Browse files
committed
Add capture dma impls
1 parent e4f8609 commit 9875ba8

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/hrtim/capture.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use stm32_hrtim::{
2+
capture::{Ch1, Ch2, Dma, HrCapt},
3+
pac::{HRTIM_TIMA, HRTIM_TIMB, HRTIM_TIMC, HRTIM_TIMD, HRTIM_TIME, HRTIM_TIMF},
4+
};
5+
6+
use crate::dma::{mux::DmaMuxResources, traits::TargetAddress, PeripheralToMemory};
7+
8+
macro_rules! impl_dma_traits {
9+
($TIMX:ident, $CH:ident, $cptXr:ident) => {
10+
unsafe impl<PSCL> TargetAddress<PeripheralToMemory> for HrCapt<$TIMX, PSCL, $CH, Dma> {
11+
#[inline(always)]
12+
fn address(&self) -> u32 {
13+
let tim = unsafe { &*$TIMX::ptr() };
14+
&tim.$cptXr() as *const _ as u32
15+
}
16+
17+
type MemSize = u32;
18+
19+
const REQUEST_LINE: Option<u8> = Some(DmaMuxResources::$TIMX as u8);
20+
}
21+
};
22+
($($TIMX:ident),+) => {
23+
$(
24+
impl_dma_traits!($TIMX, Ch1, cpt1r);
25+
impl_dma_traits!($TIMX, Ch2, cpt2r);
26+
)+
27+
}
28+
}
29+
30+
impl_dma_traits! {
31+
HRTIM_TIMA, HRTIM_TIMB, HRTIM_TIMC, HRTIM_TIMD, HRTIM_TIME, HRTIM_TIMF
32+
}

src/hrtim/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pub mod adc_trigger;
22
pub mod external_event;
33
pub mod fault;
4+
pub mod capture;
45

56
use core::mem::MaybeUninit;
67

0 commit comments

Comments
 (0)