Skip to content

Commit

Permalink
Use CamelCase for gpio::Edge enum variants
Browse files Browse the repository at this point in the history
  • Loading branch information
Piroro-hs committed Jan 10, 2021
1 parent ca01418 commit e729ba9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/exti.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn main() -> ! {
let int_pin = unsafe { &mut *INT_PIN.as_mut_ptr() };
*int_pin = gpioa.pa7.into_floating_input(&mut gpioa.crl);
int_pin.make_interrupt_source(&mut afio);
int_pin.trigger_on_edge(&p.EXTI, Edge::RISING_FALLING);
int_pin.trigger_on_edge(&p.EXTI, Edge::RisingFalling);
int_pin.enable_interrupt(&p.EXTI);
} // initialization ends here

Expand Down
21 changes: 9 additions & 12 deletions src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,11 @@ pub enum State {
Low,
}

// 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 @@ -395,15 +392,15 @@ macro_rules! gpio {
/// Generate interrupt on rising edge, falling edge or both
fn trigger_on_edge(&mut self, exti: &EXTI, edge: Edge) {
match edge {
Edge::RISING => {
Edge::Rising => {
exti.rtsr.modify(|r, w| unsafe { w.bits(r.bits() | (1 << self.i)) });
exti.ftsr.modify(|r, w| unsafe { w.bits(r.bits() & !(1 << self.i)) });
},
Edge::FALLING => {
Edge::Falling => {
exti.ftsr.modify(|r, w| unsafe { w.bits(r.bits() | (1 << self.i)) });
exti.rtsr.modify(|r, w| unsafe { w.bits(r.bits() & !(1 << self.i)) });
},
Edge::RISING_FALLING => {
Edge::RisingFalling => {
exti.rtsr.modify(|r, w| unsafe { w.bits(r.bits() | (1 << self.i)) });
exti.ftsr.modify(|r, w| unsafe { w.bits(r.bits() | (1 << self.i)) });
}
Expand Down Expand Up @@ -912,15 +909,15 @@ macro_rules! gpio {
/// Generate interrupt on rising edge, falling edge or both
fn trigger_on_edge(&mut self, exti: &EXTI, edge: Edge) {
match edge {
Edge::RISING => {
Edge::Rising => {
exti.rtsr.modify(|r, w| unsafe { w.bits(r.bits() | (1 << $i)) });
exti.ftsr.modify(|r, w| unsafe { w.bits(r.bits() & !(1 << $i)) });
},
Edge::FALLING => {
Edge::Falling => {
exti.ftsr.modify(|r, w| unsafe { w.bits(r.bits() | (1 << $i)) });
exti.rtsr.modify(|r, w| unsafe { w.bits(r.bits() & !(1 << $i)) });
},
Edge::RISING_FALLING => {
Edge::RisingFalling => {
exti.rtsr.modify(|r, w| unsafe { w.bits(r.bits() | (1 << $i)) });
exti.ftsr.modify(|r, w| unsafe { w.bits(r.bits() | (1 << $i)) });
}
Expand Down

0 comments on commit e729ba9

Please sign in to comment.