Skip to content

Commit

Permalink
Merge pull request tock#4270 from alistair23/alistair/stimer-reset
Browse files Browse the repository at this point in the history
chips: apollo3: stimer: Reset the timer at startup
  • Loading branch information
alevy authored Dec 19, 2024
2 parents cc0994e + cc727b8 commit 9ae7d61
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions chips/apollo3/src/stimer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,16 @@ pub struct STimer<'a> {

impl<'a> STimer<'a> {
// Unsafe bc of use of STIMER_BASE internally
pub const fn new() -> STimer<'a> {
STimer {
pub fn new() -> STimer<'a> {
let timer = STimer {
registers: STIMER_BASE,
client: OptionalCell::empty(),
}
};

// Reset so that time starts at 0
let _ = timer.reset();

timer
}

pub fn handle_interrupt(&self) {
Expand Down Expand Up @@ -153,7 +158,8 @@ impl<'a> Counter<'a> for STimer<'a> {
}

fn reset(&self) -> Result<(), ErrorCode> {
Err(ErrorCode::FAIL)
self.registers.stcfg.write(STCFG::CLEAR::SET);
Ok(())
}

fn is_running(&self) -> bool {
Expand Down

0 comments on commit 9ae7d61

Please sign in to comment.