2025-11-08 20:39:52 +06:00
2025-11-08 20:18:23 +06:00
2025-11-08 00:39:15 +06:00
2025-11-08 18:00:46 +06:00
2025-11-07 17:02:04 +06:00
2025-11-07 17:02:04 +06:00
2025-11-08 20:18:23 +06:00
2025-11-08 00:39:15 +06:00
2025-11-08 00:39:15 +06:00
2025-11-07 17:02:04 +06:00
2025-11-08 00:39:15 +06:00
2025-11-07 17:02:04 +06:00
2025-11-08 20:18:23 +06:00
2025-11-08 20:18:23 +06:00
2025-11-08 20:39:52 +06:00
2025-11-07 17:02:04 +06:00

lwIP Ethernet Driver for CH32V208

This is a simple ethernetif.c driver to get lwIP working on the WCH CH32V208 MCU using the ch32fun lib.
It uses the chip's internal 10Mbps Ethernet MAC. The MAC address is pulled from the chip's 6-byte unique ID.

The provided main.c is an example that starts up, gets an IP address via DHCP, and runs a small HTTP server.

Usage

  1. Initialize lwIP and add the network interface.
  2. Poll the driver and service lwIP's timers in your main loop.
netif_add(&g_netif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &ethernet_input);
netif_set_default(&g_netif);
netif_set_up(&g_netif);
dhcp_start(&g_netif);

while (1) {
  // poll for incoming packets
  ethernetif_input(&g_netif);

  // handle lwIP timers (for TCP, DHCP, etc.)
  sys_check_timeouts();

  // poll link for link up/down cb
  ethernetif_link_poll(&g_netif);
}

Impl note

This driver is kinda functional but not optimized at all

  • Packet RX: This is done by polling. You must call ethernetif_input() continuously in your main loop to check for and process incoming packets
  • Packet TX: Kicking off a transmission is a blocking copy, but freeing the transmit buffer on completion is handled by the ETH_IRQHandler ISR
Description
ch32v208 lwip + stuff
Readme 114 KiB
Languages
C 95.9%
Makefile 2.7%
HTML 1.4%