Adds reset for timer, otherwise it would not run. (#136)

This commit is contained in:
Alexander Meißner 2021-10-02 07:41:04 +02:00 committed by GitHub
parent 2b6de3a3c9
commit 90470b6ff3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 5 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 }
}