Skip to content
This repository has been archived by the owner on Dec 3, 2021. It is now read-only.

Abstract timestamps with embedded-time #13

Open
tmplt opened this issue Jun 17, 2021 · 3 comments
Open

Abstract timestamps with embedded-time #13

tmplt opened this issue Jun 17, 2021 · 3 comments
Labels
const-generics This issue depends on const generics in stable Rust. enhancement New feature or request

Comments

@tmplt
Copy link
Member

tmplt commented Jun 17, 2021

https://crates.io/crates/embedded-time provides a lot of nice abstractions for raw timestamps. We probably want to replace Timestamp::base and Timestamp::delta with a embedded_time::Instant. The API needs to account for the clock frequency for the embedded_time::Clock we need to create.

@tmplt tmplt added the enhancement New feature or request label Jun 17, 2021
@tmplt
Copy link
Member Author

tmplt commented Jun 19, 2021

The frequency of the trace clock must be stored in an embedded_time::Clock. This will only be possible when const generics is stabilized:

use embedded_time as time;

// semi-pseudo
struct TraceClock<const Freq: usize>;
impl<Freq> time::Clock for TraceClock<Freq> {
    type T = u64;
    const SCALING_FACTOR: time::fraction::Fraction = <time::fraction::Fraction>::new(1, Freq);

    fn try_now(&self) -> Result<time::Instant<Self>, time::clock::Error> {
        // ...
    }
}

@tmplt tmplt added the const-generics This issue depends on const generics in stable Rust. label Jun 19, 2021
@Yatekii
Copy link

Yatekii commented Jun 19, 2021

I am not so sure, having a constant frequency is a good choice. The ITM clock is not fixed. So we want to change this at runtime depending on the chip.

@tmplt
Copy link
Member Author

tmplt commented Nov 16, 2021

fugit provides an alternative to embedded-time that supports const generics.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
const-generics This issue depends on const generics in stable Rust. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants