bsp::ethernet_phy::LwipPlatform
借用 ETH 句柄与 IPhy、并拥有链路线程的 LwIP 平台。
构造与析构
4LwipPlatform
bsp::ethernet_phy::LwipPlatform::LwipPlatform (ETH_HandleTypeDef ð, IPhy &phy) noexcept
只保存借用引用并初始化成员;不访问 HAL、PHY 或 RTOS,不失败。 eth STM32 ETH 句柄,借用,生命周期须覆盖本对象全部使用期。 phy 具体 PHY 的 IPhy 接口,借用,生命周期须覆盖本对象全部使用期。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:100LwipPlatform
bsp::ethernet_phy::LwipPlatform::LwipPlatform (LwipPlatform &&)=delete
上游未提供说明。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:107LwipPlatform
bsp::ethernet_phy::LwipPlatform::LwipPlatform (const LwipPlatform &)=delete
上游未提供说明。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:105~LwipPlatform
bsp::ethernet_phy::LwipPlatform::~LwipPlatform ()=default
静态存储期对象;析构不销毁 PHY、不停止 MAC、不操作 RTOS。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:103成员函数
17fail
void bsp::ethernet_phy::LwipPlatform::fail (PollResult error) noexcept
终止路径:断开 PHY 事件回调、清空线程 ID、置 link down,再调用 on_error 一次, 然后结束线程(osThreadExit)。不冒充 MAC 已停止,不重试失败的 HAL 操作。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:195handleLinkEvent
PollResult bsp::ethernet_phy::LwipPlatform::handleLinkEvent (bool force_snapshot) noexcept
确认 PHY 中断,并在有链路事件或强制快照时执行一轮 poll。 force_snapshot 为 true 时无论是否有链路事件都执行一轮 poll(首轮快照)。 ack 成功时返回 poll 结果或 Ok;ack 失败返回 PhyInterruptError。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:172initialize
bool bsp::ethernet_phy::LwipPlatform::initialize () noexcept
线程内 PHY 启动:core lock 内置 link down,锁外按 config 启动 PHY。 true 仅当 PHY start 成功;成功置 initialized_。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:157link_thread
void bsp::ethernet_phy::LwipPlatform::link_thread (void *argument) noexcept
线程入口桥接:转调 run()。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:139notifyTxComplete
void bsp::ethernet_phy::LwipPlatform::notifyTxComplete () noexcept
ETH TX 完成 ISR 入口:仅通知链路线程回收 TX,不访问 PHY/MAC/HAL。 osThreadFlagsWait 可在 ISR 上下文调用。线程 ID 已发布时无条件置 TX 标志:两种事件模式都经唤醒处理 TX——无 INT 轮询模式同样立即回收,不等到下一轮 PHY poll。 线程未发布 ID(未启动/已终止)时无操作。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:135onPhyEvent
void bsp::ethernet_phy::LwipPlatform::onPhyEvent (void *context) noexcept
PHY 事件回调(可能 ISR):仅置 Link 标志并唤醒线程。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:142operator=
LwipPlatform & bsp::ethernet_phy::LwipPlatform::operator= (LwipPlatform &&)=delete
上游未提供说明。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:108operator=
LwipPlatform & bsp::ethernet_phy::LwipPlatform::operator= (const LwipPlatform &)=delete
上游未提供说明。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:106poll
PollResult bsp::ethernet_phy::LwipPlatform::poll () noexcept
线程内单轮:读取 PHY 链路并按需切换 MAC 与 netif link。 本轮结果(语义见 PollResult)。 readLink() 每轮只调用一次,返回值用于区分失败原因;不额外访问 PHY 总线。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:165pollPeriodic
bool bsp::ethernet_phy::LwipPlatform::pollPeriodic () noexcept
执行一轮周期 PHY poll,并按事件模式判定能否继续。 true 可继续循环;false 表示已调用 fail(线程即将终止)。 无 INT 轮询模式容忍单轮 PhyReadError(poll 已安全停链),返回 true 以便下一周期重试; 有 INT 模式(含 INT 卡低退化出的周期 poll)与其余非 Ok 结果都走终止路径,不新增策略。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:181releaseTxPackets
void bsp::ethernet_phy::LwipPlatform::releaseTxPackets () noexcept
只回收已完成 TX:在 core lock 内调用 HAL_ETH_ReleaseTxPacket,不读取 PHY。 供 TX 完成通知路径复用:不产生 MDIO 流量、不改变链路状态。需 core lock,不得在 ISR 调用;未启动时无任何硬件动作直接返回。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:189run
void bsp::ethernet_phy::LwipPlatform::run () noexcept
链路线程主循环:启动 PHY 后统一等待 TX/Link 线程标志与周期 PHY poll。 无 INT 模式按绝对 deadline 每 kPollDelayTicks 执行一轮 poll;有 INT 模式在 INT 为高时 无限期等待事件,在 INT 卡低且确认后仍无事件时退化为同一周期 poll(每轮有界阻塞, 不存在断言低电平的忙等)。持续到达的 TX 通知不会推迟该节拍。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:151setLinkDownLocked
void bsp::ethernet_phy::LwipPlatform::setLinkDownLocked () noexcept
在 core lock 内置链路为 down(幂等)。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:198setLinkUpLocked
void bsp::ethernet_phy::LwipPlatform::setLinkUpLocked () noexcept
在 core lock 内置链路为 up(幂等;仅在 netif 尚未 up 时调用)。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:201start
bool bsp::ethernet_phy::LwipPlatform::start (struct netif &netif, const PhyLinkConfig &config, ErrorHandler on_error) noexcept
一次性启动:保存运行参数并创建唯一链路线程。 前置:调用方已调用 HAL_ETH_Init 完成 MAC 外设初始化,netif 已建立,且从普通线程 上下文调用;本类不初始化 MAC 外设。创建前把所有运行参数(netif 指针、config 副本、 错误回调、是否使用中断)存妥,再由线程自行发布其 ID,创建者不在创建返回后写回 ID。 config 被原样传递给 phy_.start();本类不覆盖调用方配置,也不静默取能力交集。 线程创建失败返回 false,且不再自动重试;返回 true 仅表示线程已创建,PHY 启动在线程 内异步进行,其失败经 on_error 上报 PhyStartError,不代表本函数失败。 netif 已建立的 LwIP 接口,仅借用,不拥有。 config 期望的链路配置,原样传递。 on_error 致命错误回调,必须非空;在线程内被调用一次。 true 线程创建成功;false 表示重复调用、空回调或线程创建失败,不启动 PHY。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:126startMacLocked
bool bsp::ethernet_phy::LwipPlatform::startMacLocked (std::uint32_t speed, std::uint32_t duplex) noexcept
配置并启动 MAC;前置:已持 core lock 且 MAC 已停止。 true 仅当 Get/Set/Start 全部成功。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:214stopMacLocked
bool bsp::ethernet_phy::LwipPlatform::stopMacLocked () noexcept
停止 MAC;前置:已持 core lock。 true 已停止或本就未启动;false HAL_ETH_Stop_IT 失败,此时保留 mac_started_(停止失败不得谎称已停)。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:208成员变量
17applied_state_
PhyLinkState bsp::ethernet_phy::LwipPlatform::applied_state_
上游未提供说明。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:239bound_netif_
struct netif* bsp::ethernet_phy::LwipPlatform::bound_netif_
借用 netif,创建前绑定。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:229eth_
ETH_HandleTypeDef& bsp::ethernet_phy::LwipPlatform::eth_
借用,不拥有。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:225initialized_
bool bsp::ethernet_phy::LwipPlatform::initialized_
仅线程内 PHY start 成功后置 true。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:235interrupt_mode_
bool bsp::ethernet_phy::LwipPlatform::interrupt_mode_
start 前缓存的 phy_.usesInterrupt()。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:232kLinkFlag
std::uint32_t bsp::ethernet_phy::LwipPlatform::kLinkFlag
Link 事件线程标志(ISR 置位);由 osThreadFlagsWait 唤醒时默认清除。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:217kPollDelayTicks
std::uint32_t bsp::ethernet_phy::LwipPlatform::kPollDelayTicks
周期 PHY poll 节拍(tick);无 INT 轮询模式与 INT 卡低退化均按绝对 deadline 使用。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:223kStackBytes
std::uint32_t bsp::ethernet_phy::LwipPlatform::kStackBytes
链路线程栈字节数,沿用原 EthLink 线程参数。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:221kTxFlag
std::uint32_t bsp::ethernet_phy::LwipPlatform::kTxFlag
TX 完成线程标志(ISR 置位);由 osThreadFlagsWait 唤醒时默认清除。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:219link_config_
PhyLinkConfig bsp::ethernet_phy::LwipPlatform::link_config_
PHY 启动配置副本。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:230mac_started_
bool bsp::ethernet_phy::LwipPlatform::mac_started_
上游未提供说明。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:237on_error_
ErrorHandler bsp::ethernet_phy::LwipPlatform::on_error_
致命错误回调,start 校验非空。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:231phy_
IPhy& bsp::ethernet_phy::LwipPlatform::phy_
借用,不拥有。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:226start_attempted_
bool bsp::ethernet_phy::LwipPlatform::start_attempted_
start 一次性尝试标志,仅 start 检查。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:236thread_control_block_
StaticTask_t bsp::ethernet_phy::LwipPlatform::thread_control_block_
上游未提供说明。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:242thread_id_
std::atomic<osThreadId_t> bsp::ethernet_phy::LwipPlatform::thread_id_
由工作线程自身发布,供 ISR 通知定位。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:233thread_stack_
StackType_t bsp::ethernet_phy::LwipPlatform::thread_stack_[kStackBytes/sizeof(StackType_t)] [kStackBytes/sizeof(StackType_t)]
上游未提供说明。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:243嵌套类型
1ErrorHandler
using bsp::ethernet_phy::LwipPlatform::ErrorHandler = void (*)(PollResult error) noexcept
致命错误处理器;由线程调用一次,返回后平台自行结束线程。
bsp/ethernet/lwip_platform/LwipPlatform.hpp:93