diff --git a/boards/pico/examples/pico_countdown_blinky.rs b/boards/pico/examples/pico_countdown_blinky.rs index f6a3ea7..a4d162f 100644 --- a/boards/pico/examples/pico_countdown_blinky.rs +++ b/boards/pico/examples/pico_countdown_blinky.rs @@ -61,7 +61,7 @@ fn main() -> ! { .unwrap(); // Configure the Timer peripheral in count-down mode - let timer = hal::timer::Timer::new(pac.TIMER); + let timer = hal::timer::Timer::new(pac.TIMER, &mut pac.RESETS); let mut count_down = timer.count_down(); // The single-cycle I/O block controls our GPIO pins diff --git a/boards/pico/examples/pico_usb_serial.rs b/boards/pico/examples/pico_usb_serial.rs index 2732da2..fb431b1 100644 --- a/boards/pico/examples/pico_usb_serial.rs +++ b/boards/pico/examples/pico_usb_serial.rs @@ -89,7 +89,7 @@ fn main() -> ! { .device_class(2) // from: https://www.usb.org/defined-class-codes .build(); - let timer = hal::timer::Timer::new(pac.TIMER); + let timer = hal::timer::Timer::new(pac.TIMER, &mut pac.RESETS); let mut said_hello = false; loop { // A welcome message at the beginning diff --git a/boards/pro_micro_rp2040/examples/pro_micro_rainbow.rs b/boards/pro_micro_rp2040/examples/pro_micro_rainbow.rs index dd9a094..ae825e5 100644 --- a/boards/pro_micro_rp2040/examples/pro_micro_rainbow.rs +++ b/boards/pro_micro_rp2040/examples/pro_micro_rainbow.rs @@ -71,7 +71,7 @@ fn main() -> ! { let _led: Pin<_, FunctionPio0> = pins.led.into_mode(); - let timer = Timer::new(pac.TIMER); + let timer = Timer::new(pac.TIMER, &mut pac.RESETS); let mut delay = timer.count_down(); // Configure the addressable LED diff --git a/rp2040-hal/src/timer.rs b/rp2040-hal/src/timer.rs index 89a2d11..5728627 100644 --- a/rp2040-hal/src/timer.rs +++ b/rp2040-hal/src/timer.rs @@ -3,7 +3,8 @@ use embedded_time::duration::Microseconds; -use crate::pac::TIMER; +use crate::pac::{RESETS, TIMER}; +use crate::resets::SubsystemReset; /// Timer peripheral pub struct Timer { @@ -12,7 +13,8 @@ pub struct Timer { impl Timer { /// Create a new [`Timer`] - pub fn new(timer: TIMER) -> Self { + pub fn new(timer: TIMER, resets: &mut RESETS) -> Self { + timer.reset_bring_up(resets); Self { timer } }