Skip to content

Commit f78ff85

Browse files
refactor(esp-hal-buzzer): Remove generic timer speed from Buzzer. (#11)
- Only esp32 supports HighSpeed timer for LEDC. Every device supports LowSpeed. - This simplifies the type contraints over a Buzzer instance.
1 parent ca61099 commit f78ff85

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

esp-hal-buzzer/src/lib.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use esp_hal::{
3939
gpio::{AnyPin, Level, Output, OutputPin, Pin},
4040
ledc::{
4141
channel::{self, Channel, ChannelIFace},
42-
timer::{self, Timer, TimerHW, TimerIFace, TimerSpeed},
42+
timer::{self, Timer, TimerIFace},
4343
Ledc, LowSpeed,
4444
},
4545
peripheral::{Peripheral, PeripheralRef},
@@ -124,20 +124,15 @@ struct Volume {
124124
}
125125

126126
/// A buzzer instance driven by Ledc
127-
pub struct Buzzer<'a, S: TimerSpeed, O: OutputPin> {
128-
timer: Timer<'a, S>,
127+
pub struct Buzzer<'a, O: OutputPin> {
128+
timer: Timer<'a, LowSpeed>,
129129
channel_number: channel::Number,
130130
output_pin: PeripheralRef<'a, O>,
131131
delay: Delay,
132132
volume: Option<Volume>,
133133
}
134134

135-
impl<'a, S: TimerSpeed, O: OutputPin + Peripheral<P = O>> Buzzer<'a, S, O>
136-
where
137-
S: TimerSpeed<ClockSourceType = timer::LSClockSource>,
138-
Timer<'a, S>: TimerHW<S>,
139-
Timer<'a, S>: TimerIFace<LowSpeed>,
140-
{
135+
impl<'a, O: OutputPin + Peripheral<P = O>> Buzzer<'a, O> {
141136
/// Create a new buzzer for the given pin
142137
pub fn new(
143138
ledc: &'a Ledc,

0 commit comments

Comments
 (0)