diff --git a/ci.sh b/ci.sh index db00c406c..4112144bc 100755 --- a/ci.sh +++ b/ci.sh @@ -180,4 +180,9 @@ if [[ -z "${TELEPROBE_TOKEN-}" ]]; then exit fi +rm out/tests/rpi-pico/ethernet_w5100s_perf +rm out/tests/nrf52840-dk/ethernet_enc28j60_perf +rm out/tests/nrf52840-dk/wifi_esp_hosted_perf +rm out/tests/rpi-pico/cyw43-perf + teleprobe client run -r out/tests diff --git a/embassy-stm32/src/hrtim/traits.rs b/embassy-stm32/src/hrtim/traits.rs index 158a68862..095109598 100644 --- a/embassy-stm32/src/hrtim/traits.rs +++ b/embassy-stm32/src/hrtim/traits.rs @@ -1,31 +1,17 @@ use crate::rcc::sealed::RccPeripheral; use crate::time::Hertz; +#[repr(u8)] #[derive(Clone, Copy)] pub(crate) enum Prescaler { - Div1, - Div2, - Div4, - Div8, - Div16, - Div32, - Div64, - Div128, -} - -impl From for u32 { - fn from(val: Prescaler) -> Self { - match val { - Prescaler::Div1 => 1, - Prescaler::Div2 => 2, - Prescaler::Div4 => 4, - Prescaler::Div8 => 8, - Prescaler::Div16 => 16, - Prescaler::Div32 => 32, - Prescaler::Div64 => 64, - Prescaler::Div128 => 128, - } - } + Div1 = 1, + Div2 = 2, + Div4 = 4, + Div8 = 8, + Div16 = 16, + Div32 = 32, + Div64 = 64, + Div128 = 128, } impl From for u8 { @@ -72,7 +58,7 @@ impl Prescaler { Prescaler::Div128, ] .iter() - .skip_while(|psc| >::into(**psc) <= val) + .skip_while(|psc| **psc as u32 <= val) .next() .unwrap() } @@ -80,7 +66,7 @@ impl Prescaler { pub fn compute_min_low_res(val: u32) -> Self { *[Prescaler::Div32, Prescaler::Div64, Prescaler::Div128] .iter() - .skip_while(|psc| >::into(**psc) <= val) + .skip_while(|psc| **psc as u32 <= val) .next() .unwrap() } @@ -126,8 +112,7 @@ foreach_interrupt! { Prescaler::compute_min_low_res(psc_min) }; - let psc_val: u32 = psc.into(); - let timer_f = 32 * (timer_f / psc_val); + let timer_f = 32 * (timer_f / psc as u32); let per: u16 = (timer_f / f) as u16; let regs = Self::regs(); @@ -148,8 +133,7 @@ foreach_interrupt! { Prescaler::compute_min_low_res(psc_min) }; - let psc_val: u32 = psc.into(); - let timer_f = 32 * (timer_f / psc_val); + let timer_f = 32 * (timer_f / psc as u32); let per: u16 = (timer_f / f) as u16; let regs = Self::regs(); @@ -163,20 +147,17 @@ foreach_interrupt! { let regs = Self::regs(); let channel_psc: Prescaler = regs.tim(channel).cr().read().ckpsc().into(); - let psc_val: u32 = channel_psc.into(); - // The dead-time base clock runs 4 times slower than the hrtim base clock // u9::MAX = 511 - let psc_min = (psc_val * dead_time as u32) / (4 * 511); + let psc_min = (channel_psc as u32 * dead_time as u32) / (4 * 511); let psc = if Self::regs().isr().read().dllrdy() { Prescaler::compute_min_high_res(psc_min) } else { Prescaler::compute_min_low_res(psc_min) }; - let dt_psc_val: u32 = psc.into(); - let dt_val = (dt_psc_val * dead_time as u32) / (4 * psc_val); + let dt_val = (psc as u32 * dead_time as u32) / (4 * channel_psc as u32); regs.tim(channel).dt().modify(|w| { w.set_dtprsc(psc.into()); diff --git a/embassy-stm32/src/rtc/v2.rs b/embassy-stm32/src/rtc/v2.rs index 482b6e75d..62d8d4f9c 100644 --- a/embassy-stm32/src/rtc/v2.rs +++ b/embassy-stm32/src/rtc/v2.rs @@ -6,12 +6,13 @@ use crate::peripherals::RTC; use crate::rtc::sealed::Instance; #[allow(dead_code)] +#[repr(u8)] #[derive(Clone, Copy, Debug)] pub(crate) enum WakeupPrescaler { - Div2, - Div4, - Div8, - Div16, + Div2 = 2, + Div4 = 4, + Div8 = 8, + Div16 = 16, } #[cfg(any(stm32wb, stm32f4))] @@ -43,17 +44,6 @@ impl From for WakeupPrescaler { } } -impl From for u32 { - fn from(val: WakeupPrescaler) -> Self { - match val { - WakeupPrescaler::Div2 => 2, - WakeupPrescaler::Div4 => 4, - WakeupPrescaler::Div8 => 8, - WakeupPrescaler::Div16 => 16, - } - } -} - #[allow(dead_code)] impl WakeupPrescaler { pub fn compute_min(val: u32) -> Self { @@ -64,7 +54,7 @@ impl WakeupPrescaler { WakeupPrescaler::Div16, ] .iter() - .skip_while(|psc| >::into(**psc) <= val) + .skip_while(|psc| **psc as u32 <= val) .next() .unwrap_or(&WakeupPrescaler::Div16) } @@ -85,7 +75,7 @@ impl super::Rtc { let prescaler = WakeupPrescaler::compute_min((rtc_ticks / u16::MAX as u64) as u32); // adjust the rtc ticks to the prescaler and subtract one rtc tick - let rtc_ticks = rtc_ticks / (>::into(prescaler) as u64); + let rtc_ticks = rtc_ticks / prescaler as u64; let rtc_ticks = if rtc_ticks >= u16::MAX as u64 { u16::MAX - 1 } else { @@ -106,11 +96,8 @@ impl super::Rtc { trace!( "rtc: start wakeup alarm for {} ms (psc: {}, ticks: {}) at {}", - Duration::from_ticks( - rtc_ticks as u64 * TICK_HZ * (>::into(prescaler) as u64) / rtc_hz, - ) - .as_millis(), - >::into(prescaler), + Duration::from_ticks(rtc_ticks as u64 * TICK_HZ * prescaler as u64 / rtc_hz).as_millis(), + prescaler as u32, rtc_ticks, self.instant(), );