跳转到内容

EthernetPHY::DP83822 API

文档稀疏
符号
73
已记录
28
类型
1
继承关系
1
源码分支
main

45 / 73 个公开 API 符号没有说明。

继承关系总览

继承图尚未加载。

全部继承关系

共 1 个类型

类型目录
类

bsp::ethernet_phy::DP83822Phy

查看源码

上游未提供类型说明。

继承关系

基类
  • IPhy公开

构造与析构

4

DP83822Phy

函数公开
        bsp::ethernet_phy::DP83822Phy::DP83822Phy (ETH_HandleTypeDef &eth, std::uint32_t address) noexcept
      

只保存配置的构造函数:不访问硬件、不产生总线流量、不会失败。 eth 已存在的 ETH 句柄,借用并保存引用;其生命周期须覆盖本对象。 address 原理图确定的 PHY 地址(0–31),或 AutoAddress 自动探测。 构造后对象尚未就绪(status() == NotInitialized);必须在 HAL_ETH_Init 完成、 MDIO 时钟与 HAL_GetTick() 可用之后调用 start(config)。因此构造函数可安全用于 静态存储期对象。

bsp/ethernet/phy_drivers/dp83822/DP83822Phy.hpp:70

成员函数

19

configureLink

函数公开
        PhyResult bsp::ethernet_phy::DP83822Phy::configureLink (const PhyLinkConfig &config) noexcept override
      

配置自动协商通告掩码或强制单一模式。 config 非法返回 InvalidArgument,器件不支持返回 Unsupported,均不写寄存器。 status() NotInitialized 表示!= Ok(不访问硬件);ReadError 读取现状失败 (对象仍就绪);WriteError 写入失败使对象失效;相同有效配置不重复写入并返回 Ok。 自动协商配置要求器件支持自动协商(start() 时缓存的能力),否则返回 Unsupported; 强制模式不要求该能力。

bsp/ethernet/phy_drivers/dp83822/DP83822Phy.hpp:142

getCapabilities

函数公开
        PhyResult bsp::ethernet_phy::DP83822Phy::getCapabilities (PhyCapabilities &capabilities) noexcept override
      

start() 读取时缓存的器件能力,不访问硬件。 capabilities 仅在返回 Ok 时写入缓存值。 status() NotInitialized 表示!= Ok,输出保持不变。

bsp/ethernet/phy_drivers/dp83822/DP83822Phy.hpp:131

readAndCacheCapabilities

函数私有
        PhyResult bsp::ethernet_phy::DP83822Phy::readAndCacheCapabilities () noexcept
      

从 BMSR 检测器件能力并缓存;无任何支持模式时返回 Unsupported(不支持自动协商不算失败)。

bsp/ethernet/phy_drivers/dp83822/DP83822Phy.hpp:171

readLink

函数公开
        PhyResult bsp::ethernet_phy::DP83822Phy::readLink (PhyLinkState &link_state) noexcept override
      

读取当前链路状态。 link_state 仅在成功时写入解码后的链路状态。 status() Ok 成功(含正常断链 Down);NotInitialized 表示!= Ok(不访问 硬件);ReadError 表示 MDIO 读取失败。 失败时 link_state 保持不变。

bsp/ethernet/phy_drivers/dp83822/DP83822Phy.hpp:124

restartAutoNegotiation

函数公开
        PhyResult bsp::ethernet_phy::DP83822Phy::restartAutoNegotiation () noexcept override
      

显式重启自动协商,返回时协商尚未完成。 status() NotInitialized 表示!= Ok(不访问硬件);Unsupported 当前为强制模式 (无写入);ReadError 读取 BMCR 失败(对象仍就绪);WriteError 写入失败使对象失效。

bsp/ethernet/phy_drivers/dp83822/DP83822Phy.hpp:149

setRegisterBits

函数私有
        PhyResult bsp::ethernet_phy::DP83822Phy::setRegisterBits (std::uint16_t reg, std::uint16_t bits) noexcept
      

读改写寄存器:只置位 bits 指定的位,其余位保持原值。

bsp/ethernet/phy_drivers/dp83822/DP83822Phy.hpp:163

start

函数公开
        PhyResult bsp::ethernet_phy::DP83822Phy::start (const PhyLinkConfig &config) noexcept override
      

启动驱动并按 config 配置链路;每次调用都完整重建。 流程:地址校验与 config 形状校验(InvalidArgument,不访问总线)→ 设置 MDIO 时钟范围 → 绑定或探测 PHY 地址 → 通过 PHYRCR bit 15 执行等效硬件复位并等待自清零 → 使能 Auto-MDIX 与 Robust Auto-MDIX → 从 BMSR 检测并缓存能力(只要有一种支持模式即成功, 自动协商能力单独记录)→ 按缓存能力校验 config(不受支持返回 Unsupported,此时可能 已复位并写入寄存器)→ 按 config 下发通告掩码或强制模式(相同有效配置不重复写入)。 config 被原样应用,不会被默认全部模式协商或模式交集替换。可重复调用:中断既有链路并 丢弃此前配置。阻塞调用,复位自清零等待上限 500ms,该上限不是任何上下文下的总耗时上限。 完整复位会重新锁存 strap,芯片可能自行按 strap 启动协商;本接口只保证软件不先 下发额外的默认全部模式协商配置。恢复时由调用方再次传入期望配置,不隐式保存或回退。 配置示例 readLink() start({true, PhyLinkMode::Base10Full | PhyLinkMode::Base100Full}) 仅通告全双工模式; start({false, PhyLinkMode::Base100Full}) 强制 100 Mbps 全双工。两者均须检查返回值, 再通过查询链路;本驱动不启动 MAC,也不更新协议栈状态。 Ok 对象就绪(不表示链路已建立);InvalidArgument 地址或 config 非法 (零总线访问);NotFound/AmbiguousAddress 选址失败;ReadError MDIO 读取失败; ResetTimeout 复位未完成;WriteError 写失败;Unsupported 器件无任何支持模式, 或请求的模式/自动协商不受支持(此前可能已复位或写入寄存器)。 任何失败都使对象不可用,失败后再次调用 start(config) 即可重试/恢复。 config 期望的链路配置;强制模式必须恰含一种模式。

bsp/ethernet/phy_drivers/dp83822/DP83822Phy.hpp:99

status

函数公开const
        PhyResult bsp::ethernet_phy::DP83822Phy::status () const noexcept override
      

start() 查询最近一次的粘性状态。 start() start() Ok 启动成功且对象可用;NotInitialized 尚未成功;其它值表示最近一次失败原因,或运行期写入失败导致对象失效后的 WriteError。该结果不因 其它调用改变。

bsp/ethernet/phy_drivers/dp83822/DP83822Phy.hpp:115

validateConfig

函数私有静态
        PhyResult bsp::ethernet_phy::DP83822Phy::validateConfig (const PhyLinkConfig &config) noexcept
      

纯 config 形状校验:空掩码、未知位或强制多模式 → InvalidArgument;不访问硬件。

bsp/ethernet/phy_drivers/dp83822/DP83822Phy.hpp:153

validateConfigSupport

函数私有const
        PhyResult bsp::ethernet_phy::DP83822Phy::validateConfigSupport (const PhyLinkConfig &config) const noexcept
      

按缓存能力校验 config 是否受支持;不受支持返回 Unsupported,不访问硬件。

bsp/ethernet/phy_drivers/dp83822/DP83822Phy.hpp:155

成员变量

7

其他公开符号

函数

3

anonymous_namespace{DP83822Phy.cpp}::anarAdvertisement

函数
        std::uint16_t anonymous_namespace{DP83822Phy.cpp}::anarAdvertisement (const bsp::ethernet_phy::PhyLinkMode modes) noexcept
      

上游未提供说明。

bsp/ethernet/phy_drivers/dp83822/DP83822Phy.cpp:141

变量

34

文件

2

bsp/ethernet/phy_drivers/dp83822/DP83822Phy.cpp

文件

DP83822 系列以太网 PHY 的 IPhy 实现(原生 C++ 寄存器驱动) 寄存器访问全部通过 STM32 HAL 的 MDIO 接口(HAL_ETH_ReadPHYRegister / HAL_ETH_WritePHYRegister)完成,没有任何动态分配、共享全局状态或 RTOS 依赖。 所有错误都直接以 PhyResult 返回,不经过中间状态码映射。 SPDX-License-Identifier: GPL-3.0-or-later This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. https://www.gnu.org/licenses/ You should have received a copy of the GNU General Public License along with this program. If not, see. https://github.com/HITSZ-WTRobot-Packages/BasicComponents Project repository: DP83822 寄存器定义与 Auto-MDIX 行为参考了 TI 官方 ti-ethernet-software 仓库中的 rtos_drivers/include/dp83822.h、rtos_drivers/src/dp83822.c 与 rtos_drivers/src/dp83822_priv.h(BSD-3-Clause),并已为 STM32 HAL 重新实现, 未引入其 phy_common / port 框架。以下 TI 版权与许可声明必须保留: Copyright (c) Texas Instruments Incorporated 2020 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Texas Instruments Incorporated nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

bsp/ethernet/phy_drivers/dp83822/DP83822Phy.cpp

bsp/ethernet/phy_drivers/dp83822/DP83822Phy.hpp

文件

DP83822 系列以太网 PHY(RMII,10BASE-Te / 100BASE-TX 铜缆)的 IPhy 实现 SPDX-License-Identifier: GPL-3.0-or-later 本实现直接通过 STM32 HAL 的 MDIO 接口访问 DP83822 寄存器,不依赖任何中间驱动 后端、状态码映射或 TCP/IP 协议栈。完整许可与第三方声明见 DP83822Phy.cpp。

bsp/ethernet/phy_drivers/dp83822/DP83822Phy.hpp