From fc1ef4947d463495ccd3da1d7763dcbe95a2588f Mon Sep 17 00:00:00 2001 From: Liam Murphy Date: Mon, 5 Jul 2021 18:18:05 +1000 Subject: [PATCH] Fix stm32 ethernet --- embassy-extras/src/peripheral.rs | 4 ++-- embassy-extras/src/peripheral_shared.rs | 4 ++-- embassy-stm32/src/eth/v2/mod.rs | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/embassy-extras/src/peripheral.rs b/embassy-extras/src/peripheral.rs index e3e06d69..edc5fe95 100644 --- a/embassy-extras/src/peripheral.rs +++ b/embassy-extras/src/peripheral.rs @@ -6,8 +6,8 @@ use core::ptr; use embassy::interrupt::{Interrupt, InterruptExt}; /// # Safety -/// When types implementing this trait are used with `Peripheral` or `PeripheralMutex`, -/// their lifetime must not end without first calling `Drop` on the `Peripheral` or `PeripheralMutex`. +/// When types implementing this trait are used with `PeripheralMutex`, +/// no fields referenced by `on_interrupt`'s lifetimes must end without first calling `Drop` on the `PeripheralMutex`. pub unsafe trait PeripheralStateUnchecked { type Interrupt: Interrupt; fn on_interrupt(&mut self); diff --git a/embassy-extras/src/peripheral_shared.rs b/embassy-extras/src/peripheral_shared.rs index d05ae030..820622bb 100644 --- a/embassy-extras/src/peripheral_shared.rs +++ b/embassy-extras/src/peripheral_shared.rs @@ -5,8 +5,8 @@ use core::ptr; use embassy::interrupt::{Interrupt, InterruptExt}; /// # Safety -/// When types implementing this trait are used with `Peripheral` or `PeripheralMutex`, -/// their lifetime must not end without first calling `Drop` on the `Peripheral` or `PeripheralMutex`. +/// When types implementing this trait are used with `Peripheral`, +/// no fields referenced by `on_interrupt`'s lifetimes must end without first calling `Drop` on the `Peripheral`. pub unsafe trait PeripheralStateUnchecked { type Interrupt: Interrupt; fn on_interrupt(&self); diff --git a/embassy-stm32/src/eth/v2/mod.rs b/embassy-stm32/src/eth/v2/mod.rs index a8a361df..c4be2bd2 100644 --- a/embassy-stm32/src/eth/v2/mod.rs +++ b/embassy-stm32/src/eth/v2/mod.rs @@ -343,7 +343,8 @@ impl<'d, const TX: usize, const RX: usize> Inner<'d, TX, RX> { } } -impl<'d, const TX: usize, const RX: usize> PeripheralState for Inner<'d, TX, RX> { +// SAFETY: The lifetime of `Inner` is only due to `PhantomData`; it isn't actually referencing any data with that lifetime. +unsafe impl<'d, const TX: usize, const RX: usize> PeripheralStateUnchecked for Inner<'d, TX, RX> { type Interrupt = crate::interrupt::ETH; fn on_interrupt(&mut self) {