GithubHelp home page GithubHelp logo

Support for #[cfg] on #[monotonic] about rtic HOT 4 CLOSED

ia0 avatar ia0 commented on June 2, 2024 1
Support for #[cfg] on #[monotonic]

from rtic.

Comments (4)

ia0 avatar ia0 commented on June 2, 2024 1

here I hope for your help to see how your usecases might be supported

As original author of this issue, my usecase doesn't exist anymore (I moved out of RTIC for different reasons). But for reference, my original usecase was: Use monotonic for defmt::timestamp! and thus only use it when logging is enabled. The cfg would have been something like #[cfg(feature = "defmt")]. And in the init task I would call defmt::timestamp! on monotonics::now(), gated by feature = "defmt".

from rtic.

David-OConnor avatar David-OConnor commented on June 2, 2024

Scope goes beyond Monotonic. Also applies to Shared and Local. I also would like this.

from rtic.

korken89 avatar korken89 commented on June 2, 2024

Hi,

The cfg support in RTIC 1 is broken and on the path of wont-fix.
This usr case is already supported in (under development) RTIC 2, so I think it's best to go for that

from rtic.

AfoHT avatar AfoHT commented on June 2, 2024

As an experiment to see what can be done for RTIC 1 I've created #691

The obvious limitation, as shown in examples/cfg-monotonic, is that rtic-syntax does not know what is cfg-ed out, and thus "correctly" refuses code that uses the same type, or same interrupt. Might work for other cases, here I hope for your help to see how your usecases might be supported :)

From the example, showing the rtic-syntax errors

    // A monotonic timer to enable scheduling in RTIC
    #[cfg(feature = "killmono")]
    #[monotonic(binds = SysTick, default = true)]
    type MyMono = Systick<100>; // 100 Hz / 10 ms granularity

    // Not allowed by current rtic-syntax:
    // error: `#[monotonic(...)]` on a specific type must appear at most once
    //   --> examples/cfg-monotonic.rs:23:10
    //    |
    // 23 |     type MyMono = Systick<100>; // 100 Hz / 10 ms granularity
    //    |          ^^^^^^
    // #[monotonic(binds = SysTick, default = true)]
    // type MyMono = Systick<100>; // 100 Hz / 10 ms granularity

    // Not allowed by current rtic-syntax:
    // error: this interrupt is already bound
    //   --> examples/cfg-monotonic.rs:31:25
    //    |
    // 31 |     #[monotonic(binds = SysTick, default = true)]
    //    |                         ^^^^^^^
    // #[monotonic(binds = SysTick, default = true)]
    // type MyMono2 = DwtSystick<100>; // 100 Hz / 10 ms granularity

from rtic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.