@@ -10,15 +10,15 @@ pub use miim::*;
10
10
pub ( crate ) struct MacParts {
11
11
pub eth_mac : ETHERNET_MAC ,
12
12
#[ cfg( feature = "f-series" ) ]
13
- pub eth_mmc : ETHERNET_MMC ,
13
+ pub eth_mmc : crate :: stm32 :: ETHERNET_MMC ,
14
14
}
15
15
16
16
impl MacParts {
17
17
fn enable_promicious_mode ( & self ) {
18
18
let Self { eth_mac, .. } = self ;
19
19
20
20
#[ cfg( feature = "f-series" ) ]
21
- let ( mac_filter_reg , flow_control) = ( & eth_mac. macffr , & eth_mac. macfcr ) ;
21
+ let ( mac_filter , flow_control) = ( & eth_mac. macffr , & eth_mac. macfcr ) ;
22
22
#[ cfg( feature = "stm32h7xx-hal" ) ]
23
23
let ( mac_filter, flow_control) = ( & eth_mac. macpfr , & eth_mac. macqtx_fcr ) ;
24
24
@@ -42,14 +42,9 @@ impl MacParts {
42
42
}
43
43
44
44
fn disable_mmc_interrupts ( & self ) {
45
- let Self {
46
- eth_mac,
47
- #[ cfg( feature = "f-series" ) ]
48
- eth_mmc,
49
- } = self ;
50
-
51
45
#[ cfg( feature = "f-series" ) ]
52
46
{
47
+ let eth_mmc = & self . eth_mmc ;
53
48
// Disable all MMC RX interrupts
54
49
eth_mmc
55
50
. mmcrimr
@@ -69,6 +64,8 @@ impl MacParts {
69
64
70
65
#[ cfg( feature = "stm32h7xx-hal" ) ]
71
66
{
67
+ let eth_mac = & self . eth_mac ;
68
+
72
69
// Disable all MMC RX interrupts
73
70
eth_mac. mmc_rx_interrupt_mask . write ( |w| {
74
71
w. rxlpitrcim ( )
@@ -163,11 +160,7 @@ impl EthernetMAC {
163
160
// it doesn't work.
164
161
_dma : & EthernetDMA ,
165
162
) -> Result < Self , WrongClock > {
166
- let MacParts {
167
- eth_mac,
168
- #[ cfg( feature = "f-series" ) ]
169
- eth_mmc,
170
- } = & parts;
163
+ let eth_mac = & parts. eth_mac ;
171
164
172
165
// TODO: configure MDIOS
173
166
#[ cfg( feature = "f-series" ) ]
@@ -218,12 +211,7 @@ impl EthernetMAC {
218
211
. dr ( )
219
212
. set_bit ( ) ;
220
213
221
- // Fast Ethernet speed
222
- w. fes ( )
223
- . set_bit ( )
224
- // Duplex mode
225
- . dm ( )
226
- . set_bit ( )
214
+ w
227
215
// Receiver enable
228
216
. re ( )
229
217
. set_bit ( )
@@ -244,6 +232,31 @@ impl EthernetMAC {
244
232
Ok ( me)
245
233
}
246
234
235
+ /// Set the Ethernet Speed at which the MAC communicates
236
+ ///
237
+ /// Note that this does _not_ affect the PHY in any way. To
238
+ /// configure the PHY, use [`EthernetMACWithMii`] (see: [`Self::with_mii`])
239
+ /// or [`Stm32Mii`] (see: [`Self::mii`])
240
+ pub fn set_speed ( & mut self , speed : Speed ) {
241
+ self . eth_mac . maccr . modify ( |_, w| match speed {
242
+ Speed :: HalfDuplexBase10T => w. fes ( ) . clear_bit ( ) . dm ( ) . clear_bit ( ) ,
243
+ Speed :: FullDuplexBase10T => w. fes ( ) . clear_bit ( ) . dm ( ) . set_bit ( ) ,
244
+ Speed :: HalfDuplexBase100Tx => w. fes ( ) . set_bit ( ) . dm ( ) . clear_bit ( ) ,
245
+ Speed :: FullDuplexBase100Tx => w. fes ( ) . set_bit ( ) . dm ( ) . set_bit ( ) ,
246
+ } ) ;
247
+ }
248
+
249
+ /// Get the Ethernet Speed at which the MAC communicates
250
+ pub fn get_speed ( & self ) -> Speed {
251
+ let cr = self . eth_mac . maccr . read ( ) ;
252
+ match ( cr. fes ( ) . bit_is_set ( ) , cr. dm ( ) . bit_is_set ( ) ) {
253
+ ( false , false ) => Speed :: HalfDuplexBase10T ,
254
+ ( false , true ) => Speed :: FullDuplexBase10T ,
255
+ ( true , false ) => Speed :: HalfDuplexBase100Tx ,
256
+ ( true , true ) => Speed :: FullDuplexBase100Tx ,
257
+ }
258
+ }
259
+
247
260
/// Borrow access to the MAC's SMI.
248
261
///
249
262
/// Allows for controlling and monitoring any PHYs that may be accessible via the MDIO/MDC
@@ -271,36 +284,7 @@ impl EthernetMAC {
271
284
MDIO : MdioPin ,
272
285
MDC : MdcPin ,
273
286
{
274
- EthernetMACWithMii {
275
- eth_mac : self ,
276
- mdio,
277
- mdc,
278
- }
279
- }
280
-
281
- /// Set the Ethernet Speed at which the MAC communicates
282
- ///
283
- /// Note that this does _not_ affect the PHY in any way. To
284
- /// configure the PHY, use [`EthernetMACWithMii`] (see: [`Self::with_mii`])
285
- /// or [`Stm32Mii`] (see: [`Self::mii`])
286
- pub fn set_speed ( & mut self , speed : Speed ) {
287
- self . eth_mac . maccr . modify ( |_, w| match speed {
288
- Speed :: HalfDuplexBase10T => w. fes ( ) . clear_bit ( ) . dm ( ) . clear_bit ( ) ,
289
- Speed :: FullDuplexBase10T => w. fes ( ) . clear_bit ( ) . dm ( ) . set_bit ( ) ,
290
- Speed :: HalfDuplexBase100Tx => w. fes ( ) . set_bit ( ) . dm ( ) . clear_bit ( ) ,
291
- Speed :: FullDuplexBase100Tx => w. fes ( ) . set_bit ( ) . dm ( ) . set_bit ( ) ,
292
- } ) ;
293
- }
294
-
295
- /// Get the Ethernet Speed at which the MAC communicates
296
- pub fn get_speed ( & self ) -> Speed {
297
- let cr = self . eth_mac . maccr . read ( ) ;
298
- match ( cr. fes ( ) . bit_is_set ( ) , cr. dm ( ) . bit_is_set ( ) ) {
299
- ( false , false ) => Speed :: HalfDuplexBase10T ,
300
- ( false , true ) => Speed :: FullDuplexBase10T ,
301
- ( true , false ) => Speed :: HalfDuplexBase100Tx ,
302
- ( true , true ) => Speed :: FullDuplexBase100Tx ,
303
- }
287
+ EthernetMACWithMii :: new ( self , mdio, mdc)
304
288
}
305
289
306
290
#[ cfg( feature = "ptp" ) ]
0 commit comments