1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// SPDX-License-Identifier: GPL-2.0-or-later OR Apache-2.0
// Copyright (c) Viacheslav Bocharov <v@baodeep.com> and JetHome (r)
//! MDIO-based Ethernet PHY traits and IEEE 802.3 helpers.
//!
//! This crate defines the contract between MAC and PHY layers so a
//! single PHY driver can be reused across MAC implementations
//! (ESP32 EMAC, STM32 ETH, FPGA SMI, GPIO bit-bang, mocks).
//!
//! - [`MdioBus`] — wire-level read/write trait. Implemented by MAC
//! layers.
//! - [`PhyDriver`] — what every PHY driver provides. Method receivers
//! are generic over [`MdioBus`] so the same driver instance can talk
//! to a real bus and a mock within one session.
//! - [`ieee802_3`] — Clause 22 register addresses, bit constants, and
//! convenience helpers (`soft_reset`, `enable_auto_negotiation`,
//! `is_link_up`, `read_phy_id`, `read_capabilities`, `force_link`).
//! - Shared types: [`Speed`], [`Duplex`], [`LinkStatus`],
//! [`PhyCapabilities`], [`PhyError`].
//!
//! See the crate-level README (rendered on docs.rs and shipped via
//! `Cargo.toml`'s `readme` field) for installation, worked
//! PhyDriver and MdioBus examples, mock recipes for tests, and a
//! Clause 22 frame breakdown for GPIO bit-bang implementations.
//!
//! # Quick start
//!
//! ```no_run
//! use eth_mdio_phy::{ieee802_3, LinkStatus, MdioBus, PhyDriver, PhyError};
//!
//! # fn drive<M: MdioBus, P: PhyDriver>(mdio: &mut M, phy: &mut P)
//! # -> Result<(), PhyError<M::Error>>
//! # {
//! phy.init(mdio)?;
//! while phy.poll_link(mdio)?.is_none() { /* idle */ }
//! # Ok(())
//! # }
//! ```
//!
//! # Crate features
//!
//! | Feature | Default | When to enable |
//! | --- | --- | --- |
//! | `defmt` | off | Adds `defmt::Format` derives on [`LinkStatus`], [`PhyCapabilities`], [`PhyError`]. |
//!
//! # Compatibility
//!
//! - **MSRV:** 1.75
//! - **Target:** any (`#![no_std]`, no transitive runtime deps)
//!
//! # Object-safety note
//!
//! [`PhyDriver`] is **not** object-safe (the methods are generic over
//! [`MdioBus`]), so `dyn PhyDriver` is a compile error. If you need
//! polymorphic storage (a switch driver, a multi-PHY watchdog) keep
//! the PHY drivers as concrete types behind an `enum`, or write a
//! thin object-safe wrapper that fixes a single [`MdioBus`]
//! implementation.
pub use MdioBus;
pub use ;
pub use ;