Skip to content

Commit 341ce32

Browse files
Johannes DraaijerJohannes Draaijer
authored andcommitted
Move LinkSpeed to phy because it's likely that more 10BaseT/100BaseT PHY will
be supported
1 parent 2476d41 commit 341ce32

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/phy/lan87xxa.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
11
//! SMSC LAN87xxA (LAN8742A, LAN8720A) Ethernet PHYs
2-
32
use core::convert::TryFrom;
4-
use num_enum::{IntoPrimitive, TryFromPrimitive};
53

6-
use crate::mac::StationManagement;
4+
use crate::{mac::StationManagement, LinkSpeed};
75

86
/// SMSC LAN8720A Ethernet PHY
97
pub type LAN8720A<SMI> = LAN87xxA<SMI, false>;
108
/// SMSC LAN8742A Ethernet PHY
119
pub type LAN8742A<SMI> = LAN87xxA<SMI, true>;
1210

13-
/// The link speeds supported by this PHY
14-
#[derive(Clone, Copy, Debug, IntoPrimitive, TryFromPrimitive)]
15-
#[repr(u8)]
16-
pub enum LinkSpeed {
17-
/// 10BaseT - Half duplex
18-
BaseT10HalfDuplex = 0b001,
19-
/// 10BaseT - Full duplex
20-
BaseT10FullDuplex = 0b101,
21-
/// 100BaseT - Half duplex
22-
BaseT100HalfDuplex = 0b010,
23-
/// 100BaseT - Full duplex
24-
BaseT100FullDuplex = 0b110,
25-
}
26-
2711
use self::phy_consts::*;
2812
#[allow(dead_code)]
2913
mod phy_consts {

src/phy/mod.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1+
use num_enum::{IntoPrimitive, TryFromPrimitive};
2+
13
#[cfg(feature = "phy-lan87xxa")]
24
mod lan87xxa;
35
#[cfg(feature = "phy-lan87xxa")]
46
pub use lan87xxa::*;
57

8+
/// The link speeds supported by this PHY
9+
#[derive(Clone, Copy, Debug, IntoPrimitive, TryFromPrimitive)]
10+
#[repr(u8)]
11+
pub enum LinkSpeed {
12+
/// 10BaseT - Half duplex
13+
BaseT10HalfDuplex = 0b001,
14+
/// 10BaseT - Full duplex
15+
BaseT10FullDuplex = 0b101,
16+
/// 100BaseT - Half duplex
17+
BaseT100HalfDuplex = 0b010,
18+
/// 100BaseT - Full duplex
19+
BaseT100FullDuplex = 0b110,
20+
}
21+
622
pub trait Phy {
723
type LinkSpeed;
824

@@ -18,7 +34,7 @@ pub trait Phy {
1834

1935
/// Poll the link status of this PHY. If it returns `true`, the
2036
/// link is up. If it returns `false`, the link is down.
21-
///
37+
///
2238
// TODO: return an associated type with link information?
2339
fn poll_link(&mut self) -> bool;
2440

0 commit comments

Comments
 (0)