Skip to content

Commit

Permalink
refactor(esp-hal-buzzer): Remove generic timer speed from Buzzer.
Browse files Browse the repository at this point in the history
- Only esp32 supports HighSpeed timer for LEDC. Every device supports LowSpeed.
- This simplifies the type contraints over a Buzzer instance.
  • Loading branch information
AnthonyGrondin committed Oct 24, 2024
1 parent ca61099 commit 8432e0f
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions esp-hal-buzzer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use esp_hal::{
gpio::{AnyPin, Level, Output, OutputPin, Pin},
ledc::{
channel::{self, Channel, ChannelIFace},
timer::{self, Timer, TimerHW, TimerIFace, TimerSpeed},
timer::{self, Timer, TimerIFace},
Ledc, LowSpeed,
},
peripheral::{Peripheral, PeripheralRef},
Expand Down Expand Up @@ -124,20 +124,15 @@ struct Volume {
}

/// A buzzer instance driven by Ledc
pub struct Buzzer<'a, S: TimerSpeed, O: OutputPin> {
timer: Timer<'a, S>,
pub struct Buzzer<'a, O: OutputPin> {
timer: Timer<'a, LowSpeed>,
channel_number: channel::Number,
output_pin: PeripheralRef<'a, O>,
delay: Delay,
volume: Option<Volume>,
}

impl<'a, S: TimerSpeed, O: OutputPin + Peripheral<P = O>> Buzzer<'a, S, O>
where
S: TimerSpeed<ClockSourceType = timer::LSClockSource>,
Timer<'a, S>: TimerHW<S>,
Timer<'a, S>: TimerIFace<LowSpeed>,
{
impl<'a, O: OutputPin + Peripheral<P = O>> Buzzer<'a, O> {
/// Create a new buzzer for the given pin
pub fn new(
ledc: &'a Ledc,
Expand Down

0 comments on commit 8432e0f

Please sign in to comment.