Skip to content

Commit

Permalink
Merge #179
Browse files Browse the repository at this point in the history
179: Use CamelCase for gpio::Edge enum variants r=richardeoin a=Piroro-hs

ref: [l4xx](stm32-rs/stm32l4xx-hal#187), [f1xx](stm32-rs/stm32f1xx-hal#303), [f4xx](stm32-rs/stm32f4xx-hal#250), [f7xx](stm32-rs/stm32f7xx-hal#111)


Co-authored-by: Piroro-hs <Piroro-hs@users.noreply.github.com>
  • Loading branch information
bors[bot] and Piroro-hs authored Jan 31, 2021
2 parents f22fe37 + a1717bc commit 5471426
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions examples/exti_interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ fn main() -> ! {
let gpioe = dp.GPIOE.split(ccdr.peripheral.GPIOE);
let mut button1 = gpioe.pe3.into_pull_up_input();
button1.make_interrupt_source(&mut syscfg);
button1.trigger_on_edge(&mut exti, Edge::RISING);
button1.trigger_on_edge(&mut exti, Edge::Rising);
button1.enable_interrupt(&mut exti);

let gpioc = dp.GPIOC.split(ccdr.peripheral.GPIOC);
let mut button2 = gpioc.pc5.into_pull_up_input();
button2.make_interrupt_source(&mut syscfg);
button2.trigger_on_edge(&mut exti, Edge::RISING);
button2.trigger_on_edge(&mut exti, Edge::Rising);
button2.enable_interrupt(&mut exti);

let gpioa = dp.GPIOA.split(ccdr.peripheral.GPIOA);
Expand Down
2 changes: 1 addition & 1 deletion examples/rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const APP: () = {
// Button
let mut button = gpioc.pc13.into_floating_input();
button.make_interrupt_source(&mut ctx.device.SYSCFG);
button.trigger_on_edge(&mut ctx.device.EXTI, Edge::RISING);
button.trigger_on_edge(&mut ctx.device.EXTI, Edge::Rising);
button.enable_interrupt(&mut ctx.device.EXTI);

init::LateResources {
Expand Down
2 changes: 1 addition & 1 deletion examples/rtic_low_power.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const APP: () = {
let mut exti = ctx.device.EXTI;
let mut wakeup = gpioc.pc13.into_floating_input();
wakeup.make_interrupt_source(&mut syscfg);
wakeup.trigger_on_edge(&mut exti, Edge::RISING);
wakeup.trigger_on_edge(&mut exti, Edge::Rising);
wakeup.enable_interrupt(&mut exti);

// LEDs
Expand Down
18 changes: 9 additions & 9 deletions src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ pub enum Speed {
/// GPIO Edge selection
#[derive(Copy, Clone, PartialEq)]
pub enum Edge {
RISING,
FALLING,
RISING_FALLING,
Rising,
Falling,
RisingFalling,
}

/// Alternate function 0 (type state)
Expand Down Expand Up @@ -299,15 +299,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 @@ -746,15 +746,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 5471426

Please sign in to comment.