Skip to content

Commit

Permalink
wip bench code
Browse files Browse the repository at this point in the history
  • Loading branch information
MabezDev committed Jul 25, 2023
1 parent 44110b9 commit 1579f34
Show file tree
Hide file tree
Showing 11 changed files with 1,455 additions and 44 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ exclude = [
resolver = "2"

[profile.release]
# Explicitly disable LTO which the Xtensa codegen backend has issues
lto = "off"
codegen-units = 1
opt-level = 3
debug = true

[profile.dev]
# Explicitly disable LTO which the Xtensa codegen backend has issues
Expand Down
22 changes: 3 additions & 19 deletions esp-wifi/src/timer_esp32c3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use critical_section::Mutex;
use esp32c3 as pac;
use esp32c3_hal as hal;
use esp32c3_hal::prelude::*;
use esp32c3_hal::systimer::SystemTimer;
use esp32c3_hal::trapframe::TrapFrame;
use hal::peripherals::Interrupt;
use hal::systimer::{Alarm, Periodic, Target};
Expand All @@ -18,7 +19,7 @@ pub const COUNTER_BIT_MASK: u64 = 0x000F_FFFF_FFFF_FFFF;
#[cfg(debug_assertions)]
const TIMER_DELAY: fugit::HertzU32 = fugit::HertzU32::from_raw(50);
#[cfg(not(debug_assertions))]
const TIMER_DELAY: fugit::HertzU32 = fugit::HertzU32::from_raw(100);
const TIMER_DELAY: fugit::HertzU32 = fugit::HertzU32::from_raw(750);

static ALARM0: Mutex<RefCell<Option<Alarm<Periodic, 0>>>> = Mutex::new(RefCell::new(None));

Expand Down Expand Up @@ -206,22 +207,5 @@ pub fn yield_task() {
/// Current systimer count value
/// A tick is 1 / 16_000_000 seconds
pub fn get_systimer_count() -> u64 {
critical_section::with(|_| unsafe {
let systimer = &(*pac::SYSTIMER::ptr());

systimer.unit0_op.write(|w| w.bits(1 << 30));

// wait for value available
loop {
let valid = (systimer.unit0_op.read().bits() >> 29) & 1;
if valid != 0 {
break;
}
}

let value_lo = systimer.unit0_value_lo.read().bits() as u64;
let value_hi = (systimer.unit0_value_hi.read().bits() as u64) << 32;

(value_lo | value_hi) as u64
})
SystemTimer::now()
}
22 changes: 3 additions & 19 deletions esp-wifi/src/timer_esp32c6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use esp32c6 as pac;
use esp32c6_hal as hal;
use esp32c6_hal::prelude::*;
use esp32c6_hal::trapframe::TrapFrame;
use esp32c6_hal::systimer::SystemTimer;
use hal::peripherals::Interrupt;
use hal::systimer::{Alarm, Periodic, Target};

Expand All @@ -18,7 +19,7 @@ pub const COUNTER_BIT_MASK: u64 = 0x000F_FFFF_FFFF_FFFF;
#[cfg(debug_assertions)]
const TIMER_DELAY: fugit::HertzU32 = fugit::HertzU32::from_raw(50);
#[cfg(not(debug_assertions))]
const TIMER_DELAY: fugit::HertzU32 = fugit::HertzU32::from_raw(100);
const TIMER_DELAY: fugit::HertzU32 = fugit::HertzU32::from_raw(750);

static ALARM0: Mutex<RefCell<Option<Alarm<Periodic, 0>>>> = Mutex::new(RefCell::new(None));

Expand Down Expand Up @@ -216,22 +217,5 @@ pub fn yield_task() {
/// Current systimer count value
/// A tick is 1 / 16_000_000 seconds
pub fn get_systimer_count() -> u64 {
critical_section::with(|_| unsafe {
let systimer = &(*pac::SYSTIMER::ptr());

systimer.unit0_op.write(|w| w.bits(1 << 30));

// wait for value available
loop {
let valid = (systimer.unit0_op.read().bits() >> 29) & 1;
if valid != 0 {
break;
}
}

let value_lo = systimer.unit0_value_lo.read().bits() as u64;
let value_hi = (systimer.unit0_value_hi.read().bits() as u64) << 32;

(value_lo | value_hi) as u64
})
SystemTimer::now()
}
2 changes: 1 addition & 1 deletion esp-wifi/src/timer_esp32s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub const COUNTER_BIT_MASK: u64 = 0xFFFF_FFFF_FFFF_FFFF;
#[cfg(debug_assertions)]
const TIMER_DELAY: fugit::HertzU64 = fugit::HertzU64::from_raw(50);
#[cfg(not(debug_assertions))]
const TIMER_DELAY: fugit::HertzU64 = fugit::HertzU64::from_raw(100);
const TIMER_DELAY: fugit::HertzU64 = fugit::HertzU64::from_raw(500);

static TIMER1: Mutex<RefCell<Option<Timer<Timer0<TIMG1>>>>> = Mutex::new(RefCell::new(None));

Expand Down
Loading

0 comments on commit 1579f34

Please sign in to comment.