Skip to content

Commit 411af3c

Browse files
author
Johannes Draaijer
committed
Fix docs
1 parent f3910f3 commit 411af3c

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! An abstraction layer for ethernet periperhals embedded in STM32 processors.
22
//!
3-
//! For initialisation, see [`new`], and [`new_with_smi_pins`]
3+
//! For initialisation, see [`new`], and [`new_with_smi`]
44
#![no_std]
55

66
use mac::EthernetMACWithSmi;
@@ -135,7 +135,7 @@ where
135135
/// This method does not initialise the external PHY.
136136
///
137137
/// The SMI for the external PHY can be accessed through the
138-
/// returned [`EthernetMAC<OwnedSmi>`], which implements [`mac::StationManagement`].
138+
/// returned [`EthernetMACWithSmi`], which implements [`mac::StationManagement`].
139139
///
140140
/// # Note
141141
/// - Make sure that the buffers reside in a memory region that is

src/mac/mod.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ impl EthernetMAC {
4141
{
4242
EthernetMACWithSmi {
4343
eth_mac: self.eth_mac,
44-
mdio: mdio,
45-
mdc: mdc,
44+
mdio,
45+
mdc,
4646
}
4747
}
4848
}
4949

50-
/// Ethernet media access control (MAC)
50+
/// Ethernet media access control (MAC) with owned SMI
5151
///
52-
/// This version of the struct owns it's Station Management Interface
53-
/// pins, allowing it to be used [`StationManagement`] directly.
52+
/// This version of the struct owns it's SMI pins,
53+
/// allowing it to be used [`StationManagement`] directly.
5454
pub struct EthernetMACWithSmi<MDIO, MDC>
5555
where
5656
MDIO: MdioPin,
@@ -71,11 +71,7 @@ where
7171
/// To interact with a connected Phy, use this struct's impl of
7272
/// [`StationManagement`]
7373
pub fn new(eth_mac: ETHERNET_MAC, mdio: MDIO, mdc: MDC) -> Self {
74-
Self {
75-
eth_mac,
76-
mdio: mdio,
77-
mdc: mdc,
78-
}
74+
Self { eth_mac, mdio, mdc }
7975
}
8076

8177
/// Release the owned MDIO and MDC pins, and return an EthernetMAC that

src/mac/smi.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ pub unsafe trait MdioPin {}
55
/// MDC pin types.
66
pub unsafe trait MdcPin {}
77

8+
/// A trait used for implementing access to SMI
9+
/// peripherals/functionality
810
pub trait StationManagement {
11+
/// Read an SMI register
912
fn read(&self, phy: u8, reg: u8) -> u16;
13+
/// Write an SMI register
1014
fn write(&mut self, phy: u8, reg: u8, data: u16);
1115
}
1216

@@ -52,9 +56,10 @@ pub(crate) fn smi_read(iar: &MACMIIAR, dr: &MACMIIDR, phy: u8, reg: u8) -> u16 {
5256
dr.read().md().bits()
5357
}
5458

55-
/// Station Management Interface with pins and registers borrowed from [`EthernetMAC`].
59+
/// Station Management Interface
5660
///
57-
/// Can also be constructed by borrowing from [`ETHERNET_MAC`] and borrowing the pins manually.
61+
/// Borrows [`MACMIIAR`] and [`MACMIIDR`] from (ETHERNET_MAC)[`crate::stm32::ETHERNET_MAC`], and holds a mutable borrow
62+
/// to the SMI pins.
5863
///
5964
/// Provides access to the MIIM implementation exposed by the MCU's MAC API.
6065
pub struct Smi<'eth, 'pins, Mdio, Mdc> {
@@ -69,12 +74,10 @@ where
6974
Mdio: MdioPin,
7075
Mdc: MdcPin,
7176
{
72-
/// Read an SMI register
7377
fn read(&self, phy: u8, reg: u8) -> u16 {
7478
smi_read(&self.macmiiar, &self.macmiidr, phy, reg)
7579
}
7680

77-
/// Write an SMI register
7881
fn write(&mut self, phy: u8, reg: u8, data: u16) {
7982
smi_write(&self.macmiiar, &self.macmiidr, phy, reg, data)
8083
}
@@ -85,7 +88,7 @@ where
8588
Mdio: MdioPin,
8689
Mdc: MdcPin,
8790
{
88-
/// Create the temporary `Smi` instance.
91+
/// Create a temporary `Smi` instance.
8992
///
9093
/// Temporarily take exclusive access to the MDIO and MDC pins to ensure they are not used
9194
/// elsewhere for the duration of SMI communication.
@@ -102,11 +105,6 @@ where
102105
_mdc,
103106
}
104107
}
105-
106-
/// Read an SMI register
107-
pub fn read(&self, phy: u8, reg: u8) -> u16 {
108-
smi_read(&self.macmiiar, &self.macmiidr, phy, reg)
109-
}
110108
}
111109

112110
#[cfg(feature = "stm32f4xx-hal")]

0 commit comments

Comments
 (0)