Struct w5500_ll::PhyCfg

source ·
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

source

pub const RESET: u8 = 184u8

PHY configuration register reset value.

source

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());
source

pub const RST_OFFSET: u8 = 7u8

Bit offset for the RST field.

source

pub const OPMD_OFFSET: u8 = 6u8

Bit offset for the OPMD field.

source

pub const OPMDC_OFFSET: u8 = 3u8

Bit offset for the OPMDC field.

source

pub const DPX_OFFSET: u8 = 2u8

Bit offset for the DPX field.

source

pub const SPD_OFFSET: u8 = 1u8

Bit offset for the SPD field.

source

pub const LNK_OFFSET: u8 = 0u8

Bit offset for the LNK field.

source

pub const RST_MASK: u8 = 128u8

Bit mask for the RST field.

source

pub const OPMD_MASK: u8 = 64u8

Bit mask for the OPMD field.

source

pub const OPMDC_MASK: u8 = 56u8

Bit mask for the OPMDC field.

source

pub const DPX_MASK: u8 = 4u8

Bit mask for the DPX field.

source

pub const SPD_MASK: u8 = 2u8

Bit mask for the SPD field.

source

pub const LNK_MASK: u8 = 1u8

Bit mask for the LNK field.

source

pub const fn rst(self) -> Self

Set the PHY reset bit to 0, resetting the PHY.

source

pub const fn opmd(&self) -> bool

Get the PHY operation mode.

  • true configure PHY with software.
  • false (reset value) configure PHY with hardware.
source

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
00010BT Half-duplex, Auto-negotiation disabled
00110BT Full-duplex, Auto-negotiation disabled
010100BT Half-duplex, Auto-negotiation disabled
011100BT Full-duplex, Auto-negotiation disabled
100100BT Half-duplex, Auto-negotiation enabled
101Not used
110Not used
111All 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());
source

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());
source

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);
source

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);
source

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);
source

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);
source

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);

Trait Implementations§

source§

impl Clone for PhyCfg

source§

fn clone(&self) -> PhyCfg

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for PhyCfg

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for PhyCfg

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for PhyCfg

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Format for PhyCfg

Available on crate feature defmt only.
source§

fn format(&self, fmt: Formatter<'_>)

Writes the defmt representation of self to fmt.
source§

impl From<PhyCfg> for u8

source§

fn from(val: PhyCfg) -> u8

Converts to this type from the input type.
source§

impl From<u8> for PhyCfg

source§

fn from(val: u8) -> Self

Converts to this type from the input type.
source§

impl PartialEq for PhyCfg

source§

fn eq(&self, other: &PhyCfg) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for PhyCfg

source§

impl Eq for PhyCfg

source§

impl StructuralEq for PhyCfg

source§

impl StructuralPartialEq for PhyCfg

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.