diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-06-12 22:15:44 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-06-12 22:22:31 +0200 |
| commit | a8703b75988e1e700af701116464025679d2feb8 (patch) | |
| tree | f4ec5de70ec05e793a774049e010935ac45853ed /examples/stm32h7/src/bin/low_level_timer_api.rs | |
| parent | 6199bdea710cde33e5d5381b6d6abfc8af46df19 (diff) | |
Run rustfmt.
Diffstat (limited to 'examples/stm32h7/src/bin/low_level_timer_api.rs')
| -rw-r--r-- | examples/stm32h7/src/bin/low_level_timer_api.rs | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs index 647c5a8fa..3a728a0dd 100644 --- a/examples/stm32h7/src/bin/low_level_timer_api.rs +++ b/examples/stm32h7/src/bin/low_level_timer_api.rs | |||
| @@ -3,8 +3,6 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use core::marker::PhantomData; | 5 | use core::marker::PhantomData; |
| 6 | use defmt_rtt as _; // global logger | ||
| 7 | use panic_probe as _; | ||
| 8 | 6 | ||
| 9 | use defmt::*; | 7 | use defmt::*; |
| 10 | use embassy::executor::Spawner; | 8 | use embassy::executor::Spawner; |
| @@ -13,9 +11,8 @@ use embassy_stm32::gpio::low_level::AFType; | |||
| 13 | use embassy_stm32::gpio::Speed; | 11 | use embassy_stm32::gpio::Speed; |
| 14 | use embassy_stm32::pwm::*; | 12 | use embassy_stm32::pwm::*; |
| 15 | use embassy_stm32::time::{Hertz, U32Ext}; | 13 | use embassy_stm32::time::{Hertz, U32Ext}; |
| 16 | use embassy_stm32::unborrow; | 14 | use embassy_stm32::{unborrow, Config, Peripherals, Unborrow}; |
| 17 | use embassy_stm32::Unborrow; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 18 | use embassy_stm32::{Config, Peripherals}; | ||
| 19 | 16 | ||
| 20 | pub fn config() -> Config { | 17 | pub fn config() -> Config { |
| 21 | let mut config = Config::default(); | 18 | let mut config = Config::default(); |
| @@ -108,25 +105,18 @@ impl<'d, T: CaptureCompare32bitInstance> SimplePwm32<'d, T> { | |||
| 108 | 105 | ||
| 109 | pub fn enable(&mut self, channel: Channel) { | 106 | pub fn enable(&mut self, channel: Channel) { |
| 110 | unsafe { | 107 | unsafe { |
| 111 | T::regs_gp32() | 108 | T::regs_gp32().ccer().modify(|w| w.set_cce(channel.raw(), true)); |
| 112 | .ccer() | ||
| 113 | .modify(|w| w.set_cce(channel.raw(), true)); | ||
| 114 | } | 109 | } |
| 115 | } | 110 | } |
| 116 | 111 | ||
| 117 | pub fn disable(&mut self, channel: Channel) { | 112 | pub fn disable(&mut self, channel: Channel) { |
| 118 | unsafe { | 113 | unsafe { |
| 119 | T::regs_gp32() | 114 | T::regs_gp32().ccer().modify(|w| w.set_cce(channel.raw(), false)); |
| 120 | .ccer() | ||
| 121 | .modify(|w| w.set_cce(channel.raw(), false)); | ||
| 122 | } | 115 | } |
| 123 | } | 116 | } |
| 124 | 117 | ||
| 125 | pub fn set_freq<F: Into<Hertz>>(&mut self, freq: F) { | 118 | pub fn set_freq<F: Into<Hertz>>(&mut self, freq: F) { |
| 126 | <T as embassy_stm32::timer::low_level::GeneralPurpose32bitInstance>::set_frequency( | 119 | <T as embassy_stm32::timer::low_level::GeneralPurpose32bitInstance>::set_frequency(&mut self.inner, freq); |
| 127 | &mut self.inner, | ||
| 128 | freq, | ||
| 129 | ); | ||
| 130 | } | 120 | } |
| 131 | 121 | ||
| 132 | pub fn get_max_duty(&self) -> u32 { | 122 | pub fn get_max_duty(&self) -> u32 { |
| @@ -135,10 +125,6 @@ impl<'d, T: CaptureCompare32bitInstance> SimplePwm32<'d, T> { | |||
| 135 | 125 | ||
| 136 | pub fn set_duty(&mut self, channel: Channel, duty: u32) { | 126 | pub fn set_duty(&mut self, channel: Channel, duty: u32) { |
| 137 | defmt::assert!(duty < self.get_max_duty()); | 127 | defmt::assert!(duty < self.get_max_duty()); |
| 138 | unsafe { | 128 | unsafe { T::regs_gp32().ccr(channel.raw()).modify(|w| w.set_ccr(duty)) } |
| 139 | T::regs_gp32() | ||
| 140 | .ccr(channel.raw()) | ||
| 141 | .modify(|w| w.set_ccr(duty)) | ||
| 142 | } | ||
| 143 | } | 129 | } |
| 144 | } | 130 | } |
