Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CamelCase for gpio::Edge enum variants #303

Merged
merged 1 commit into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Breaking changes
- Rename `gpio::Edge::{RISING, FALLING, RISING_FALLING}` to `Rising`, `Falling`, `RisingFalling`, respectively

### Added

- LSB/MSB bit format selection for `SPI`
Expand Down
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