Skip to content

Commit bb2d65e

Browse files
hannobraunYatekii
authored andcommitted
Remove UarteExt
1 parent 1846fcc commit bb2d65e

File tree

7 files changed

+15
-17
lines changed

7 files changed

+15
-17
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ impl Board {
241241
pub fn new(cp: CorePeripherals, p: Peripherals) -> Self {
242242
let pins = p.P0.split();
243243

244-
let cdc_uarte = p.UARTE0.constrain(
244+
let cdc_uarte = Uarte::new(
245+
p.UARTE0,
245246
uarte::Pins {
246247
txd: pins.p0_06.into_push_pull_output(Level::High).degrade(),
247248
rxd: pins.p0_08.into_floating_input().degrade(),

boards/nRF52-DK/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,9 @@ impl Board {
300300
// The nRF52-DK features an USB CDC port.
301301
// It features HWFC but does not have to use it.
302302
// It can transmit a flexible baudrate of up to 1Mbps.
303-
let cdc_uart = p.UARTE0.constrain(uarte::Pins {
303+
let cdc_uart = Uarte::new(
304+
p.UARTE0,
305+
uarte::Pins {
304306
txd: pins0.p0_06.into_push_pull_output(Level::High).degrade(),
305307
rxd: pins0.p0_08.into_floating_input().degrade(),
306308
cts: Some(pins0.p0_07.into_floating_input().degrade()),

boards/nRF52840-DK/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,9 @@ impl Board {
329329
// The nRF52840-DK features an USB CDC port.
330330
// It features HWFC but does not have to use it.
331331
// It can transmit a flexible baudrate of up to 1Mbps.
332-
let cdc_uart = p.UARTE0.constrain(uarte::Pins {
332+
let cdc_uart = Uarte::new(
333+
p.UARTE0,
334+
uarte::Pins {
333335
txd: pins0.p0_06.into_push_pull_output(Level::High).degrade(),
334336
rxd: pins0.p0_08.into_floating_input().degrade(),
335337
cts: Some(pins0.p0_07.into_floating_input().degrade()),

nrf52-hal-common/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ pub mod prelude {
3030
pub use crate::clocks::ClocksExt;
3131
pub use crate::gpio::GpioExt;
3232
pub use crate::time::U32Ext;
33-
pub use crate::uarte::UarteExt;
3433
}
3534

3635
/// Length of Nordic EasyDMA differs for MCUs

nrf52-hal-common/src/uarte.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ pub use crate::target::uarte0::{
3030
config::PARITYW as Parity,
3131
};
3232

33-
pub trait UarteExt: Deref<Target = uarte0::RegisterBlock> + Sized {
34-
fn constrain(self, pins: Pins, parity: Parity, baudrate: Baudrate) -> Uarte<Self>;
35-
}
36-
37-
impl UarteExt for UARTE0 {
38-
fn constrain(self, pins: Pins, parity: Parity, baudrate: Baudrate) -> Uarte<Self> {
39-
Uarte::new(self, pins, parity, baudrate)
40-
}
41-
}
4233

4334
/// Interface to a UARTE instance
4435
///
@@ -50,7 +41,7 @@ impl UarteExt for UARTE0 {
5041
/// - nrf52840: Section 6.1.2
5142
pub struct Uarte<T>(T);
5243

53-
impl<T> Uarte<T> where T: UarteExt {
44+
impl<T> Uarte<T> where T: Instance {
5445
pub fn new(uarte: T, mut pins: Pins, parity: Parity, baudrate: Baudrate) -> Self {
5546
// Select pins
5647
uarte.psel.rxd.write(|w| {
@@ -337,7 +328,7 @@ impl<T> Uarte<T> where T: UarteExt {
337328
}
338329
}
339330

340-
impl<T> fmt::Write for Uarte<T> where T: UarteExt {
331+
impl<T> fmt::Write for Uarte<T> where T: Instance {
341332
fn write_str(&mut self, s: &str) -> fmt::Result {
342333
// Copy all data into an on-stack buffer so we never try to EasyDMA from
343334
// flash
@@ -367,3 +358,8 @@ pub enum Error {
367358
Receive,
368359
Timeout(usize),
369360
}
361+
362+
363+
pub trait Instance: Deref<Target = uarte0::RegisterBlock> {}
364+
365+
impl Instance for UARTE0 {}

nrf52810-hal/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ pub mod prelude {
1111
pub use crate::clocks::ClocksExt;
1212
pub use crate::gpio::GpioExt;
1313
pub use crate::time::U32Ext;
14-
pub use crate::uarte::UarteExt;
1514
}
1615

1716
pub use crate::clocks::Clocks;

nrf52840-hal/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ pub mod prelude {
1111
pub use crate::clocks::ClocksExt;
1212
pub use crate::gpio::GpioExt;
1313
pub use crate::time::U32Ext;
14-
pub use crate::uarte::UarteExt;
1514
}
1615

1716
pub use crate::clocks::Clocks;

0 commit comments

Comments
 (0)