aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrafael <[email protected]>2024-10-21 11:54:17 +0200
committerrafael <[email protected]>2024-10-21 11:54:17 +0200
commit693bd8c6ded003f78ae89fa2700ba7282fee64d0 (patch)
tree9d93f412b46cdcd7bcfda3bee98468b4e1bbf67e
parent8baf88f8f4668bdb54c1415bdb8ad62cf2fa5f24 (diff)
re-export SetDutyCycle for user convenience
-rw-r--r--embassy-rp/src/pwm.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/embassy-rp/src/pwm.rs b/embassy-rp/src/pwm.rs
index 79e626802..de2c2f81e 100644
--- a/embassy-rp/src/pwm.rs
+++ b/embassy-rp/src/pwm.rs
@@ -1,7 +1,7 @@
1//! Pulse Width Modulation (PWM) 1//! Pulse Width Modulation (PWM)
2 2
3use embassy_hal_internal::{into_ref, Peripheral, PeripheralRef}; 3use embassy_hal_internal::{into_ref, Peripheral, PeripheralRef};
4use embedded_hal_1::pwm::{Error, ErrorKind, ErrorType, SetDutyCycle}; 4use embedded_hal_1::pwm::{Error, ErrorKind, ErrorType};
5use fixed::traits::ToFixed; 5use fixed::traits::ToFixed;
6use fixed::FixedU16; 6use fixed::FixedU16;
7use pac::pwm::regs::{ChDiv, Intr}; 7use pac::pwm::regs::{ChDiv, Intr};
@@ -10,6 +10,8 @@ use pac::pwm::vals::Divmode;
10use crate::gpio::{AnyPin, Pin as GpioPin, Pull, SealedPin as _}; 10use crate::gpio::{AnyPin, Pin as GpioPin, Pull, SealedPin as _};
11use crate::{pac, peripherals, RegExt}; 11use crate::{pac, peripherals, RegExt};
12 12
13pub use embedded_hal_1::pwm::SetDutyCycle;
14
13/// The configuration of a PWM slice. 15/// The configuration of a PWM slice.
14/// Note the period in clock cycles of a slice can be computed as: 16/// Note the period in clock cycles of a slice can be computed as:
15/// `(top + 1) * (phase_correct ? 1 : 2) * divider` 17/// `(top + 1) * (phase_correct ? 1 : 2) * divider`
@@ -113,9 +115,7 @@ impl<'d> SetDutyCycle for Pwm<'d> {
113 } 115 }
114 116
115 fn set_duty_cycle(&mut self, duty: u16) -> Result<(), Self::Error> { 117 fn set_duty_cycle(&mut self, duty: u16) -> Result<(), Self::Error> {
116 info!("duty {}",&duty);
117 let max_duty = self.max_duty_cycle(); 118 let max_duty = self.max_duty_cycle();
118 info!("max duty {}", &max_duty);
119 if duty > max_duty { 119 if duty > max_duty {
120 return Err(PwmError::InvalidDutyCycle); 120 return Err(PwmError::InvalidDutyCycle);
121 } 121 }