aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32
diff options
context:
space:
mode:
authorxoviat <[email protected]>2023-07-31 17:04:51 +0000
committerGitHub <[email protected]>2023-07-31 17:04:51 +0000
commit4a9df60a7bcc1c52d82107382ed10ceaefc483ef (patch)
tree2b64a4f22dd39f2675824d62b4ba4998c4b579a1 /embassy-stm32
parentebc173ea75459c602a40f6ebbbbda071f9b3aae7 (diff)
parent5c2ba3b212f51950bfebf51d64edcc8d6ac7170a (diff)
Merge pull request #1727 from embassy-rs/hrtim-v2
stm32: add hrtim v2
Diffstat (limited to 'embassy-stm32')
-rw-r--r--embassy-stm32/build.rs2
-rw-r--r--embassy-stm32/src/hrtim/mod.rs18
-rw-r--r--embassy-stm32/src/lib.rs2
3 files changed, 21 insertions, 1 deletions
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs
index 9b3caefd5..30d4d7b0b 100644
--- a/embassy-stm32/build.rs
+++ b/embassy-stm32/build.rs
@@ -597,6 +597,8 @@ fn main() {
597 (("hrtim", "CHD2"), quote!(crate::hrtim::ChannelDComplementaryPin)), 597 (("hrtim", "CHD2"), quote!(crate::hrtim::ChannelDComplementaryPin)),
598 (("hrtim", "CHE1"), quote!(crate::hrtim::ChannelEPin)), 598 (("hrtim", "CHE1"), quote!(crate::hrtim::ChannelEPin)),
599 (("hrtim", "CHE2"), quote!(crate::hrtim::ChannelEComplementaryPin)), 599 (("hrtim", "CHE2"), quote!(crate::hrtim::ChannelEComplementaryPin)),
600 (("hrtim", "CHF1"), quote!(crate::hrtim::ChannelFPin)),
601 (("hrtim", "CHF2"), quote!(crate::hrtim::ChannelFComplementaryPin)),
600 (("sdmmc", "CK"), quote!(crate::sdmmc::CkPin)), 602 (("sdmmc", "CK"), quote!(crate::sdmmc::CkPin)),
601 (("sdmmc", "CMD"), quote!(crate::sdmmc::CmdPin)), 603 (("sdmmc", "CMD"), quote!(crate::sdmmc::CmdPin)),
602 (("sdmmc", "D0"), quote!(crate::sdmmc::D0Pin)), 604 (("sdmmc", "D0"), quote!(crate::sdmmc::D0Pin)),
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);
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs
index 34220fbf5..fb0279dcf 100644
--- a/embassy-stm32/src/lib.rs
+++ b/embassy-stm32/src/lib.rs
@@ -39,7 +39,7 @@ pub mod exti;
39pub mod flash; 39pub mod flash;
40#[cfg(fmc)] 40#[cfg(fmc)]
41pub mod fmc; 41pub mod fmc;
42#[cfg(hrtim_v1)] 42#[cfg(hrtim)]
43pub mod hrtim; 43pub mod hrtim;
44#[cfg(i2c)] 44#[cfg(i2c)]
45pub mod i2c; 45pub mod i2c;