From 8432e0fb49c6df9e1d9f1a2951090f7f879babf5 Mon Sep 17 00:00:00 2001 From: Anthony Grondin <104731965+AnthonyGrondin@users.noreply.github.com> Date: Thu, 24 Oct 2024 01:46:16 -0400 Subject: [PATCH] refactor(esp-hal-buzzer): Remove generic timer speed from Buzzer. - Only esp32 supports HighSpeed timer for LEDC. Every device supports LowSpeed. - This simplifies the type contraints over a Buzzer instance. --- esp-hal-buzzer/src/lib.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/esp-hal-buzzer/src/lib.rs b/esp-hal-buzzer/src/lib.rs index 334d5dc..02cce56 100644 --- a/esp-hal-buzzer/src/lib.rs +++ b/esp-hal-buzzer/src/lib.rs @@ -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}, @@ -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, } -impl<'a, S: TimerSpeed, O: OutputPin + Peripheral

> Buzzer<'a, S, O> -where - S: TimerSpeed, - Timer<'a, S>: TimerHW, - Timer<'a, S>: TimerIFace, -{ +impl<'a, O: OutputPin + Peripheral

> Buzzer<'a, O> { /// Create a new buzzer for the given pin pub fn new( ledc: &'a Ledc,