aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/hrtim
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-07-31 15:42:03 +0200
committerDario Nieuwenhuis <[email protected]>2023-07-31 15:42:03 +0200
commit5c2ba3b212f51950bfebf51d64edcc8d6ac7170a (patch)
tree54d0677e10e5285a55bb4ef6fe3d1526f7662efa /embassy-stm32/src/hrtim
parent958cace36dec6d0473c85a4129c871be9e563f2a (diff)
stm32: add hrtim v2
Diffstat (limited to 'embassy-stm32/src/hrtim')
-rw-r--r--embassy-stm32/src/hrtim/mod.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/embassy-stm32/src/hrtim/mod.rs b/embassy-stm32/src/hrtim/mod.rs
index a930ff73f..31c488144 100644
--- a/embassy-stm32/src/hrtim/mod.rs
+++ b/embassy-stm32/src/hrtim/mod.rs
@@ -18,6 +18,8 @@ pub enum Source {
18 ChC, 18 ChC,
19 ChD, 19 ChD,
20 ChE, 20 ChE,
21 #[cfg(hrtim_v2)]
22 ChF,
21} 23}
22 24
23pub struct BurstController<T: Instance> { 25pub struct BurstController<T: Instance> {
@@ -41,6 +43,10 @@ pub struct ChD<T: Instance> {
41pub struct ChE<T: Instance> { 43pub struct ChE<T: Instance> {
42 phantom: PhantomData<T>, 44 phantom: PhantomData<T>,
43} 45}
46#[cfg(hrtim_v2)]
47pub struct ChF<T: Instance> {
48 phantom: PhantomData<T>,
49}
44 50
45mod sealed { 51mod sealed {
46 use super::Instance; 52 use super::Instance;
@@ -110,6 +116,8 @@ advanced_channel_impl!(new_chb, ChB, 1, ChannelBPin, ChannelBComplementaryPin);
110advanced_channel_impl!(new_chc, ChC, 2, ChannelCPin, ChannelCComplementaryPin); 116advanced_channel_impl!(new_chc, ChC, 2, ChannelCPin, ChannelCComplementaryPin);
111advanced_channel_impl!(new_chd, ChD, 3, ChannelDPin, ChannelDComplementaryPin); 117advanced_channel_impl!(new_chd, ChD, 3, ChannelDPin, ChannelDComplementaryPin);
112advanced_channel_impl!(new_che, ChE, 4, ChannelEPin, ChannelEComplementaryPin); 118advanced_channel_impl!(new_che, ChE, 4, ChannelEPin, ChannelEComplementaryPin);
119#[cfg(hrtim_v2)]
120advanced_channel_impl!(new_chf, ChF, 5, ChannelFPin, ChannelFComplementaryPin);
113 121
114/// Struct used to divide a high resolution timer into multiple channels 122/// Struct used to divide a high resolution timer into multiple channels
115pub struct AdvancedPwm<'d, T: Instance> { 123pub struct AdvancedPwm<'d, T: Instance> {
@@ -121,6 +129,8 @@ pub struct AdvancedPwm<'d, T: Instance> {
121 pub ch_c: ChC<T>, 129 pub ch_c: ChC<T>,
122 pub ch_d: ChD<T>, 130 pub ch_d: ChD<T>,
123 pub ch_e: ChE<T>, 131 pub ch_e: ChE<T>,
132 #[cfg(hrtim_v2)]
133 pub ch_f: ChF<T>,
124} 134}
125 135
126impl<'d, T: Instance> AdvancedPwm<'d, T> { 136impl<'d, T: Instance> AdvancedPwm<'d, T> {
@@ -136,6 +146,8 @@ impl<'d, T: Instance> AdvancedPwm<'d, T> {
136 _chdn: Option<ComplementaryPwmPin<'d, T, ChD<T>>>, 146 _chdn: Option<ComplementaryPwmPin<'d, T, ChD<T>>>,
137 _che: Option<PwmPin<'d, T, ChE<T>>>, 147 _che: Option<PwmPin<'d, T, ChE<T>>>,
138 _chen: Option<ComplementaryPwmPin<'d, T, ChE<T>>>, 148 _chen: Option<ComplementaryPwmPin<'d, T, ChE<T>>>,
149 #[cfg(hrtim_v2)] _chf: Option<PwmPin<'d, T, ChF<T>>>,
150 #[cfg(hrtim_v2)] _chfn: Option<ComplementaryPwmPin<'d, T, ChF<T>>>,
139 ) -> Self { 151 ) -> Self {
140 Self::new_inner(tim) 152 Self::new_inner(tim)
141 } 153 }
@@ -167,6 +179,8 @@ impl<'d, T: Instance> AdvancedPwm<'d, T> {
167 ch_c: ChC { phantom: PhantomData }, 179 ch_c: ChC { phantom: PhantomData },
168 ch_d: ChD { phantom: PhantomData }, 180 ch_d: ChD { phantom: PhantomData },
169 ch_e: ChE { phantom: PhantomData }, 181 ch_e: ChE { phantom: PhantomData },
182 #[cfg(hrtim_v2)]
183 ch_f: ChF { phantom: PhantomData },
170 } 184 }
171 } 185 }
172} 186}
@@ -407,3 +421,7 @@ pin_trait!(ChannelDPin, Instance);
407pin_trait!(ChannelDComplementaryPin, Instance); 421pin_trait!(ChannelDComplementaryPin, Instance);
408pin_trait!(ChannelEPin, Instance); 422pin_trait!(ChannelEPin, Instance);
409pin_trait!(ChannelEComplementaryPin, Instance); 423pin_trait!(ChannelEComplementaryPin, Instance);
424#[cfg(hrtim_v2)]
425pin_trait!(ChannelFPin, Instance);
426#[cfg(hrtim_v2)]
427pin_trait!(ChannelFComplementaryPin, Instance);