mii – Media-independent interface (MII) is a family of standards to connect an Ethernet medium access control (MAC) peripheral to an Ethernet physical transceiver (PHY). Different versions have different pinouts depending on the pin count and Ethernet speed. Reduced pin count variants like reduced media-independent interface (RMII) and reduced gigabit media-independent interface (RGMII) are often used in microcontrollers to save pin count.
A portion of the pins in MII are for the Management Data Input/Output (MDIO) which is used to configure the PHY. Like I2C, multiple PHYs can share an MDIO because the commands include an address. This module splits the Management Data Input/Output (MDIO) definition from the MII portion because the MDIO bus can be shared between PHYs.
See: https://en.wikipedia.org/wiki/Media-independent_interface
Available on these boards
- class mii.Ethernet(rmii: RMII)
Wired ethernet interface.
Boards with onboard ethernet PHYs provide it as
board.ETHERNETor another distinguishing name.Further interfaces can be created by wiring an external PHY over a variant of the media independent interface (MII) bus. See other classes in this module for supported MII variants. The interface is enabled and DHCP is started automatically.
Create another ethernet interface driving the PHY wired to
rmii.Only Espressif ports support this; Zephyr ports only serve the interface from the devicetree, available as
board.ETHERNET, and raise NotImplementedError here.- enabled: bool
Truewhen the ethernet interface is enabled. If you set the value toFalse, any open sockets will be closed.
- hostname: str | circuitpython_typing.ReadableBuffer
Hostname for the ethernet interface. When the hostname is altered after the interface is started the changes would only be reflected once the interface restarts.
- ipv4_address: ipaddress.IPv4Address | None
IP v4 address when connected. None otherwise. (read-only)
- ipv4_gateway: ipaddress.IPv4Address | None
IP v4 gateway address when connected. None otherwise. (read-only)
- ipv4_subnet: ipaddress.IPv4Address | None
IP v4 subnet mask when connected. None otherwise. (read-only)
- ipv4_dns: ipaddress.IPv4Address
IP v4 address of the DNS server to be used.
- addresses: Sequence[str]
Address(es) of the interface when connected. Empty sequence when not connected. (read-only)
- set_ipv4_address(*, ipv4: ipaddress.IPv4Address, netmask: ipaddress.IPv4Address, gateway: ipaddress.IPv4Address, ipv4_dns: ipaddress.IPv4Address | None) None
Sets the IP v4 address of the interface. Must include the netmask and gateway. DNS address is optional. Setting the address manually will stop the DHCP client.
- class mii.MDIO(mdc: microcontroller.Pin, mdio: microcontroller.Pin)
Management data input/output (MDIO) bus wiring.
MDIO is the two wire management bus used to configure Ethernet PHYs over an
miivariant.mdcis the management data clock andmdiois the bidirectional management data line. Configuration commands on the bus address a PHY by a number between 0 and 31, so, like I2C, multiple PHYs can share one bus.Create the MDIO bus on the given clock and data pins.
- class mii.RMII(mdio: MDIO, device: int, rxd0: microcontroller.Pin, rxd1: microcontroller.Pin, rx_dv: microcontroller.Pin, txd0: microcontroller.Pin, txd1: microcontroller.Pin, tx_en: microcontroller.Pin, refclk: microcontroller.Pin, reset: microcontroller.Pin | None = None)
Reduced media independent interface (RMII) bus wiring for the built-in ethernet MAC.
RMII is a pin-reduced variant of the media independent interface (MII) family: it shifts two data bits on a pair of pins at a 50 MHz reference clock instead of running a wider bus more slowly, saving pins on microcontrollers. The PHY sends data to the MAC over
rxd0andrxd1and marks received bytes withrx_dv(receive data valid). The MAC sends data back overtxd0andtxd1and frames it withtx_en(transmit enable).refclkis the 50 MHz reference clock, usually driven by an oscillator on the PHY.The PHY is configured over an
mii.MDIOmanagement bus, which may be shared between interfaces; pass it asmdio.deviceselects the PHY’s MDIO address (0-31) on that bus, so that twomii.Ethernetinterfaces on chips with more than one MAC can share it. Optionally, passresetwired to the PHY’s active-low reset, if it has one.Not all chips can route RMII signals freely: ports that can’t (or Zephyr ports, which take their wiring from the devicetree) raise NotImplementedError.
Create the RMII bus on the given
mii.MDIOmanagement bus, with the PHY at its MDIOdeviceaddress, and the given data signals.