diff --git a/examples/blinky-blocking.rs b/examples/blinky-blocking.rs index 8c529f90e5d175882e857534ea54b5109d1d444c..adf9d1f31a183a459bb1d013aa0ac5f6cb4c341a 100644 --- a/examples/blinky-blocking.rs +++ b/examples/blinky-blocking.rs @@ -14,7 +14,7 @@ extern crate cortex_m_rtfm as rtfm; extern crate nb; use blue_pill::Timer; -use blue_pill::led::{self, PC13}; +use blue_pill::led::{self, LED}; use blue_pill::prelude::*; use blue_pill::time::Hertz; use rtfm::{app, Threshold}; @@ -48,9 +48,9 @@ fn idle(_t: &mut Threshold, r: idle::Resources) -> ! { state = !state; if state { - PC13.on(); + LED.on(); } else { - PC13.off(); + LED.off(); } } } diff --git a/examples/blinky-rtc.rs b/examples/blinky-rtc.rs index 6583a5b09915abea804ad9cd9a14392ea6bcf7bd..10940fbcf87c647c5cd7197cd576ae2c12974eb7 100644 --- a/examples/blinky-rtc.rs +++ b/examples/blinky-rtc.rs @@ -9,7 +9,7 @@ extern crate cortex_m_rtfm as rtfm; use blue_pill::Rtc; use blue_pill::rtc::{RtcClkSource, RtcEvent}; -use blue_pill::led::{self, PC13}; +use blue_pill::led::{self, LED}; use blue_pill::stm32f103xx::Interrupt; use rtfm::{app, Threshold}; @@ -54,8 +54,8 @@ fn toggle(_t: &mut Threshold, r: RTC::Resources) { **r.ON = !**r.ON; if **r.ON { - PC13.on(); + LED.on(); } else { - PC13.off(); + LED.off(); } } diff --git a/examples/blinky.rs b/examples/blinky.rs index 31122c54a47fbbdefe6f88e89dbe9c5c1cc6103a..107d2c861bdeb112a40103811f7c70991aaed10c 100644 --- a/examples/blinky.rs +++ b/examples/blinky.rs @@ -8,7 +8,7 @@ extern crate blue_pill; extern crate cortex_m; extern crate cortex_m_rtfm as rtfm; -use blue_pill::led::{self, PC13}; +use blue_pill::led::{self, LED}; use cortex_m::peripheral::SystClkSource; use rtfm::{app, Threshold}; @@ -48,8 +48,8 @@ fn toggle(_t: &mut Threshold, r: SYS_TICK::Resources) { **r.ON = !**r.ON; if **r.ON { - PC13.on(); + LED.on(); } else { - PC13.off(); + LED.off(); } } diff --git a/examples/capture1.rs b/examples/capture1.rs index a413904c883c606b3f5ec9b24394939676aa39c5..9cd5fc512174981fa83ef5fcd00354cf7afe256e 100644 --- a/examples/capture1.rs +++ b/examples/capture1.rs @@ -33,8 +33,7 @@ fn init(p: init::Peripherals) { } fn idle(_t: &mut Threshold, r: idle::Resources) -> ! { - const CHANNELS: [Channel; 4] = - [Channel::_1, Channel::_2, Channel::_3, Channel::_4]; + const CHANNELS: [Channel; 4] = [Channel::_1, Channel::_2, Channel::_3, Channel::_4]; let capture = Capture(&*r.TIM1); diff --git a/examples/capture2.rs b/examples/capture2.rs index bb08c5055c2642cfb1d0bced65dc13e64e9844dc..42922e96f552593ac11b3be910477027958ad23d 100644 --- a/examples/capture2.rs +++ b/examples/capture2.rs @@ -33,8 +33,7 @@ fn init(p: init::Peripherals) { } fn idle(_t: &mut Threshold, r: idle::Resources) -> ! { - const CHANNELS: [Channel; 4] = - [Channel::_1, Channel::_2, Channel::_3, Channel::_4]; + const CHANNELS: [Channel; 4] = [Channel::_1, Channel::_2, Channel::_3, Channel::_4]; let capture = Capture(&*r.TIM2); diff --git a/examples/capture4.rs b/examples/capture4.rs index 2073106828f401598cf4e3dccb5f2d135f644fd8..d123f430f359cfea6922afc00bfcfdeaa72f6254 100644 --- a/examples/capture4.rs +++ b/examples/capture4.rs @@ -32,8 +32,7 @@ fn init(p: init::Peripherals) { } fn idle(_t: &mut Threshold, r: idle::Resources) -> ! { - const CHANNELS: [Channel; 4] = - [Channel::_1, Channel::_2, Channel::_3, Channel::_4]; + const CHANNELS: [Channel; 4] = [Channel::_1, Channel::_2, Channel::_3, Channel::_4]; let capture = Capture(&*r.TIM4); diff --git a/examples/concurrent.rs b/examples/concurrent.rs index d0ea6f1f70f2426eec76c573d41bbd5472e8fef6..009a95937e2f5492521001e6bbe6ef25e7ce09f1 100644 --- a/examples/concurrent.rs +++ b/examples/concurrent.rs @@ -9,7 +9,7 @@ extern crate cortex_m; extern crate cortex_m_rtfm as rtfm; use blue_pill::Serial; -use blue_pill::led::{self, PC13}; +use blue_pill::led::{self, LED}; use blue_pill::prelude::*; use blue_pill::serial::Event; use blue_pill::time::Hertz; @@ -69,8 +69,8 @@ fn toggle(_t: &mut Threshold, r: SYS_TICK::Resources) { **r.ON = !**r.ON; if **r.ON { - PC13.on(); + LED.on(); } else { - PC13.off(); + LED.off(); } } diff --git a/examples/led.rs b/examples/led.rs index a8473b7a333d9493bb9fb8e66102809dfc646eeb..e89b13b0b8b09f21f770369ab64d4e0fb9726c9a 100644 --- a/examples/led.rs +++ b/examples/led.rs @@ -8,7 +8,7 @@ extern crate blue_pill; extern crate cortex_m_rtfm as rtfm; -use blue_pill::led::{self, PC13}; +use blue_pill::led::{self, LED}; use rtfm::app; app! { @@ -20,7 +20,7 @@ fn init(p: init::Peripherals) { } fn idle() -> ! { - PC13.on(); + LED.on(); // Sleep loop { diff --git a/examples/preemption.rs b/examples/preemption.rs index 69bac66fa244ebea83c6e9092ec719adbc0be651..99b968eb7ebc1a2043e87ea3cb7f920501781b39 100644 --- a/examples/preemption.rs +++ b/examples/preemption.rs @@ -9,7 +9,7 @@ extern crate cortex_m; extern crate cortex_m_rtfm as rtfm; use blue_pill::Serial; -use blue_pill::led::{self, PC13}; +use blue_pill::led::{self, LED}; use blue_pill::prelude::*; use blue_pill::serial::Event; use blue_pill::time::Hertz; @@ -79,8 +79,8 @@ fn toggle(t: &mut Threshold, mut r: SYS_TICK::Resources) { **r.ON = !**r.ON; if **r.ON { - PC13.on(); + LED.on(); } else { - PC13.off(); + LED.off(); } } diff --git a/examples/pwm-control.rs b/examples/pwm-control.rs index a72977f0b4fb201ed976b851ea015d52f61d7827..20d3b86ede83614e32bf370ecd8d819c375b2e9b 100644 --- a/examples/pwm-control.rs +++ b/examples/pwm-control.rs @@ -66,10 +66,7 @@ fn rx(_t: &mut Threshold, r: USART1::Resources) { match byte { b'+' => { let max = pwm.get_max_duty(); - pwm.set_duty( - Channel::_1, - if duty < max { duty + 1 } else { max }, - ); + pwm.set_duty(Channel::_1, if duty < max { duty + 1 } else { max }); } b'-' => { pwm.set_duty(Channel::_1, duty.checked_sub(1).unwrap_or(0)); diff --git a/examples/pwm1.rs b/examples/pwm1.rs index 60d520cb8598a045597e87ba3e8df53b127ff8a8..a95b114b6a4a1a85df8d5deb62a96ec8f19d44ab 100644 --- a/examples/pwm1.rs +++ b/examples/pwm1.rs @@ -26,8 +26,7 @@ fn init(p: init::Peripherals) { pwm.init(FREQUENCY.invert(), p.AFIO, p.GPIOA, p.RCC); let duty = pwm.get_max_duty() / 16; - const CHANNELS: [Channel; 4] = - [Channel::_1, Channel::_2, Channel::_3, Channel::_4]; + const CHANNELS: [Channel; 4] = [Channel::_1, Channel::_2, Channel::_3, Channel::_4]; for c in &CHANNELS { pwm.set_duty(*c, duty); diff --git a/examples/pwm2.rs b/examples/pwm2.rs index 5b6773fc5bd4b3b46ce0f88f680496ad80aac555..f727b55acea6d94f7ba9e942e62255634f010979 100644 --- a/examples/pwm2.rs +++ b/examples/pwm2.rs @@ -25,8 +25,7 @@ fn init(p: init::Peripherals) { pwm.init(FREQUENCY.invert(), p.AFIO, None, p.GPIOA, p.RCC); let duty = pwm.get_max_duty() / 16; - const CHANNELS: [Channel; 4] = - [Channel::_1, Channel::_2, Channel::_3, Channel::_4]; + const CHANNELS: [Channel; 4] = [Channel::_1, Channel::_2, Channel::_3, Channel::_4]; for c in &CHANNELS { pwm.set_duty(*c, duty); diff --git a/examples/pwm4.rs b/examples/pwm4.rs index c5d6b7fb073852337d60c1fef6dcad9cf3a22516..db0210b3fe78a5bbc544952bf187d63928dbaf58 100644 --- a/examples/pwm4.rs +++ b/examples/pwm4.rs @@ -25,8 +25,7 @@ fn init(p: init::Peripherals) { pwm.init(FREQUENCY.invert(), p.AFIO, None, p.GPIOB, p.RCC); let duty = pwm.get_max_duty() / 16; - const CHANNELS: [Channel; 4] = - [Channel::_1, Channel::_2, Channel::_3, Channel::_4]; + const CHANNELS: [Channel; 4] = [Channel::_1, Channel::_2, Channel::_3, Channel::_4]; for c in &CHANNELS { pwm.set_duty(*c, duty); diff --git a/examples/sharing.rs b/examples/sharing.rs index dcf0934b46c1022b4e38e150a22bf3cd92276f90..b8439c181f8061ef88d579915c241b97d0f02e8e 100644 --- a/examples/sharing.rs +++ b/examples/sharing.rs @@ -9,7 +9,7 @@ extern crate cortex_m; extern crate cortex_m_rtfm as rtfm; use blue_pill::Serial; -use blue_pill::led::{self, PC13}; +use blue_pill::led::{self, LED}; use blue_pill::prelude::*; use blue_pill::serial::Event; use blue_pill::time::Hertz; @@ -74,8 +74,8 @@ fn toggle(_t: &mut Threshold, r: SYS_TICK::Resources) { **r.ON = !**r.ON; if **r.ON { - PC13.on(); + LED.on(); } else { - PC13.off(); + LED.off(); } } diff --git a/examples/wait1.rs b/examples/wait1.rs index 0675e3be13997733219db6321670e2147583c1ee..4c2faff198da7fb28b3635a486a068a0c97e7558 100644 --- a/examples/wait1.rs +++ b/examples/wait1.rs @@ -9,7 +9,7 @@ extern crate blue_pill; extern crate cortex_m_rtfm as rtfm; use blue_pill::Timer; -use blue_pill::led::{self, PC13}; +use blue_pill::led::{self, LED}; use blue_pill::prelude::*; use blue_pill::time::Hertz; use rtfm::{app, Threshold}; @@ -43,9 +43,9 @@ fn idle(_t: &mut Threshold, r: idle::Resources) -> ! { state = !state; if state { - PC13.on(); + LED.on(); } else { - PC13.off(); + LED.off(); } } } diff --git a/examples/wait2.rs b/examples/wait2.rs index 8cfe53a6166e55c1fafd2b79e3fb1dc27dc51f1e..8f25e5a1b71602ab7acbe22f827f8acee4b3e295 100644 --- a/examples/wait2.rs +++ b/examples/wait2.rs @@ -9,7 +9,7 @@ extern crate blue_pill; extern crate cortex_m_rtfm as rtfm; use blue_pill::Timer; -use blue_pill::led::{self, PC13}; +use blue_pill::led::{self, LED}; use blue_pill::prelude::*; use blue_pill::time::Hertz; use rtfm::{app, Threshold}; @@ -42,9 +42,9 @@ fn idle(_t: &mut Threshold, r: idle::Resources) -> ! { state = !state; if state { - PC13.on(); + LED.on(); } else { - PC13.off(); + LED.off(); } } } diff --git a/examples/wait3.rs b/examples/wait3.rs index ae367f439a95de83c4a2452e8c307bfcbbb1302b..1c650cff2e7929d749df0fee3a96e14ed3fb1002 100644 --- a/examples/wait3.rs +++ b/examples/wait3.rs @@ -9,7 +9,7 @@ extern crate blue_pill; extern crate cortex_m_rtfm as rtfm; use blue_pill::Timer; -use blue_pill::led::{self, PC13}; +use blue_pill::led::{self, LED}; use blue_pill::prelude::*; use blue_pill::time::Hertz; use rtfm::{app, Threshold}; @@ -43,9 +43,9 @@ fn idle(_t: &mut Threshold, r: idle::Resources) -> ! { state = !state; if state { - PC13.on(); + LED.on(); } else { - PC13.off(); + LED.off(); } } } diff --git a/examples/wait4.rs b/examples/wait4.rs index 94284bb3e5f2ffa5c5e5191bb397d4e6276fed2e..be5c7ce9fd2b838f1c4d17f765449e30ac5ed4d4 100644 --- a/examples/wait4.rs +++ b/examples/wait4.rs @@ -9,7 +9,7 @@ extern crate blue_pill; extern crate cortex_m_rtfm as rtfm; use blue_pill::Timer; -use blue_pill::led::{self, PC13}; +use blue_pill::led::{self, LED}; use blue_pill::prelude::*; use blue_pill::time::Hertz; use rtfm::{app, Threshold}; @@ -43,9 +43,9 @@ fn idle(_t: &mut Threshold, r: idle::Resources) -> ! { state = !state; if state { - PC13.on(); + LED.on(); } else { - PC13.off(); + LED.off(); } } } diff --git a/src/led.rs b/src/led.rs index 5aa0de4698465107359c0e70c636976d50c6eb53..e9b24f2b363a6623cb145f3b4ce1719c3a9cbaba 100644 --- a/src/led.rs +++ b/src/led.rs @@ -5,7 +5,7 @@ use stm32f103xx::{GPIOC, RCC}; /// LED connected to pin PC13 -pub type LED = PC13; +pub const LED: PC13 = PC13; /// Pin PC13. There's an LED connected to this pin pub struct PC13;