Skip to content

Commit b5e76b0

Browse files
hannobraunYatekii
authored andcommitted
Remove GpioExt
1 parent 7245b99 commit b5e76b0

File tree

10 files changed

+11
-29
lines changed

10 files changed

+11
-29
lines changed

boards/adafruit-nrf52-bluefruit-le/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl Board {
239239
}
240240

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

244244
let cdc_uarte = Uarte::new(
245245
p.UARTE0,

boards/adafruit_nrf52pro/examples/blinky.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use panic_semihosting;
99

1010
use adafruit_nrf52pro_bsc::hal::{
1111
prelude::*,
12-
gpio::Level,
12+
gpio::{p0, Level},
1313
timer::{self, Timer},
1414
};
1515
use adafruit_nrf52pro_bsc::nrf52832_pac::{Peripherals};
@@ -19,7 +19,7 @@ use adafruit_nrf52pro_bsc::Pins;
1919
#[entry]
2020
fn main() -> ! {
2121
let p = Peripherals::take().unwrap();
22-
let pins = Pins::new(p.P0.split());
22+
let pins = Pins::new(p0::Parts::new(p.P0));
2323

2424
let mut led1 = pins.led1.into_push_pull_output(Level::Low);
2525
let mut led2 = pins.led2.into_push_pull_output(Level::Low);

boards/nRF52-DK/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl Board {
295295
}
296296

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

300300
// The nRF52-DK features an USB CDC port.
301301
// It features HWFC but does not have to use it.

boards/nRF52840-DK/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ impl Board {
313313
}
314314

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

319319
// The nRF52840-DK has an 64MB SPI flash on board which can be interfaced through SPI or Quad SPI.
320320
// As for now, only the normal SPI mode is available, so we are using this for the interface.

examples/spi-demo/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use nrf52832_hal::gpio;
1414
use nrf52832_hal::gpio::p0::*;
1515
use nrf52832_hal::gpio::Level;
1616
use nrf52832_hal::gpio::*;
17-
use nrf52832_hal::prelude::GpioExt;
1817
use nrf52832_hal::spim::Spim;
1918

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

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

examples/twi-ssd1306/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use nrf52840_hal::{
3434
#[entry]
3535
fn main() -> ! {
3636
let p = pac::Peripherals::take().unwrap();
37-
let port0 = p.P0.split();
37+
let port0 = p0::Parts::new(p.P0);
3838

3939
let scl = port0.p0_26.into_floating_input().degrade();
4040
let sda = port0.p0_27.into_floating_input().degrade();

nrf52-hal-common/src/gpio.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,6 @@ pub struct Output<MODE> {
2121
_mode: PhantomData<MODE>,
2222
}
2323

24-
/// Extension trait to split a GPIO peripheral in independent pins and registers
25-
pub trait GpioExt {
26-
/// The to split the GPIO into
27-
type Parts;
28-
29-
/// Splits the GPIO block into independent pins and registers
30-
fn split(
31-
self,
32-
// apb2: &mut APB2
33-
) -> Self::Parts;
34-
}
3524

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

334323
// Alternate,
335324
Floating,
336-
GpioExt,
337325
Input,
338326
Level,
339327
OpenDrain,
@@ -364,11 +352,9 @@ macro_rules! gpio {
364352
)+
365353
}
366354

367-
impl GpioExt for $PX {
368-
type Parts = Parts;
369-
370-
fn split(self) -> Parts {
371-
Parts {
355+
impl Parts {
356+
pub fn new(_gpio: $PX) -> Self {
357+
Self {
372358
$(
373359
$pxi: $PXi {
374360
_mode: PhantomData,

nrf52-hal-common/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pub mod uarte;
2727
pub mod prelude {
2828
pub use crate::hal::prelude::*;
2929

30-
pub use crate::gpio::GpioExt;
3130
pub use crate::time::U32Ext;
3231
}
3332

nrf52810-hal/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ pub mod prelude {
88
pub use crate::hal::prelude::*;
99
pub use nrf52_hal_common::prelude::*;
1010

11-
pub use crate::gpio::GpioExt;
1211
pub use crate::time::U32Ext;
1312
}
1413

nrf52840-hal/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ pub mod prelude {
88
pub use crate::hal::prelude::*;
99
pub use nrf52_hal_common::prelude::*;
1010

11-
pub use crate::gpio::GpioExt;
1211
pub use crate::time::U32Ext;
1312
}
1413

0 commit comments

Comments
 (0)