From 39f215e2bc900dd986a77bd8c2093d2c1755cac4 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Mon, 16 Mar 2020 07:21:48 +0100 Subject: [PATCH 1/2] Separate Capture, Pwm and Qei traits into modules --- src/capture.rs | 96 ++++++++++++++++ src/lib.rs | 296 +------------------------------------------------ src/pwm.rs | 124 +++++++++++++++++++++ src/qei.rs | 78 +++++++++++++ 4 files changed, 304 insertions(+), 290 deletions(-) create mode 100644 src/capture.rs create mode 100644 src/pwm.rs create mode 100644 src/qei.rs diff --git a/src/capture.rs b/src/capture.rs new file mode 100644 index 000000000..09073c945 --- /dev/null +++ b/src/capture.rs @@ -0,0 +1,96 @@ +//! Input capture + +use nb; + +/// Input capture +/// +/// # Examples +/// +/// You can use this interface to measure the period of (quasi) periodic signals +/// / events +/// +/// ``` +/// extern crate embedded_hal as hal; +/// #[macro_use(block)] +/// extern crate nb; +/// +/// use hal::prelude::*; +/// +/// fn main() { +/// let mut capture: Capture1 = { +/// // .. +/// # Capture1 +/// }; +/// +/// capture.try_set_resolution(1.ms()).unwrap(); +/// +/// let before = block!(capture.try_capture(Channel::_1)).unwrap(); +/// let after = block!(capture.try_capture(Channel::_1)).unwrap(); +/// +/// let period = after.wrapping_sub(before); +/// +/// println!("Period: {} ms", period); +/// } +/// +/// # use core::convert::Infallible; +/// # struct MilliSeconds(u32); +/// # trait U32Ext { fn ms(self) -> MilliSeconds; } +/// # impl U32Ext for u32 { fn ms(self) -> MilliSeconds { MilliSeconds(self) } } +/// # struct Capture1; +/// # enum Channel { _1 } +/// # impl hal::Capture for Capture1 { +/// # type Error = Infallible; +/// # type Capture = u16; +/// # type Channel = Channel; +/// # type Time = MilliSeconds; +/// # fn try_capture(&mut self, _: Channel) -> ::nb::Result { Ok(0) } +/// # fn try_disable(&mut self, _: Channel) -> Result<(), Self::Error> { unimplemented!() } +/// # fn try_enable(&mut self, _: Channel) -> Result<(), Self::Error> { unimplemented!() } +/// # fn try_get_resolution(&self) -> Result { unimplemented!() } +/// # fn try_set_resolution(&mut self, _: T) -> Result<(), Self::Error> where T: Into { Ok(()) } +/// # } +/// ``` +// unproven reason: pre-singletons API. With singletons a `CapturePin` (cf. `PwmPin`) trait seems more +// appropriate +pub trait Capture { + /// Enumeration of `Capture` errors + /// + /// Possible errors: + /// + /// - *overcapture*, the previous capture value was overwritten because it + /// was not read in a timely manner + type Error; + + /// Enumeration of channels that can be used with this `Capture` interface + /// + /// If your `Capture` interface has no channels you can use the type `()` + /// here + type Channel; + + /// A time unit that can be converted into a human time unit (e.g. seconds) + type Time; + + /// The type of the value returned by `capture` + type Capture; + + /// "Waits" for a transition in the capture `channel` and returns the value + /// of counter at that instant + /// + /// NOTE that you must multiply the returned value by the *resolution* of + /// this `Capture` interface to get a human time unit (e.g. seconds) + fn try_capture(&mut self, channel: Self::Channel) -> nb::Result; + + /// Disables a capture `channel` + fn try_disable(&mut self, channel: Self::Channel) -> Result<(), Self::Error>; + + /// Enables a capture `channel` + fn try_enable(&mut self, channel: Self::Channel) -> Result<(), Self::Error>; + + /// Returns the current resolution + fn try_get_resolution(&self) -> Result; + + /// Sets the resolution of the capture timer + fn try_set_resolution(&mut self, resolution: R) -> Result<(), Self::Error> + where + R: Into; +} diff --git a/src/lib.rs b/src/lib.rs index 8429767f5..83ad2db37 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -697,295 +697,11 @@ pub mod spi; pub mod timer; pub mod watchdog; -/// Input capture -/// -/// # Examples -/// -/// You can use this interface to measure the period of (quasi) periodic signals -/// / events -/// -/// ``` -/// extern crate embedded_hal as hal; -/// #[macro_use(block)] -/// extern crate nb; -/// -/// use hal::prelude::*; -/// -/// fn main() { -/// let mut capture: Capture1 = { -/// // .. -/// # Capture1 -/// }; -/// -/// capture.try_set_resolution(1.ms()).unwrap(); -/// -/// let before = block!(capture.try_capture(Channel::_1)).unwrap(); -/// let after = block!(capture.try_capture(Channel::_1)).unwrap(); -/// -/// let period = after.wrapping_sub(before); -/// -/// println!("Period: {} ms", period); -/// } -/// -/// # use core::convert::Infallible; -/// # struct MilliSeconds(u32); -/// # trait U32Ext { fn ms(self) -> MilliSeconds; } -/// # impl U32Ext for u32 { fn ms(self) -> MilliSeconds { MilliSeconds(self) } } -/// # struct Capture1; -/// # enum Channel { _1 } -/// # impl hal::Capture for Capture1 { -/// # type Error = Infallible; -/// # type Capture = u16; -/// # type Channel = Channel; -/// # type Time = MilliSeconds; -/// # fn try_capture(&mut self, _: Channel) -> ::nb::Result { Ok(0) } -/// # fn try_disable(&mut self, _: Channel) -> Result<(), Self::Error> { unimplemented!() } -/// # fn try_enable(&mut self, _: Channel) -> Result<(), Self::Error> { unimplemented!() } -/// # fn try_get_resolution(&self) -> Result { unimplemented!() } -/// # fn try_set_resolution(&mut self, _: T) -> Result<(), Self::Error> where T: Into { Ok(()) } -/// # } -/// ``` -// unproven reason: pre-singletons API. With singletons a `CapturePin` (cf. `PwmPin`) trait seems more -// appropriate -pub trait Capture { - /// Enumeration of `Capture` errors - /// - /// Possible errors: - /// - /// - *overcapture*, the previous capture value was overwritten because it - /// was not read in a timely manner - type Error; +mod capture; +pub use capture::Capture; - /// Enumeration of channels that can be used with this `Capture` interface - /// - /// If your `Capture` interface has no channels you can use the type `()` - /// here - type Channel; +mod pwm; +pub use pwm::{Pwm, PwmPin}; - /// A time unit that can be converted into a human time unit (e.g. seconds) - type Time; - - /// The type of the value returned by `capture` - type Capture; - - /// "Waits" for a transition in the capture `channel` and returns the value - /// of counter at that instant - /// - /// NOTE that you must multiply the returned value by the *resolution* of - /// this `Capture` interface to get a human time unit (e.g. seconds) - fn try_capture(&mut self, channel: Self::Channel) -> nb::Result; - - /// Disables a capture `channel` - fn try_disable(&mut self, channel: Self::Channel) -> Result<(), Self::Error>; - - /// Enables a capture `channel` - fn try_enable(&mut self, channel: Self::Channel) -> Result<(), Self::Error>; - - /// Returns the current resolution - fn try_get_resolution(&self) -> Result; - - /// Sets the resolution of the capture timer - fn try_set_resolution(&mut self, resolution: R) -> Result<(), Self::Error> - where - R: Into; -} - -/// Pulse Width Modulation -/// -/// # Examples -/// -/// Use this interface to control the power output of some actuator -/// -/// ``` -/// extern crate embedded_hal as hal; -/// -/// use hal::prelude::*; -/// -/// fn main() { -/// let mut pwm: Pwm1 = { -/// // .. -/// # Pwm1 -/// }; -/// -/// pwm.try_set_period(1.khz()).unwrap(); -/// -/// let max_duty = pwm.try_get_max_duty().unwrap(); -/// -/// // brightest LED -/// pwm.try_set_duty(Channel::_1, max_duty).unwrap(); -/// -/// // dimmer LED -/// pwm.try_set_duty(Channel::_2, max_duty / 4).unwrap(); -/// } -/// -/// # use core::convert::Infallible; -/// # struct KiloHertz(u32); -/// # trait U32Ext { fn khz(self) -> KiloHertz; } -/// # impl U32Ext for u32 { fn khz(self) -> KiloHertz { KiloHertz(self) } } -/// # enum Channel { _1, _2 } -/// # struct Pwm1; -/// # impl hal::Pwm for Pwm1 { -/// # type Error = Infallible; -/// # type Channel = Channel; -/// # type Time = KiloHertz; -/// # type Duty = u16; -/// # fn try_disable(&mut self, _: Channel) -> Result<(), Self::Error> { unimplemented!() } -/// # fn try_enable(&mut self, _: Channel) -> Result<(), Self::Error> { unimplemented!() } -/// # fn try_get_duty(&self, _: Channel) -> Result { unimplemented!() } -/// # fn try_get_max_duty(&self) -> Result { Ok(0) } -/// # fn try_set_duty(&mut self, _: Channel, _: u16) -> Result<(), Self::Error> { Ok(()) } -/// # fn try_get_period(&self) -> Result { unimplemented!() } -/// # fn try_set_period(&mut self, _: T) -> Result<(), Self::Error> where T: Into { Ok(()) } -/// # } -/// ``` -// unproven reason: pre-singletons API. The `PwmPin` trait seems more useful because it models independent -// PWM channels. Here a certain number of channels are multiplexed in a single implementer. -pub trait Pwm { - /// Enumeration of `Pwm` errors - type Error; - - /// Enumeration of channels that can be used with this `Pwm` interface - /// - /// If your `Pwm` interface has no channels you can use the type `()` - /// here - type Channel; - - /// A time unit that can be converted into a human time unit (e.g. seconds) - type Time; - - /// Type for the `duty` methods - /// - /// The implementer is free to choose a float / percentage representation - /// (e.g. `0.0 .. 1.0`) or an integer representation (e.g. `0 .. 65535`) - type Duty; - - /// Disables a PWM `channel` - fn try_disable(&mut self, channel: Self::Channel) -> Result<(), Self::Error>; - - /// Enables a PWM `channel` - fn try_enable(&mut self, channel: Self::Channel) -> Result<(), Self::Error>; - - /// Returns the current PWM period - fn try_get_period(&self) -> Result; - - /// Returns the current duty cycle - fn try_get_duty(&self, channel: Self::Channel) -> Result; - - /// Returns the maximum duty cycle value - fn try_get_max_duty(&self) -> Result; - - /// Sets a new duty cycle - fn try_set_duty(&mut self, channel: Self::Channel, duty: Self::Duty) - -> Result<(), Self::Error>; - - /// Sets a new PWM period - fn try_set_period

(&mut self, period: P) -> Result<(), Self::Error> - where - P: Into; -} - -/// A single PWM channel / pin -/// -/// See `Pwm` for details -pub trait PwmPin { - /// Enumeration of `PwmPin` errors - type Error; - - /// Type for the `duty` methods - /// - /// The implementer is free to choose a float / percentage representation - /// (e.g. `0.0 .. 1.0`) or an integer representation (e.g. `0 .. 65535`) - type Duty; - - /// Disables a PWM `channel` - fn try_disable(&mut self) -> Result<(), Self::Error>; - - /// Enables a PWM `channel` - fn try_enable(&mut self) -> Result<(), Self::Error>; - - /// Returns the current duty cycle - fn try_get_duty(&self) -> Result; - - /// Returns the maximum duty cycle value - fn try_get_max_duty(&self) -> Result; - - /// Sets a new duty cycle - fn try_set_duty(&mut self, duty: Self::Duty) -> Result<(), Self::Error>; -} - -/// Quadrature encoder interface -/// -/// # Examples -/// -/// You can use this interface to measure the speed of a motor -/// -/// ``` -/// extern crate embedded_hal as hal; -/// #[macro_use(block)] -/// extern crate nb; -/// -/// use hal::prelude::*; -/// -/// fn main() { -/// let mut qei: Qei1 = { -/// // .. -/// # Qei1 -/// }; -/// let mut timer: Timer6 = { -/// // .. -/// # Timer6 -/// }; -/// -/// -/// let before = qei.try_count().unwrap(); -/// timer.try_start(1.s()).unwrap(); -/// block!(timer.try_wait()); -/// let after = qei.try_count().unwrap(); -/// -/// let speed = after.wrapping_sub(before); -/// println!("Speed: {} pulses per second", speed); -/// } -/// -/// # use core::convert::Infallible; -/// # struct Seconds(u32); -/// # trait U32Ext { fn s(self) -> Seconds; } -/// # impl U32Ext for u32 { fn s(self) -> Seconds { Seconds(self) } } -/// # struct Qei1; -/// # impl hal::Qei for Qei1 { -/// # type Error = Infallible; -/// # type Count = u16; -/// # fn try_count(&self) -> Result { Ok(0) } -/// # fn try_direction(&self) -> Result<::hal::Direction, Self::Error> { unimplemented!() } -/// # } -/// # struct Timer6; -/// # impl hal::timer::CountDown for Timer6 { -/// # type Error = Infallible; -/// # type Time = Seconds; -/// # fn try_start(&mut self, _: T) -> Result<(), Infallible> where T: Into { Ok(()) } -/// # fn try_wait(&mut self) -> ::nb::Result<(), Infallible> { Ok(()) } -/// # } -/// ``` -// unproven reason: needs to be re-evaluated in the new singletons world. At the very least this needs a -// reference implementation -pub trait Qei { - /// Enumeration of `Qei` errors - type Error; - - /// The type of the value returned by `count` - type Count; - - /// Returns the current pulse count of the encoder - fn try_count(&self) -> Result; - - /// Returns the count direction - fn try_direction(&self) -> Result; -} - -/// Count direction -#[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub enum Direction { - /// 3, 2, 1 - Downcounting, - /// 1, 2, 3 - Upcounting, -} +mod qei; +pub use qei::{Direction, Qei}; diff --git a/src/pwm.rs b/src/pwm.rs new file mode 100644 index 000000000..c50f05f86 --- /dev/null +++ b/src/pwm.rs @@ -0,0 +1,124 @@ +//! Pulse Width Modulation + +/// Pulse Width Modulation +/// +/// # Examples +/// +/// Use this interface to control the power output of some actuator +/// +/// ``` +/// extern crate embedded_hal as hal; +/// +/// use hal::prelude::*; +/// +/// fn main() { +/// let mut pwm: Pwm1 = { +/// // .. +/// # Pwm1 +/// }; +/// +/// pwm.try_set_period(1.khz()).unwrap(); +/// +/// let max_duty = pwm.try_get_max_duty().unwrap(); +/// +/// // brightest LED +/// pwm.try_set_duty(Channel::_1, max_duty).unwrap(); +/// +/// // dimmer LED +/// pwm.try_set_duty(Channel::_2, max_duty / 4).unwrap(); +/// } +/// +/// # use core::convert::Infallible; +/// # struct KiloHertz(u32); +/// # trait U32Ext { fn khz(self) -> KiloHertz; } +/// # impl U32Ext for u32 { fn khz(self) -> KiloHertz { KiloHertz(self) } } +/// # enum Channel { _1, _2 } +/// # struct Pwm1; +/// # impl hal::Pwm for Pwm1 { +/// # type Error = Infallible; +/// # type Channel = Channel; +/// # type Time = KiloHertz; +/// # type Duty = u16; +/// # fn try_disable(&mut self, _: Channel) -> Result<(), Self::Error> { unimplemented!() } +/// # fn try_enable(&mut self, _: Channel) -> Result<(), Self::Error> { unimplemented!() } +/// # fn try_get_duty(&self, _: Channel) -> Result { unimplemented!() } +/// # fn try_get_max_duty(&self) -> Result { Ok(0) } +/// # fn try_set_duty(&mut self, _: Channel, _: u16) -> Result<(), Self::Error> { Ok(()) } +/// # fn try_get_period(&self) -> Result { unimplemented!() } +/// # fn try_set_period(&mut self, _: T) -> Result<(), Self::Error> where T: Into { Ok(()) } +/// # } +/// ``` +// unproven reason: pre-singletons API. The `PwmPin` trait seems more useful because it models independent +// PWM channels. Here a certain number of channels are multiplexed in a single implementer. +pub trait Pwm { + /// Enumeration of `Pwm` errors + type Error; + + /// Enumeration of channels that can be used with this `Pwm` interface + /// + /// If your `Pwm` interface has no channels you can use the type `()` + /// here + type Channel; + + /// A time unit that can be converted into a human time unit (e.g. seconds) + type Time; + + /// Type for the `duty` methods + /// + /// The implementer is free to choose a float / percentage representation + /// (e.g. `0.0 .. 1.0`) or an integer representation (e.g. `0 .. 65535`) + type Duty; + + /// Disables a PWM `channel` + fn try_disable(&mut self, channel: Self::Channel) -> Result<(), Self::Error>; + + /// Enables a PWM `channel` + fn try_enable(&mut self, channel: Self::Channel) -> Result<(), Self::Error>; + + /// Returns the current PWM period + fn try_get_period(&self) -> Result; + + /// Returns the current duty cycle + fn try_get_duty(&self, channel: Self::Channel) -> Result; + + /// Returns the maximum duty cycle value + fn try_get_max_duty(&self) -> Result; + + /// Sets a new duty cycle + fn try_set_duty(&mut self, channel: Self::Channel, duty: Self::Duty) + -> Result<(), Self::Error>; + + /// Sets a new PWM period + fn try_set_period

(&mut self, period: P) -> Result<(), Self::Error> + where + P: Into; +} + +/// A single PWM channel / pin +/// +/// See `Pwm` for details +pub trait PwmPin { + /// Enumeration of `PwmPin` errors + type Error; + + /// Type for the `duty` methods + /// + /// The implementer is free to choose a float / percentage representation + /// (e.g. `0.0 .. 1.0`) or an integer representation (e.g. `0 .. 65535`) + type Duty; + + /// Disables a PWM `channel` + fn try_disable(&mut self) -> Result<(), Self::Error>; + + /// Enables a PWM `channel` + fn try_enable(&mut self) -> Result<(), Self::Error>; + + /// Returns the current duty cycle + fn try_get_duty(&self) -> Result; + + /// Returns the maximum duty cycle value + fn try_get_max_duty(&self) -> Result; + + /// Sets a new duty cycle + fn try_set_duty(&mut self, duty: Self::Duty) -> Result<(), Self::Error>; +} diff --git a/src/qei.rs b/src/qei.rs new file mode 100644 index 000000000..4a58c3f37 --- /dev/null +++ b/src/qei.rs @@ -0,0 +1,78 @@ +//! Quadrature encoder interface + +/// Quadrature encoder interface +/// +/// # Examples +/// +/// You can use this interface to measure the speed of a motor +/// +/// ``` +/// extern crate embedded_hal as hal; +/// #[macro_use(block)] +/// extern crate nb; +/// +/// use hal::prelude::*; +/// +/// fn main() { +/// let mut qei: Qei1 = { +/// // .. +/// # Qei1 +/// }; +/// let mut timer: Timer6 = { +/// // .. +/// # Timer6 +/// }; +/// +/// +/// let before = qei.try_count().unwrap(); +/// timer.try_start(1.s()).unwrap(); +/// block!(timer.try_wait()); +/// let after = qei.try_count().unwrap(); +/// +/// let speed = after.wrapping_sub(before); +/// println!("Speed: {} pulses per second", speed); +/// } +/// +/// # use core::convert::Infallible; +/// # struct Seconds(u32); +/// # trait U32Ext { fn s(self) -> Seconds; } +/// # impl U32Ext for u32 { fn s(self) -> Seconds { Seconds(self) } } +/// # struct Qei1; +/// # impl hal::Qei for Qei1 { +/// # type Error = Infallible; +/// # type Count = u16; +/// # fn try_count(&self) -> Result { Ok(0) } +/// # fn try_direction(&self) -> Result<::hal::Direction, Self::Error> { unimplemented!() } +/// # } +/// # struct Timer6; +/// # impl hal::timer::CountDown for Timer6 { +/// # type Error = Infallible; +/// # type Time = Seconds; +/// # fn try_start(&mut self, _: T) -> Result<(), Infallible> where T: Into { Ok(()) } +/// # fn try_wait(&mut self) -> ::nb::Result<(), Infallible> { Ok(()) } +/// # } +/// ``` +// unproven reason: needs to be re-evaluated in the new singletons world. At the very least this needs a +// reference implementation +pub trait Qei { + /// Enumeration of `Qei` errors + type Error; + + /// The type of the value returned by `count` + type Count; + + /// Returns the current pulse count of the encoder + fn try_count(&self) -> Result; + + /// Returns the count direction + fn try_direction(&self) -> Result; +} + +/// Count direction +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum Direction { + /// 3, 2, 1 + Downcounting, + /// 1, 2, 3 + Upcounting, +} From 60c9263a83395333f78c0981fadde6876b60c8e9 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Thu, 19 Mar 2020 20:00:10 +0100 Subject: [PATCH 2/2] Expose capture, pwm and qei modules only for consistency --- src/capture.rs | 2 +- src/lib.rs | 12 +++--------- src/prelude.rs | 8 ++++---- src/pwm.rs | 2 +- src/qei.rs | 4 ++-- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/capture.rs b/src/capture.rs index 09073c945..57e79b8f7 100644 --- a/src/capture.rs +++ b/src/capture.rs @@ -38,7 +38,7 @@ use nb; /// # impl U32Ext for u32 { fn ms(self) -> MilliSeconds { MilliSeconds(self) } } /// # struct Capture1; /// # enum Channel { _1 } -/// # impl hal::Capture for Capture1 { +/// # impl hal::capture::Capture for Capture1 { /// # type Error = Infallible; /// # type Capture = u16; /// # type Channel = Channel; diff --git a/src/lib.rs b/src/lib.rs index 83ad2db37..9e04139ff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -688,20 +688,14 @@ extern crate nb; pub mod adc; pub mod blocking; +pub mod capture; pub mod digital; pub mod fmt; pub mod prelude; +pub mod pwm; +pub mod qei; pub mod rng; pub mod serial; pub mod spi; pub mod timer; pub mod watchdog; - -mod capture; -pub use capture::Capture; - -mod pwm; -pub use pwm::{Pwm, PwmPin}; - -mod qei; -pub use qei::{Direction, Qei}; diff --git a/src/prelude.rs b/src/prelude.rs index 8205aef20..223c7222a 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -15,9 +15,13 @@ pub use crate::blocking::serial::Write as _embedded_hal_blocking_serial_Write; pub use crate::blocking::spi::{ Transfer as _embedded_hal_blocking_spi_Transfer, Write as _embedded_hal_blocking_spi_Write, }; +pub use crate::capture::Capture as _embedded_hal_Capture; pub use crate::digital::InputPin as _embedded_hal_digital_InputPin; pub use crate::digital::OutputPin as _embedded_hal_digital_OutputPin; pub use crate::digital::ToggleableOutputPin as _embedded_hal_digital_ToggleableOutputPin; +pub use crate::pwm::Pwm as _embedded_hal_Pwm; +pub use crate::pwm::PwmPin as _embedded_hal_PwmPin; +pub use crate::qei::Qei as _embedded_hal_Qei; pub use crate::rng::Read as _embedded_hal_rng_Read; pub use crate::serial::Read as _embedded_hal_serial_Read; pub use crate::serial::Write as _embedded_hal_serial_Write; @@ -26,7 +30,3 @@ pub use crate::timer::CountDown as _embedded_hal_timer_CountDown; pub use crate::watchdog::Watchdog as _embedded_hal_watchdog_Watchdog; pub use crate::watchdog::WatchdogDisable as _embedded_hal_watchdog_WatchdogDisable; pub use crate::watchdog::WatchdogEnable as _embedded_hal_watchdog_WatchdogEnable; -pub use crate::Capture as _embedded_hal_Capture; -pub use crate::Pwm as _embedded_hal_Pwm; -pub use crate::PwmPin as _embedded_hal_PwmPin; -pub use crate::Qei as _embedded_hal_Qei; diff --git a/src/pwm.rs b/src/pwm.rs index c50f05f86..eaa6a92d6 100644 --- a/src/pwm.rs +++ b/src/pwm.rs @@ -34,7 +34,7 @@ /// # impl U32Ext for u32 { fn khz(self) -> KiloHertz { KiloHertz(self) } } /// # enum Channel { _1, _2 } /// # struct Pwm1; -/// # impl hal::Pwm for Pwm1 { +/// # impl hal::pwm::Pwm for Pwm1 { /// # type Error = Infallible; /// # type Channel = Channel; /// # type Time = KiloHertz; diff --git a/src/qei.rs b/src/qei.rs index 4a58c3f37..75cfb667d 100644 --- a/src/qei.rs +++ b/src/qei.rs @@ -38,11 +38,11 @@ /// # trait U32Ext { fn s(self) -> Seconds; } /// # impl U32Ext for u32 { fn s(self) -> Seconds { Seconds(self) } } /// # struct Qei1; -/// # impl hal::Qei for Qei1 { +/// # impl hal::qei::Qei for Qei1 { /// # type Error = Infallible; /// # type Count = u16; /// # fn try_count(&self) -> Result { Ok(0) } -/// # fn try_direction(&self) -> Result<::hal::Direction, Self::Error> { unimplemented!() } +/// # fn try_direction(&self) -> Result<::hal::qei::Direction, Self::Error> { unimplemented!() } /// # } /// # struct Timer6; /// # impl hal::timer::CountDown for Timer6 {