Skip to content

Commit 0ce88ed

Browse files
committed
doc-inline on some items and some From impls
1 parent 0d5537a commit 0ce88ed

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use hal::rcc::Clocks;
2626

2727
#[cfg(feature = "device-selected")]
2828
pub mod dma;
29+
#[doc(inline)]
2930
#[cfg(feature = "device-selected")]
3031
pub use dma::eth_interrupt_handler;
3132

@@ -34,6 +35,7 @@ pub mod mac;
3435

3536
#[cfg(feature = "device-selected")]
3637
pub mod setup;
38+
#[doc(inline)]
3739
#[cfg(feature = "device-selected")]
3840
pub use setup::{EthPins, Parts, PartsIn};
3941

src/setup.rs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pub trait AlternateVeryHighSpeed {
184184
fn into_af11_very_high_speed(self);
185185
}
186186

187-
/// A struct that contains all parts required to configure
187+
/// A struct that contains all peripheral parts required to configure
188188
/// the ethernet peripheral.
189189
#[allow(missing_docs)]
190190
pub struct PartsIn {
@@ -195,6 +195,29 @@ pub struct PartsIn {
195195
pub ptp: ETHERNET_PTP,
196196
}
197197

198+
#[cfg(feature = "ptp")]
199+
impl From<(ETHERNET_MAC, ETHERNET_MMC, ETHERNET_DMA, ETHERNET_PTP)> for PartsIn {
200+
fn from(value: (ETHERNET_MAC, ETHERNET_MMC, ETHERNET_DMA, ETHERNET_PTP)) -> Self {
201+
Self {
202+
mac: value.0,
203+
mmc: value.1,
204+
dma: value.2,
205+
ptp: value.3,
206+
}
207+
}
208+
}
209+
210+
#[cfg(not(feature = "ptp"))]
211+
impl From<(ETHERNET_MAC, ETHERNET_MMC, ETHERNET_DMA)> for PartsIn {
212+
fn from(value: (ETHERNET_MAC, ETHERNET_MMC, ETHERNET_DMA)) -> Self {
213+
Self {
214+
mac: value.0,
215+
mmc: value.1,
216+
dma: value.2,
217+
}
218+
}
219+
}
220+
198221
/// Access to all configured parts of the ethernet peripheral.
199222
pub struct Parts<'rx, 'tx, T> {
200223
/// Access to and control over the ethernet MAC.
@@ -206,6 +229,22 @@ pub struct Parts<'rx, 'tx, T> {
206229
pub ptp: EthernetPTP,
207230
}
208231

232+
#[cfg(feature = "ptp")]
233+
impl<'rx, 'tx, T> Parts<'rx, 'tx, T> {
234+
/// Split this [`Parts`] into its components.
235+
pub fn split(self) -> (T, EthernetDMA<'rx, 'tx>, EthernetPTP) {
236+
(self.mac, self.dma, self.ptp)
237+
}
238+
}
239+
240+
#[cfg(not(feature = "ptp"))]
241+
impl<'rx, 'tx, T> Parts<'rx, 'tx, T> {
242+
/// Split this [`Parts`] into its components.
243+
pub fn split(self) -> (T, EthernetDMA<'rx, 'tx>) {
244+
(self.mac, self.dma)
245+
}
246+
}
247+
209248
/// A struct that represents a combination of pins to be used
210249
/// as RMII pins for the ethernet peripheral(s)
211250
// NOTE(missing_docs): all fields of this struct are self-explanatory

0 commit comments

Comments
 (0)