pub struct PhyCfg(/* private fields */);
Expand description
PHY configuration register (PHYCFGR).
Used for:
- PHY reset.
- PHY operation modes.
- PHY status.
This is used by the Registers::phycfgr
and
Registers::set_phycfgr
methods.
Implementations§
source§impl PhyCfg
impl PhyCfg
sourcepub const DEFAULT: Self = _
pub const DEFAULT: Self = _
Default value.
This is the same as default
, but as a const
value.
Example
use w5500_ll::PhyCfg;
assert_eq!(PhyCfg::DEFAULT, PhyCfg::default());
sourcepub const RST_OFFSET: u8 = 7u8
pub const RST_OFFSET: u8 = 7u8
Bit offset for the RST
field.
sourcepub const OPMD_OFFSET: u8 = 6u8
pub const OPMD_OFFSET: u8 = 6u8
Bit offset for the OPMD
field.
sourcepub const OPMDC_OFFSET: u8 = 3u8
pub const OPMDC_OFFSET: u8 = 3u8
Bit offset for the OPMDC
field.
sourcepub const DPX_OFFSET: u8 = 2u8
pub const DPX_OFFSET: u8 = 2u8
Bit offset for the DPX
field.
sourcepub const SPD_OFFSET: u8 = 1u8
pub const SPD_OFFSET: u8 = 1u8
Bit offset for the SPD
field.
sourcepub const LNK_OFFSET: u8 = 0u8
pub const LNK_OFFSET: u8 = 0u8
Bit offset for the LNK
field.
sourcepub const OPMDC_MASK: u8 = 56u8
pub const OPMDC_MASK: u8 = 56u8
Bit mask for the OPMDC
field.
sourcepub const fn opmd(&self) -> bool
pub const fn opmd(&self) -> bool
Get the PHY operation mode.
true
configure PHY with software.false
(reset value) configure PHY with hardware.
sourcepub const fn hardware_op(self) -> Self
pub const fn hardware_op(self) -> Self
Enable hardware configuration of the PHY operation mode.
This uses the PMODE pins to select the PHY operation mode.
PMODE[2] | PMODE[1] | PMODE[0] | Description |
---|---|---|---|
0 | 0 | 0 | 10BT Half-duplex, Auto-negotiation disabled |
0 | 0 | 1 | 10BT Full-duplex, Auto-negotiation disabled |
0 | 1 | 0 | 100BT Half-duplex, Auto-negotiation disabled |
0 | 1 | 1 | 100BT Full-duplex, Auto-negotiation disabled |
1 | 0 | 0 | 100BT Half-duplex, Auto-negotiation enabled |
1 | 0 | 1 | Not used |
1 | 1 | 0 | Not used |
1 | 1 | 1 | All capable, Auto-negotiation enabled |
Example
use w5500_ll::PhyCfg;
let phy_cfg: PhyCfg = PhyCfg::DEFAULT;
assert!(!phy_cfg.opmd());
let phy_cfg: PhyCfg = phy_cfg.software_op();
assert!(phy_cfg.opmd());
let phy_cfg: PhyCfg = phy_cfg.hardware_op();
assert!(!phy_cfg.opmd());
sourcepub const fn software_op(self) -> Self
pub const fn software_op(self) -> Self
Enable software configuration of the PHY operation mode.
Example
use w5500_ll::PhyCfg;
let phy_cfg: PhyCfg = PhyCfg::DEFAULT;
assert!(!phy_cfg.opmd());
let phy_cfg: PhyCfg = phy_cfg.software_op();
assert!(phy_cfg.opmd());
sourcepub const fn opmdc(&self) -> OperationMode
pub const fn opmdc(&self) -> OperationMode
Get the operation mode.
This returns an Err(u8)
with the opmdc bits if the opmdc bits do not
match a valid operation mode.
Example
use w5500_ll::{OperationMode, PhyCfg};
assert_eq!(PhyCfg::DEFAULT.opmdc(), OperationMode::Auto);
sourcepub const fn set_opmdc(self, mode: OperationMode) -> Self
pub const fn set_opmdc(self, mode: OperationMode) -> Self
Set the PHY operation mode.
Setting this will also call PhyCfg::software_op
to enable the PHY
configuration with the value stored in this register.
Example
use w5500_ll::{OperationMode, PhyCfg};
let phy_cfg: PhyCfg = PhyCfg::DEFAULT;
assert!(!phy_cfg.opmd());
let phy_cfg: PhyCfg = phy_cfg.set_opmdc(OperationMode::PowerDown);
assert!(phy_cfg.opmd());
assert_eq!(phy_cfg.opmdc(), OperationMode::PowerDown);
let phy_cfg: PhyCfg = phy_cfg.set_opmdc(OperationMode::Auto);
assert_eq!(phy_cfg.opmdc(), OperationMode::Auto);
sourcepub const fn dpx(&self) -> DuplexStatus
pub const fn dpx(&self) -> DuplexStatus
Get the duplex status.
Example
use w5500_ll::{DuplexStatus, PhyCfg};
let phy_cfg: PhyCfg = PhyCfg::DEFAULT;
assert_eq!(phy_cfg.dpx(), DuplexStatus::Half);
sourcepub const fn spd(&self) -> SpeedStatus
pub const fn spd(&self) -> SpeedStatus
Get the speed status.
Example
use w5500_ll::{PhyCfg, SpeedStatus};
let phy_cfg: PhyCfg = PhyCfg::DEFAULT;
assert_eq!(phy_cfg.spd(), SpeedStatus::Mbps10);
sourcepub const fn lnk(&self) -> LinkStatus
pub const fn lnk(&self) -> LinkStatus
Get the link status.
Example
use w5500_ll::{LinkStatus, PhyCfg};
let phy_cfg: PhyCfg = PhyCfg::DEFAULT;
assert_eq!(phy_cfg.lnk(), LinkStatus::Down);