Skip to content

Commit

Permalink
Use CamelCase for gpio::Edge enum variants (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
Piroro-hs authored Jan 14, 2021
1 parent 09c6526 commit 8b84f85
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/irq_button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 9 additions & 12 deletions src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)) });
}
Expand Down Expand Up @@ -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)) });
}
Expand Down

0 comments on commit 8b84f85

Please sign in to comment.