int AT91_EMAC_LWIP_Driver::Open(int index) { /* Network interface variables */ struct ip_addr ipaddr, subnetmask, gateway; struct netif *pNetIF; int len; const SOCK_NetworkConfiguration *iface; /* Apply network configuration */ iface = &g_NetworkConfig.NetworkInterfaces[index]; len = g_AT91_EMAC_NetIF.hwaddr_len; if(len == 0 || iface->macAddressLen < len) { len = iface->macAddressLen; g_AT91_EMAC_NetIF.hwaddr_len = len; } memcpy(g_AT91_EMAC_NetIF.hwaddr, iface->macAddressBuffer, len); if(0 == (iface->flags & SOCK_NETWORKCONFIGURATION_FLAGS_DHCP)) { ipaddr.addr = iface->ipaddr; gateway.addr = iface->gateway; subnetmask.addr = iface->subnetmask; } else { /* Set network address variables - this will be set by either DHCP or when the configuration is applied */ IP4_ADDR(&gateway, 0,0,0,0); IP4_ADDR(&ipaddr, 0,0,0,0); IP4_ADDR(&subnetmask, 255,255,255,0); } // PHY Power Up CPU_GPIO_EnableOutputPin(g_AT91_EMAC_LWIP_Config.PHY_PD_GPIO_Pin, FALSE); // Enable Interrupt CPU_INTC_ActivateInterrupt(AT91C_ID_EMAC, (HAL_CALLBACK_FPN)AT91_EMAC_LWIP_interrupt, &g_AT91_EMAC_NetIF); g_AT91_EMAC_NetIF.flags = NETIF_FLAG_IGMP | NETIF_FLAG_BROADCAST; pNetIF = netif_add( &g_AT91_EMAC_NetIF, &ipaddr, &subnetmask, &gateway, NULL, AT91_EMAC_ethhw_init, ethernet_input ); netif_set_default( pNetIF ); LWIP_STATUS_setorclear( LWIP_STATUS_LinkUp, 0 != dm9161_lwip_GetLinkStatus( ) ); if (LWIP_STATUS_isset(LWIP_STATUS_LinkUp)) { netif_set_link_up( pNetIF ); netif_set_up ( pNetIF ); Network_PostEvent( NETWORK_EVENT_TYPE__AVAILABILITY_CHANGED, NETWORK_EVENT_FLAGS_IS_AVAILABLE ); } /* Initialize the continuation routine for the driver interrupt and receive */ InitContinuations( pNetIF ); return g_AT91_EMAC_NetIF.num; }
int AT91_EMAC_LWIP_Driver::Open(int index) { /* Network interface variables */ struct ip_addr ipaddr, subnetmask, gateway; struct netif *pNetIF; int len; const SOCK_NetworkConfiguration *iface; /* Apply network configuration */ iface = &g_NetworkConfig.NetworkInterfaces[index]; len = g_AT91_EMAC_NetIF.hwaddr_len; if(len == 0 || iface->macAddressLen < len) { len = iface->macAddressLen; g_AT91_EMAC_NetIF.hwaddr_len = len; } memcpy(g_AT91_EMAC_NetIF.hwaddr, iface->macAddressBuffer, len); ipaddr.addr = iface->ipaddr; gateway.addr = iface->gateway; subnetmask.addr = iface->subnetmask; // PHY Power Up CPU_GPIO_EnableOutputPin(g_AT91_EMAC_LWIP_Config.PHY_PD_GPIO_Pin, FALSE); // Enable Interrupt CPU_INTC_ActivateInterrupt(AT91C_ID_EMAC, (HAL_CALLBACK_FPN)AT91_EMAC_LWIP_interrupt, &g_AT91_EMAC_NetIF); /* Initialize the continuation routine for the driver interrupt and receive */ InitContinuations( pNetIF ); pNetIF = netif_add( &g_AT91_EMAC_NetIF, &ipaddr, &subnetmask, &gateway, NULL, AT91_EMAC_ethhw_init, ethernet_input ); netif_set_default( pNetIF ); LwipNetworkStatus = dm9161_lwip_GetLinkStatus( ); if (LwipNetworkStatus) { netif_set_up( pNetIF ); } /* Initialize the continuation routine for the driver interrupt and receive */ InitContinuations( pNetIF ); return g_AT91_EMAC_NetIF.num; }
int STM32F4_ETH_LWIP_Driver::Open(int index) { /* Network interface variables */ struct ip_addr ipaddr, subnetmask, gateway; struct netif *pNetIF; int len; const SOCK_NetworkConfiguration *iface; EthernetPrepareZero(); /* Enable Phy Powerdown on Deepsleep */ STM32F4_SetPowerHandlers(EthernetDeepSleep, EthernetWakeUp); /* Apply network configuration */ iface = &g_NetworkConfig.NetworkInterfaces[index]; len = g_STM32F4_ETH_NetIF.hwaddr_len; if (len == 0 || iface->macAddressLen < len) { len = iface->macAddressLen; g_STM32F4_ETH_NetIF.hwaddr_len = len; } memcpy(g_STM32F4_ETH_NetIF.hwaddr, iface->macAddressBuffer, len); ipaddr.addr = iface->ipaddr; gateway.addr = iface->gateway; subnetmask.addr = iface->subnetmask; pNetIF = netif_add( &g_STM32F4_ETH_NetIF, &ipaddr, &subnetmask, &gateway, NULL, STM32F4_ETH_ethhw_init, ethernet_input ); CPU_INTC_ActivateInterrupt(ETH_IRQn, (HAL_CALLBACK_FPN)STM32F4_ETH_LWIP_interrupt, &g_STM32F4_ETH_NetIF); netif_set_default( pNetIF ); if (LwipNetworkStatus) { netif_set_up( pNetIF ); } else { netif_set_down( pNetIF); } /* Initialize the continuation routine for the driver interrupt and receive */ InitContinuations( pNetIF ); /* Return LWIP's net interface number */ return g_STM32F4_ETH_NetIF.num; }
int LPC24XX_EMAC_LWIP_Driver::Open(int index) { /* Network interface variables */ struct ip_addr ipaddr, subnetmask, gateway; struct netif *pNetIF; int len; const SOCK_NetworkConfiguration *iface; /* Apply network configuration */ iface = &g_NetworkConfig.NetworkInterfaces[index]; len = g_LPC24XX_EMAC_NetIF.hwaddr_len; if(len == 0 || iface->macAddressLen < len) { len = iface->macAddressLen; g_LPC24XX_EMAC_NetIF.hwaddr_len = len; } memcpy(g_LPC24XX_EMAC_NetIF.hwaddr, iface->macAddressBuffer, len); ipaddr.addr = iface->ipaddr; gateway.addr = iface->gateway; subnetmask.addr = iface->subnetmask; pNetIF = netif_add( &g_LPC24XX_EMAC_NetIF, &ipaddr, &subnetmask, &gateway, NULL, lpc24xx_ethhw_init, ethernet_input ); /* Enable the INTERRUPT */ CPU_INTC_ActivateInterrupt(LPC24XX_VIC::c_IRQ_INDEX_EMAC, (HAL_CALLBACK_FPN)LPC24XX_EMAC_lwip_interrupt, &g_LPC24XX_EMAC_NetIF); netif_set_default( pNetIF ); LwipNetworkStatus = ENET_PHY_lwip_get_link_status( ); if (LwipNetworkStatus) { netif_set_up( pNetIF ); } /* Initialize the continuation routine for the driver interrupt and receive */ InitContinuations( pNetIF ); // Return LWIP's net interface number return g_LPC24XX_EMAC_NetIF.num; }
int SH7264_SMSC_LWIP_Driver::Open(int index) { /* Network interface variables */ struct ip_addr ipaddr, subnetmask, gateway; struct netif *pNetIF; int len; const SOCK_NetworkConfiguration *iface; /* Apply network configuration */ iface = &g_NetworkConfig.NetworkInterfaces[index]; len = g_SH7264_SMSC_NetIF.hwaddr_len; if(len == 0 || iface->macAddressLen < len) { len = iface->macAddressLen; g_SH7264_SMSC_NetIF.hwaddr_len = len; } memcpy(g_SH7264_SMSC_NetIF.hwaddr, iface->macAddressBuffer, len); ipaddr.addr = iface->ipaddr; gateway.addr = iface->gateway; subnetmask.addr = iface->subnetmask; g_SH7264_SMSC_NetIF.flags |= NETIF_FLAG_IGMP; pNetIF = netif_add( &g_SH7264_SMSC_NetIF, &ipaddr, &subnetmask, &gateway, NULL, SH7264_SMSC_ethhw_init, ethernet_input ); netif_set_default( pNetIF ); LwipNetworkStatus = (SMSC9218_lwip_Get_Link_Mode() != LINK_NO_LINK); if (LwipNetworkStatus) { netif_set_up( pNetIF ); } /* Initialize the continuation routine for the driver interrupt and receive */ InitContinuations( pNetIF ); // Return LWIP's net interface number return g_SH7264_SMSC_NetIF.num; }
int ENC28J60_LWIP_Driver::Open( ENC28J60_LWIP_DRIVER_CONFIG* config, int index ) { NATIVE_PROFILE_HAL_DRIVERS_ETHERNET(); /* Network interface variables */ struct ip_addr ipaddr, netmask, gw; struct netif *pNetIF; int len; const SOCK_NetworkConfiguration *iface; if(config == NULL) return -1; iface = &g_NetworkConfig.NetworkInterfaces[index]; if(0 == (iface->flags & SOCK_NETWORKCONFIGURATION_FLAGS_DHCP)) { ipaddr.addr = iface->ipaddr; gw.addr = iface->gateway; netmask.addr = iface->subnetmask; } else { /* Set network address variables - this will be set by either DHCP or when the configuration is applied */ IP4_ADDR(&gw , 0, 0, 0, 0); IP4_ADDR(&ipaddr , 0, 0, 0, 0); IP4_ADDR(&netmask, 255, 255, 255, 0); } len = g_ENC28J60_NetIF.hwaddr_len; if(len == 0 || iface->macAddressLen < len) { len = iface->macAddressLen; g_ENC28J60_NetIF.hwaddr_len = len; } memcpy(g_ENC28J60_NetIF.hwaddr, iface->macAddressBuffer, len); pNetIF = netif_add( &g_ENC28J60_NetIF, &ipaddr, &netmask, &gw, NULL, enc28j60_ethhw_init, ethernet_input ); netif_set_default( pNetIF ); LwipNetworkStatus = enc28j60_get_link_status(&config->SPI_Config); /* Initialize the continuation routine for the driver interrupt and receive */ InitContinuations( pNetIF ); /* Enable the INTERRUPT pin */ if (CPU_GPIO_EnableInputPin2(config->INT_Pin, FALSE, /* Glitch filter enable */ (GPIO_INTERRUPT_SERVICE_ROUTINE) &enc28j60_lwip_pre_interrupt, /* ISR */ &g_ENC28J60_NetIF, /* minor number */ GPIO_INT_EDGE_LOW , /* Interrupt edge */ RESISTOR_PULLUP) == FALSE) /* Resistor State */ { return -1; } /* Enable the CHIP SELECT pin */ if (CPU_GPIO_EnableInputPin (config->SPI_Config.DeviceCS, FALSE, NULL, GPIO_INT_NONE, RESISTOR_PULLUP) == FALSE) { return -1; } return g_ENC28J60_NetIF.num; }
void EthernetWakeUp() { CPU_INTC_ActivateInterrupt(ETH_IRQn, (HAL_CALLBACK_FPN)STM32F4_ETH_LWIP_interrupt, &g_STM32F4_ETH_NetIF); InitContinuations(&g_STM32F4_ETH_NetIF); }