-
-
Notifications
You must be signed in to change notification settings - Fork 52
feat: Add embassy-based sleeper for no_std #173
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ad7d2c3
Add embassy-based sleeper for no_std
wackazong e4b7ac5
Remove embassy-sleep as default sleeper, minor fixes
wackazong 8a0f159
Typo
wackazong 8d6725c
Typos
wackazong 3560865
Move embassy-sleeper implementation to its own file
wackazong 9b27b9a
rustfmt
wackazong a21566f
Require to define EmbassySleeper explicitly
wackazong 92a2131
Reduce to one EmbassySleeper
wackazong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| use crate::{BlockingSleeper, Sleeper}; | ||
| use core::time::Duration; | ||
|
|
||
| /// A no_std async sleeper based on the embassy framework (https://embassy.dev) | ||
| #[derive(Clone, Copy, Debug, Default)] | ||
| pub struct EmbassySleeper; | ||
|
|
||
| impl Sleeper for EmbassySleeper { | ||
| type Sleep = embassy_time::Timer; | ||
|
|
||
| fn sleep(&self, dur: Duration) -> Self::Sleep { | ||
| embassy_time::Timer::after_millis(dur.as_millis() as u64) | ||
| } | ||
| } | ||
|
|
||
| /// A no_std blocking sleeper based on the embassy framework (https://embassy.dev) | ||
| #[derive(Clone, Copy, Debug, Default)] | ||
| pub struct EmbassyBlockingSleeper; | ||
wackazong marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| impl BlockingSleeper for EmbassySleeper { | ||
| fn sleep(&self, dur: Duration) { | ||
| embassy_time::block_for(embassy_time::Duration::from_millis(dur.as_millis() as u64)); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.