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 Nov 28, 2024
1 parent b2f311e commit 8c5e7d4
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<'_> {
// 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 8c5e7d4

Please sign in to comment.