Skip to content

Commit ba8253f

Browse files
committed
Turn modules inside-out
1 parent 8940cfd commit ba8253f

File tree

29 files changed

+123
-99
lines changed

29 files changed

+123
-99
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414
### Changed
1515
- Swap PWM channel arguments to references
1616
- All trait methods have been renamed to remove the `try_` prefix (i.e. `try_send` -> `send`) for consistency.
17-
- Moved all traits into two modules depending on the execution model: `blocking` and `nb` (non-blocking).
17+
- Moved all traits into two sub modules for each feature depending on the execution model: `blocking` and `nb` (non-blocking). For example, the spi traits can now be found under `embedded_hal::spi::blocking` or `embedded_hal::spi::nb`.
1818
- Re-export `nb::{block!, Error, Result}` to avoid version mismatches. These should be used instead of
19-
importing the `nb` crate directly in dependendent crates.
19+
importing the `nb` crate directly in dependent crates.
2020
- `blocking::Serial`: renamed `bwrite_all` to `write`, `bflush` to `flush.
2121
- Removed `prelude` to avoid method name conflicts between different flavors (blocking, nb) of the same trait. Traits must now be manually imported.
2222

src/adc/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//! Analog-digital conversion traits
2+
3+
pub mod nb;

src/nb/adc.rs renamed to src/adc/nb.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
///
99
/// ```
1010
/// # use core::marker::PhantomData;
11-
/// # use embedded_hal::nb::adc::Channel;
11+
/// # use embedded_hal::adc::nb::Channel;
1212
///
1313
/// struct Adc1; // Example ADC with single bank of 8 channels
1414
/// struct Gpio1Pin1<MODE>(PhantomData<MODE>);
@@ -55,7 +55,7 @@ pub trait Channel<ADC> {
5555
/// of the request (in contrast to continuous asynchronous sampling).
5656
///
5757
/// ```
58-
/// use embedded_hal::nb::adc::{Channel, OneShot};
58+
/// use embedded_hal::adc::nb::{Channel, OneShot};
5959
///
6060
/// struct MyAdc; // 10-bit ADC, with 5 channels
6161
/// # impl MyAdc {

src/blocking/mod.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/capture/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//! Input capture traits
2+
3+
pub mod nb;
File renamed without changes.
File renamed without changes.

src/delay/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//! Delay traits
2+
3+
pub mod blocking;

src/blocking/digital.rs renamed to src/digital/blocking.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
//! Digital I/O
2+
//!
3+
//! In some cases it's possible to implement these blocking traits on top of one of the core HAL
4+
//! traits. To save boilerplate when that's the case a `Default` marker trait may be provided.
5+
//! Implementing that marker trait will opt in your type into a blanket implementation.
26
37
use core::{convert::From, ops::Not};
48

@@ -7,7 +11,7 @@ use core::{convert::From, ops::Not};
711
/// Conversion from `bool` and logical negation are also implemented
812
/// for this type.
913
/// ```rust
10-
/// # use embedded_hal::blocking::digital::PinState;
14+
/// # use embedded_hal::digital::blocking::PinState;
1115
/// let state = PinState::from(false);
1216
/// assert_eq!(state, PinState::Low);
1317
/// assert_eq!(!state, PinState::High);
@@ -100,8 +104,8 @@ pub trait ToggleableOutputPin {
100104
/// toggleable by software.
101105
///
102106
/// ```
103-
/// use embedded_hal::blocking::digital::{OutputPin, StatefulOutputPin, ToggleableOutputPin};
104-
/// use embedded_hal::blocking::digital::toggleable;
107+
/// use embedded_hal::digital::blocking::{OutputPin, StatefulOutputPin, ToggleableOutputPin};
108+
/// use embedded_hal::digital::blocking::toggleable;
105109
/// use core::convert::Infallible;
106110
///
107111
/// /// A virtual output pin that exists purely in software
@@ -182,7 +186,7 @@ pub trait InputPin {
182186
///
183187
/// ```
184188
/// use core::time::Duration;
185-
/// use embedded_hal::blocking::digital::{IoPin, InputPin, OutputPin};
189+
/// use embedded_hal::digital::blocking::{IoPin, InputPin, OutputPin};
186190
///
187191
/// pub fn ping_and_read<TInputPin, TOutputPin, TError>(
188192
/// mut pin: TOutputPin, delay_fn: &dyn Fn(Duration) -> ()) -> Result<bool, TError>

src/digital/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//! Digital I/O traits
2+
3+
pub mod blocking;

0 commit comments

Comments
 (0)