Skip to content

feat(emac): add Synopsys DWC Ethernet MAC driver for CH32V307#157

Open
ArthurHeymans wants to merge 1 commit intoch32-rs:mainfrom
ArthurHeymans:ch32v307_eth
Open

feat(emac): add Synopsys DWC Ethernet MAC driver for CH32V307#157
ArthurHeymans wants to merge 1 commit intoch32-rs:mainfrom
ArthurHeymans:ch32v307_eth

Conversation

@ArthurHeymans
Copy link
Copy Markdown
Contributor

Add an EMAC driver for the CH32V307's Synopsys DesignWare Ethernet MAC,
supporting both the built-in 10M PHY and external PHYs via RMII/MII.

The driver implements embassy_net_driver::Driver with DMA descriptor
rings (chained mode), SMI/MDIO PHY management, and async TX/RX via
interrupt-driven wakeups.

For the built-in 10M PHY (PhyInterface::Internal10M):

  • Configures PLL3 to 60MHz as the PHY clock source
  • Enables the PHY via EXTEND.CTR.ETH_10M_EN
  • Sets MACCR.IRE for 50-ohm impedance matching
  • Writes PHY_MDIX register (0x1E) for auto PN polarity detection
  • Enables promiscuous mode for PHY polarity detection

Includes a TCP echo server example (examples/ch32v307/src/bin/eth.rs)
that initializes the 10M PHY, obtains an IP via DHCP, and echoes TCP
data on port 1234. Tested on hardware with ping and TCP.

Depends on EMAC register definitions from ArthurHeymans/ch32-data,
generated into ArthurHeymans/ch32-metapac (rev b079130). The
ch32-metapac dependency is temporarily pointed at this fork until the
register definitions are upstreamed to ch32-rs/ch32-data.

ch32-rs/ch32-data#27 is the PR for the ch32-data update.

Add an EMAC driver for the CH32V307's Synopsys DesignWare Ethernet MAC,
supporting both the built-in 10M PHY and external PHYs via RMII/MII.

The driver implements embassy_net_driver::Driver with DMA descriptor
rings (chained mode), SMI/MDIO PHY management, and async TX/RX via
interrupt-driven wakeups.

For the built-in 10M PHY (PhyInterface::Internal10M):
- Configures PLL3 to 60MHz as the PHY clock source
- Enables the PHY via EXTEND.CTR.ETH_10M_EN
- Sets MACCR.IRE for 50-ohm impedance matching
- Writes PHY_MDIX register (0x1E) for auto PN polarity detection
- Enables promiscuous mode for PHY polarity detection

Includes a TCP echo server example (examples/ch32v307/src/bin/eth.rs)
that initializes the 10M PHY, obtains an IP via DHCP, and echoes TCP
data on port 1234. Tested on hardware with ping and TCP.

Depends on EMAC register definitions from ArthurHeymans/ch32-data,
generated into ArthurHeymans/ch32-metapac (rev b079130). The
ch32-metapac dependency is temporarily pointed at this fork until the
register definitions are upstreamed to ch32-rs/ch32-data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant