eth 初始化
struct net_driver_s g_eth1_dev
struct net_driver_s {
struct netif d_netif;
u8_t d_lltype; /* See enum net_lltype_e */
/** IP address configuration in network byte order */
ip_addr_t d_ipaddr;
ip_addr_t d_netmask;
ip_addr_t d_gateway;
err_t (*d_init)(struct net_driver_s *dev);
err_t (*d_txavail)(struct net_driver_s *dev, struct pbuf *p);
u32_t (*d_getmac)(struct net_driver_s *dev, void *buf, u32_t max_len);
u32_t (*d_getmtu)(struct net_driver_s *dev);
void *d_private;
};
typedef struct dwc_eth_dev {
bool init;
dwc_eth_config_t *config;
struct eqos_priv *eqos;
dma_rx_int_cb_t rx_cb;
phy_bus_t phy_bus;
} dwc_eth_dev_t;
struct netif {
struct netif next;
ip_addr_t ip_addr;
ip_addr_t netmask;
ip_addr_t gw;
ip_addr_t ip6_addr[LWIP_IPV6_NUM_ADDRESSES];
u8_t ip6_addr_state[LWIP_IPV6_NUM_ADDRESSES];
u32_t ip6_addr_valid_life[LWIP_IPV6_NUM_ADDRESSES];
u32_t ip6_addr_pref_life[LWIP_IPV6_NUM_ADDRESSES];
netif_input_fn input;
netif_output_fn output;
netif_linkoutput_fn linkoutput;
netif_output_ip6_fn output_ip6;
netif_status_callback_fn status_callback;
netif_status_callback_fn link_callback;
netif_status_callback_fn remove_callback;
void state;
void client_data[LWIP_NETIF_CLIENT_DATA_INDEX_MAX + LWIP_NUM_NETIF_CLIENT_DATA];
const char hostname;
u16_t chksum_flags;
u16_t mtu;
u16_t mtu6;
u8_t hwaddr[NETIF_MAX_HWADDR_LEN];
u8_t hwaddr_len;
u8_t flags;
char name[2];
u8_t num;
u8_t ip6_autoconfig_enabled;
u8_t rs_count;
u8_t link_type;
u32_t link_speed;
u32_t ts;
struct stats_mib2_netif_ctrs mib2_counters;
netif_igmp_mac_filter_fn igmp_mac_filter;
netif_mld_mac_filter_fn mld_mac_filter;
struct acd *acd_list;
struct netif_hint *hints;
struct pbuf *loop_first;
struct pbuf *loop_last;
u16_t loop_cnt_current;
u8_t reschedule_poll;
};
static dwc_eth_config_t g_eth1_cfg = {
.base = APB_ENET1_BASE,
.irq_num = ENET1_SBD_INTR_NUM,
.mtu = 1500,
.dma_bus_width = 64,
.phy_intf_mode = ETH_PHY_INTF_SEL_RGMII,
.set_phy_intf = set_phyif_mode,
.ip = {10, 18, 252, 50},
.mask = {255, 255, 255, 0},
.phy = g_phy_arr1
};
dev->d_init = dwc_eth_init;
dev->d_txavail = dwc_eth_txavail;
dev->d_getmac = dwc_eth_getmac;
dev->d_getmtu = dwc_eth_getmtu;
dwc_eth_dev_t *dw_eth_dev = alloc_dwc_eth_device();