Skip to content

Commit

Permalink
Remove borrowing from ethernet DMA
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Apr 9, 2019
1 parent 5ed7599 commit 077a665
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/bin/async-await.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ where
&mut self.rcc,
&mut self.syscfg,
&mut self.ethernet_mac,
&mut self.ethernet_dma,
self.ethernet_dma,
ETH_ADDR,
)
.map(|device| device.into_interface(Ipv4Address::new(192, 168, 42, 69)));
Expand Down
4 changes: 2 additions & 2 deletions src/bin/polling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn main() -> ! {
let mut sdmmc = peripherals.SDMMC1;
let mut syscfg = peripherals.SYSCFG;
let mut ethernet_mac = peripherals.ETHERNET_MAC;
let mut ethernet_dma = peripherals.ETHERNET_DMA;
let ethernet_dma = peripherals.ETHERNET_DMA;

init::init_system_clock_216mhz(&mut rcc, &mut pwr, &mut flash);
init::enable_gpio_ports(&mut rcc);
Expand Down Expand Up @@ -138,7 +138,7 @@ fn main() -> ! {
&mut rcc,
&mut syscfg,
&mut ethernet_mac,
&mut ethernet_dma,
ethernet_dma,
ETH_ADDR,
)
.map(|device| {
Expand Down
16 changes: 8 additions & 8 deletions src/ethernet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ pub const MTU: usize = 1536;
/// Represents an ethernet device that allows sending and receiving packets.
///
/// This struct implements the [smoltcp::phy::Device] trait.
pub struct EthernetDevice<'d> {
pub struct EthernetDevice {
rx: RxDevice,
tx: TxDevice,
ethernet_dma: &'d mut ETHERNET_DMA,
ethernet_dma: ETHERNET_DMA,
ethernet_address: EthernetAddress,
}

impl<'d> EthernetDevice<'d> {
impl EthernetDevice {
/// Creates and initializes a new `EthernetDevice`.
///
/// This function takes the following parameters:
Expand All @@ -48,12 +48,12 @@ impl<'d> EthernetDevice<'d> {
rcc: &mut RCC,
syscfg: &mut SYSCFG,
ethernet_mac: &mut ETHERNET_MAC,
ethernet_dma: &'d mut ETHERNET_DMA,
mut ethernet_dma: ETHERNET_DMA,
ethernet_address: EthernetAddress,
) -> Result<Self, PhyError> {
use byteorder::{ByteOrder, LittleEndian};

init::init(rcc, syscfg, ethernet_mac, ethernet_dma)?;
init::init(rcc, syscfg, ethernet_mac, &mut ethernet_dma)?;

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

init::start(ethernet_mac, ethernet_dma);
init::start(ethernet_mac, &mut ethernet_dma);
Ok(EthernetDevice {
rx: rx_device,
tx: tx_device,
Expand Down Expand Up @@ -104,14 +104,14 @@ impl<'d> EthernetDevice<'d> {
}
}

impl<'d> Drop for EthernetDevice<'d> {
impl Drop for EthernetDevice {
fn drop(&mut self) {
// TODO stop ethernet device and wait for idle
unimplemented!();
}
}

impl<'a, 'd> Device<'a> for EthernetDevice<'d> {
impl<'a> Device<'a> for EthernetDevice {
type RxToken = RxToken<'a>;
type TxToken = TxToken<'a>;

Expand Down

0 comments on commit 077a665

Please sign in to comment.