17#ifndef MBED_OS_GENERICETHPHY_H
18#define MBED_OS_GENERICETHPHY_H
20#include "CompositeEMAC.h"
21#include "DigitalOut.h"
30inline constexpr uint8_t BMCR = 0;
32inline constexpr size_t BMCR_SW_RST_Pos = 15;
33inline constexpr uint16_t BMCR_SW_RST_Msk = 1 << BMCR_SW_RST_Pos;
35inline constexpr size_t BMCR_SPEED_100M_Pos = 13;
36inline constexpr uint16_t BMCR_SPEED_100M_Msk = 1 << BMCR_SPEED_100M_Pos;
38inline constexpr size_t BMCR_ANEG_EN_Pos = 12;
39inline constexpr uint16_t BMCR_ANEG_EN_Msk = 1 << BMCR_ANEG_EN_Pos;
41inline constexpr size_t BMCR_ANEG_RESTART_Pos = 9;
42inline constexpr uint16_t BMCR_ANEG_RESTART_Msk = 1 << BMCR_ANEG_RESTART_Pos;
44inline constexpr size_t BMCR_DUPLEX_FULL_Pos = 8;
45inline constexpr uint16_t BMCR_DUPLEX_FULL_Msk = 1 << BMCR_DUPLEX_FULL_Pos;
47inline constexpr uint8_t BMSR = 1;
49inline constexpr size_t BMCR_LINK_UP_Pos = 2;
50inline constexpr uint16_t BMCR_LINK_UP_Msk = 1 << BMCR_LINK_UP_Pos;
52inline constexpr uint8_t PHYIDR1 = 2;
53inline constexpr uint8_t PHYIDR2 = 3;
54inline constexpr uint8_t ANAR = 4;
56inline constexpr size_t ANAR_100BTX_FD_Pos = 8;
57inline constexpr uint16_t ANAR_100BTX_FD_Msk = 1 << ANAR_100BTX_FD_Pos;
59inline constexpr size_t ANAR_100BTX_Pos = 7;
60inline constexpr uint16_t ANAR_100BTX_Msk = 1 << ANAR_100BTX_Pos;
62inline constexpr size_t ANAR_10BT_FD_Pos = 6;
63inline constexpr uint16_t ANAR_10BT_FD_Msk = 1 << ANAR_10BT_FD_Pos;
65inline constexpr size_t ANAR_10BT_Pos = 5;
66inline constexpr uint16_t ANAR_10BT_Msk = 1 << ANAR_10BT_Pos;
69inline constexpr uint16_t ANAR_PROTOCOL_IEE_802_3U_Val = 1;
71inline constexpr uint8_t ANLPAR = 5;
99 std::chrono::microseconds
resetLowTime = std::chrono::microseconds(100);
127 std::pair<CompositeEMAC::LinkSpeed, CompositeEMAC::Duplex>
fixedEthSettings = {CompositeEMAC::LinkSpeed::LINK_100MBIT, CompositeEMAC::Duplex::FULL};
132 Config
const &config;
134 std::optional<DigitalOut> resetDigitalOut;
141 CompositeEMAC::ErrCode init()
override;
143 CompositeEMAC::ErrCode checkLinkStatus(
bool &status)
override;
145 CompositeEMAC::ErrCode checkLinkType(CompositeEMAC::LinkSpeed &speed, CompositeEMAC::Duplex &duplex)
override;
Driver for a generic, Ethernet-standard compliant PHY chip.
Configuration structure for a generic Ethernet PHY.
uint8_t model_min
Range of 5-bit model number of the phy.
bool advertise100M
Whether the PHY should advertise 100Mbit modes.
bool autonegEnabled
Whether autonegotiation shall be enabled on the phy.
bool advertiseFullDuplex
Whether the PHY should advertise full duplex modes.
std::chrono::microseconds resetHighTime
Time to wait after resetting the phy before trying to talk to it.
bool advertiseHalfDuplex
Whether the PHY should advertise half duplex modes.
std::chrono::microseconds resetLowTime
Time to hold reset low on this phy.
std::pair< CompositeEMAC::LinkSpeed, CompositeEMAC::Duplex > fixedEthSettings
If autonegEnabled is false, this gives the fixed link settings to advertise.
uint32_t OUI
24-bit OUI of the organization that produced the ethernet PHY.
bool advertise10M
Whether the PHY should advertise 10Mbit modes.
uint8_t address
MDIO address of the phy chip.