diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-07-11 02:51:06 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-07-11 02:51:06 +0000 |
| commit | 2adee4af3878cb0e8027752c9d29a6ce236f4ab3 (patch) | |
| tree | e6f2700ab17bcb62d0195debade2df44c54b03b4 /embassy-stm32/src/timer | |
| parent | 99f4fd33b493f11ec3202eb98fc3ae9e18b9d589 (diff) | |
| parent | 5ecbe5c9181d2392540a3273f21d53c01474d341 (diff) | |
Merge #858
858: embassy-stm32: Simplify time r=Dirbaio a=GrantM11235
- Remove unused `MilliSeconds`, `MicroSeconds`, and `NanoSeconds` types
- Remove `Bps`, `KiloHertz`, and `MegaHertz` types that were only used
for converting to `Hertz`
- Replace all instances of `impl Into<Hertz>` with `Hertz`
- Add `hz`, `khz`, and `mhz` methods to `Hertz`, as well as
free function shortcuts
- Remove `U32Ext` extension trait
Co-authored-by: Grant Miller <[email protected]>
Diffstat (limited to 'embassy-stm32/src/timer')
| -rw-r--r-- | embassy-stm32/src/timer/mod.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/embassy-stm32/src/timer/mod.rs b/embassy-stm32/src/timer/mod.rs index 9067fa462..e92015ee9 100644 --- a/embassy-stm32/src/timer/mod.rs +++ b/embassy-stm32/src/timer/mod.rs | |||
| @@ -23,7 +23,7 @@ pub(crate) mod sealed { | |||
| 23 | 23 | ||
| 24 | fn reset(&mut self); | 24 | fn reset(&mut self); |
| 25 | 25 | ||
| 26 | fn set_frequency<F: Into<Hertz>>(&mut self, frequency: F); | 26 | fn set_frequency(&mut self, frequency: Hertz); |
| 27 | 27 | ||
| 28 | fn clear_update_interrupt(&mut self) -> bool; | 28 | fn clear_update_interrupt(&mut self) -> bool; |
| 29 | 29 | ||
| @@ -37,7 +37,7 @@ pub(crate) mod sealed { | |||
| 37 | pub trait GeneralPurpose32bitInstance: GeneralPurpose16bitInstance { | 37 | pub trait GeneralPurpose32bitInstance: GeneralPurpose16bitInstance { |
| 38 | fn regs_gp32() -> crate::pac::timer::TimGp32; | 38 | fn regs_gp32() -> crate::pac::timer::TimGp32; |
| 39 | 39 | ||
| 40 | fn set_frequency<F: Into<Hertz>>(&mut self, frequency: F); | 40 | fn set_frequency(&mut self, frequency: Hertz); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | pub trait AdvancedControlInstance: Basic16bitInstance { | 43 | pub trait AdvancedControlInstance: Basic16bitInstance { |
| @@ -81,9 +81,9 @@ macro_rules! impl_basic_16bit_timer { | |||
| 81 | } | 81 | } |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | fn set_frequency<F: Into<Hertz>>(&mut self, frequency: F) { | 84 | fn set_frequency(&mut self, frequency: Hertz) { |
| 85 | use core::convert::TryInto; | 85 | use core::convert::TryInto; |
| 86 | let f = frequency.into().0; | 86 | let f = frequency.0; |
| 87 | let timer_f = Self::frequency().0; | 87 | let timer_f = Self::frequency().0; |
| 88 | let pclk_ticks_per_timer_period = timer_f / f; | 88 | let pclk_ticks_per_timer_period = timer_f / f; |
| 89 | let psc: u16 = unwrap!(((pclk_ticks_per_timer_period - 1) / (1 << 16)).try_into()); | 89 | let psc: u16 = unwrap!(((pclk_ticks_per_timer_period - 1) / (1 << 16)).try_into()); |
| @@ -132,9 +132,9 @@ macro_rules! impl_32bit_timer { | |||
| 132 | crate::pac::$inst | 132 | crate::pac::$inst |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | fn set_frequency<F: Into<Hertz>>(&mut self, frequency: F) { | 135 | fn set_frequency(&mut self, frequency: Hertz) { |
| 136 | use core::convert::TryInto; | 136 | use core::convert::TryInto; |
| 137 | let f = frequency.into().0; | 137 | let f = frequency.0; |
| 138 | let timer_f = Self::frequency().0; | 138 | let timer_f = Self::frequency().0; |
| 139 | let pclk_ticks_per_timer_period = (timer_f / f) as u64; | 139 | let pclk_ticks_per_timer_period = (timer_f / f) as u64; |
| 140 | let psc: u16 = unwrap!(((pclk_ticks_per_timer_period - 1) / (1 << 32)).try_into()); | 140 | let psc: u16 = unwrap!(((pclk_ticks_per_timer_period - 1) / (1 << 32)).try_into()); |
