Skip to content

Commit dddd3ef

Browse files
Johannes DraaijerJohannes Draaijer
authored andcommitted
Fix examples
Make `mac` a bit more encapsulated to avoid polluting `lib` scope
1 parent de4995b commit dddd3ef

File tree

7 files changed

+27
-27
lines changed

7 files changed

+27
-27
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn main() {
6666
6767
let mut rx_ring: [RingEntry<_>; 16] = Default::default();
6868
let mut tx_ring: [RingEntry<_>; 8] = Default::default();
69-
let (mut eth_dma, _eth_mac) = stm32_eth::new(
69+
let (mut eth_dma, _eth_mac) = stm32_eth::new_no_smi(
7070
p.ETHERNET_MAC,
7171
p.ETHERNET_MMC,
7272
p.ETHERNET_DMA,

examples/arp-smoltcp.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// cargo build --example arp-smoltcp --features=stm32f407,smi,smoltcp-phy,smoltcp/socket-tcp,smoltcp/socket-icmp
1+
// cargo build --example arp-smoltcp --features=stm32f407,smoltcp-phy,smoltcp/socket-tcp,smoltcp/socket-icmp
22
// This example uses the STM32F407 and the KSZ8051R as PHY. If necessary the pins,
33
// the PHY register addresses and masks have to be adapted, as well as the IPs.
44
// With Wireshark, you can see the ARP packets, which should look like this:
@@ -25,7 +25,7 @@ use smoltcp::wire::{
2525
use stm32_eth::{
2626
hal::gpio::{GpioExt, Speed},
2727
hal::rcc::RccExt,
28-
smi,
28+
mac::{MdcPin, MdioPin, Smi},
2929
stm32::{interrupt, CorePeripherals, Peripherals, SYST},
3030
};
3131
use stm32_eth::{EthPins, RingEntry, TxError};
@@ -75,7 +75,7 @@ fn main() -> ! {
7575

7676
let mut rx_ring: [RingEntry<_>; 16] = Default::default();
7777
let mut tx_ring: [RingEntry<_>; 8] = Default::default();
78-
let (mut eth_dma, mut eth_mac) = stm32_eth::new(
78+
let (mut eth_dma, mut eth_mac) = stm32_eth::new_borrowed_smi(
7979
p.ETHERNET_MAC,
8080
p.ETHERNET_MMC,
8181
p.ETHERNET_DMA,
@@ -180,10 +180,10 @@ fn ETH() {
180180
stm32_eth::eth_interrupt_handler(&p.ETHERNET_DMA);
181181
}
182182

183-
fn link_detected<Mdio, Mdc>(smi: smi::Smi<Mdio, Mdc>) -> bool
183+
fn link_detected<Mdio, Mdc>(smi: Smi<Mdio, Mdc>) -> bool
184184
where
185-
Mdio: smi::MdioPin,
186-
Mdc: smi::MdcPin,
185+
Mdio: MdioPin,
186+
Mdc: MdcPin,
187187
{
188188
let status = smi.read(PHY_ADDR, PHY_REG_BSR);
189189
(status & PHY_REG_BSR_UP) == PHY_REG_BSR_UP

examples/arp.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// cargo build --example arp --features=stm32f407,smi
1+
// cargo build --example arp --features=stm32f407
22
// This example uses the STM32F407 and the KSZ8051R as PHY. If necessary the pins,
33
// the PHY register addresses and masks have to be adapted, as well as the IPs.
44
// With Wireshark, you can see the ARP packets, which should look like this:
@@ -20,7 +20,7 @@ use fugit::RateExtU32;
2020
use stm32_eth::{
2121
hal::gpio::{GpioExt, Speed},
2222
hal::rcc::RccExt,
23-
smi,
23+
mac,
2424
stm32::{interrupt, CorePeripherals, Peripherals, SYST},
2525
};
2626

@@ -73,7 +73,7 @@ fn main() -> ! {
7373

7474
let mut rx_ring: [RingEntry<_>; 16] = Default::default();
7575
let mut tx_ring: [RingEntry<_>; 8] = Default::default();
76-
let (mut eth_dma, mut eth_mac) = stm32_eth::new(
76+
let (mut eth_dma, mut eth_mac) = stm32_eth::new_borrowed_smi(
7777
p.ETHERNET_MAC,
7878
p.ETHERNET_MMC,
7979
p.ETHERNET_DMA,
@@ -178,10 +178,10 @@ fn ETH() {
178178
stm32_eth::eth_interrupt_handler(&p.ETHERNET_DMA);
179179
}
180180

181-
fn link_detected<Mdio, Mdc>(smi: smi::Smi<Mdio, Mdc>) -> bool
181+
fn link_detected<Mdio, Mdc>(smi: mac::Smi<Mdio, Mdc>) -> bool
182182
where
183-
Mdio: smi::MdioPin,
184-
Mdc: smi::MdcPin,
183+
Mdio: mac::MdioPin,
184+
Mdc: mac::MdcPin,
185185
{
186186
let status = smi.read(PHY_ADDR, PHY_REG_BSR);
187187
(status & PHY_REG_BSR_UP) == PHY_REG_BSR_UP

examples/ip-f107.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn main() -> ! {
102102

103103
let mut rx_ring: [RingEntry<_>; 8] = Default::default();
104104
let mut tx_ring: [RingEntry<_>; 2] = Default::default();
105-
let (mut eth_dma, _eth_mac) = stm32_eth::new(
105+
let (mut eth_dma, _eth_mac) = stm32_eth::new_no_smi(
106106
p.ETHERNET_MAC,
107107
p.ETHERNET_MMC,
108108
p.ETHERNET_DMA,

examples/ip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn main() -> ! {
8585

8686
let mut rx_ring: [RingEntry<_>; 8] = Default::default();
8787
let mut tx_ring: [RingEntry<_>; 2] = Default::default();
88-
let (mut eth_dma, _eth_mac) = stm32_eth::new(
88+
let (mut eth_dma, _eth_mac) = stm32_eth::new_no_smi(
8989
p.ETHERNET_MAC,
9090
p.ETHERNET_MMC,
9191
p.ETHERNET_DMA,

examples/pktgen.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use fugit::RateExtU32;
1717
use stm32_eth::{
1818
hal::gpio::{GpioExt, Speed},
1919
hal::rcc::RccExt,
20-
smi,
20+
mac,
2121
stm32::{interrupt, CorePeripherals, Peripherals, SYST},
2222
};
2323

@@ -70,7 +70,7 @@ fn main() -> ! {
7070

7171
let mut rx_ring: [RingEntry<_>; 16] = Default::default();
7272
let mut tx_ring: [RingEntry<_>; 8] = Default::default();
73-
let (mut eth_dma, mut eth_mac) = stm32_eth::new(
73+
let (mut eth_dma, mut eth_mac) = stm32_eth::new_borrowed_smi(
7474
p.ETHERNET_MAC,
7575
p.ETHERNET_MMC,
7676
p.ETHERNET_DMA,
@@ -214,10 +214,10 @@ fn ETH() {
214214
stm32_eth::eth_interrupt_handler(&p.ETHERNET_DMA);
215215
}
216216

217-
fn link_detected<Mdio, Mdc>(smi: smi::Smi<Mdio, Mdc>) -> bool
217+
fn link_detected<Mdio, Mdc>(smi: mac::Smi<Mdio, Mdc>) -> bool
218218
where
219-
Mdio: smi::MdioPin,
220-
Mdc: smi::MdcPin,
219+
Mdio: mac::MdioPin,
220+
Mdc: mac::MdcPin,
221221
{
222222
const STATUS_REG_ADDR: u8 = 0x3;
223223
const STATUS_REG_UP_MASK: u16 = 1 << 2;

src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ use stm32::{Interrupt, ETHERNET_DMA, ETHERNET_MAC, ETHERNET_MMC, NVIC};
3030
mod ring;
3131
pub use ring::RingEntry;
3232
mod desc;
33-
mod mac;
34-
pub use mac::*;
33+
pub mod mac;
34+
pub use mac::EthernetMAC;
3535
mod rx;
3636
pub use rx::{RxDescriptor, RxError, RxRingEntry};
3737
use rx::{RxPacket, RxRing};
@@ -131,8 +131,8 @@ macro_rules! new {
131131
};
132132
}
133133

134-
new!(new_no_smi, NoSmi);
135-
new!(new_borrowed_smi, BorrowedSmi);
134+
new!(new_no_smi, mac::NoSmi);
135+
new!(new_borrowed_smi, mac::BorrowedSmi);
136136

137137
/// Create and initialise the ethernet driver.
138138
///
@@ -177,12 +177,12 @@ where
177177
TXD1: RmiiTxD1 + AlternateVeryHighSpeed,
178178
RXD0: RmiiRxD0 + AlternateVeryHighSpeed,
179179
RXD1: RmiiRxD1 + AlternateVeryHighSpeed,
180-
MDIO: MdioPin,
181-
MDC: MdcPin,
180+
MDIO: mac::MdioPin,
181+
MDC: mac::MdcPin,
182182
{
183183
pins.setup_pins();
184184

185-
let eth_mac = EthernetMAC::<OwnedSmi<MDIO, MDC>>::new(eth_mac, mdio, mdc);
185+
let eth_mac = EthernetMAC::<mac::OwnedSmi<MDIO, MDC>>::new(eth_mac, mdio, mdc);
186186

187187
unsafe { new_unchecked(eth_mac, eth_mmc, eth_dma, rx_buffer, tx_buffer, clocks) }
188188
}

0 commit comments

Comments
 (0)