1
1
#![ no_std]
2
2
#![ no_main]
3
3
4
- // A simple TCP echo server using RTIC
5
- //
6
- // To run, use the following command:
7
- // DEFMT_LOG=info PROBE_RUN_CHIP=<probe-run chip> cargo run --example rtic-echo --features <chip here> --target <correct target for chip> --release --features="cortex-m-rtic smoltcp-phy smoltcp/medium-ethernet smoltcp/socket-tcp defmt-rtt panic-probe systick-monotonic fugit defmt smoltcp/defmt"
4
+ //! A simple TCP echo server using RTIC.
5
+ //!
6
+ //! Starts a TCP echo server on port `1337` at `ADDRESS`. `ADDRESS` is `10.0.0.1/24` by default.
7
+ //!
8
+ //! By default, the example assumes that the default RMII pins are used.
9
+ //! To use it on an stm32-nucleo-f746zg dev board, the `rtic-echo-example-altpin` feature should be enabled. This may work on other
10
+ //! boards, but that hasn't been tested so your mileage may vary.
11
+ //!
12
+ //! To run this, install `probe-run` (`cargo install probe-run --version '~0.3'`), and ensure that `probe-run` can
13
+ //! attach to your test board.
14
+ //! Then, use the following command:
15
+ //! DEFMT_LOG=info PROBE_RUN_CHIP=<probe-run chip> cargo run --example rtic-echo --features <chip here>,rtic-echo-example --target <correct target for chip> --release
8
16
9
17
use defmt_rtt as _;
10
18
use panic_probe as _;
@@ -160,14 +168,16 @@ mod app {
160
168
161
169
interface. poll ( now_fn ( ) ) . unwrap ( ) ;
162
170
163
- let mut phy = crate :: EthernetPhy :: from_miim ( mac, 0 ) . unwrap ( ) ;
164
-
165
- defmt:: info!(
166
- "Resetting PHY as an extra step. Type: {}" ,
167
- phy. ident_string( )
168
- ) ;
171
+ if let Ok ( mut phy) = crate :: EthernetPhy :: from_miim ( mac, 0 ) {
172
+ defmt:: info!(
173
+ "Resetting PHY as an extra step. Type: {}" ,
174
+ phy. ident_string( )
175
+ ) ;
169
176
170
- phy. phy_init ( ) ;
177
+ phy. phy_init ( ) ;
178
+ } else {
179
+ defmt:: info!( "Not resetting unsupported PHY." ) ;
180
+ }
171
181
172
182
defmt:: info!( "Setup done." ) ;
173
183
@@ -262,18 +272,24 @@ mod pins {
262
272
pub type RxD0 = PC4 < Input > ;
263
273
pub type RxD1 = PC5 < Input > ;
264
274
275
+ #[ cfg( not( feature = "rtic-echo-example-altpin" ) ) ]
265
276
pub type TxEn = PB11 < Input > ;
277
+ #[ cfg( not( feature = "rtic-echo-example-altpin" ) ) ]
266
278
pub type TxD0 = PB12 < Input > ;
267
279
280
+ #[ cfg( all( feature = "rtic-echo-example-altpin" ) ) ]
281
+ pub type TxEn = PG11 < Input > ;
282
+ #[ cfg( feature = "rtic-echo-example-altpin" ) ]
283
+ pub type TxD0 = PG13 < Input > ;
284
+
268
285
pub type Mdio = PA2 < Alternate < 11 > > ;
269
286
pub type Mdc = PC1 < Alternate < 11 > > ;
270
287
271
- #[ allow( unused_variables) ]
272
288
pub fn get_pins (
273
289
gpioa : gpioa:: Parts ,
274
290
gpiob : gpiob:: Parts ,
275
291
gpioc : gpioc:: Parts ,
276
- gpiog : gpiog:: Parts ,
292
+ # [ allow ( unused_variables ) ] gpiog : gpiog:: Parts ,
277
293
) -> (
278
294
EthPins < RefClk , Crs , TxEn , TxD0 , TxD1 , RxD0 , RxD1 > ,
279
295
Mdio ,
@@ -285,11 +301,18 @@ mod pins {
285
301
let rx_d0 = gpioc. pc4 . into_floating_input ( ) ;
286
302
let rx_d1 = gpioc. pc5 . into_floating_input ( ) ;
287
303
304
+ #[ cfg( not( feature = "rtic-echo-example-altpin" ) ) ]
288
305
let ( tx_en, tx_d0) = (
289
306
gpiob. pb11 . into_floating_input ( ) ,
290
307
gpiob. pb12 . into_floating_input ( ) ,
291
308
) ;
292
309
310
+ #[ cfg( feature = "rtic-echo-example-altpin" ) ]
311
+ let ( tx_en, tx_d0) = (
312
+ gpiog. pg11 . into_floating_input ( ) ,
313
+ gpiog. pg13 . into_floating_input ( ) ,
314
+ ) ;
315
+
293
316
#[ cfg( feature = "stm32f4xx-hal" ) ]
294
317
let ( mdio, mdc) = {
295
318
let mut mdio = gpioa. pa2 . into_alternate ( ) ;
@@ -322,7 +345,6 @@ mod pins {
322
345
}
323
346
324
347
#[ cfg( any( feature = "stm32f1xx-hal" ) ) ]
325
- #[ allow( missing_docs) ]
326
348
mod pins {
327
349
use stm32_eth:: {
328
350
hal:: gpio:: { Alternate , Input , PushPull , * } ,
0 commit comments