Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is the StateMachine::new not a const function? #45

Closed
tolgaparlan opened this issue Aug 29, 2022 · 0 comments · Fixed by #56
Closed

Why is the StateMachine::new not a const function? #45

tolgaparlan opened this issue Aug 29, 2022 · 0 comments · Fixed by #56

Comments

@tolgaparlan
Copy link

I am using this library in an interrupt in an embedded project. I wanted to take advantage of the fact that static mut can be safely used in interrupt/exception contexts. However I cannot do something like:

#[interrupt]
fn TIM2() {
    static mut sm: StateMachine<Context> = StateMachine::new(Context::new_const_default());
...}

because StateMachine::new is not a const function. I have to wrap it in a Option, adding an unnecessary check at each interrupt call. Can something be done to enhance this given that a no-std library like this is going to see a lot of embedded usage?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant