diff --git a/esp-hal-common/src/ledc/mod.rs b/esp-hal-common/src/ledc/mod.rs index 04efb51df..64b99bad6 100644 --- a/esp-hal-common/src/ledc/mod.rs +++ b/esp-hal-common/src/ledc/mod.rs @@ -11,7 +11,7 @@ //! 10% duty using the ABPClock //! //! ```rust,ignore -//! let mut ledc = LEDC::new(&clock_control, &mut system.peripheral_clock_control); +//! let mut ledc = LEDC::new(peripherals.LEDC, &clock_control, &mut system.peripheral_clock_control); //! ledc.set_global_slow_clock(LSGlobalClkSource::APBClk); //! //! let mut lstimer0 = ledc.get_timer::(timer::Number::Timer0); @@ -38,7 +38,7 @@ //! 10% duty using the ABPClock //! //! ```rust,ignore -//! let ledc = LEDC::new(&clock_control, &mut system.peripheral_clock_control); +//! let ledc = LEDC::new(peripherals.LEDC, &clock_control, &mut system.peripheral_clock_control); //! //! let mut hstimer0 = ledc.get_timer::(timer::Number::Timer0); //! hstimer0 @@ -85,6 +85,7 @@ pub enum LSGlobalClkSource { /// LEDC (LED PWM Controller) pub struct LEDC<'a> { + _instance: crate::pac::LEDC, ledc: &'a crate::pac::ledc::RegisterBlock, clock_control_config: &'a Clocks, } @@ -105,11 +106,12 @@ impl Speed for LowSpeed {} impl<'a> LEDC<'a> { /// Return a new LEDC - pub fn new(clock_control_config: &'a Clocks, system: &mut PeripheralClockControl) -> Self { + pub fn new(_instance: crate::pac::LEDC, clock_control_config: &'a Clocks, system: &mut PeripheralClockControl) -> Self { system.enable(Peripheral::Ledc); let ledc = unsafe { &*crate::pac::LEDC::ptr() }; LEDC { + _instance, ledc, clock_control_config, } diff --git a/esp32-hal/examples/ledc.rs b/esp32-hal/examples/ledc.rs index 1ffeaa29a..a331fc42d 100644 --- a/esp32-hal/examples/ledc.rs +++ b/esp32-hal/examples/ledc.rs @@ -46,7 +46,7 @@ fn main() -> ! { writeln!(serial0, "\nESP32 Started\n\n").unwrap(); - let ledc = LEDC::new(&clocks, &mut system.peripheral_clock_control); + let ledc = LEDC::new(peripherals.LEDC, &clocks, &mut system.peripheral_clock_control); let mut hstimer0 = ledc.get_timer::(timer::Number::Timer0); diff --git a/esp32c3-hal/examples/ledc.rs b/esp32c3-hal/examples/ledc.rs index 62d2576e1..e65cb2119 100644 --- a/esp32c3-hal/examples/ledc.rs +++ b/esp32c3-hal/examples/ledc.rs @@ -49,7 +49,7 @@ fn main() -> ! { esp_println::println!("\nESP32C3 Started\n\n"); - let mut ledc = LEDC::new(&clocks, &mut system.peripheral_clock_control); + let mut ledc = LEDC::new(peripherals.LEDC, &clocks, &mut system.peripheral_clock_control); ledc.set_global_slow_clock(LSGlobalClkSource::APBClk); diff --git a/esp32s2-hal/examples/ledc.rs b/esp32s2-hal/examples/ledc.rs index 7fbf579d8..f908c4e07 100644 --- a/esp32s2-hal/examples/ledc.rs +++ b/esp32s2-hal/examples/ledc.rs @@ -47,7 +47,7 @@ fn main() -> ! { esp_println::println!("\nESP32S2 Started\n\n"); - let mut ledc = LEDC::new(&clocks, &mut system.peripheral_clock_control); + let mut ledc = LEDC::new(peripherals.LEDC, &clocks, &mut system.peripheral_clock_control); ledc.set_global_slow_clock(LSGlobalClkSource::APBClk); diff --git a/esp32s3-hal/examples/ledc.rs b/esp32s3-hal/examples/ledc.rs index 52d09c317..e7e7016d9 100644 --- a/esp32s3-hal/examples/ledc.rs +++ b/esp32s3-hal/examples/ledc.rs @@ -47,7 +47,7 @@ fn main() -> ! { esp_println::println!("\nESP32S3 Started\n\n"); - let mut ledc = LEDC::new(&clocks, &mut system.peripheral_clock_control); + let mut ledc = LEDC::new(peripherals.LEDC, &clocks, &mut system.peripheral_clock_control); ledc.set_global_slow_clock(LSGlobalClkSource::APBClk);