File tree Expand file tree Collapse file tree 10 files changed +11
-29
lines changed
adafruit-nrf52-bluefruit-le/src
adafruit_nrf52pro/examples Expand file tree Collapse file tree 10 files changed +11
-29
lines changed Original file line number Diff line number Diff line change @@ -239,7 +239,7 @@ impl Board {
239
239
}
240
240
241
241
pub fn new ( cp : CorePeripherals , p : Peripherals ) -> Self {
242
- let pins = p. P0 . split ( ) ;
242
+ let pins = p0 :: Parts :: new ( p. P0 ) ;
243
243
244
244
let cdc_uarte = Uarte :: new (
245
245
p. UARTE0 ,
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ use panic_semihosting;
9
9
10
10
use adafruit_nrf52pro_bsc:: hal:: {
11
11
prelude:: * ,
12
- gpio:: Level ,
12
+ gpio:: { p0 , Level } ,
13
13
timer:: { self , Timer } ,
14
14
} ;
15
15
use adafruit_nrf52pro_bsc:: nrf52832_pac:: { Peripherals } ;
@@ -19,7 +19,7 @@ use adafruit_nrf52pro_bsc::Pins;
19
19
#[ entry]
20
20
fn main ( ) -> ! {
21
21
let p = Peripherals :: take ( ) . unwrap ( ) ;
22
- let pins = Pins :: new ( p. P0 . split ( ) ) ;
22
+ let pins = Pins :: new ( p0 :: Parts :: new ( p. P0 ) ) ;
23
23
24
24
let mut led1 = pins. led1 . into_push_pull_output ( Level :: Low ) ;
25
25
let mut led2 = pins. led2 . into_push_pull_output ( Level :: Low ) ;
Original file line number Diff line number Diff line change @@ -295,7 +295,7 @@ impl Board {
295
295
}
296
296
297
297
fn new ( cp : CorePeripherals , p : Peripherals ) -> Self {
298
- let pins0 = p. P0 . split ( ) ;
298
+ let pins0 = p0 :: Parts :: new ( p. P0 ) ;
299
299
300
300
// The nRF52-DK features an USB CDC port.
301
301
// It features HWFC but does not have to use it.
Original file line number Diff line number Diff line change @@ -313,8 +313,8 @@ impl Board {
313
313
}
314
314
315
315
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 ) ;
318
318
319
319
// The nRF52840-DK has an 64MB SPI flash on board which can be interfaced through SPI or Quad SPI.
320
320
// As for now, only the normal SPI mode is available, so we are using this for the interface.
Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ use nrf52832_hal::gpio;
14
14
use nrf52832_hal:: gpio:: p0:: * ;
15
15
use nrf52832_hal:: gpio:: Level ;
16
16
use nrf52832_hal:: gpio:: * ;
17
- use nrf52832_hal:: prelude:: GpioExt ;
18
17
use nrf52832_hal:: spim:: Spim ;
19
18
20
19
/// SPIM demonstation code.
@@ -25,7 +24,7 @@ use nrf52832_hal::spim::Spim;
25
24
#[ entry]
26
25
fn main ( ) -> ! {
27
26
let p = nrf52832_hal:: nrf52832_pac:: Peripherals :: take ( ) . unwrap ( ) ;
28
- let port0 = p. P0 . split ( ) ;
27
+ let port0 = p0 :: Parts :: new ( p. P0 ) ;
29
28
30
29
let cs: P0_21 < gpio:: Output < PushPull > > = port0. p0_21 . into_push_pull_output ( Level :: Low ) ;
31
30
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ use nrf52840_hal::{
34
34
#[ entry]
35
35
fn main ( ) -> ! {
36
36
let p = pac:: Peripherals :: take ( ) . unwrap ( ) ;
37
- let port0 = p. P0 . split ( ) ;
37
+ let port0 = p0 :: Parts :: new ( p. P0 ) ;
38
38
39
39
let scl = port0. p0_26 . into_floating_input ( ) . degrade ( ) ;
40
40
let sda = port0. p0_27 . into_floating_input ( ) . degrade ( ) ;
Original file line number Diff line number Diff line change @@ -21,17 +21,6 @@ pub struct Output<MODE> {
21
21
_mode : PhantomData < MODE > ,
22
22
}
23
23
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
- }
35
24
36
25
/// Push pull output (type state)
37
26
pub struct PushPull ;
@@ -333,7 +322,6 @@ macro_rules! gpio {
333
322
334
323
// Alternate,
335
324
Floating ,
336
- GpioExt ,
337
325
Input ,
338
326
Level ,
339
327
OpenDrain ,
@@ -364,11 +352,9 @@ macro_rules! gpio {
364
352
) +
365
353
}
366
354
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 {
372
358
$(
373
359
$pxi: $PXi {
374
360
_mode: PhantomData ,
Original file line number Diff line number Diff line change @@ -27,7 +27,6 @@ pub mod uarte;
27
27
pub mod prelude {
28
28
pub use crate :: hal:: prelude:: * ;
29
29
30
- pub use crate :: gpio:: GpioExt ;
31
30
pub use crate :: time:: U32Ext ;
32
31
}
33
32
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ pub mod prelude {
8
8
pub use crate :: hal:: prelude:: * ;
9
9
pub use nrf52_hal_common:: prelude:: * ;
10
10
11
- pub use crate :: gpio:: GpioExt ;
12
11
pub use crate :: time:: U32Ext ;
13
12
}
14
13
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ pub mod prelude {
8
8
pub use crate :: hal:: prelude:: * ;
9
9
pub use nrf52_hal_common:: prelude:: * ;
10
10
11
- pub use crate :: gpio:: GpioExt ;
12
11
pub use crate :: time:: U32Ext ;
13
12
}
14
13
You can’t perform that action at this time.
0 commit comments