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

Changes durations in the time module to use u64 instead of u32 #820

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kyp44
Copy link
Contributor

@kyp44 kyp44 commented Feb 7, 2025

Summary

Currently many time durations pass/stored throughout the HAL use nanoseconds for maximum precision. However these are stored using a u32 for a maximum of about 4 seconds. Since delays/times longer than this could be useful and should be possible, this changes all type defs in the time module to use u64 instead, extending the maximum time (when stored as nanoseconds) to over 584 years.

There were also several places in the HAL that import fugit duration types directly. These were changed to use the type defs in the time time module instead so that the entire HAL uses these exclusively.

See the commit message for more details.

Note that the rate/frequency types defined in time still use u32 as rates above 4 GHz are not likely to be useful.

Also note that this is a breaking change.

Checklist

  • All new or modified code is well documented, especially public items
  • No new warnings or clippy suggestions have been introduced - CI will deny clippy warnings by default! You may #[allow] certain lints where reasonable, but ideally justify those with a short comment.

…for durations instead of `u32`

* This allows for delays and durations longer than 4 seconds in parts of the HAL where durations are stored or passed in nanoseconds.
* Also ensures that the type defs in the `time` module are used throughout the HAL, as some places still imported and used `fugit` durations explicitly.
* Replaces `fugit::ExtU32` in the prelude with `fugit::ExtU64`, and also adds `fugit::ExtU64Ceil`.

examples: Updates applicable examples to use the HAL duration types instead of those directly from `fugit`

* feather_m0: async_timer
* metro_m4: async_timer
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 this pull request may close these issues.

1 participant