stm32: add hrtim v2

This commit is contained in:
Dario Nieuwenhuis 2023-07-31 15:42:03 +02:00
parent 958cace36d
commit 5c2ba3b212
4 changed files with 22 additions and 1 deletions

1
ci.sh
View File

@ -88,6 +88,7 @@ cargo batch \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,stm32l552ze,defmt,exti,time-driver-any,unstable-traits \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,stm32l552ze,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32wl54jc-cm0p,defmt,exti,time-driver-any,unstable-traits \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32wl54jc-cm0p,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wle5jb,defmt,exti,time-driver-any,unstable-traits \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wle5jb,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32g474pe,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f107vc,defmt,exti,time-driver-any,unstable-traits \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f107vc,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f103re,defmt,exti,time-driver-any,unstable-traits \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f103re,defmt,exti,time-driver-any,unstable-traits \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f100c4,defmt,exti,time-driver-any,unstable-traits \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f100c4,defmt,exti,time-driver-any,unstable-traits \

View File

@ -597,6 +597,8 @@ fn main() {
(("hrtim", "CHD2"), quote!(crate::hrtim::ChannelDComplementaryPin)), (("hrtim", "CHD2"), quote!(crate::hrtim::ChannelDComplementaryPin)),
(("hrtim", "CHE1"), quote!(crate::hrtim::ChannelEPin)), (("hrtim", "CHE1"), quote!(crate::hrtim::ChannelEPin)),
(("hrtim", "CHE2"), quote!(crate::hrtim::ChannelEComplementaryPin)), (("hrtim", "CHE2"), quote!(crate::hrtim::ChannelEComplementaryPin)),
(("hrtim", "CHF1"), quote!(crate::hrtim::ChannelFPin)),
(("hrtim", "CHF2"), quote!(crate::hrtim::ChannelFComplementaryPin)),
(("sdmmc", "CK"), quote!(crate::sdmmc::CkPin)), (("sdmmc", "CK"), quote!(crate::sdmmc::CkPin)),
(("sdmmc", "CMD"), quote!(crate::sdmmc::CmdPin)), (("sdmmc", "CMD"), quote!(crate::sdmmc::CmdPin)),
(("sdmmc", "D0"), quote!(crate::sdmmc::D0Pin)), (("sdmmc", "D0"), quote!(crate::sdmmc::D0Pin)),

View File

@ -18,6 +18,8 @@ pub enum Source {
ChC, ChC,
ChD, ChD,
ChE, ChE,
#[cfg(hrtim_v2)]
ChF,
} }
pub struct BurstController<T: Instance> { pub struct BurstController<T: Instance> {
@ -41,6 +43,10 @@ pub struct ChD<T: Instance> {
pub struct ChE<T: Instance> { pub struct ChE<T: Instance> {
phantom: PhantomData<T>, phantom: PhantomData<T>,
} }
#[cfg(hrtim_v2)]
pub struct ChF<T: Instance> {
phantom: PhantomData<T>,
}
mod sealed { mod sealed {
use super::Instance; use super::Instance;
@ -110,6 +116,8 @@ advanced_channel_impl!(new_chb, ChB, 1, ChannelBPin, ChannelBComplementaryPin);
advanced_channel_impl!(new_chc, ChC, 2, ChannelCPin, ChannelCComplementaryPin); advanced_channel_impl!(new_chc, ChC, 2, ChannelCPin, ChannelCComplementaryPin);
advanced_channel_impl!(new_chd, ChD, 3, ChannelDPin, ChannelDComplementaryPin); advanced_channel_impl!(new_chd, ChD, 3, ChannelDPin, ChannelDComplementaryPin);
advanced_channel_impl!(new_che, ChE, 4, ChannelEPin, ChannelEComplementaryPin); advanced_channel_impl!(new_che, ChE, 4, ChannelEPin, ChannelEComplementaryPin);
#[cfg(hrtim_v2)]
advanced_channel_impl!(new_chf, ChF, 5, ChannelFPin, ChannelFComplementaryPin);
/// Struct used to divide a high resolution timer into multiple channels /// Struct used to divide a high resolution timer into multiple channels
pub struct AdvancedPwm<'d, T: Instance> { pub struct AdvancedPwm<'d, T: Instance> {
@ -121,6 +129,8 @@ pub struct AdvancedPwm<'d, T: Instance> {
pub ch_c: ChC<T>, pub ch_c: ChC<T>,
pub ch_d: ChD<T>, pub ch_d: ChD<T>,
pub ch_e: ChE<T>, pub ch_e: ChE<T>,
#[cfg(hrtim_v2)]
pub ch_f: ChF<T>,
} }
impl<'d, T: Instance> AdvancedPwm<'d, T> { impl<'d, T: Instance> AdvancedPwm<'d, T> {
@ -136,6 +146,8 @@ impl<'d, T: Instance> AdvancedPwm<'d, T> {
_chdn: Option<ComplementaryPwmPin<'d, T, ChD<T>>>, _chdn: Option<ComplementaryPwmPin<'d, T, ChD<T>>>,
_che: Option<PwmPin<'d, T, ChE<T>>>, _che: Option<PwmPin<'d, T, ChE<T>>>,
_chen: Option<ComplementaryPwmPin<'d, T, ChE<T>>>, _chen: Option<ComplementaryPwmPin<'d, T, ChE<T>>>,
#[cfg(hrtim_v2)] _chf: Option<PwmPin<'d, T, ChF<T>>>,
#[cfg(hrtim_v2)] _chfn: Option<ComplementaryPwmPin<'d, T, ChF<T>>>,
) -> Self { ) -> Self {
Self::new_inner(tim) Self::new_inner(tim)
} }
@ -167,6 +179,8 @@ impl<'d, T: Instance> AdvancedPwm<'d, T> {
ch_c: ChC { phantom: PhantomData }, ch_c: ChC { phantom: PhantomData },
ch_d: ChD { phantom: PhantomData }, ch_d: ChD { phantom: PhantomData },
ch_e: ChE { phantom: PhantomData }, ch_e: ChE { phantom: PhantomData },
#[cfg(hrtim_v2)]
ch_f: ChF { phantom: PhantomData },
} }
} }
} }
@ -407,3 +421,7 @@ pin_trait!(ChannelDPin, Instance);
pin_trait!(ChannelDComplementaryPin, Instance); pin_trait!(ChannelDComplementaryPin, Instance);
pin_trait!(ChannelEPin, Instance); pin_trait!(ChannelEPin, Instance);
pin_trait!(ChannelEComplementaryPin, Instance); pin_trait!(ChannelEComplementaryPin, Instance);
#[cfg(hrtim_v2)]
pin_trait!(ChannelFPin, Instance);
#[cfg(hrtim_v2)]
pin_trait!(ChannelFComplementaryPin, Instance);

View File

@ -39,7 +39,7 @@ pub mod exti;
pub mod flash; pub mod flash;
#[cfg(fmc)] #[cfg(fmc)]
pub mod fmc; pub mod fmc;
#[cfg(hrtim_v1)] #[cfg(hrtim)]
pub mod hrtim; pub mod hrtim;
#[cfg(i2c)] #[cfg(i2c)]
pub mod i2c; pub mod i2c;