Skip to content

Commit 077a665

Browse files
committed
Remove borrowing from ethernet DMA
1 parent 5ed7599 commit 077a665

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/bin/async-await.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ where
494494
&mut self.rcc,
495495
&mut self.syscfg,
496496
&mut self.ethernet_mac,
497-
&mut self.ethernet_dma,
497+
self.ethernet_dma,
498498
ETH_ADDR,
499499
)
500500
.map(|device| device.into_interface(Ipv4Address::new(192, 168, 42, 69)));

src/bin/polling.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn main() -> ! {
6363
let mut sdmmc = peripherals.SDMMC1;
6464
let mut syscfg = peripherals.SYSCFG;
6565
let mut ethernet_mac = peripherals.ETHERNET_MAC;
66-
let mut ethernet_dma = peripherals.ETHERNET_DMA;
66+
let ethernet_dma = peripherals.ETHERNET_DMA;
6767

6868
init::init_system_clock_216mhz(&mut rcc, &mut pwr, &mut flash);
6969
init::enable_gpio_ports(&mut rcc);
@@ -138,7 +138,7 @@ fn main() -> ! {
138138
&mut rcc,
139139
&mut syscfg,
140140
&mut ethernet_mac,
141-
&mut ethernet_dma,
141+
ethernet_dma,
142142
ETH_ADDR,
143143
)
144144
.map(|device| {

src/ethernet/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ pub const MTU: usize = 1536;
2424
/// Represents an ethernet device that allows sending and receiving packets.
2525
///
2626
/// This struct implements the [smoltcp::phy::Device] trait.
27-
pub struct EthernetDevice<'d> {
27+
pub struct EthernetDevice {
2828
rx: RxDevice,
2929
tx: TxDevice,
30-
ethernet_dma: &'d mut ETHERNET_DMA,
30+
ethernet_dma: ETHERNET_DMA,
3131
ethernet_address: EthernetAddress,
3232
}
3333

34-
impl<'d> EthernetDevice<'d> {
34+
impl EthernetDevice {
3535
/// Creates and initializes a new `EthernetDevice`.
3636
///
3737
/// This function takes the following parameters:
@@ -48,12 +48,12 @@ impl<'d> EthernetDevice<'d> {
4848
rcc: &mut RCC,
4949
syscfg: &mut SYSCFG,
5050
ethernet_mac: &mut ETHERNET_MAC,
51-
ethernet_dma: &'d mut ETHERNET_DMA,
51+
mut ethernet_dma: ETHERNET_DMA,
5252
ethernet_address: EthernetAddress,
5353
) -> Result<Self, PhyError> {
5454
use byteorder::{ByteOrder, LittleEndian};
5555

56-
init::init(rcc, syscfg, ethernet_mac, ethernet_dma)?;
56+
init::init(rcc, syscfg, ethernet_mac, &mut ethernet_dma)?;
5757

5858
let rx_device = RxDevice::new(rx_config)?;
5959
let tx_device = TxDevice::new(tx_config);
@@ -75,7 +75,7 @@ impl<'d> EthernetDevice<'d> {
7575
.maca0hr
7676
.write(|w| w.maca0h().bits(LittleEndian::read_u16(&eth_bytes[4..])));
7777

78-
init::start(ethernet_mac, ethernet_dma);
78+
init::start(ethernet_mac, &mut ethernet_dma);
7979
Ok(EthernetDevice {
8080
rx: rx_device,
8181
tx: tx_device,
@@ -104,14 +104,14 @@ impl<'d> EthernetDevice<'d> {
104104
}
105105
}
106106

107-
impl<'d> Drop for EthernetDevice<'d> {
107+
impl Drop for EthernetDevice {
108108
fn drop(&mut self) {
109109
// TODO stop ethernet device and wait for idle
110110
unimplemented!();
111111
}
112112
}
113113

114-
impl<'a, 'd> Device<'a> for EthernetDevice<'d> {
114+
impl<'a> Device<'a> for EthernetDevice {
115115
type RxToken = RxToken<'a>;
116116
type TxToken = TxToken<'a>;
117117

0 commit comments

Comments
 (0)