From 178a05522ded1b7f676400db173856dfd0933f80 Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Wed, 29 Jun 2022 11:39:33 -0700 Subject: [PATCH] Update all examples to reflect changes to `Timer` API --- esp32-hal/examples/blinky.rs | 2 +- esp32-hal/examples/gpio_interrupt.rs | 2 +- esp32-hal/examples/hello_rgb.rs | 2 +- esp32-hal/examples/hello_world.rs | 8 +++++--- esp32-hal/examples/i2c_display.rs | 4 ++-- esp32-hal/examples/ram.rs | 7 +++++-- esp32-hal/examples/read_efuse.rs | 14 ++++++++++++-- esp32-hal/examples/spi_loopback.rs | 2 +- esp32-hal/examples/timer_interrupt.rs | 15 +++++++++------ esp32c3-hal/examples/blinky.rs | 4 ++-- esp32c3-hal/examples/gpio_interrupt.rs | 4 ++-- esp32c3-hal/examples/hello_rgb.rs | 2 +- esp32c3-hal/examples/hello_world.rs | 10 ++++++---- esp32c3-hal/examples/i2c_display.rs | 6 +++--- esp32c3-hal/examples/ram.rs | 12 ++++++++---- esp32c3-hal/examples/read_efuse.rs | 16 +++++++++++++--- esp32c3-hal/examples/spi_loopback.rs | 4 ++-- esp32c3-hal/examples/systimer.rs | 7 +++++-- esp32c3-hal/examples/timer_interrupt.rs | 15 +++++++++------ esp32c3-hal/examples/usb_serial_jtag.rs | 4 ++-- esp32s2-hal/examples/blinky.rs | 2 +- esp32s2-hal/examples/gpio_interrupt.rs | 2 +- esp32s2-hal/examples/hello_rgb.rs | 2 +- esp32s2-hal/examples/hello_world.rs | 8 +++++--- esp32s2-hal/examples/i2c_display.rs | 4 ++-- esp32s2-hal/examples/ram.rs | 7 +++++-- esp32s2-hal/examples/read_efuse.rs | 14 ++++++++++++-- esp32s2-hal/examples/spi_loopback.rs | 2 +- esp32s2-hal/examples/systimer.rs | 2 +- esp32s2-hal/examples/timer_interrupt.rs | 15 +++++++++------ esp32s3-hal/examples/blinky.rs | 2 +- esp32s3-hal/examples/gpio_interrupt.rs | 2 +- esp32s3-hal/examples/hello_rgb.rs | 2 +- esp32s3-hal/examples/hello_world.rs | 8 +++++--- esp32s3-hal/examples/i2c_display.rs | 4 ++-- esp32s3-hal/examples/ram.rs | 7 +++++-- esp32s3-hal/examples/read_efuse.rs | 14 ++++++++++++-- esp32s3-hal/examples/spi_loopback.rs | 2 +- esp32s3-hal/examples/systimer.rs | 2 +- esp32s3-hal/examples/timer_interrupt.rs | 15 +++++++++------ esp32s3-hal/examples/usb_serial_jtag.rs | 2 +- 41 files changed, 167 insertions(+), 91 deletions(-) diff --git a/esp32-hal/examples/blinky.rs b/esp32-hal/examples/blinky.rs index e13b70b4f..c3500711d 100644 --- a/esp32-hal/examples/blinky.rs +++ b/esp32-hal/examples/blinky.rs @@ -19,7 +19,7 @@ fn main() -> ! { let system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); // Disable MWDT and RWDT (Watchdog) flash boot protection diff --git a/esp32-hal/examples/gpio_interrupt.rs b/esp32-hal/examples/gpio_interrupt.rs index 3180664d7..9643fd91f 100644 --- a/esp32-hal/examples/gpio_interrupt.rs +++ b/esp32-hal/examples/gpio_interrupt.rs @@ -32,7 +32,7 @@ fn main() -> ! { let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); // Disable the TIMG watchdog timer. - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let serial0 = Serial::new(peripherals.UART0).unwrap(); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); diff --git a/esp32-hal/examples/hello_rgb.rs b/esp32-hal/examples/hello_rgb.rs index f3092862a..9446f9637 100644 --- a/esp32-hal/examples/hello_rgb.rs +++ b/esp32-hal/examples/hello_rgb.rs @@ -41,7 +41,7 @@ fn main() -> ! { let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); // Disable MWDT and RWDT (Watchdog) flash boot protection diff --git a/esp32-hal/examples/hello_world.rs b/esp32-hal/examples/hello_world.rs index def2f3b69..96ba92e41 100644 --- a/esp32-hal/examples/hello_world.rs +++ b/esp32-hal/examples/hello_world.rs @@ -3,7 +3,7 @@ use core::fmt::Write; -use esp32_hal::{pac::Peripherals, prelude::*, RtcCntl, Serial, Timer}; +use esp32_hal::{clock::ClockControl, pac::Peripherals, prelude::*, RtcCntl, Serial, Timer}; use nb::block; use panic_halt as _; use xtensa_lx_rt::entry; @@ -11,8 +11,10 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { let peripherals = Peripherals::take().unwrap(); + let system = peripherals.DPORT.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); @@ -20,7 +22,7 @@ fn main() -> ! { timer0.disable(); rtc_cntl.set_wdt_global_enable(false); - timer0.start(10_000_000u64); + timer0.start(1u64.secs()); loop { writeln!(serial0, "Hello world!").unwrap(); diff --git a/esp32-hal/examples/i2c_display.rs b/esp32-hal/examples/i2c_display.rs index d6144f3c3..8441b546a 100644 --- a/esp32-hal/examples/i2c_display.rs +++ b/esp32-hal/examples/i2c_display.rs @@ -42,7 +42,7 @@ fn main() -> ! { let mut system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); @@ -67,7 +67,7 @@ fn main() -> ! { .unwrap(); // Start timer (5 second interval) - timer0.start(50_000_000u64); + timer0.start(5u64.secs()); writeln!(serial0, "Starting timer!").unwrap(); diff --git a/esp32-hal/examples/ram.rs b/esp32-hal/examples/ram.rs index 5a27b5e8a..f5a93133f 100644 --- a/esp32-hal/examples/ram.rs +++ b/esp32-hal/examples/ram.rs @@ -4,6 +4,7 @@ use core::fmt::Write; use esp32_hal::{ + clock::ClockControl, pac::{Peripherals, UART0}, prelude::*, ram, @@ -26,8 +27,10 @@ static mut SOME_ZEROED_DATA: [u8; 8] = [0; 8]; #[entry] fn main() -> ! { let peripherals = Peripherals::take().unwrap(); + let system = peripherals.DPORT.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); // Disable MWDT flash boot protection @@ -35,7 +38,7 @@ fn main() -> ! { // The RWDT flash boot protection remains enabled and it being triggered is part // of the example - timer0.start(10_000_000u64); + timer0.start(1u64.secs()); writeln!( serial0, diff --git a/esp32-hal/examples/read_efuse.rs b/esp32-hal/examples/read_efuse.rs index df96b044f..43613fc56 100644 --- a/esp32-hal/examples/read_efuse.rs +++ b/esp32-hal/examples/read_efuse.rs @@ -3,15 +3,25 @@ use core::fmt::Write; -use esp32_hal::{efuse::Efuse, pac::Peripherals, prelude::*, RtcCntl, Serial, Timer}; +use esp32_hal::{ + clock::ClockControl, + efuse::Efuse, + pac::Peripherals, + prelude::*, + RtcCntl, + Serial, + Timer, +}; use panic_halt as _; use xtensa_lx_rt::entry; #[entry] fn main() -> ! { let peripherals = Peripherals::take().unwrap(); + let system = peripherals.DPORT.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); diff --git a/esp32-hal/examples/spi_loopback.rs b/esp32-hal/examples/spi_loopback.rs index ebdf614e8..8b7dca4f2 100644 --- a/esp32-hal/examples/spi_loopback.rs +++ b/esp32-hal/examples/spi_loopback.rs @@ -41,7 +41,7 @@ fn main() -> ! { // Disable the watchdog timers. For the ESP32-C3, this includes the Super WDT, // the RTC WDT, and the TIMG WDTs. let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); timer0.disable(); diff --git a/esp32-hal/examples/timer_interrupt.rs b/esp32-hal/examples/timer_interrupt.rs index df084ce75..5e06832d4 100644 --- a/esp32-hal/examples/timer_interrupt.rs +++ b/esp32-hal/examples/timer_interrupt.rs @@ -4,6 +4,7 @@ use core::{cell::RefCell, fmt::Write}; use esp32_hal::{ + clock::ClockControl, interrupt, pac::{self, Peripherals, TIMG0, TIMG1, UART0}, prelude::*, @@ -26,10 +27,12 @@ static mut TIMER1: SpinLockMutex>>> = #[entry] fn main() -> ! { let peripherals = Peripherals::take().unwrap(); + let system = peripherals.DPORT.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); // Disable the TIMG watchdog timer. - let mut timer0 = Timer::new(peripherals.TIMG0); - let mut timer1 = Timer::new(peripherals.TIMG1); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); + let mut timer1 = Timer::new(peripherals.TIMG1, clocks.apb_clock); let serial0 = Serial::new(peripherals.UART0).unwrap(); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); @@ -43,7 +46,7 @@ fn main() -> ! { pac::Interrupt::TG0_T0_LEVEL, interrupt::CpuInterrupt::Interrupt20LevelPriority2, ); - timer0.start(50_000_000u64); + timer0.start(500u64.millis()); timer0.listen(); interrupt::enable( @@ -51,7 +54,7 @@ fn main() -> ! { pac::Interrupt::TG1_T0_LEVEL, interrupt::CpuInterrupt::Interrupt23LevelPriority3, ); - timer1.start(100_000_000u64); + timer1.start(1u64.secs()); timer1.listen(); unsafe { @@ -89,7 +92,7 @@ pub fn level2_interrupt() { let mut timer0 = data.borrow_mut(); let timer0 = timer0.as_mut().unwrap(); timer0.clear_interrupt(); - timer0.start(50_000_000u64); + timer0.start(500u64.millis()); }); } } @@ -114,7 +117,7 @@ pub fn level3_interrupt() { let mut timer1 = data.borrow_mut(); let timer1 = timer1.as_mut().unwrap(); timer1.clear_interrupt(); - timer1.start(100_000_000u64); + timer1.start(1u64.secs()); }); } } diff --git a/esp32c3-hal/examples/blinky.rs b/esp32c3-hal/examples/blinky.rs index 0587c343b..c856d6226 100644 --- a/esp32c3-hal/examples/blinky.rs +++ b/esp32c3-hal/examples/blinky.rs @@ -23,8 +23,8 @@ fn main() -> ! { // Disable the watchdog timers. For the ESP32-C3, this includes the Super WDT, // the RTC WDT, and the TIMG WDTs. let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); - let mut timer0 = Timer::new(peripherals.TIMG0); - let mut timer1 = Timer::new(peripherals.TIMG1); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); + let mut timer1 = Timer::new(peripherals.TIMG1, clocks.apb_clock); rtc_cntl.set_super_wdt_enable(false); rtc_cntl.set_wdt_enable(false); diff --git a/esp32c3-hal/examples/gpio_interrupt.rs b/esp32c3-hal/examples/gpio_interrupt.rs index 1cee470c7..597bd9894 100644 --- a/esp32c3-hal/examples/gpio_interrupt.rs +++ b/esp32c3-hal/examples/gpio_interrupt.rs @@ -32,8 +32,8 @@ fn main() -> ! { // Disable the watchdog timers. For the ESP32-C3, this includes the Super WDT, // the RTC WDT, and the TIMG WDTs. let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); - let mut timer0 = Timer::new(peripherals.TIMG0); - let mut timer1 = Timer::new(peripherals.TIMG1); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); + let mut timer1 = Timer::new(peripherals.TIMG1, clocks.apb_clock); let serial0 = Serial::new(peripherals.UART0).unwrap(); rtc_cntl.set_super_wdt_enable(false); diff --git a/esp32c3-hal/examples/hello_rgb.rs b/esp32c3-hal/examples/hello_rgb.rs index d0ceb1e27..a658e5fc4 100644 --- a/esp32c3-hal/examples/hello_rgb.rs +++ b/esp32c3-hal/examples/hello_rgb.rs @@ -40,7 +40,7 @@ fn main() -> ! { let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); // Disable watchdogs diff --git a/esp32c3-hal/examples/hello_world.rs b/esp32c3-hal/examples/hello_world.rs index bd744d060..32c38454e 100644 --- a/esp32c3-hal/examples/hello_world.rs +++ b/esp32c3-hal/examples/hello_world.rs @@ -3,7 +3,7 @@ use core::fmt::Write; -use esp32c3_hal::{pac::Peripherals, prelude::*, RtcCntl, Serial, Timer}; +use esp32c3_hal::{clock::ClockControl, pac::Peripherals, prelude::*, RtcCntl, Serial, Timer}; use nb::block; use panic_halt as _; use riscv_rt::entry; @@ -11,11 +11,13 @@ use riscv_rt::entry; #[entry] fn main() -> ! { let peripherals = Peripherals::take().unwrap(); + let system = peripherals.SYSTEM.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); - let mut timer0 = Timer::new(peripherals.TIMG0); - let mut timer1 = Timer::new(peripherals.TIMG1); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); + let mut timer1 = Timer::new(peripherals.TIMG1, clocks.apb_clock); // Disable watchdog timers rtc_cntl.set_super_wdt_enable(false); @@ -23,7 +25,7 @@ fn main() -> ! { timer0.disable(); timer1.disable(); - timer0.start(10_000_000u64); + timer0.start(1u64.secs()); loop { writeln!(serial0, "Hello world!").unwrap(); diff --git a/esp32c3-hal/examples/i2c_display.rs b/esp32c3-hal/examples/i2c_display.rs index 7df4346e3..9dd52534f 100644 --- a/esp32c3-hal/examples/i2c_display.rs +++ b/esp32c3-hal/examples/i2c_display.rs @@ -40,8 +40,8 @@ fn main() -> ! { let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); - let mut timer0 = Timer::new(peripherals.TIMG0); - let mut timer1 = Timer::new(peripherals.TIMG1); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); + let mut timer1 = Timer::new(peripherals.TIMG1, clocks.apb_clock); // Disable watchdog timers rtc_cntl.set_super_wdt_enable(false); @@ -64,7 +64,7 @@ fn main() -> ! { .unwrap(); // Start timer (5 second interval) - timer0.start(50_000_000u64); + timer0.start(5u64.secs()); // Initialize display let interface = I2CDisplayInterface::new(i2c); diff --git a/esp32c3-hal/examples/ram.rs b/esp32c3-hal/examples/ram.rs index 23ae3d32b..ee87bc9b7 100644 --- a/esp32c3-hal/examples/ram.rs +++ b/esp32c3-hal/examples/ram.rs @@ -4,7 +4,8 @@ use core::fmt::Write; use esp32c3_hal::{ - pac::{self, UART0}, + clock::ClockControl, + pac::{Peripherals, UART0}, prelude::*, ram, Serial, @@ -25,8 +26,11 @@ static mut SOME_ZEROED_DATA: [u8; 8] = [0; 8]; #[entry] fn main() -> ! { - let peripherals = pac::Peripherals::take().unwrap(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let peripherals = Peripherals::take().unwrap(); + let system = peripherals.SYSTEM.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); + + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); // Disable MWDT flash boot protection @@ -34,7 +38,7 @@ fn main() -> ! { // The RWDT flash boot protection remains enabled and it being triggered is part // of the example - timer0.start(10_000_000u64); + timer0.start(1u64.secs()); writeln!( serial0, diff --git a/esp32c3-hal/examples/read_efuse.rs b/esp32c3-hal/examples/read_efuse.rs index 65923a703..a6bfced88 100644 --- a/esp32c3-hal/examples/read_efuse.rs +++ b/esp32c3-hal/examples/read_efuse.rs @@ -3,18 +3,28 @@ use core::fmt::Write; -use esp32c3_hal::{efuse::Efuse, pac::Peripherals, prelude::*, RtcCntl, Serial, Timer}; +use esp32c3_hal::{ + clock::ClockControl, + efuse::Efuse, + pac::Peripherals, + prelude::*, + RtcCntl, + Serial, + Timer, +}; use panic_halt as _; use riscv_rt::entry; #[entry] fn main() -> ! { let peripherals = Peripherals::take().unwrap(); + let system = peripherals.SYSTEM.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); - let mut timer0 = Timer::new(peripherals.TIMG0); - let mut timer1 = Timer::new(peripherals.TIMG1); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); + let mut timer1 = Timer::new(peripherals.TIMG1, clocks.apb_clock); // Disable watchdog timers rtc_cntl.set_super_wdt_enable(false); diff --git a/esp32c3-hal/examples/spi_loopback.rs b/esp32c3-hal/examples/spi_loopback.rs index 1272fb6d4..5de240088 100644 --- a/esp32c3-hal/examples/spi_loopback.rs +++ b/esp32c3-hal/examples/spi_loopback.rs @@ -41,8 +41,8 @@ fn main() -> ! { // Disable the watchdog timers. For the ESP32-C3, this includes the Super WDT, // the RTC WDT, and the TIMG WDTs. let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); - let mut timer0 = Timer::new(peripherals.TIMG0); - let mut timer1 = Timer::new(peripherals.TIMG1); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); + let mut timer1 = Timer::new(peripherals.TIMG1, clocks.apb_clock); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); rtc_cntl.set_super_wdt_enable(false); diff --git a/esp32c3-hal/examples/systimer.rs b/esp32c3-hal/examples/systimer.rs index a333c28af..59b859e53 100644 --- a/esp32c3-hal/examples/systimer.rs +++ b/esp32c3-hal/examples/systimer.rs @@ -5,6 +5,7 @@ use core::{cell::RefCell, fmt::Write}; use bare_metal::Mutex; use esp32c3_hal::{ + clock::ClockControl, interrupt, pac::{self, Peripherals, UART0}, prelude::*, @@ -25,12 +26,14 @@ static mut ALARM2: Mutex>>> = Mutex::new(RefCell #[entry] fn main() -> ! { let peripherals = Peripherals::take().unwrap(); + let system = peripherals.SYSTEM.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); // Disable the watchdog timers. For the ESP32-C3, this includes the Super WDT, // the RTC WDT, and the TIMG WDTs. let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); - let mut timer0 = Timer::new(peripherals.TIMG0); - let mut timer1 = Timer::new(peripherals.TIMG1); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); + let mut timer1 = Timer::new(peripherals.TIMG1, clocks.apb_clock); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); rtc_cntl.set_super_wdt_enable(false); diff --git a/esp32c3-hal/examples/timer_interrupt.rs b/esp32c3-hal/examples/timer_interrupt.rs index dc7b0dcd7..e37fa3a71 100644 --- a/esp32c3-hal/examples/timer_interrupt.rs +++ b/esp32c3-hal/examples/timer_interrupt.rs @@ -5,6 +5,7 @@ use core::{cell::RefCell, fmt::Write}; use bare_metal::Mutex; use esp32c3_hal::{ + clock::ClockControl, interrupt, pac::{self, Peripherals, TIMG0, TIMG1, UART0}, prelude::*, @@ -23,12 +24,14 @@ static mut TIMER1: Mutex>>> = Mutex::new(RefCell::ne #[entry] fn main() -> ! { let peripherals = Peripherals::take().unwrap(); + let system = peripherals.SYSTEM.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); // Disable the watchdog timers. For the ESP32-C3, this includes the Super WDT, // the RTC WDT, and the TIMG WDTs. let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); - let mut timer0 = Timer::new(peripherals.TIMG0); - let mut timer1 = Timer::new(peripherals.TIMG1); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); + let mut timer1 = Timer::new(peripherals.TIMG1, clocks.apb_clock); let serial0 = Serial::new(peripherals.UART0).unwrap(); rtc_cntl.set_super_wdt_enable(false); @@ -52,7 +55,7 @@ fn main() -> ! { interrupt::Priority::Priority1, ); - timer0.start(10_000_000u64); + timer0.start(500u64.millis()); timer0.listen(); interrupt::enable( @@ -71,7 +74,7 @@ fn main() -> ! { interrupt::Priority::Priority1, ); - timer1.start(20_000_000u64); + timer1.start(1u64.secs()); timer1.listen(); riscv::interrupt::free(|_cs| unsafe { @@ -100,7 +103,7 @@ pub fn interrupt1() { interrupt::clear(Cpu::ProCpu, interrupt::CpuInterrupt::Interrupt1); timer0.clear_interrupt(); - timer0.start(10_000_000u64); + timer0.start(500u64.millis()); }); } @@ -117,6 +120,6 @@ pub fn interrupt11() { interrupt::clear(Cpu::ProCpu, interrupt::CpuInterrupt::Interrupt11); timer1.clear_interrupt(); - timer1.start(20_000_000u64); + timer1.start(1u64.secs()); }); } diff --git a/esp32c3-hal/examples/usb_serial_jtag.rs b/esp32c3-hal/examples/usb_serial_jtag.rs index 3c276b874..6f76da83b 100644 --- a/esp32c3-hal/examples/usb_serial_jtag.rs +++ b/esp32c3-hal/examples/usb_serial_jtag.rs @@ -23,8 +23,8 @@ fn main() -> ! { let mut delay = Delay::new(&clocks); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); - let mut timer0 = Timer::new(peripherals.TIMG0); - let mut timer1 = Timer::new(peripherals.TIMG1); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); + let mut timer1 = Timer::new(peripherals.TIMG1, clocks.apb_clock); // Disable watchdog timers rtc_cntl.set_super_wdt_enable(false); diff --git a/esp32s2-hal/examples/blinky.rs b/esp32s2-hal/examples/blinky.rs index 581546fb6..2a2606669 100644 --- a/esp32s2-hal/examples/blinky.rs +++ b/esp32s2-hal/examples/blinky.rs @@ -19,7 +19,7 @@ fn main() -> ! { let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); // Disable MWDT and RWDT (Watchdog) flash boot protection diff --git a/esp32s2-hal/examples/gpio_interrupt.rs b/esp32s2-hal/examples/gpio_interrupt.rs index 4b73529e3..6a408b305 100644 --- a/esp32s2-hal/examples/gpio_interrupt.rs +++ b/esp32s2-hal/examples/gpio_interrupt.rs @@ -31,7 +31,7 @@ fn main() -> ! { let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); let serial0 = Serial::new(peripherals.UART0).unwrap(); diff --git a/esp32s2-hal/examples/hello_rgb.rs b/esp32s2-hal/examples/hello_rgb.rs index d98a049e4..8e3d22886 100644 --- a/esp32s2-hal/examples/hello_rgb.rs +++ b/esp32s2-hal/examples/hello_rgb.rs @@ -39,7 +39,7 @@ fn main() -> ! { let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); // Disable MWDT and RWDT (Watchdog) flash boot protection diff --git a/esp32s2-hal/examples/hello_world.rs b/esp32s2-hal/examples/hello_world.rs index 520a65cb1..1472d4468 100644 --- a/esp32s2-hal/examples/hello_world.rs +++ b/esp32s2-hal/examples/hello_world.rs @@ -3,7 +3,7 @@ use core::fmt::Write; -use esp32s2_hal::{pac::Peripherals, prelude::*, RtcCntl, Serial, Timer}; +use esp32s2_hal::{clock::ClockControl, pac::Peripherals, prelude::*, RtcCntl, Serial, Timer}; use nb::block; use panic_halt as _; use xtensa_lx_rt::entry; @@ -11,8 +11,10 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { let peripherals = Peripherals::take().unwrap(); + let system = peripherals.SYSTEM.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); @@ -20,7 +22,7 @@ fn main() -> ! { timer0.disable(); rtc_cntl.set_wdt_global_enable(false); - timer0.start(40_000_000u64); + timer0.start(1u64.secs()); loop { writeln!(serial0, "Hello world!").unwrap(); diff --git a/esp32s2-hal/examples/i2c_display.rs b/esp32s2-hal/examples/i2c_display.rs index 5a2aa3985..71caeb6ed 100644 --- a/esp32s2-hal/examples/i2c_display.rs +++ b/esp32s2-hal/examples/i2c_display.rs @@ -42,7 +42,7 @@ fn main() -> ! { let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); @@ -67,7 +67,7 @@ fn main() -> ! { .unwrap(); // Start timer (5 second interval) - timer0.start(50_000_000u64); + timer0.start(5u64.secs()); writeln!(serial0, "Starting timer!").unwrap(); diff --git a/esp32s2-hal/examples/ram.rs b/esp32s2-hal/examples/ram.rs index 8b82a501a..dda67d644 100644 --- a/esp32s2-hal/examples/ram.rs +++ b/esp32s2-hal/examples/ram.rs @@ -4,6 +4,7 @@ use core::fmt::Write; use esp32s2_hal::{ + clock::ClockControl, pac::{Peripherals, UART0}, prelude::*, ram, @@ -26,8 +27,10 @@ static mut SOME_ZEROED_DATA: [u8; 8] = [0; 8]; #[entry] fn main() -> ! { let peripherals = Peripherals::take().unwrap(); + let system = peripherals.SYSTEM.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); // Disable MWDT flash boot protection @@ -35,7 +38,7 @@ fn main() -> ! { // The RWDT flash boot protection remains enabled and it being triggered is part // of the example - timer0.start(10_000_000u64); + timer0.start(1u64.secs()); writeln!( serial0, diff --git a/esp32s2-hal/examples/read_efuse.rs b/esp32s2-hal/examples/read_efuse.rs index c329d45d7..426ce6db6 100644 --- a/esp32s2-hal/examples/read_efuse.rs +++ b/esp32s2-hal/examples/read_efuse.rs @@ -3,15 +3,25 @@ use core::fmt::Write; -use esp32s2_hal::{efuse::Efuse, pac::Peripherals, prelude::*, RtcCntl, Serial, Timer}; +use esp32s2_hal::{ + clock::ClockControl, + efuse::Efuse, + pac::Peripherals, + prelude::*, + RtcCntl, + Serial, + Timer, +}; use panic_halt as _; use xtensa_lx_rt::entry; #[entry] fn main() -> ! { let peripherals = Peripherals::take().unwrap(); + let system = peripherals.SYSTEM.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); diff --git a/esp32s2-hal/examples/spi_loopback.rs b/esp32s2-hal/examples/spi_loopback.rs index e55f19b35..b6f8ec9b5 100644 --- a/esp32s2-hal/examples/spi_loopback.rs +++ b/esp32s2-hal/examples/spi_loopback.rs @@ -41,7 +41,7 @@ fn main() -> ! { // Disable the watchdog timers. For the ESP32-C3, this includes the Super WDT, // the RTC WDT, and the TIMG WDTs. let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); timer0.disable(); diff --git a/esp32s2-hal/examples/systimer.rs b/esp32s2-hal/examples/systimer.rs index f774cd1ab..832b28f5c 100644 --- a/esp32s2-hal/examples/systimer.rs +++ b/esp32s2-hal/examples/systimer.rs @@ -34,7 +34,7 @@ fn main() -> ! { let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); diff --git a/esp32s2-hal/examples/timer_interrupt.rs b/esp32s2-hal/examples/timer_interrupt.rs index fce393f57..241d1bc30 100644 --- a/esp32s2-hal/examples/timer_interrupt.rs +++ b/esp32s2-hal/examples/timer_interrupt.rs @@ -4,6 +4,7 @@ use core::{cell::RefCell, fmt::Write}; use esp32s2_hal::{ + clock::ClockControl, interrupt, pac::{self, Peripherals, TIMG0, TIMG1, UART0}, prelude::*, @@ -26,10 +27,12 @@ static mut TIMER1: CriticalSectionMutex>>> = #[entry] fn main() -> ! { let peripherals = Peripherals::take().unwrap(); + let system = peripherals.SYSTEM.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); // Disable the TIMG watchdog timer. - let mut timer0 = Timer::new(peripherals.TIMG0); - let mut timer1 = Timer::new(peripherals.TIMG1); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); + let mut timer1 = Timer::new(peripherals.TIMG1, clocks.apb_clock); let serial0 = Serial::new(peripherals.UART0).unwrap(); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); @@ -43,7 +46,7 @@ fn main() -> ! { pac::Interrupt::TG0_T0_LEVEL, interrupt::CpuInterrupt::Interrupt20LevelPriority2, ); - timer0.start(50_000_000u64); + timer0.start(500u64.millis()); timer0.listen(); interrupt::enable( @@ -51,7 +54,7 @@ fn main() -> ! { pac::Interrupt::TG1_T0_LEVEL, interrupt::CpuInterrupt::Interrupt23LevelPriority3, ); - timer1.start(100_000_000u64); + timer1.start(1u64.secs()); timer1.listen(); unsafe { @@ -89,7 +92,7 @@ pub fn level2_interrupt() { let mut timer0 = data.borrow_mut(); let timer0 = timer0.as_mut().unwrap(); timer0.clear_interrupt(); - timer0.start(50_000_000u64); + timer0.start(500u64.millis()); }); } } @@ -114,7 +117,7 @@ pub fn level3_interrupt() { let mut timer1 = data.borrow_mut(); let timer1 = timer1.as_mut().unwrap(); timer1.clear_interrupt(); - timer1.start(100_000_000u64); + timer1.start(1u64.secs()); }); } } diff --git a/esp32s3-hal/examples/blinky.rs b/esp32s3-hal/examples/blinky.rs index c59e12e54..3a1c5eb52 100644 --- a/esp32s3-hal/examples/blinky.rs +++ b/esp32s3-hal/examples/blinky.rs @@ -19,7 +19,7 @@ fn main() -> ! { let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); // Disable MWDT and RWDT (Watchdog) flash boot protection diff --git a/esp32s3-hal/examples/gpio_interrupt.rs b/esp32s3-hal/examples/gpio_interrupt.rs index aeaa7b4f5..436020e36 100644 --- a/esp32s3-hal/examples/gpio_interrupt.rs +++ b/esp32s3-hal/examples/gpio_interrupt.rs @@ -31,7 +31,7 @@ fn main() -> ! { let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); let serial0 = Serial::new(peripherals.UART0).unwrap(); diff --git a/esp32s3-hal/examples/hello_rgb.rs b/esp32s3-hal/examples/hello_rgb.rs index 948eb4c9e..04633a52a 100644 --- a/esp32s3-hal/examples/hello_rgb.rs +++ b/esp32s3-hal/examples/hello_rgb.rs @@ -40,7 +40,7 @@ fn main() -> ! { let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); // Disable MWDT and RWDT (Watchdog) flash boot protection diff --git a/esp32s3-hal/examples/hello_world.rs b/esp32s3-hal/examples/hello_world.rs index ce17d3cd8..901ce91a4 100644 --- a/esp32s3-hal/examples/hello_world.rs +++ b/esp32s3-hal/examples/hello_world.rs @@ -3,7 +3,7 @@ use core::fmt::Write; -use esp32s3_hal::{pac::Peripherals, prelude::*, RtcCntl, Serial, Timer}; +use esp32s3_hal::{clock::ClockControl, pac::Peripherals, prelude::*, RtcCntl, Serial, Timer}; use nb::block; use panic_halt as _; use xtensa_lx_rt::entry; @@ -11,8 +11,10 @@ use xtensa_lx_rt::entry; #[entry] fn main() -> ! { let peripherals = Peripherals::take().unwrap(); + let system = peripherals.SYSTEM.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); @@ -20,7 +22,7 @@ fn main() -> ! { timer0.disable(); rtc_cntl.set_wdt_global_enable(false); - timer0.start(40_000_000u64); + timer0.start(1u64.secs()); loop { writeln!(serial0, "Hello world!").unwrap(); diff --git a/esp32s3-hal/examples/i2c_display.rs b/esp32s3-hal/examples/i2c_display.rs index 308b7ff9e..e4811f3d7 100644 --- a/esp32s3-hal/examples/i2c_display.rs +++ b/esp32s3-hal/examples/i2c_display.rs @@ -42,7 +42,7 @@ fn main() -> ! { let mut system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); @@ -67,7 +67,7 @@ fn main() -> ! { .unwrap(); // Start timer (5 second interval) - timer0.start(50_000_000u64); + timer0.start(5u64.secs()); writeln!(serial0, "Starting timer!").unwrap(); diff --git a/esp32s3-hal/examples/ram.rs b/esp32s3-hal/examples/ram.rs index cee69e979..71930ab8a 100644 --- a/esp32s3-hal/examples/ram.rs +++ b/esp32s3-hal/examples/ram.rs @@ -4,6 +4,7 @@ use core::fmt::Write; use esp32s3_hal::{ + clock::ClockControl, pac::{Peripherals, UART0}, prelude::*, ram, @@ -26,8 +27,10 @@ static mut SOME_ZEROED_DATA: [u8; 8] = [0; 8]; #[entry] fn main() -> ! { let peripherals = Peripherals::take().unwrap(); + let system = peripherals.SYSTEM.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); // Disable MWDT flash boot protection @@ -35,7 +38,7 @@ fn main() -> ! { // The RWDT flash boot protection remains enabled and it being triggered is part // of the example - timer0.start(10_000_000u64); + timer0.start(1u64.secs()); writeln!( serial0, diff --git a/esp32s3-hal/examples/read_efuse.rs b/esp32s3-hal/examples/read_efuse.rs index c1d9310ec..dc5440107 100644 --- a/esp32s3-hal/examples/read_efuse.rs +++ b/esp32s3-hal/examples/read_efuse.rs @@ -3,15 +3,25 @@ use core::fmt::Write; -use esp32s3_hal::{efuse::Efuse, pac::Peripherals, prelude::*, RtcCntl, Serial, Timer}; +use esp32s3_hal::{ + clock::ClockControl, + efuse::Efuse, + pac::Peripherals, + prelude::*, + RtcCntl, + Serial, + Timer, +}; use panic_halt as _; use xtensa_lx_rt::entry; #[entry] fn main() -> ! { let peripherals = Peripherals::take().unwrap(); + let system = peripherals.SYSTEM.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); diff --git a/esp32s3-hal/examples/spi_loopback.rs b/esp32s3-hal/examples/spi_loopback.rs index b48920aff..9fb557953 100644 --- a/esp32s3-hal/examples/spi_loopback.rs +++ b/esp32s3-hal/examples/spi_loopback.rs @@ -41,7 +41,7 @@ fn main() -> ! { // Disable the watchdog timers. For the ESP32-C3, this includes the Super WDT, // the RTC WDT, and the TIMG WDTs. let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut serial0 = Serial::new(peripherals.UART0).unwrap(); timer0.disable(); diff --git a/esp32s3-hal/examples/systimer.rs b/esp32s3-hal/examples/systimer.rs index e9672573e..f23679670 100644 --- a/esp32s3-hal/examples/systimer.rs +++ b/esp32s3-hal/examples/systimer.rs @@ -34,7 +34,7 @@ fn main() -> ! { let system = peripherals.SYSTEM.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); let serial0 = Serial::new(peripherals.UART0).unwrap(); diff --git a/esp32s3-hal/examples/timer_interrupt.rs b/esp32s3-hal/examples/timer_interrupt.rs index 6e5451443..9387772db 100644 --- a/esp32s3-hal/examples/timer_interrupt.rs +++ b/esp32s3-hal/examples/timer_interrupt.rs @@ -4,6 +4,7 @@ use core::{cell::RefCell, fmt::Write}; use esp32s3_hal::{ + clock::ClockControl, interrupt, pac::{self, Peripherals, TIMG0, TIMG1, UART0}, prelude::*, @@ -26,10 +27,12 @@ static mut TIMER1: SpinLockMutex>>> = #[entry] fn main() -> ! { let peripherals = Peripherals::take().unwrap(); + let system = peripherals.SYSTEM.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); // Disable the TIMG watchdog timer. - let mut timer0 = Timer::new(peripherals.TIMG0); - let mut timer1 = Timer::new(peripherals.TIMG1); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); + let mut timer1 = Timer::new(peripherals.TIMG1, clocks.apb_clock); let serial0 = Serial::new(peripherals.UART0).unwrap(); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); @@ -43,7 +46,7 @@ fn main() -> ! { pac::Interrupt::TG0_T0_LEVEL, interrupt::CpuInterrupt::Interrupt20LevelPriority2, ); - timer0.start(50_000_000u64); + timer0.start(500u64.millis()); timer0.listen(); interrupt::enable( @@ -51,7 +54,7 @@ fn main() -> ! { pac::Interrupt::TG1_T0_LEVEL, interrupt::CpuInterrupt::Interrupt23LevelPriority3, ); - timer1.start(100_000_000u64); + timer1.start(1u64.secs()); timer1.listen(); unsafe { @@ -89,7 +92,7 @@ pub fn level2_interrupt() { let mut timer0 = data.borrow_mut(); let timer0 = timer0.as_mut().unwrap(); timer0.clear_interrupt(); - timer0.start(50_000_000u64); + timer0.start(500u64.millis()); }); } } @@ -114,7 +117,7 @@ pub fn level3_interrupt() { let mut timer1 = data.borrow_mut(); let timer1 = timer1.as_mut().unwrap(); timer1.clear_interrupt(); - timer1.start(100_000_000u64); + timer1.start(1u64.secs()); }); } } diff --git a/esp32s3-hal/examples/usb_serial_jtag.rs b/esp32s3-hal/examples/usb_serial_jtag.rs index d4ac44f7e..5745ccaba 100644 --- a/esp32s3-hal/examples/usb_serial_jtag.rs +++ b/esp32s3-hal/examples/usb_serial_jtag.rs @@ -23,7 +23,7 @@ fn main() -> ! { let mut delay = Delay::new(&clocks); let mut rtc_cntl = RtcCntl::new(peripherals.RTC_CNTL); - let mut timer0 = Timer::new(peripherals.TIMG0); + let mut timer0 = Timer::new(peripherals.TIMG0, clocks.apb_clock); // Disable MWDT and RWDT (Watchdog) flash boot protection timer0.disable();