@@ -8,11 +8,13 @@ use cortex_m::iprintln;
8
8
9
9
use cortex_m_rt:: entry;
10
10
use embedded_hal:: digital:: v2:: OutputPin ;
11
+ use embedded_hal:: blocking:: delay:: DelayMs ;
11
12
use stm32f4xx_hal:: {
12
13
rcc:: RccExt ,
13
14
gpio:: GpioExt ,
14
15
time:: U32Ext ,
15
16
stm32:: { CorePeripherals , Peripherals } ,
17
+ delay:: Delay ,
16
18
spi:: Spi ,
17
19
time:: Hertz
18
20
} ;
@@ -36,7 +38,7 @@ use stm32f4xx_hal::{
36
38
rcc:: Clocks ,
37
39
time:: MilliSeconds ,
38
40
timer:: { Timer , Event as TimerEvent } ,
39
- stm32:: SYST ,
41
+ stm32:: SYST
40
42
} ;
41
43
/// Rate in Hz
42
44
const TIMER_RATE : u32 = 20 ;
@@ -117,6 +119,7 @@ fn main() -> ! {
117
119
// NIC100 / ENC424J600 Set-up
118
120
let spi1 = dp. SPI1 ;
119
121
let gpioa = dp. GPIOA . split ( ) ;
122
+ let mut delay = Delay :: new ( cp. SYST , clocks) ;
120
123
// Mapping: see Table 9, STM32F407ZG Manual
121
124
let spi1_sck = gpioa. pa5 . into_alternate_af5 ( ) ;
122
125
let spi1_miso = gpioa. pa6 . into_alternate_af5 ( ) ;
@@ -125,6 +128,7 @@ fn main() -> ! {
125
128
// Map SPISEL: see Table 1, NIC100 Manual
126
129
let mut spisel = gpioa. pa1 . into_push_pull_output ( ) ;
127
130
spisel. set_high ( ) . unwrap ( ) ;
131
+ delay. delay_ms ( 1_u32 ) ;
128
132
spisel. set_low ( ) . unwrap ( ) ;
129
133
// Create SPI1 for HAL
130
134
let spi_eth_port = Spi :: spi1 (
@@ -134,7 +138,7 @@ fn main() -> ! {
134
138
clocks) ;
135
139
let mut spi_eth = enc424j600:: SpiEth :: new ( spi_eth_port, spi1_nss) ;
136
140
// Init
137
- match spi_eth. init_dev ( ) {
141
+ match spi_eth. init_dev ( & mut delay ) {
138
142
Ok ( _) => {
139
143
iprintln ! ( stim0, "Ethernet initialised." )
140
144
}
@@ -145,7 +149,7 @@ fn main() -> ! {
145
149
146
150
// Setup SysTick
147
151
// Reference to stm32-eth:examples/ip.rs
148
- timer_setup ( cp . SYST , clocks) ;
152
+ timer_setup ( delay . free ( ) , clocks) ;
149
153
iprintln ! ( stim0, "Timer initialised." ) ;
150
154
151
155
// Read MAC
@@ -165,7 +169,7 @@ fn main() -> ! {
165
169
// examples/loopback.rs, examples/multicast.rs
166
170
let device = smoltcp_phy:: SmoltcpDevice :: new ( & mut spi_eth) ;
167
171
let mut neighbor_cache_entries = [ None ; 16 ] ;
168
- let mut neighbor_cache = NeighborCache :: new ( & mut neighbor_cache_entries[ ..] ) ;
172
+ let neighbor_cache = NeighborCache :: new ( & mut neighbor_cache_entries[ ..] ) ;
169
173
let ip_addr = IpCidr :: new ( IpAddress :: v4 (
170
174
arg_ip[ 0 ] , arg_ip[ 1 ] , arg_ip[ 2 ] , arg_ip[ 3 ] ) , arg_ip_pref) ;
171
175
let mut ip_addrs = [ ip_addr] ;
0 commit comments