Skip to content

Commit 882a554

Browse files
careyk007hannobraun
authored andcommitted
Updating to embedded-hal digital::v2
1 parent 07344d8 commit 882a554

File tree

19 files changed

+111
-82
lines changed

19 files changed

+111
-82
lines changed

boards/actinius-icarus/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ cortex-m = "0.6.0"
1616
cortex-m-rt = "0.6.10"
1717
panic-halt = "0.2.0"
1818
nrf9160-hal = { version = "0.1.0", path = "../../nrf9160-hal" }
19+
embedded-hal = "0.2.3"
1920

2021
[dev-dependencies]
2122
nb = "0.1.1"

boards/actinius-icarus/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ pub mod prelude {
1818
use hal::{
1919
gpio::{p0, Floating, Input, Level, Output, Pin, PullUp, PushPull},
2020
pac::{CorePeripherals, Peripherals},
21-
prelude::*,
2221
uarte::{self, Baudrate as UartBaudrate, Parity as UartParity, Uarte},
2322
};
2423

24+
use embedded_hal::digital::v2::{InputPin, OutputPin};
25+
2526
pub use hal::pac;
2627

2728
/// Provides access to all features of the Actinius Icarus board
@@ -630,12 +631,12 @@ impl Led {
630631

631632
/// Enable the LED
632633
pub fn enable(&mut self) {
633-
self.0.set_low()
634+
self.0.set_low().unwrap()
634635
}
635636

636637
/// Disable the LED
637638
pub fn disable(&mut self) {
638-
self.0.set_high()
639+
self.0.set_high().unwrap()
639640
}
640641
}
641642

@@ -648,6 +649,6 @@ impl Button {
648649
}
649650

650651
pub fn is_active(&self) -> bool {
651-
self.0.is_low()
652+
self.0.is_low().unwrap()
652653
}
653654
}

boards/adafruit-nrf52-bluefruit-le/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ edition = "2018"
1010

1111
[dependencies]
1212
nrf52832-hal = { path = "../../nrf52832-hal" }
13+
embedded-hal = "0.2.3"
1314

1415
[dev-dependencies]
1516
cortex-m-rt = "0.6.8"

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ pub mod prelude {
66

77
use nrf52832_hal::{
88
gpio::{p0, Floating, Input, Level, Output, Pin, PushPull},
9-
prelude::*,
109
target::{self as pac, CorePeripherals, Peripherals},
1110
uarte, Uarte,
1211
};
1312

13+
use embedded_hal::digital::v2::OutputPin;
14+
1415
#[allow(non_snake_case)]
1516
pub struct Board {
1617
pub pins: Pins,
@@ -378,11 +379,11 @@ impl Led {
378379
}
379380

380381
pub fn enable(&mut self) {
381-
self.0.set_high();
382+
self.0.set_high().unwrap();
382383
}
383384

384385
pub fn disable(&mut self) {
385-
self.0.set_low();
386+
self.0.set_low().unwrap();
386387
}
387388
}
388389

boards/adafruit_nrf52pro/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ edition = "2018"
1111

1212
[dependencies]
1313
nrf52832-hal = { path = "../../nrf52832-hal" }
14+
embedded-hal = "0.2.3"
1415

1516
[dev-dependencies]
1617
cortex-m-rt = "0.6.8"

boards/adafruit_nrf52pro/examples/blinky.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use adafruit_nrf52pro_bsc::hal::{
1515
use adafruit_nrf52pro_bsc::nrf52832_pac::{Peripherals};
1616
use adafruit_nrf52pro_bsc::Pins;
1717

18+
use embedded_hal::digital::v2::OutputPin;
19+
1820

1921
#[entry]
2022
fn main() -> ! {
@@ -28,11 +30,11 @@ fn main() -> ! {
2830

2931
// Alternately flash the red and blue leds
3032
loop {
31-
led1.set_low();
32-
led2.set_high();
33+
led1.set_low().unwrap();
34+
led2.set_high().unwrap();
3335
delay(&mut timer, 250_000); // 250ms
34-
led1.set_high();
35-
led2.set_low();
36+
led1.set_high().unwrap();
37+
led2.set_low().unwrap();
3638
delay(&mut timer, 1_000_000); // 1s
3739
}
3840
}
@@ -42,5 +44,5 @@ where
4244
T: timer::Instance,
4345
{
4446
timer.start(cycles);
45-
block!(timer.wait());
47+
block!(timer.wait()).unwrap();
4648
}

boards/nRF52-DK/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ cortex-m = "0.6.0"
1414
cortex-m-rt = "0.6.7"
1515
panic-halt = "0.2.0"
1616
nrf52832-hal = { version = "0.8.0", path = "../../nrf52832-hal" }
17+
embedded-hal = "0.2.3"
1718

1819
[dev-dependencies]
1920
nb = "0.1.1"

boards/nRF52-DK/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ pub mod prelude {
1414
}
1515

1616
use nrf52832_hal::{
17-
prelude::*,
1817
gpio::{
1918
p0,
2019
Pin,
@@ -38,6 +37,8 @@ use nrf52832_hal::{
3837
},
3938
};
4039

40+
use embedded_hal::digital::v2::OutputPin;
41+
4142
/// Provides access to all features of the nRF52-DK board
4243
#[allow(non_snake_case)]
4344
pub struct Board {
@@ -483,12 +484,12 @@ impl Led {
483484

484485
/// Enable the LED
485486
pub fn enable(&mut self) {
486-
self.0.set_low()
487+
self.0.set_low().unwrap()
487488
}
488489

489490
/// Disable the LED
490491
pub fn disable(&mut self) {
491-
self.0.set_high()
492+
self.0.set_high().unwrap()
492493
}
493494
}
494495

boards/nRF52840-DK/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ cortex-m-rt = "0.6.5"
1919
cortex-m-semihosting = "~0.3"
2020
panic-semihosting = "~0.5"
2121
nb = "~0.1"
22+
embedded-hal = "0.2.3"
2223

2324
[features]
2425
rt = ["nrf52840-hal/rt"]

boards/nRF52840-DK/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ pub mod prelude {
1818
// pub mod debug;
1919

2020
use nrf52840_hal::{
21-
prelude::*,
2221
gpio::{
2322
p0,
2423
p1,
@@ -49,6 +48,8 @@ use nrf52840_hal::{
4948
},
5049
};
5150

51+
use embedded_hal::digital::v2::OutputPin;
52+
5253
/// Provides access to all features of the nRF52840-DK board
5354
#[allow(non_snake_case)]
5455
pub struct Board {
@@ -532,12 +533,12 @@ impl Led {
532533

533534
/// Enable the LED
534535
pub fn enable(&mut self) {
535-
self.0.set_low()
536+
self.0.set_low().unwrap()
536537
}
537538

538539
/// Disable the LED
539540
pub fn disable(&mut self) {
540-
self.0.set_high()
541+
self.0.set_high().unwrap()
541542
}
542543
}
543544

0 commit comments

Comments
 (0)