-
Notifications
You must be signed in to change notification settings - Fork 251
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
refactor esp-wifi to ease using external task scheduler #3106
Merged
bjoernQ
merged 5 commits into
esp-rs:main
from
kaspar030:v0.23.1+ariel-os+preeempt-refactor+ariel-threads
Feb 7, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
df1d340
esp-wifi: untangle `setup_timer_isr`
kaspar030 636166a
esp-wifi: bundle scheduler functions into `preempt`
kaspar030 eb7c31b
esp-wifi: split `timer` into `preempt::timer`, `radio` and `time`
kaspar030 e4ac994
move more deinit stuff into `preempt::disable()`
kaspar030 02e25cc
move getter of `thread_semaphore` into `preempt`
kaspar030 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 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 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 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 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 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 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 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,11 @@ | ||
use esp_hal::sync::Locked; | ||
|
||
#[cfg_attr(xtensa, path = "xtensa.rs")] | ||
#[cfg_attr(riscv, path = "riscv.rs")] | ||
mod arch_specific; | ||
|
||
pub(crate) use arch_specific::*; | ||
|
||
use crate::TimeBase; | ||
|
||
pub(crate) static TIMER: Locked<Option<TimeBase>> = Locked::new(None); |
This file contains 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 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 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,10 @@ | ||
#[cfg_attr(esp32, path = "radio_esp32.rs")] | ||
#[cfg_attr(esp32c2, path = "radio_esp32c2.rs")] | ||
#[cfg_attr(esp32c3, path = "radio_esp32c3.rs")] | ||
#[cfg_attr(esp32c6, path = "radio_esp32c6.rs")] | ||
#[cfg_attr(esp32h2, path = "radio_esp32h2.rs")] | ||
#[cfg_attr(esp32s3, path = "radio_esp32s3.rs")] | ||
#[cfg_attr(esp32s2, path = "radio_esp32s2.rs")] | ||
mod chip_specific; | ||
|
||
pub(crate) use chip_specific::*; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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 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,51 @@ | ||
// Time keeping | ||
pub const TICKS_PER_SECOND: u64 = 1_000_000; | ||
|
||
/// Current systimer count value | ||
/// A tick is 1 / 1_000_000 seconds | ||
/// This function must not be called in a critical section. Doing so may return | ||
/// an incorrect value. | ||
pub(crate) fn systimer_count() -> u64 { | ||
esp_hal::time::Instant::now() | ||
.duration_since_epoch() | ||
.as_micros() | ||
} | ||
|
||
// TODO: use an Instance type instead... | ||
#[cfg(target_arch = "riscv32")] | ||
pub(crate) fn time_diff(start: u64, end: u64) -> u64 { | ||
// 52-bit wrapping sub | ||
end.wrapping_sub(start) & 0x000f_ffff_ffff_ffff | ||
} | ||
|
||
// TODO: use an Instance type instead... | ||
#[cfg(target_arch = "xtensa")] | ||
pub(crate) fn time_diff(start: u64, end: u64) -> u64 { | ||
end.wrapping_sub(start) | ||
} | ||
|
||
#[allow(unused)] | ||
pub(crate) fn micros_to_ticks(us: u64) -> u64 { | ||
us * (TICKS_PER_SECOND / 1_000_000) | ||
} | ||
|
||
#[allow(unused)] | ||
pub(crate) fn millis_to_ticks(ms: u64) -> u64 { | ||
ms * (TICKS_PER_SECOND / 1_000) | ||
} | ||
|
||
#[allow(unused)] | ||
pub(crate) fn ticks_to_micros(ticks: u64) -> u64 { | ||
ticks / (TICKS_PER_SECOND / 1_000_000) | ||
} | ||
|
||
#[allow(unused)] | ||
pub(crate) fn ticks_to_millis(ticks: u64) -> u64 { | ||
ticks / (TICKS_PER_SECOND / 1_000) | ||
} | ||
|
||
/// Do not call this in a critical section! | ||
pub(crate) fn elapsed_time_since(start: u64) -> u64 { | ||
let now = systimer_count(); | ||
time_diff(start, now) | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function was identical for riscv and xtensa. the comments are a mix. I don't know which statements are true for either architecture.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this change will probably make it simpler to just throw all this out in favour of esp_hal::time::* :)