aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32h7/src/bin/low_level_timer_api.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-06-13 07:22:04 +0000
committerGitHub <[email protected]>2022-06-13 07:22:04 +0000
commitdb685c04049449ac3e4f256f2e7e26dad550d94c (patch)
treef4ec5de70ec05e793a774049e010935ac45853ed /examples/stm32h7/src/bin/low_level_timer_api.rs
parentfff0a03fe0f9e84209dd40fd8f93790871d03d75 (diff)
parenta8703b75988e1e700af701116464025679d2feb8 (diff)
Merge #808
808: Add rustfmt.toml with some nice settings. r=lulf a=Dirbaio Co-authored-by: Dario Nieuwenhuis <[email protected]>
Diffstat (limited to 'examples/stm32h7/src/bin/low_level_timer_api.rs')
-rw-r--r--examples/stm32h7/src/bin/low_level_timer_api.rs26
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
5use core::marker::PhantomData; 5use core::marker::PhantomData;
6use defmt_rtt as _; // global logger
7use panic_probe as _;
8 6
9use defmt::*; 7use defmt::*;
10use embassy::executor::Spawner; 8use embassy::executor::Spawner;
@@ -13,9 +11,8 @@ use embassy_stm32::gpio::low_level::AFType;
13use embassy_stm32::gpio::Speed; 11use embassy_stm32::gpio::Speed;
14use embassy_stm32::pwm::*; 12use embassy_stm32::pwm::*;
15use embassy_stm32::time::{Hertz, U32Ext}; 13use embassy_stm32::time::{Hertz, U32Ext};
16use embassy_stm32::unborrow; 14use embassy_stm32::{unborrow, Config, Peripherals, Unborrow};
17use embassy_stm32::Unborrow; 15use {defmt_rtt as _, panic_probe as _};
18use embassy_stm32::{Config, Peripherals};
19 16
20pub fn config() -> Config { 17pub 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}