Add trait for count down times that allow reading out elapsed time #277
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Concrete suggestion to resolve #186.
I'd prefer
Elapsed::elapsed
to be infallible, but that is probably against the tide of the times :)We use pretty much this implementation in https://github.com/lpc55/lpc55-hal/blob/5c70be5f73da2a6e1330aefc82a53f6cd3ddc7d6/src/drivers/timer.rs#L43-L48; looking at various STM32 and the nRF HAL this seems very implementable.
Of course this is infinitely bike-sheddable (remaining? now? etc...), it would be a pity not to have a standardized way of reading out a timer if embedded HAL is headed for a 1.0.
Perhaps Elapsed would pair better with a CountUp timer, and Remaining with a CountDown timer?
The trait is "add on" on purpose, the goal being to have a simple upstream trait to bound on (perhaps bounding Self::Time on some embedded-time type) in drivers and portable firmware. The Timer type (!) from embeded-time seems too heavy-weight with its generic parameters, and rtic-monotonic has additional requirements.