mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2025-02-23 23:57:43 +11:00
Adds reset for timer, otherwise it would not run. (#136)
This commit is contained in:
parent
2b6de3a3c9
commit
90470b6ff3
4 changed files with 7 additions and 5 deletions
boards
pico/examples
pro_micro_rp2040/examples
rp2040-hal/src
|
@ -61,7 +61,7 @@ fn main() -> ! {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Configure the Timer peripheral in count-down mode
|
// 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();
|
let mut count_down = timer.count_down();
|
||||||
|
|
||||||
// The single-cycle I/O block controls our GPIO pins
|
// The single-cycle I/O block controls our GPIO pins
|
||||||
|
|
|
@ -89,7 +89,7 @@ fn main() -> ! {
|
||||||
.device_class(2) // from: https://www.usb.org/defined-class-codes
|
.device_class(2) // from: https://www.usb.org/defined-class-codes
|
||||||
.build();
|
.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;
|
let mut said_hello = false;
|
||||||
loop {
|
loop {
|
||||||
// A welcome message at the beginning
|
// A welcome message at the beginning
|
||||||
|
|
|
@ -71,7 +71,7 @@ fn main() -> ! {
|
||||||
|
|
||||||
let _led: Pin<_, FunctionPio0> = pins.led.into_mode();
|
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();
|
let mut delay = timer.count_down();
|
||||||
|
|
||||||
// Configure the addressable LED
|
// Configure the addressable LED
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
use embedded_time::duration::Microseconds;
|
use embedded_time::duration::Microseconds;
|
||||||
|
|
||||||
use crate::pac::TIMER;
|
use crate::pac::{RESETS, TIMER};
|
||||||
|
use crate::resets::SubsystemReset;
|
||||||
|
|
||||||
/// Timer peripheral
|
/// Timer peripheral
|
||||||
pub struct Timer {
|
pub struct Timer {
|
||||||
|
@ -12,7 +13,8 @@ pub struct Timer {
|
||||||
|
|
||||||
impl Timer {
|
impl Timer {
|
||||||
/// Create a new [`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 }
|
Self { timer }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue