Skip to content

Commit 8bac2aa

Browse files
committed
Actually use the device-selected feature
1 parent db84bab commit 8bac2aa

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

src/lib.rs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,44 @@ pub use stm32f1xx_hal as hal;
2424
#[cfg(feature = "stm32f1xx-hal")]
2525
pub use stm32f1xx_hal::pac as stm32;
2626

27-
use hal::rcc::Clocks;
28-
use stm32::{ETHERNET_DMA, ETHERNET_MAC, ETHERNET_MMC};
27+
#[cfg(feature = "device-selected")]
28+
use {
29+
hal::rcc::Clocks,
30+
stm32::{ETHERNET_DMA, ETHERNET_MAC, ETHERNET_MMC},
31+
};
2932

33+
#[cfg(feature = "device-selected")]
3034
mod dma;
35+
#[cfg(feature = "device-selected")]
3136
pub use dma::{eth_interrupt_handler, EthernetDMA};
37+
38+
#[cfg(feature = "device-selected")]
3239
mod ring;
40+
#[cfg(feature = "device-selected")]
3341
pub use ring::RingEntry;
42+
3443
mod desc;
44+
45+
#[cfg(feature = "device-selected")]
3546
pub mod mac;
47+
#[cfg(feature = "device-selected")]
3648
pub use mac::{EthernetMAC, EthernetMACWithMii, WrongClock};
49+
50+
#[cfg(feature = "device-selected")]
3751
mod rx;
52+
#[cfg(feature = "device-selected")]
3853
pub use rx::{RxDescriptor, RxError, RxRingEntry};
54+
55+
#[cfg(feature = "device-selected")]
3956
mod tx;
57+
#[cfg(feature = "device-selected")]
4058
pub use tx::{TxDescriptor, TxError, TxRingEntry};
59+
60+
#[cfg(feature = "device-selected")]
4161
pub mod setup;
62+
#[cfg(feature = "device-selected")]
4263
pub use setup::EthPins;
64+
#[cfg(feature = "device-selected")]
4365
use setup::{
4466
AlternateVeryHighSpeed, RmiiCrsDv, RmiiRefClk, RmiiRxD0, RmiiRxD1, RmiiTxD0, RmiiTxD1, RmiiTxEN,
4567
};
@@ -51,6 +73,9 @@ mod smoltcp_phy;
5173
#[cfg(feature = "smoltcp-phy")]
5274
pub use smoltcp_phy::{EthRxToken, EthTxToken};
5375

76+
#[cfg(not(feature = "device-selected"))]
77+
compile_error!("No device was selected! Exactly one stm32fxxx feature must be selected.");
78+
5479
/// From the datasheet: *VLAN Frame maxsize = 1522*
5580
const MTU: usize = 1522;
5681

@@ -62,13 +87,14 @@ const MTU: usize = 1522;
6287
/// Automatically sets slew rate to VeryHigh.
6388
///
6489
/// This method does not initialise the external PHY. Interacting with a PHY
65-
/// can be done by using the struct returned from [`EthernetMAC::smi`].
90+
/// can be done by using the struct returned from [`EthernetMAC::mii`].
6691
///
6792
/// /// # Note
6893
/// - Make sure that the buffers reside in a memory region that is
6994
/// accessible by the peripheral. Core-Coupled Memory (CCM) is
7095
/// usually not accessible.
7196
/// - HCLK must be at least 25 MHz.
97+
#[cfg(feature = "device-selected")]
7298
pub fn new<'rx, 'tx, REFCLK, CRS, TXEN, TXD0, TXD1, RXD0, RXD1>(
7399
eth_mac: ETHERNET_MAC,
74100
eth_mmc: ETHERNET_MMC,
@@ -113,6 +139,7 @@ where
113139
/// accessible by the peripheral. Core-Coupled Memory (CCM) is
114140
/// usually not accessible.
115141
/// - HCLK must be at least 25 MHz.
142+
#[cfg(feature = "device-selected")]
116143
pub fn new_with_mii<'rx, 'tx, REFCLK, CRS, TXEN, TXD0, TXD1, RXD0, RXD1, MDIO, MDC>(
117144
eth_mac: ETHERNET_MAC,
118145
eth_mmc: ETHERNET_MMC,

0 commit comments

Comments
 (0)