Struct w5500_ll::PhyCfg [−][src]
pub struct PhyCfg(_);
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
Default value.
This is the same as default
, but as a const
value.
Example
use w5500_ll::PhyCfg;
assert_eq!(PhyCfg::DEFAULT, PhyCfg::default());
Bit offset for the RST
field.
Bit offset for the OPMD
field.
Bit offset for the OPMDC
field.
Bit offset for the DPX
field.
Bit offset for the SPD
field.
Bit offset for the LNK
field.
Bit mask for the OPMDC
field.
Get the PHY operation mode.
true
configure PHY with software.false
(reset value) configure PHY with hardware.
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());
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());
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);
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);
Get the duplex status.
Example
use w5500_ll::{DuplexStatus, PhyCfg};
let phy_cfg: PhyCfg = PhyCfg::DEFAULT;
assert_eq!(phy_cfg.dpx(), DuplexStatus::Half);
Get the speed status.
Example
use w5500_ll::{PhyCfg, SpeedStatus};
let phy_cfg: PhyCfg = PhyCfg::DEFAULT;
assert_eq!(phy_cfg.spd(), SpeedStatus::Mbps10);
Get the link status.
Example
use w5500_ll::{LinkStatus, PhyCfg};
let phy_cfg: PhyCfg = PhyCfg::DEFAULT;
assert_eq!(phy_cfg.lnk(), LinkStatus::Down);
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for PhyCfg
impl UnwindSafe for PhyCfg
Blanket Implementations
Mutably borrows from an owned value. Read more