@@ -20,38 +20,34 @@ cargo build --example="ip-f107" --features="stm32f107 smoltcp-phy log smoltcp/so
20
20
21
21
## Usage
22
22
23
- Add to the ` [dependencies] ` section in your ` Cargo.toml ` :
23
+ Add one of the following to the ` [dependencies] ` section in your ` Cargo.toml ` (with the correct MCU specified) :
24
24
25
- ``` rust
26
- stm32f4xx - hal = { version = " 0.10.1" , features = [" stm32f429" ] }
27
- stm32 - eth = { version = " 0.2.0" , features = [" stm32f429" ] }
25
+ ``` toml
26
+ stm32-eth = { version = " 0.3.0" , features = [" stm32f429" ] } # For stm32f4xx-like MCUs
27
+ stm32-eth = { version = " 0.3.0" , features = [" stm32f767" ] } # For stm32f7xx-like MCUs
28
+ stm32-eth = { version = " 0.3.0" , features = [" stm32f107" ] } # For stm32f107
28
29
```
29
30
30
- or
31
-
32
- ``` rust
33
- stm32f7xx - hal = { version = " 0.6.0" , features = [" stm32f767" ] }
34
- stm32 - eth = { version = " 0.2.0" , features = [" stm32f767" ]}
35
- ```
31
+ ` stm32_eth ` re-exports the underlying HAL as ` stm32_eth::hal ` .
36
32
37
33
In ` src/main.rs ` add:
38
34
39
- ``` rust
35
+ ``` rust,no_run
40
36
use stm32_eth::{
41
37
hal::gpio::GpioExt,
42
38
hal::rcc::RccExt,
43
39
stm32::Peripherals,
40
+ RingEntry,
41
+ EthPins,
44
42
};
45
-
46
-
47
- use stm32_eth :: {RingEntry };
43
+ use fugit::RateExtU32;
48
44
49
45
fn main() {
50
46
let p = Peripherals::take().unwrap();
51
47
52
48
let rcc = p.RCC.constrain();
53
49
// HCLK must be at least 25MHz to use the ethernet peripheral
54
- let clocks = rcc . cfgr. sysclk (32. mhz ()). hclk (32. mhz ()). freeze ();
50
+ let clocks = rcc.cfgr.sysclk(32.MHz ()).hclk(32.MHz ()).freeze();
55
51
56
52
let gpioa = p.GPIOA.split();
57
53
let gpiob = p.GPIOB.split();
@@ -60,8 +56,6 @@ fn main() {
60
56
61
57
let eth_pins = EthPins {
62
58
ref_clk: gpioa.pa1,
63
- md_io : gpioa . pa2,
64
- md_clk : gpioc . pc1,
65
59
crs: gpioa.pa7,
66
60
tx_en: gpiog.pg11,
67
61
tx_d0: gpiog.pg13,
@@ -74,6 +68,7 @@ fn main() {
74
68
let mut tx_ring: [RingEntry<_>; 8] = Default::default();
75
69
let (mut eth_dma, _eth_mac) = stm32_eth::new(
76
70
p.ETHERNET_MAC,
71
+ p.ETHERNET_MMC,
77
72
p.ETHERNET_DMA,
78
73
&mut rx_ring[..],
79
74
&mut tx_ring[..],
@@ -83,10 +78,11 @@ fn main() {
83
78
.unwrap();
84
79
eth_dma.enable_interrupt();
85
80
86
- if let Ok (pkt ) = eth . recv_next () {
81
+ if let Ok(pkt) = eth_dma .recv_next() {
87
82
// handle received pkt
88
83
}
89
84
85
+ let size = 42;
90
86
eth_dma.send(size, |buf| {
91
87
// write up to `size` bytes into buf before it is being sent
92
88
}).expect("send");
0 commit comments