mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-26 00:32:33 +00:00
Implemented Pwm trait for complementary pwm from embedded_hal
This commit is contained in:
parent
b217d147de
commit
710874021a
@ -122,6 +122,46 @@ impl<'d, T: ComplementaryCaptureCompare16bitInstance> ComplementaryPwm<'d, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d, T: ComplementaryCaptureCompare16bitInstance> embedded_hal_02::Pwm for ComplementaryPwm<'d, T> {
|
||||
type Channel = Channel;
|
||||
type Time = Hertz;
|
||||
type Duty = u16;
|
||||
|
||||
fn disable(&mut self, channel: Self::Channel) {
|
||||
self.inner.enable_complementary_channel(channel, false);
|
||||
self.inner.enable_channel(channel, false);
|
||||
}
|
||||
|
||||
fn enable(&mut self, channel: Self::Channel) {
|
||||
self.inner.enable_channel(channel, true);
|
||||
self.inner.enable_complementary_channel(channel, true);
|
||||
}
|
||||
|
||||
fn get_period(&self) -> Self::Time {
|
||||
self.inner.get_frequency().into()
|
||||
}
|
||||
|
||||
fn get_duty(&self, channel: Self::Channel) -> Self::Duty {
|
||||
self.inner.get_compare_value(channel)
|
||||
}
|
||||
|
||||
fn get_max_duty(&self) -> Self::Duty {
|
||||
self.inner.get_max_compare_value() + 1
|
||||
}
|
||||
|
||||
fn set_duty(&mut self, channel: Self::Channel, duty: Self::Duty) {
|
||||
assert!(duty <= self.get_max_duty());
|
||||
self.inner.set_compare_value(channel, duty)
|
||||
}
|
||||
|
||||
fn set_period<P>(&mut self, period: P)
|
||||
where
|
||||
P: Into<Self::Time>,
|
||||
{
|
||||
self.inner.set_frequency(period.into());
|
||||
}
|
||||
}
|
||||
|
||||
fn compute_dead_time_value(value: u16) -> (Ckd, u8) {
|
||||
/*
|
||||
Dead-time = T_clk * T_dts * T_dtg
|
||||
|
Loading…
Reference in New Issue
Block a user