Skip to content

Commit d568009

Browse files
committed
both embedded-hals for PwmPin
1 parent 4f1c2ef commit d568009

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

src/pwm.rs

+25-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use crate::{
2-
bb, hal as pwm,
2+
bb,
33
time::Hertz,
44
timer::{General, Timer},
55
};
66
use cast::u16;
7-
use core::{marker::PhantomData, mem::MaybeUninit};
7+
use core::{convert::Infallible, marker::PhantomData, mem::MaybeUninit};
88

99
pub trait Pins<TIM, P> {
1010
const C1: bool = false;
@@ -132,8 +132,9 @@ macro_rules! pwm_pin {
132132
}
133133
}
134134

135-
impl pwm::PwmPin for PwmChannels<$TIMX, $C> {
135+
impl embedded_hal::PwmPin for PwmChannels<$TIMX, $C> {
136136
type Duty = u16;
137+
137138
fn disable(&mut self) {
138139
self.disable()
139140
}
@@ -150,6 +151,27 @@ macro_rules! pwm_pin {
150151
self.set_duty(duty)
151152
}
152153
}
154+
155+
impl embedded_hal_one::pwm::blocking::PwmPin for PwmChannels<$TIMX, $C> {
156+
type Error = Infallible;
157+
type Duty = u16;
158+
159+
fn disable(&mut self) -> Result<(), Self::Error> {
160+
Ok(self.disable())
161+
}
162+
fn enable(&mut self) -> Result<(), Self::Error> {
163+
Ok(self.enable())
164+
}
165+
fn get_duty(&self) -> Result<Self::Duty, Self::Error> {
166+
Ok(self.get_duty())
167+
}
168+
fn get_max_duty(&self) -> Result<Self::Duty, Self::Error> {
169+
Ok(self.get_max_duty())
170+
}
171+
fn set_duty(&mut self, duty: Self::Duty) -> Result<(), Self::Error> {
172+
Ok(self.set_duty(duty))
173+
}
174+
}
153175
};
154176
}
155177

0 commit comments

Comments
 (0)