diff options
| author | xoviat <[email protected]> | 2023-07-28 17:37:14 -0500 |
|---|---|---|
| committer | xoviat <[email protected]> | 2023-07-28 17:37:14 -0500 |
| commit | a8d3bcbb759293f93b7a623910ead15f2cae0a95 (patch) | |
| tree | f4397840bbb419c6b7bcd17003e7c2e0573507f1 /embassy-stm32/src/hrtim | |
| parent | ec787d3518211a91cbecc4056fde88d7d9eb3a34 (diff) | |
stm32/hrtim: shorten names
Diffstat (limited to 'embassy-stm32/src/hrtim')
| -rw-r--r-- | embassy-stm32/src/hrtim/mod.rs | 64 | ||||
| -rw-r--r-- | embassy-stm32/src/hrtim/traits.rs | 119 |
2 files changed, 88 insertions, 95 deletions
diff --git a/embassy-stm32/src/hrtim/mod.rs b/embassy-stm32/src/hrtim/mod.rs index 3a05719b0..9ed03a219 100644 --- a/embassy-stm32/src/hrtim/mod.rs +++ b/embassy-stm32/src/hrtim/mod.rs | |||
| @@ -7,7 +7,7 @@ use embassy_hal_internal::{into_ref, PeripheralRef}; | |||
| 7 | #[allow(unused_imports)] | 7 | #[allow(unused_imports)] |
| 8 | use crate::gpio::sealed::{AFType, Pin}; | 8 | use crate::gpio::sealed::{AFType, Pin}; |
| 9 | use crate::gpio::AnyPin; | 9 | use crate::gpio::AnyPin; |
| 10 | use crate::hrtim::traits::HighResolutionCaptureCompare16bitInstance; | 10 | use crate::hrtim::traits::Instance; |
| 11 | use crate::time::Hertz; | 11 | use crate::time::Hertz; |
| 12 | use crate::Peripheral; | 12 | use crate::Peripheral; |
| 13 | 13 | ||
| @@ -20,37 +20,37 @@ pub enum Source { | |||
| 20 | ChE, | 20 | ChE, |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | pub struct BurstController<T: HighResolutionCaptureCompare16bitInstance> { | 23 | pub struct BurstController<T: Instance> { |
| 24 | phantom: PhantomData<T>, | 24 | phantom: PhantomData<T>, |
| 25 | } | 25 | } |
| 26 | pub struct Master<T: HighResolutionCaptureCompare16bitInstance> { | 26 | pub struct Master<T: Instance> { |
| 27 | phantom: PhantomData<T>, | 27 | phantom: PhantomData<T>, |
| 28 | } | 28 | } |
| 29 | pub struct ChA<T: HighResolutionCaptureCompare16bitInstance> { | 29 | pub struct ChA<T: Instance> { |
| 30 | phantom: PhantomData<T>, | 30 | phantom: PhantomData<T>, |
| 31 | } | 31 | } |
| 32 | pub struct ChB<T: HighResolutionCaptureCompare16bitInstance> { | 32 | pub struct ChB<T: Instance> { |
| 33 | phantom: PhantomData<T>, | 33 | phantom: PhantomData<T>, |
| 34 | } | 34 | } |
| 35 | pub struct ChC<T: HighResolutionCaptureCompare16bitInstance> { | 35 | pub struct ChC<T: Instance> { |
| 36 | phantom: PhantomData<T>, | 36 | phantom: PhantomData<T>, |
| 37 | } | 37 | } |
| 38 | pub struct ChD<T: HighResolutionCaptureCompare16bitInstance> { | 38 | pub struct ChD<T: Instance> { |
| 39 | phantom: PhantomData<T>, | 39 | phantom: PhantomData<T>, |
| 40 | } | 40 | } |
| 41 | pub struct ChE<T: HighResolutionCaptureCompare16bitInstance> { | 41 | pub struct ChE<T: Instance> { |
| 42 | phantom: PhantomData<T>, | 42 | phantom: PhantomData<T>, |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | mod sealed { | 45 | mod sealed { |
| 46 | use super::HighResolutionCaptureCompare16bitInstance; | 46 | use super::Instance; |
| 47 | 47 | ||
| 48 | pub trait AdvancedChannel<T: HighResolutionCaptureCompare16bitInstance> { | 48 | pub trait AdvancedChannel<T: Instance> { |
| 49 | fn raw() -> usize; | 49 | fn raw() -> usize; |
| 50 | } | 50 | } |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | pub trait AdvancedChannel<T: HighResolutionCaptureCompare16bitInstance>: sealed::AdvancedChannel<T> {} | 53 | pub trait AdvancedChannel<T: Instance>: sealed::AdvancedChannel<T> {} |
| 54 | 54 | ||
| 55 | pub struct PwmPin<'d, Perip, Channel> { | 55 | pub struct PwmPin<'d, Perip, Channel> { |
| 56 | _pin: PeripheralRef<'d, AnyPin>, | 56 | _pin: PeripheralRef<'d, AnyPin>, |
| @@ -64,7 +64,7 @@ pub struct ComplementaryPwmPin<'d, Perip, Channel> { | |||
| 64 | 64 | ||
| 65 | macro_rules! advanced_channel_impl { | 65 | macro_rules! advanced_channel_impl { |
| 66 | ($new_chx:ident, $channel:tt, $ch_num:expr, $pin_trait:ident, $complementary_pin_trait:ident) => { | 66 | ($new_chx:ident, $channel:tt, $ch_num:expr, $pin_trait:ident, $complementary_pin_trait:ident) => { |
| 67 | impl<'d, Perip: HighResolutionCaptureCompare16bitInstance> PwmPin<'d, Perip, $channel<Perip>> { | 67 | impl<'d, Perip: Instance> PwmPin<'d, Perip, $channel<Perip>> { |
| 68 | pub fn $new_chx(pin: impl Peripheral<P = impl $pin_trait<Perip>> + 'd) -> Self { | 68 | pub fn $new_chx(pin: impl Peripheral<P = impl $pin_trait<Perip>> + 'd) -> Self { |
| 69 | into_ref!(pin); | 69 | into_ref!(pin); |
| 70 | critical_section::with(|_| { | 70 | critical_section::with(|_| { |
| @@ -80,7 +80,7 @@ macro_rules! advanced_channel_impl { | |||
| 80 | } | 80 | } |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | impl<'d, Perip: HighResolutionCaptureCompare16bitInstance> ComplementaryPwmPin<'d, Perip, $channel<Perip>> { | 83 | impl<'d, Perip: Instance> ComplementaryPwmPin<'d, Perip, $channel<Perip>> { |
| 84 | pub fn $new_chx(pin: impl Peripheral<P = impl $complementary_pin_trait<Perip>> + 'd) -> Self { | 84 | pub fn $new_chx(pin: impl Peripheral<P = impl $complementary_pin_trait<Perip>> + 'd) -> Self { |
| 85 | into_ref!(pin); | 85 | into_ref!(pin); |
| 86 | critical_section::with(|_| { | 86 | critical_section::with(|_| { |
| @@ -96,12 +96,12 @@ macro_rules! advanced_channel_impl { | |||
| 96 | } | 96 | } |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | impl<T: HighResolutionCaptureCompare16bitInstance> sealed::AdvancedChannel<T> for $channel<T> { | 99 | impl<T: Instance> sealed::AdvancedChannel<T> for $channel<T> { |
| 100 | fn raw() -> usize { | 100 | fn raw() -> usize { |
| 101 | $ch_num | 101 | $ch_num |
| 102 | } | 102 | } |
| 103 | } | 103 | } |
| 104 | impl<T: HighResolutionCaptureCompare16bitInstance> AdvancedChannel<T> for $channel<T> {} | 104 | impl<T: Instance> AdvancedChannel<T> for $channel<T> {} |
| 105 | }; | 105 | }; |
| 106 | } | 106 | } |
| 107 | 107 | ||
| @@ -112,7 +112,7 @@ advanced_channel_impl!(new_chd, ChD, 3, ChannelDPin, ChannelDComplementaryPin); | |||
| 112 | advanced_channel_impl!(new_che, ChE, 4, ChannelEPin, ChannelEComplementaryPin); | 112 | advanced_channel_impl!(new_che, ChE, 4, ChannelEPin, ChannelEComplementaryPin); |
| 113 | 113 | ||
| 114 | /// Struct used to divide a high resolution timer into multiple channels | 114 | /// Struct used to divide a high resolution timer into multiple channels |
| 115 | pub struct AdvancedPwm<'d, T: HighResolutionCaptureCompare16bitInstance> { | 115 | pub struct AdvancedPwm<'d, T: Instance> { |
| 116 | _inner: PeripheralRef<'d, T>, | 116 | _inner: PeripheralRef<'d, T>, |
| 117 | pub master: Master<T>, | 117 | pub master: Master<T>, |
| 118 | pub burst_controller: BurstController<T>, | 118 | pub burst_controller: BurstController<T>, |
| @@ -123,7 +123,7 @@ pub struct AdvancedPwm<'d, T: HighResolutionCaptureCompare16bitInstance> { | |||
| 123 | pub ch_e: ChE<T>, | 123 | pub ch_e: ChE<T>, |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | impl<'d, T: HighResolutionCaptureCompare16bitInstance> AdvancedPwm<'d, T> { | 126 | impl<'d, T: Instance> AdvancedPwm<'d, T> { |
| 127 | pub fn new( | 127 | pub fn new( |
| 128 | tim: impl Peripheral<P = T> + 'd, | 128 | tim: impl Peripheral<P = T> + 'd, |
| 129 | _cha: Option<PwmPin<'d, T, ChA<T>>>, | 129 | _cha: Option<PwmPin<'d, T, ChA<T>>>, |
| @@ -171,7 +171,7 @@ impl<'d, T: HighResolutionCaptureCompare16bitInstance> AdvancedPwm<'d, T> { | |||
| 171 | } | 171 | } |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | impl<T: HighResolutionCaptureCompare16bitInstance> BurstController<T> { | 174 | impl<T: Instance> BurstController<T> { |
| 175 | pub fn set_source(&mut self, _source: Source) { | 175 | pub fn set_source(&mut self, _source: Source) { |
| 176 | todo!("burst mode control registers not implemented") | 176 | todo!("burst mode control registers not implemented") |
| 177 | } | 177 | } |
| @@ -186,7 +186,7 @@ impl<T: HighResolutionCaptureCompare16bitInstance> BurstController<T> { | |||
| 186 | /// It is important to remember that in synchronous topologies, energy can flow in reverse during | 186 | /// It is important to remember that in synchronous topologies, energy can flow in reverse during |
| 187 | /// light loading conditions, and that the low-side switch must be active for a short time to drive | 187 | /// light loading conditions, and that the low-side switch must be active for a short time to drive |
| 188 | /// a bootstrapped high-side switch. | 188 | /// a bootstrapped high-side switch. |
| 189 | pub struct BridgeConverter<T: HighResolutionCaptureCompare16bitInstance, C: AdvancedChannel<T>> { | 189 | pub struct BridgeConverter<T: Instance, C: AdvancedChannel<T>> { |
| 190 | timer: PhantomData<T>, | 190 | timer: PhantomData<T>, |
| 191 | channel: PhantomData<C>, | 191 | channel: PhantomData<C>, |
| 192 | dead_time: u16, | 192 | dead_time: u16, |
| @@ -195,7 +195,7 @@ pub struct BridgeConverter<T: HighResolutionCaptureCompare16bitInstance, C: Adva | |||
| 195 | max_secondary_duty: u16, | 195 | max_secondary_duty: u16, |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | impl<T: HighResolutionCaptureCompare16bitInstance, C: AdvancedChannel<T>> BridgeConverter<T, C> { | 198 | impl<T: Instance, C: AdvancedChannel<T>> BridgeConverter<T, C> { |
| 199 | pub fn new(_channel: C, frequency: Hertz) -> Self { | 199 | pub fn new(_channel: C, frequency: Hertz) -> Self { |
| 200 | use crate::pac::hrtim::vals::{Activeeffect, Inactiveeffect}; | 200 | use crate::pac::hrtim::vals::{Activeeffect, Inactiveeffect}; |
| 201 | 201 | ||
| @@ -333,14 +333,14 @@ impl<T: HighResolutionCaptureCompare16bitInstance, C: AdvancedChannel<T>> Bridge | |||
| 333 | /// This implementation of a resonsant converter is appropriate for a half or full bridge, | 333 | /// This implementation of a resonsant converter is appropriate for a half or full bridge, |
| 334 | /// but does not include secondary rectification, which is appropriate for applications | 334 | /// but does not include secondary rectification, which is appropriate for applications |
| 335 | /// with a low-voltage on the secondary side. | 335 | /// with a low-voltage on the secondary side. |
| 336 | pub struct ResonantConverter<T: HighResolutionCaptureCompare16bitInstance, C: AdvancedChannel<T>> { | 336 | pub struct ResonantConverter<T: Instance, C: AdvancedChannel<T>> { |
| 337 | timer: PhantomData<T>, | 337 | timer: PhantomData<T>, |
| 338 | channel: PhantomData<C>, | 338 | channel: PhantomData<C>, |
| 339 | min_period: u16, | 339 | min_period: u16, |
| 340 | max_period: u16, | 340 | max_period: u16, |
| 341 | } | 341 | } |
| 342 | 342 | ||
| 343 | impl<T: HighResolutionCaptureCompare16bitInstance, C: AdvancedChannel<T>> ResonantConverter<T, C> { | 343 | impl<T: Instance, C: AdvancedChannel<T>> ResonantConverter<T, C> { |
| 344 | pub fn new(_channel: C, min_frequency: Hertz, max_frequency: Hertz) -> Self { | 344 | pub fn new(_channel: C, min_frequency: Hertz, max_frequency: Hertz) -> Self { |
| 345 | T::set_channel_frequency(C::raw(), min_frequency); | 345 | T::set_channel_frequency(C::raw(), min_frequency); |
| 346 | 346 | ||
| @@ -397,13 +397,13 @@ impl<T: HighResolutionCaptureCompare16bitInstance, C: AdvancedChannel<T>> Resona | |||
| 397 | } | 397 | } |
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | pin_trait!(ChannelAPin, HighResolutionCaptureCompare16bitInstance); | 400 | pin_trait!(ChannelAPin, Instance); |
| 401 | pin_trait!(ChannelAComplementaryPin, HighResolutionCaptureCompare16bitInstance); | 401 | pin_trait!(ChannelAComplementaryPin, Instance); |
| 402 | pin_trait!(ChannelBPin, HighResolutionCaptureCompare16bitInstance); | 402 | pin_trait!(ChannelBPin, Instance); |
| 403 | pin_trait!(ChannelBComplementaryPin, HighResolutionCaptureCompare16bitInstance); | 403 | pin_trait!(ChannelBComplementaryPin, Instance); |
| 404 | pin_trait!(ChannelCPin, HighResolutionCaptureCompare16bitInstance); | 404 | pin_trait!(ChannelCPin, Instance); |
| 405 | pin_trait!(ChannelCComplementaryPin, HighResolutionCaptureCompare16bitInstance); | 405 | pin_trait!(ChannelCComplementaryPin, Instance); |
| 406 | pin_trait!(ChannelDPin, HighResolutionCaptureCompare16bitInstance); | 406 | pin_trait!(ChannelDPin, Instance); |
| 407 | pin_trait!(ChannelDComplementaryPin, HighResolutionCaptureCompare16bitInstance); | 407 | pin_trait!(ChannelDComplementaryPin, Instance); |
| 408 | pin_trait!(ChannelEPin, HighResolutionCaptureCompare16bitInstance); | 408 | pin_trait!(ChannelEPin, Instance); |
| 409 | pin_trait!(ChannelEComplementaryPin, HighResolutionCaptureCompare16bitInstance); | 409 | pin_trait!(ChannelEComplementaryPin, Instance); |
diff --git a/embassy-stm32/src/hrtim/traits.rs b/embassy-stm32/src/hrtim/traits.rs index 7f2cedda5..158a68862 100644 --- a/embassy-stm32/src/hrtim/traits.rs +++ b/embassy-stm32/src/hrtim/traits.rs | |||
| @@ -2,7 +2,7 @@ use crate::rcc::sealed::RccPeripheral; | |||
| 2 | use crate::time::Hertz; | 2 | use crate::time::Hertz; |
| 3 | 3 | ||
| 4 | #[derive(Clone, Copy)] | 4 | #[derive(Clone, Copy)] |
| 5 | pub(crate) enum HighResolutionControlPrescaler { | 5 | pub(crate) enum Prescaler { |
| 6 | Div1, | 6 | Div1, |
| 7 | Div2, | 7 | Div2, |
| 8 | Div4, | 8 | Div4, |
| @@ -13,87 +13,83 @@ pub(crate) enum HighResolutionControlPrescaler { | |||
| 13 | Div128, | 13 | Div128, |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | impl From<HighResolutionControlPrescaler> for u32 { | 16 | impl From<Prescaler> for u32 { |
| 17 | fn from(val: HighResolutionControlPrescaler) -> Self { | 17 | fn from(val: Prescaler) -> Self { |
| 18 | match val { | 18 | match val { |
| 19 | HighResolutionControlPrescaler::Div1 => 1, | 19 | Prescaler::Div1 => 1, |
| 20 | HighResolutionControlPrescaler::Div2 => 2, | 20 | Prescaler::Div2 => 2, |
| 21 | HighResolutionControlPrescaler::Div4 => 4, | 21 | Prescaler::Div4 => 4, |
| 22 | HighResolutionControlPrescaler::Div8 => 8, | 22 | Prescaler::Div8 => 8, |
| 23 | HighResolutionControlPrescaler::Div16 => 16, | 23 | Prescaler::Div16 => 16, |
| 24 | HighResolutionControlPrescaler::Div32 => 32, | 24 | Prescaler::Div32 => 32, |
| 25 | HighResolutionControlPrescaler::Div64 => 64, | 25 | Prescaler::Div64 => 64, |
| 26 | HighResolutionControlPrescaler::Div128 => 128, | 26 | Prescaler::Div128 => 128, |
| 27 | } | 27 | } |
| 28 | } | 28 | } |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | impl From<HighResolutionControlPrescaler> for u8 { | 31 | impl From<Prescaler> for u8 { |
| 32 | fn from(val: HighResolutionControlPrescaler) -> Self { | 32 | fn from(val: Prescaler) -> Self { |
| 33 | match val { | 33 | match val { |
| 34 | HighResolutionControlPrescaler::Div1 => 0b000, | 34 | Prescaler::Div1 => 0b000, |
| 35 | HighResolutionControlPrescaler::Div2 => 0b001, | 35 | Prescaler::Div2 => 0b001, |
| 36 | HighResolutionControlPrescaler::Div4 => 0b010, | 36 | Prescaler::Div4 => 0b010, |
| 37 | HighResolutionControlPrescaler::Div8 => 0b011, | 37 | Prescaler::Div8 => 0b011, |
| 38 | HighResolutionControlPrescaler::Div16 => 0b100, | 38 | Prescaler::Div16 => 0b100, |
| 39 | HighResolutionControlPrescaler::Div32 => 0b101, | 39 | Prescaler::Div32 => 0b101, |
| 40 | HighResolutionControlPrescaler::Div64 => 0b110, | 40 | Prescaler::Div64 => 0b110, |
| 41 | HighResolutionControlPrescaler::Div128 => 0b111, | 41 | Prescaler::Div128 => 0b111, |
| 42 | } | 42 | } |
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | impl From<u8> for HighResolutionControlPrescaler { | 46 | impl From<u8> for Prescaler { |
| 47 | fn from(val: u8) -> Self { | 47 | fn from(val: u8) -> Self { |
| 48 | match val { | 48 | match val { |
| 49 | 0b000 => HighResolutionControlPrescaler::Div1, | 49 | 0b000 => Prescaler::Div1, |
| 50 | 0b001 => HighResolutionControlPrescaler::Div2, | 50 | 0b001 => Prescaler::Div2, |
| 51 | 0b010 => HighResolutionControlPrescaler::Div4, | 51 | 0b010 => Prescaler::Div4, |
| 52 | 0b011 => HighResolutionControlPrescaler::Div8, | 52 | 0b011 => Prescaler::Div8, |
| 53 | 0b100 => HighResolutionControlPrescaler::Div16, | 53 | 0b100 => Prescaler::Div16, |
| 54 | 0b101 => HighResolutionControlPrescaler::Div32, | 54 | 0b101 => Prescaler::Div32, |
| 55 | 0b110 => HighResolutionControlPrescaler::Div64, | 55 | 0b110 => Prescaler::Div64, |
| 56 | 0b111 => HighResolutionControlPrescaler::Div128, | 56 | 0b111 => Prescaler::Div128, |
| 57 | _ => unreachable!(), | 57 | _ => unreachable!(), |
| 58 | } | 58 | } |
| 59 | } | 59 | } |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | impl HighResolutionControlPrescaler { | 62 | impl Prescaler { |
| 63 | pub fn compute_min_high_res(val: u32) -> Self { | 63 | pub fn compute_min_high_res(val: u32) -> Self { |
| 64 | *[ | 64 | *[ |
| 65 | HighResolutionControlPrescaler::Div1, | 65 | Prescaler::Div1, |
| 66 | HighResolutionControlPrescaler::Div2, | 66 | Prescaler::Div2, |
| 67 | HighResolutionControlPrescaler::Div4, | 67 | Prescaler::Div4, |
| 68 | HighResolutionControlPrescaler::Div8, | 68 | Prescaler::Div8, |
| 69 | HighResolutionControlPrescaler::Div16, | 69 | Prescaler::Div16, |
| 70 | HighResolutionControlPrescaler::Div32, | 70 | Prescaler::Div32, |
| 71 | HighResolutionControlPrescaler::Div64, | 71 | Prescaler::Div64, |
| 72 | HighResolutionControlPrescaler::Div128, | 72 | Prescaler::Div128, |
| 73 | ] | 73 | ] |
| 74 | .iter() | 74 | .iter() |
| 75 | .skip_while(|psc| <HighResolutionControlPrescaler as Into<u32>>::into(**psc) <= val) | 75 | .skip_while(|psc| <Prescaler as Into<u32>>::into(**psc) <= val) |
| 76 | .next() | 76 | .next() |
| 77 | .unwrap() | 77 | .unwrap() |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | pub fn compute_min_low_res(val: u32) -> Self { | 80 | pub fn compute_min_low_res(val: u32) -> Self { |
| 81 | *[ | 81 | *[Prescaler::Div32, Prescaler::Div64, Prescaler::Div128] |
| 82 | HighResolutionControlPrescaler::Div32, | 82 | .iter() |
| 83 | HighResolutionControlPrescaler::Div64, | 83 | .skip_while(|psc| <Prescaler as Into<u32>>::into(**psc) <= val) |
| 84 | HighResolutionControlPrescaler::Div128, | 84 | .next() |
| 85 | ] | 85 | .unwrap() |
| 86 | .iter() | ||
| 87 | .skip_while(|psc| <HighResolutionControlPrescaler as Into<u32>>::into(**psc) <= val) | ||
| 88 | .next() | ||
| 89 | .unwrap() | ||
| 90 | } | 86 | } |
| 91 | } | 87 | } |
| 92 | 88 | ||
| 93 | pub(crate) mod sealed { | 89 | pub(crate) mod sealed { |
| 94 | use super::*; | 90 | use super::*; |
| 95 | 91 | ||
| 96 | pub trait HighResolutionCaptureCompare16bitInstance: RccPeripheral { | 92 | pub trait Instance: RccPeripheral { |
| 97 | fn regs() -> crate::pac::hrtim::Hrtim; | 93 | fn regs() -> crate::pac::hrtim::Hrtim; |
| 98 | 94 | ||
| 99 | fn set_master_frequency(frequency: Hertz); | 95 | fn set_master_frequency(frequency: Hertz); |
| @@ -109,14 +105,11 @@ pub(crate) mod sealed { | |||
| 109 | } | 105 | } |
| 110 | } | 106 | } |
| 111 | 107 | ||
| 112 | pub trait HighResolutionCaptureCompare16bitInstance: | 108 | pub trait Instance: sealed::Instance + 'static {} |
| 113 | sealed::HighResolutionCaptureCompare16bitInstance + 'static | ||
| 114 | { | ||
| 115 | } | ||
| 116 | 109 | ||
| 117 | foreach_interrupt! { | 110 | foreach_interrupt! { |
| 118 | ($inst:ident, hrtim, HRTIM, MASTER, $irq:ident) => { | 111 | ($inst:ident, hrtim, HRTIM, MASTER, $irq:ident) => { |
| 119 | impl sealed::HighResolutionCaptureCompare16bitInstance for crate::peripherals::$inst { | 112 | impl sealed::Instance for crate::peripherals::$inst { |
| 120 | fn regs() -> crate::pac::hrtim::Hrtim { | 113 | fn regs() -> crate::pac::hrtim::Hrtim { |
| 121 | crate::pac::$inst | 114 | crate::pac::$inst |
| 122 | } | 115 | } |
| @@ -128,9 +121,9 @@ foreach_interrupt! { | |||
| 128 | let timer_f = Self::frequency().0; | 121 | let timer_f = Self::frequency().0; |
| 129 | let psc_min = (timer_f / f) / (u16::MAX as u32 / 32); | 122 | let psc_min = (timer_f / f) / (u16::MAX as u32 / 32); |
| 130 | let psc = if Self::regs().isr().read().dllrdy() { | 123 | let psc = if Self::regs().isr().read().dllrdy() { |
| 131 | HighResolutionControlPrescaler::compute_min_high_res(psc_min) | 124 | Prescaler::compute_min_high_res(psc_min) |
| 132 | } else { | 125 | } else { |
| 133 | HighResolutionControlPrescaler::compute_min_low_res(psc_min) | 126 | Prescaler::compute_min_low_res(psc_min) |
| 134 | }; | 127 | }; |
| 135 | 128 | ||
| 136 | let psc_val: u32 = psc.into(); | 129 | let psc_val: u32 = psc.into(); |
| @@ -150,9 +143,9 @@ foreach_interrupt! { | |||
| 150 | let timer_f = Self::frequency().0; | 143 | let timer_f = Self::frequency().0; |
| 151 | let psc_min = (timer_f / f) / (u16::MAX as u32 / 32); | 144 | let psc_min = (timer_f / f) / (u16::MAX as u32 / 32); |
| 152 | let psc = if Self::regs().isr().read().dllrdy() { | 145 | let psc = if Self::regs().isr().read().dllrdy() { |
| 153 | HighResolutionControlPrescaler::compute_min_high_res(psc_min) | 146 | Prescaler::compute_min_high_res(psc_min) |
| 154 | } else { | 147 | } else { |
| 155 | HighResolutionControlPrescaler::compute_min_low_res(psc_min) | 148 | Prescaler::compute_min_low_res(psc_min) |
| 156 | }; | 149 | }; |
| 157 | 150 | ||
| 158 | let psc_val: u32 = psc.into(); | 151 | let psc_val: u32 = psc.into(); |
| @@ -169,7 +162,7 @@ foreach_interrupt! { | |||
| 169 | 162 | ||
| 170 | let regs = Self::regs(); | 163 | let regs = Self::regs(); |
| 171 | 164 | ||
| 172 | let channel_psc: HighResolutionControlPrescaler = regs.tim(channel).cr().read().ckpsc().into(); | 165 | let channel_psc: Prescaler = regs.tim(channel).cr().read().ckpsc().into(); |
| 173 | let psc_val: u32 = channel_psc.into(); | 166 | let psc_val: u32 = channel_psc.into(); |
| 174 | 167 | ||
| 175 | 168 | ||
| @@ -177,9 +170,9 @@ foreach_interrupt! { | |||
| 177 | // u9::MAX = 511 | 170 | // u9::MAX = 511 |
| 178 | let psc_min = (psc_val * dead_time as u32) / (4 * 511); | 171 | let psc_min = (psc_val * dead_time as u32) / (4 * 511); |
| 179 | let psc = if Self::regs().isr().read().dllrdy() { | 172 | let psc = if Self::regs().isr().read().dllrdy() { |
| 180 | HighResolutionControlPrescaler::compute_min_high_res(psc_min) | 173 | Prescaler::compute_min_high_res(psc_min) |
| 181 | } else { | 174 | } else { |
| 182 | HighResolutionControlPrescaler::compute_min_low_res(psc_min) | 175 | Prescaler::compute_min_low_res(psc_min) |
| 183 | }; | 176 | }; |
| 184 | 177 | ||
| 185 | let dt_psc_val: u32 = psc.into(); | 178 | let dt_psc_val: u32 = psc.into(); |
| @@ -193,7 +186,7 @@ foreach_interrupt! { | |||
| 193 | } | 186 | } |
| 194 | } | 187 | } |
| 195 | 188 | ||
| 196 | impl HighResolutionCaptureCompare16bitInstance for crate::peripherals::$inst { | 189 | impl Instance for crate::peripherals::$inst { |
| 197 | 190 | ||
| 198 | } | 191 | } |
| 199 | }; | 192 | }; |
