Skip to content

Commit a139265

Browse files
committed
Fix examples
1 parent 4b133c0 commit a139265

File tree

4 files changed

+38
-17
lines changed

4 files changed

+38
-17
lines changed

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,16 @@ smoltcp-verbose = ["smoltcp/verbose"]
4343
cortex-m = "0.5"
4444
cortex-m-rt = "0.6"
4545
panic-itm = "0.4"
46+
cortex-m-semihosting = "0.3.5"
47+
stm32f4xx-hal = {version = "0.8.3", features = ["rt"] }
4648

4749
[[example]]
4850
name = "pktgen"
51+
required-features = ["stm32f429"]
4952

5053
[[example]]
5154
name = "ip"
52-
required-features = ["smoltcp-phy", "stm32f429"]
55+
required-features = ["stm32f429", "smoltcp-phy", "smoltcp-log", "smoltcp-verbose"]
5356

5457
[profile.release]
5558
debug = 2

examples/ip.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use smoltcp::socket::{SocketSet, TcpSocket, TcpSocketBuffer};
2222
use smoltcp::time::Instant;
2323
use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr, Ipv4Address};
2424

25-
use stm32_eth::{Eth, RingEntry};
25+
use stm32_eth::{Eth, EthPins, RingEntry};
2626

2727
static mut LOGGER: HioLogger = HioLogger {};
2828

@@ -62,15 +62,24 @@ fn main() -> ! {
6262
setup_systick(&mut cp.SYST);
6363

6464
writeln!(stdout, "Enabling ethernet...").unwrap();
65-
stm32_eth::setup(&p.RCC, &p.SYSCFG);
65+
stm32_eth::setup();
6666
let gpioa = p.GPIOA.split();
6767
let gpiob = p.GPIOB.split();
6868
let gpioc = p.GPIOC.split();
6969
let gpiog = p.GPIOG.split();
70-
stm32_eth::setup_pins(
71-
gpioa.pa1, gpioa.pa2, gpioa.pa7, gpiob.pb13, gpioc.pc1, gpioc.pc4, gpioc.pc5, gpiog.pg11,
72-
gpiog.pg13,
73-
);
70+
71+
let eth_pins = EthPins {
72+
ref_clk: gpioa.pa1,
73+
md_io: gpioa.pa2,
74+
md_clk: gpioc.pc1,
75+
crs: gpioa.pa7,
76+
tx_en: gpiog.pg11,
77+
tx_d0: gpiog.pg13,
78+
tx_d1: gpiob.pb13,
79+
rx_d0: gpioc.pc4,
80+
rx_d1: gpioc.pc5,
81+
};
82+
eth_pins.setup();
7483

7584
let mut rx_ring: [RingEntry<_>; 8] = Default::default();
7685
let mut tx_ring: [RingEntry<_>; 2] = Default::default();
@@ -80,7 +89,7 @@ fn main() -> ! {
8089
&mut rx_ring[..],
8190
&mut tx_ring[..],
8291
);
83-
eth.enable_interrupt(&mut cp.NVIC);
92+
eth.enable_interrupt();
8493

8594
let local_addr = Ipv4Address::new(10, 0, 0, 1);
8695
let ip_addr = IpCidr::new(IpAddress::from(local_addr), 24);

examples/pktgen.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use stm32f4xx_hal::{
1717
use core::fmt::Write;
1818
use cortex_m_semihosting::hio;
1919

20-
use stm32_eth::{Eth, RingEntry, TxError};
20+
use stm32_eth::{Eth, EthPins, RingEntry, TxError};
2121

2222
const SRC_MAC: [u8; 6] = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
2323
const DST_MAC: [u8; 6] = [0x00, 0x00, 0xBE, 0xEF, 0xDE, 0xAD];
@@ -36,15 +36,24 @@ fn main() -> ! {
3636
setup_systick(&mut cp.SYST);
3737

3838
writeln!(stdout, "Enabling ethernet...").unwrap();
39-
stm32_eth::setup(&p.RCC, &p.SYSCFG);
39+
stm32_eth::setup();
4040
let gpioa = p.GPIOA.split();
4141
let gpiob = p.GPIOB.split();
4242
let gpioc = p.GPIOC.split();
4343
let gpiog = p.GPIOG.split();
44-
stm32_eth::setup_pins(
45-
gpioa.pa1, gpioa.pa2, gpioa.pa7, gpiob.pb13, gpioc.pc1, gpioc.pc4, gpioc.pc5, gpiog.pg11,
46-
gpiog.pg13,
47-
);
44+
45+
let eth_pins = EthPins {
46+
ref_clk: gpioa.pa1,
47+
md_io: gpioa.pa2,
48+
md_clk: gpioc.pc1,
49+
crs: gpioa.pa7,
50+
tx_en: gpiog.pg11,
51+
tx_d0: gpiog.pg13,
52+
tx_d1: gpiob.pb13,
53+
rx_d0: gpioc.pc4,
54+
rx_d1: gpioc.pc5,
55+
};
56+
eth_pins.setup();
4857

4958
let mut rx_ring: [RingEntry<_>; 16] = Default::default();
5059
let mut tx_ring: [RingEntry<_>; 8] = Default::default();
@@ -54,7 +63,7 @@ fn main() -> ! {
5463
&mut rx_ring[..],
5564
&mut tx_ring[..],
5665
);
57-
eth.enable_interrupt(&mut cp.NVIC);
66+
eth.enable_interrupt();
5867

5968
// Main loop
6069
let mut last_stats_time = 0usize;

src/setup.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub trait AlternateVeryHighSpeed {
8686
pub struct EthPins<REFCLK, IO, CLK, CRS, TXEN, TXD0, TXD1, RXD0, RXD1> {
8787
pub ref_clk: REFCLK,
8888
pub md_io: IO,
89-
pub m_clk: CLK,
89+
pub md_clk: CLK,
9090
pub crs: CRS,
9191
pub tx_en: TXEN,
9292
pub tx_d0: TXD0,
@@ -119,7 +119,7 @@ where
119119
pub fn setup(self) {
120120
self.ref_clk.into_af11_very_high_speed();
121121
self.md_io.into_af11_very_high_speed();
122-
self.m_clk.into_af11_very_high_speed();
122+
self.md_clk.into_af11_very_high_speed();
123123
self.crs.into_af11_very_high_speed();
124124
self.tx_en.into_af11_very_high_speed();
125125
self.tx_d0.into_af11_very_high_speed();

0 commit comments

Comments
 (0)