Skip to content

Commit

Permalink
Remove GpioExt
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun authored and Yatekii committed Apr 28, 2019
1 parent 7245b99 commit b5e76b0
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 29 deletions.
2 changes: 1 addition & 1 deletion boards/adafruit-nrf52-bluefruit-le/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl Board {
}

pub fn new(cp: CorePeripherals, p: Peripherals) -> Self {
let pins = p.P0.split();
let pins = p0::Parts::new(p.P0);

let cdc_uarte = Uarte::new(
p.UARTE0,
Expand Down
4 changes: 2 additions & 2 deletions boards/adafruit_nrf52pro/examples/blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use panic_semihosting;

use adafruit_nrf52pro_bsc::hal::{
prelude::*,
gpio::Level,
gpio::{p0, Level},
timer::{self, Timer},
};
use adafruit_nrf52pro_bsc::nrf52832_pac::{Peripherals};
Expand All @@ -19,7 +19,7 @@ use adafruit_nrf52pro_bsc::Pins;
#[entry]
fn main() -> ! {
let p = Peripherals::take().unwrap();
let pins = Pins::new(p.P0.split());
let pins = Pins::new(p0::Parts::new(p.P0));

let mut led1 = pins.led1.into_push_pull_output(Level::Low);
let mut led2 = pins.led2.into_push_pull_output(Level::Low);
Expand Down
2 changes: 1 addition & 1 deletion boards/nRF52-DK/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl Board {
}

fn new(cp: CorePeripherals, p: Peripherals) -> Self {
let pins0 = p.P0.split();
let pins0 = p0::Parts::new(p.P0);

// The nRF52-DK features an USB CDC port.
// It features HWFC but does not have to use it.
Expand Down
4 changes: 2 additions & 2 deletions boards/nRF52840-DK/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ impl Board {
}

fn new(cp: CorePeripherals, p: Peripherals) -> Self {
let pins0 = p.P0.split();
let pins1 = p.P1.split();
let pins0 = p0::Parts::new(p.P0);
let pins1 = p1::Parts::new(p.P1);

// The nRF52840-DK has an 64MB SPI flash on board which can be interfaced through SPI or Quad SPI.
// As for now, only the normal SPI mode is available, so we are using this for the interface.
Expand Down
3 changes: 1 addition & 2 deletions examples/spi-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use nrf52832_hal::gpio;
use nrf52832_hal::gpio::p0::*;
use nrf52832_hal::gpio::Level;
use nrf52832_hal::gpio::*;
use nrf52832_hal::prelude::GpioExt;
use nrf52832_hal::spim::Spim;

/// SPIM demonstation code.
Expand All @@ -25,7 +24,7 @@ use nrf52832_hal::spim::Spim;
#[entry]
fn main() -> ! {
let p = nrf52832_hal::nrf52832_pac::Peripherals::take().unwrap();
let port0 = p.P0.split();
let port0 = p0::Parts::new(p.P0);

let cs: P0_21<gpio::Output<PushPull>> = port0.p0_21.into_push_pull_output(Level::Low);

Expand Down
2 changes: 1 addition & 1 deletion examples/twi-ssd1306/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use nrf52840_hal::{
#[entry]
fn main() -> ! {
let p = pac::Peripherals::take().unwrap();
let port0 = p.P0.split();
let port0 = p0::Parts::new(p.P0);

let scl = port0.p0_26.into_floating_input().degrade();
let sda = port0.p0_27.into_floating_input().degrade();
Expand Down
20 changes: 3 additions & 17 deletions nrf52-hal-common/src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ pub struct Output<MODE> {
_mode: PhantomData<MODE>,
}

/// Extension trait to split a GPIO peripheral in independent pins and registers
pub trait GpioExt {
/// The to split the GPIO into
type Parts;

/// Splits the GPIO block into independent pins and registers
fn split(
self,
// apb2: &mut APB2
) -> Self::Parts;
}

/// Push pull output (type state)
pub struct PushPull;
Expand Down Expand Up @@ -333,7 +322,6 @@ macro_rules! gpio {

// Alternate,
Floating,
GpioExt,
Input,
Level,
OpenDrain,
Expand Down Expand Up @@ -364,11 +352,9 @@ macro_rules! gpio {
)+
}

impl GpioExt for $PX {
type Parts = Parts;

fn split(self) -> Parts {
Parts {
impl Parts {
pub fn new(_gpio: $PX) -> Self {
Self {
$(
$pxi: $PXi {
_mode: PhantomData,
Expand Down
1 change: 0 additions & 1 deletion nrf52-hal-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ pub mod uarte;
pub mod prelude {
pub use crate::hal::prelude::*;

pub use crate::gpio::GpioExt;
pub use crate::time::U32Ext;
}

Expand Down
1 change: 0 additions & 1 deletion nrf52810-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pub mod prelude {
pub use crate::hal::prelude::*;
pub use nrf52_hal_common::prelude::*;

pub use crate::gpio::GpioExt;
pub use crate::time::U32Ext;
}

Expand Down
1 change: 0 additions & 1 deletion nrf52840-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pub mod prelude {
pub use crate::hal::prelude::*;
pub use nrf52_hal_common::prelude::*;

pub use crate::gpio::GpioExt;
pub use crate::time::U32Ext;
}

Expand Down

0 comments on commit b5e76b0

Please sign in to comment.