Ejemplo n.º 1
0
uint32_t ENET_initialize
   (
         /* [IN] the FEC to initialize */
      uint32_t              device,
         /* [IN] the local Ethernet address */
      _enet_address        address,
         /* [IN] optional flags, zero = default, 
            this parameter IS NOT USED! (ignored) */
      uint32_t              flags,
         /* [OUT] the Ethernet state structure */
      _enet_handle    *handle
   )
{ 
   if (device <BSP_ENET_DEVICE_COUNT) {
      return ENET_initialize_ex(&ENET_default_params[device],address,handle);
   } else {
      return ENETERR_INVALID_DEVICE;
   }
}
Ejemplo n.º 2
0
void SEC_InitializeNetworking(uint_32 pcbs, uint_32 msgs, uint_32 sockets, boolean dhcp) 
{
  int_32                 error;
  IPCFG_IP_ADDRESS_DATA  ip_data;
  _enet_address          enet_address;
    
#if PSP_MQX_CPU_IS_MCF51CN
   _enet_handle ehandle;
   _rtcs_if_handle ihandle;
#endif



    /* runtime RTCS configuration */
   _RTCSPCB_init = pcbs;
   _RTCS_msgpool_init = msgs;
   _RTCS_socket_part_init = sockets;
    
   error = RTCS_create();
   if (error == RTCS_OK) {

      ip_data.ip = ENET_IPADDR;
      ip_data.mask = ENET_IPMASK;
      ip_data.gateway = ENET_IPGATEWAY;
#if RTCSCFG_ENABLE_LWDNS
      LWDNS_server_ipaddr = ENET_IPDNS;
#endif 

      ENET_get_mac_address(BSP_DEFAULT_ENET_DEVICE, ENET_IPADDR, enet_address);
#if PSP_MQX_CPU_IS_MCF51CN
      ENET_initialize_ex(&ENET_param, BSP_DEFAULT_ENET_DEVICE, &ehandle);
      
      if (RTCS_if_add(ehandle, RTCS_IF_ENET, &ihandle) == 0) {
         if (ipcfg_init_interface(-1, ihandle) != 0) {
            RTCS_if_remove(ihandle);
            ENET_shutdown(ehandle);
                _task_block();
         }
      }
      else {
         ENET_shutdown(ehandle);
      }
#else
      ipcfg_init_device(BSP_DEFAULT_ENET_DEVICE, enet_address);
#endif
      ipcfg_add_dns_ip(BSP_DEFAULT_ENET_DEVICE,LWDNS_server_ipaddr);

      // check link status
      printf("\nWaiting for ethernet cable plug in ... ");
      while(!ipcfg_get_link_active(BSP_DEFAULT_ENET_DEVICE)) {};
      printf("Cable connected\n");

       /* If DHCP Enabled, get IP address from DHCP server */
      if (dhcp) {
         printf("\nDHCP bind ... ");
         error = ipcfg_bind_dhcp_wait(BSP_DEFAULT_ENET_DEVICE, 1, &ip_data);
            if (error != IPCFG_ERROR_OK) {
               printf("Error %08x!\n", error);
            }
            else {
               printf("Successful!\n");
            }
      } else {
         /* Else bind with static IP */
         printf ("\nStatic IP bind ... ");
         error = ipcfg_bind_staticip(BSP_DEFAULT_ENET_DEVICE, &ip_data);

         if (error != IPCFG_ERROR_OK) {
            printf("Error %08x!\n",error);
         }
         else {
            printf("Successful!\n");
         }
       }

       if (error == IPCFG_ERROR_OK) {
          ipcfg_get_ip(BSP_DEFAULT_ENET_DEVICE, &ip_data);
          printf("\nIP Address      : %d.%d.%d.%d\n",IPBYTES(ip_data.ip));
          printf("\nSubnet Address  : %d.%d.%d.%d\n",IPBYTES(ip_data.mask));
          printf("\nGateway Address : %d.%d.%d.%d\n",IPBYTES(ip_data.gateway));
          printf("\nDNS Address     : %d.%d.%d.%d\n",IPBYTES(ipcfg_get_dns_ip(BSP_DEFAULT_ENET_DEVICE,0)));
       }
   } else {
       printf("\nRTCS_Create failed !\n");
       _task_block();
   }
    SEC_GetTime();
}