Skip to content

Commit

Permalink
chips: apollo3: stimer: Reset timer on creation
Browse files Browse the repository at this point in the history
When creating the STimer reset the count to zero. This way the timer
roughly aligns to the total time the system has been running, otherwise
the timer starts at a random value.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
  • Loading branch information
alistair23 committed Dec 18, 2024
1 parent 0144c18 commit cc727b8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 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

0 comments on commit cc727b8

Please sign in to comment.