From 8b84f85cd4a3c6eb5df1be46793ed5ce6e4a261c Mon Sep 17 00:00:00 2001 From: Piroro-hs Date: Thu, 14 Jan 2021 17:25:45 +0900 Subject: [PATCH] Use CamelCase for gpio::Edge enum variants (#187) --- examples/irq_button.rs | 2 +- src/gpio.rs | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/examples/irq_button.rs b/examples/irq_button.rs index d8647640..8b12f9cd 100644 --- a/examples/irq_button.rs +++ b/examples/irq_button.rs @@ -46,7 +46,7 @@ fn main() -> ! { .into_pull_up_input(&mut gpioc.moder, &mut gpioc.pupdr); board_btn.make_interrupt_source(&mut dp.SYSCFG, &mut rcc.apb2); board_btn.enable_interrupt(&mut dp.EXTI); - board_btn.trigger_on_edge(&mut dp.EXTI, Edge::FALLING); + board_btn.trigger_on_edge(&mut dp.EXTI, Edge::Falling); // Enable interrupts unsafe { diff --git a/src/gpio.rs b/src/gpio.rs index 0ec04fb4..519ebf6e 100644 --- a/src/gpio.rs +++ b/src/gpio.rs @@ -115,14 +115,11 @@ pub struct AF14; /// Alternate function 15 (type state) pub struct AF15; -// Using SCREAMING_SNAKE_CASE to be consistent with other HALs -// see 59b2740 and #125 for motivation -#[allow(non_camel_case_types)] #[derive(Debug, PartialEq)] pub enum Edge { - RISING, - FALLING, - RISING_FALLING, + Rising, + Falling, + RisingFalling, } /// External Interrupt Pin @@ -354,15 +351,15 @@ macro_rules! gpio { /// Generate interrupt on rising edge, falling edge or both fn trigger_on_edge(&mut self, exti: &mut EXTI, edge: Edge) { match edge { - Edge::RISING => { + Edge::Rising => { exti.rtsr1.modify(|r, w| unsafe { w.bits(r.bits() | (1 << self.i)) }); exti.ftsr1.modify(|r, w| unsafe { w.bits(r.bits() & !(1 << self.i)) }); }, - Edge::FALLING => { + Edge::Falling => { exti.ftsr1.modify(|r, w| unsafe { w.bits(r.bits() | (1 << self.i)) }); exti.rtsr1.modify(|r, w| unsafe { w.bits(r.bits() & !(1 << self.i)) }); }, - Edge::RISING_FALLING => { + Edge::RisingFalling => { exti.rtsr1.modify(|r, w| unsafe { w.bits(r.bits() | (1 << self.i)) }); exti.ftsr1.modify(|r, w| unsafe { w.bits(r.bits() | (1 << self.i)) }); } @@ -699,15 +696,15 @@ macro_rules! gpio { /// Generate interrupt on rising edge, falling edge or both fn trigger_on_edge(&mut self, exti: &mut EXTI, edge: Edge) { match edge { - Edge::RISING => { + Edge::Rising => { exti.rtsr1.modify(|r, w| unsafe { w.bits(r.bits() | (1 << $i)) }); exti.ftsr1.modify(|r, w| unsafe { w.bits(r.bits() & !(1 << $i)) }); }, - Edge::FALLING => { + Edge::Falling => { exti.ftsr1.modify(|r, w| unsafe { w.bits(r.bits() | (1 << $i)) }); exti.rtsr1.modify(|r, w| unsafe { w.bits(r.bits() & !(1 << $i)) }); }, - Edge::RISING_FALLING => { + Edge::RisingFalling => { exti.rtsr1.modify(|r, w| unsafe { w.bits(r.bits() | (1 << $i)) }); exti.ftsr1.modify(|r, w| unsafe { w.bits(r.bits() | (1 << $i)) }); }