-
Notifications
You must be signed in to change notification settings - Fork 201
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
Discussion: Add way to read the current timer value in CountDown trait #186
Comments
I also need a way to get the current counter value of a timer. However, in my case I only need that, no need for starting / resetting / waiting. In the case of an STM32 timer, an implementation is actually really simple, you just start the timer and then read the CNT (counter) register of the timer. However, I'm not sure what the best API design is around timers... Seems that they can be used in a lot of different ways, so it's hard to build an abstraction that works everywhere. Maybe the focus should be on use cases, not on the capabilities. One use case is "waiting until a certain time has elapsed". That is best solved by an interrupt based timer like Another use case is "measuring relative time that has elapsed" between two events. That can be done using a periodic up- or downcounting timer where the counter register can be read. Depending on timer resolution, an implementation might need to deal with overflows. I'm not sure whether this is something that should be in An example of the second use case is the An example implementation can be found here. |
The However, per current discussions, |
Struggling with a similar problem, would be good if the (I am actually trying to make a specialized version of software timers similar to embedded-time, but which uses callback functions instead of the futures which is used in @PTaylor-us Would adding this allow the embedded-time crate to use the |
@arjanmels Actually, Regarding the |
@PTaylor-us thanks for the insight. Interesting thought that the embedded-rust trait would be the output instead of the input... That is for me an indication that the abstraction is not powerful enough in its current form. Would love to get some input from the wider community. |
I don't see much use for the |
I'd like to use a timer to measure how long something takes. I can't use the timer trait currently since there's no way to read the current timer value. What do we think about adding a method to
CountDown
that returns the current timer value?For example, see
lap
method below.The text was updated successfully, but these errors were encountered: