-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor esp-wifi to ease using external task scheduler (#3106)
* esp-wifi: untangle `setup_timer_isr` * esp-wifi: bundle scheduler functions into `preempt` * esp-wifi: split `timer` into `preempt::timer`, `radio` and `time` * move more deinit stuff into `preempt::disable()` * move getter of `thread_semaphore` into `preempt`
- Loading branch information
Showing
22 changed files
with
138 additions
and
136 deletions.
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.