Skip to content

Commit 0b20a08

Browse files
author
Johannes Draaijer
committed
Docs
1 parent 92397ab commit 0b20a08

File tree

3 files changed

+33
-29
lines changed

3 files changed

+33
-29
lines changed

src/lib.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ mod ring;
3333
pub use ring::RingEntry;
3434
mod desc;
3535
pub mod mac;
36-
pub use mac::{EthernetMAC, EthernetMACWithMiim, WrongClock};
36+
pub use mac::{EthernetMAC, EthernetMACWithMii, WrongClock};
3737
mod rx;
3838
pub use rx::{RxDescriptor, RxError, RxRingEntry};
3939
mod tx;
@@ -60,11 +60,15 @@ const MTU: usize = 1522;
6060
/// Sets up the peripheral clocks and GPIO configuration,
6161
/// and configures the ETH MAC and DMA peripherals.
6262
/// Automatically sets slew rate to VeryHigh.
63-
/// If you wish to use another configuration, please see
64-
/// [new_unchecked](new_unchecked).
6563
///
6664
/// This method does not initialise the external PHY. Interacting with a PHY
6765
/// can be done by using the struct returned from [`EthernetMAC::smi`].
66+
///
67+
/// /// # Note
68+
/// - Make sure that the buffers reside in a memory region that is
69+
/// accessible by the peripheral. Core-Coupled Memory (CCM) is
70+
/// usually not accessible.
71+
/// - HCLK must be at least 25 MHz.
6872
pub fn new<'rx, 'tx, REFCLK, CRS, TXEN, TXD0, TXD1, RXD0, RXD1>(
6973
eth_mac: ETHERNET_MAC,
7074
eth_mmc: ETHERNET_MMC,
@@ -96,13 +100,11 @@ where
96100
/// Sets up the peripheral clocks and GPIO configuration,
97101
/// and configures the ETH MAC and DMA peripherals.
98102
/// Automatically sets slew rate to VeryHigh.
99-
/// If you wish to use another configuration, please see
100-
/// [new_unchecked](new_unchecked).
101103
///
102104
/// This method does not initialise the external PHY.
103105
///
104106
/// The SMI for the external PHY can be accessed through the
105-
/// returned [`EthernetMACWithSmi`], which implements [`mac::SerialManagement`].
107+
/// returned [`EthernetMACWithMii`], .
106108
///
107109
/// # Note
108110
/// - Make sure that the buffers reside in a memory region that is
@@ -119,7 +121,7 @@ pub fn new_with_smi<'rx, 'tx, REFCLK, CRS, TXEN, TXD0, TXD1, RXD0, RXD1, MDIO, M
119121
pins: EthPins<REFCLK, CRS, TXEN, TXD0, TXD1, RXD0, RXD1>,
120122
mdio: MDIO,
121123
mdc: MDC,
122-
) -> Result<(EthernetDMA<'rx, 'tx>, EthernetMACWithMiim<MDIO, MDC>), WrongClock>
124+
) -> Result<(EthernetDMA<'rx, 'tx>, EthernetMACWithMii<MDIO, MDC>), WrongClock>
123125
where
124126
REFCLK: RmiiRefClk + AlternateVeryHighSpeed,
125127
CRS: RmiiCrsDv + AlternateVeryHighSpeed,

src/mac/miim.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,14 @@ fn miim_read(eth_mac: &mut ETHERNET_MAC, phy: u8, reg: u8) -> u16 {
5858

5959
/// Serial Management Interface
6060
///
61-
/// Borrows [`MACMIIAR`] and [`MACMIIDR`] from (ETHERNET_MAC)[`crate::stm32::ETHERNET_MAC`], and holds a mutable borrow
62-
/// to the SMI pins.
63-
pub struct Stm32Miim<'mac, 'pins, Mdio, Mdc> {
61+
/// Borrows an [`EthernetMAC`] and holds a mutable borrow to the SMI pins.
62+
pub struct Stm32Mii<'mac, 'pins, Mdio, Mdc> {
6463
mac: &'mac mut EthernetMAC,
6564
_mdio: &'pins mut Mdio,
6665
_mdc: &'pins mut Mdc,
6766
}
6867

69-
impl<'mac, 'pins, Mdio, Mdc> Stm32Miim<'mac, 'pins, Mdio, Mdc>
68+
impl<'mac, 'pins, Mdio, Mdc> Stm32Mii<'mac, 'pins, Mdio, Mdc>
7069
where
7170
Mdio: MdioPin,
7271
Mdc: MdcPin,
@@ -81,7 +80,7 @@ where
8180
}
8281

8382
#[cfg(feature = "ieee802_3_miim")]
84-
impl<'eth, 'pins, Mdio, Mdc> Miim for Stm32Miim<'eth, 'pins, Mdio, Mdc>
83+
impl<'eth, 'pins, Mdio, Mdc> Miim for Stm32Mii<'eth, 'pins, Mdio, Mdc>
8584
where
8685
Mdio: MdioPin,
8786
Mdc: MdcPin,
@@ -95,7 +94,7 @@ where
9594
}
9695
}
9796

98-
impl<'eth, 'pins, Mdio, Mdc> Stm32Miim<'eth, 'pins, Mdio, Mdc>
97+
impl<'eth, 'pins, Mdio, Mdc> Stm32Mii<'eth, 'pins, Mdio, Mdc>
9998
where
10099
Mdio: MdioPin,
101100
Mdc: MdcPin,

src/mac/mod.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ impl EthernetMAC {
4040
///
4141
/// HCLK must be at least 25MHz, else this function will return `Err(WrongClock)`.
4242
///
43-
/// This method does not initialise the external PHY. However it does return an
44-
/// [`EthernetMAC`] which implements the
45-
/// [`mac::SerialManagement`] trait. This can be used to
46-
/// communicate with the external PHY.
43+
/// This method does not initialise the external PHY. However, you can access SMI
44+
/// `read` and `write` functions through the `smi` and `with_smi` functions.
45+
///
46+
/// Additionally, an optional `impl` of the [`ieee802_3_miim::Miim`] trait is available
47+
/// with the `ieee802_3_miim` feature (enabled by default), for PHY communication.
4748
pub fn new<REFCLK, CRS, TXEN, TXD0, TXD1, RXD0, RXD1>(
4849
eth_mac: ETHERNET_MAC,
4950
eth_mmc: ETHERNET_MMC,
@@ -154,21 +155,21 @@ impl EthernetMAC {
154155
&'eth mut self,
155156
mdio: &'pins mut Mdio,
156157
mdc: &'pins mut Mdc,
157-
) -> Stm32Miim<'eth, 'pins, Mdio, Mdc>
158+
) -> Stm32Mii<'eth, 'pins, Mdio, Mdc>
158159
where
159160
Mdio: MdioPin,
160161
Mdc: MdcPin,
161162
{
162-
Stm32Miim::new(self, mdio, mdc)
163+
Stm32Mii::new(self, mdio, mdc)
163164
}
164165

165-
/// Turn this [`EthernetMAC`] into an [`EthernetMACWithSmi`]
166-
pub fn with_smi<MDIO, MDC>(self, mdio: MDIO, mdc: MDC) -> EthernetMACWithMiim<MDIO, MDC>
166+
/// Turn this [`EthernetMAC`] into an [`EthernetMACWithMii`]
167+
pub fn with_smi<MDIO, MDC>(self, mdio: MDIO, mdc: MDC) -> EthernetMACWithMii<MDIO, MDC>
167168
where
168169
MDIO: MdioPin,
169170
MDC: MdcPin,
170171
{
171-
EthernetMACWithMiim {
172+
EthernetMACWithMii {
172173
eth_mac: self,
173174
mdio,
174175
mdc,
@@ -181,7 +182,7 @@ impl EthernetMAC {
181182
/// This version of the struct owns it's SMI pins,
182183
/// allowing it to be used directly, instead of requiring
183184
/// that a [`Miim`] is created.
184-
pub struct EthernetMACWithMiim<MDIO, MDC>
185+
pub struct EthernetMACWithMii<MDIO, MDC>
185186
where
186187
MDIO: MdioPin,
187188
MDC: MdcPin,
@@ -191,15 +192,17 @@ where
191192
mdc: MDC,
192193
}
193194

194-
impl<MDIO, MDC> EthernetMACWithMiim<MDIO, MDC>
195+
impl<MDIO, MDC> EthernetMACWithMii<MDIO, MDC>
195196
where
196197
MDIO: MdioPin,
197198
MDC: MdcPin,
198199
{
199200
/// Create a new EthernetMAC with owned MDIO and MDC pins.
200201
///
201-
/// To interact with a connected Phy, use this struct's impl of
202-
/// [`SerialManagement`]
202+
/// To interact with a connected Phy, use the `read` and `write` functions.
203+
///
204+
/// Functionality for interacting with PHYs from the `ieee802_3_miim` crate
205+
/// is available if the default feature `ieee802_3_miim` is enabled.
203206
pub fn new(eth_mac: EthernetMAC, mdio: MDIO, mdc: MDC) -> Self {
204207
Self { eth_mac, mdio, mdc }
205208
}
@@ -211,7 +214,7 @@ where
211214
}
212215
}
213216

214-
impl<MDIO, MDC> Deref for EthernetMACWithMiim<MDIO, MDC>
217+
impl<MDIO, MDC> Deref for EthernetMACWithMii<MDIO, MDC>
215218
where
216219
MDIO: MdioPin,
217220
MDC: MdcPin,
@@ -223,7 +226,7 @@ where
223226
}
224227
}
225228

226-
impl<MDIO, MDC> EthernetMACWithMiim<MDIO, MDC>
229+
impl<MDIO, MDC> EthernetMACWithMii<MDIO, MDC>
227230
where
228231
MDIO: MdioPin,
229232
MDC: MdcPin,
@@ -242,7 +245,7 @@ where
242245
}
243246

244247
#[cfg(feature = "ieee802_3_miim")]
245-
impl<MDIO, MDC> miim::Miim for EthernetMACWithMiim<MDIO, MDC>
248+
impl<MDIO, MDC> miim::Miim for EthernetMACWithMii<MDIO, MDC>
246249
where
247250
MDIO: MdioPin,
248251
MDC: MdcPin,

0 commit comments

Comments
 (0)