Esempio n. 1
0
File: util.c Progetto: sdhczw/WK5500
void Set_network(void)
{
    uint8 tmp_array[6];
    uint8 i;
     ip_from       = IP_FROM_DHCP;	        //DHCP
    // MAC ADDRESS
    for (i = 0 ; i < 6; i++) Config_Msg.Mac[i] = MAC[i];

    setSHAR(Config_Msg.Mac);

        
    // Set DHCP
    Config_Msg.DHCP = Enable_DHCP;
    //Destination IP address for TCP Client

    //Set PTR and RCR register
    setRTR(2000);
    setRCR(5);

    //Init. TX & RX Memory size
    sysinit(txsize, rxsize);

    printf("\r\n----------------------------------------- \r\n");
    printf("W5500E01-M3                       \r\n");
    printf("Network Configuration Information \r\n");
    printf("----------------------------------------- ");

    getSHAR(tmp_array);
    printf("\r\nMAC : %.2X.%.2X.%.2X.%.2X.%.2X.%.2X\r\n", tmp_array[0],tmp_array[1],tmp_array[2],tmp_array[3],tmp_array[4],tmp_array[5]);
}
Esempio n. 2
0
void W5500_Init()
{
	uint8_t memsize[2][8] = { { 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, 2, 2, 2, 2, 2, 2 } };

	Chip_GPIO_SetPinState(LPC_GPIO, 0, 2, true);	// SSEL(CS)

	Chip_GPIO_SetPinState(LPC_GPIO, 0, 22, false);	// N_RESET
	delay_cnt(1000);
	Chip_GPIO_SetPinState(LPC_GPIO, 0, 22, true);	// N_RESET

	reg_wizchip_cs_cbfunc(wizchip_select, wizchip_deselect);
	reg_wizchip_spi_cbfunc(wizchip_read, wizchip_write);
	reg_wizchip_spiburst_cbfunc(wizchip_readburst, wizchip_writeburst);

	/* wizchip initialize*/
	if (ctlwizchip(CW_INIT_WIZCHIP, (void*) memsize) == -1) {
		//printf("WIZCHIP Initialized fail.\r\n");
		while (1);
	}

	/* For Delay */
	delay_cnt(10000);

	setRCR(3);
}
Esempio n. 3
0
void Set_network(void)
{
        uint8 tmp_array[6];       
        uint8 i;
        
        // MAC ADDRESS
        for (i = 0 ; i < 6; i++) Config_Msg.Mac[i] = MAC[i];
        // Local IP ADDRESS
        Config_Msg.Lip[0] = IP[0]; Config_Msg.Lip[1] = IP[1]; Config_Msg.Lip[2] = IP[2]; Config_Msg.Lip[3] = IP[3];
        // GateWay ADDRESS
        Config_Msg.Gw[0] = GateWay[0]; Config_Msg.Gw[1] = GateWay[1]; Config_Msg.Gw[2] = GateWay[2]; Config_Msg.Gw[3] = GateWay[3];
        // Subnet Mask ADDRESS
        Config_Msg.Sub[0] = SubNet[0]; Config_Msg.Sub[1] = SubNet[1]; Config_Msg.Sub[2] = SubNet[2]; Config_Msg.Sub[3] = SubNet[3];
        
        setSHAR(Config_Msg.Mac);
//        setSUBR(Config_Msg.Sub);
        saveSUBR(Config_Msg.Sub);
        setGAR(Config_Msg.Gw);
        setSIPR(Config_Msg.Lip);

        // Set DHCP
        Config_Msg.DHCP = Enable_DHCP;    
        //Destination IP address for TCP Client
        Chconfig_Type_Def.destip[0] = Dest_IP[0]; Chconfig_Type_Def.destip[1] = Dest_IP[1];
        Chconfig_Type_Def.destip[2] = Dest_IP[2]; Chconfig_Type_Def.destip[3] = Dest_IP[3];
        Chconfig_Type_Def.port = Dest_PORT;

        //Set PTR and RCR register	
        setRTR(6000);
        setRCR(3);

        //Init. TX & RX Memory size
        sysinit(txsize, rxsize); 
        
        printf("\r\n----------------------------------------- \r\n");         		
        printf("W5200E01-M3                       \r\n");        
        printf("Network Configuration Information \r\n");        
        printf("----------------------------------------- ");         		
        
        printf("\r\nMAC : %.2X.%.2X.%.2X.%.2X.%.2X.%.2X", IINCHIP_READ(SHAR0+0),IINCHIP_READ(SHAR0+1),IINCHIP_READ(SHAR0+2),
                                                                                                                                                                   IINCHIP_READ(SHAR0+3),IINCHIP_READ(SHAR0+4),IINCHIP_READ(SHAR0+5));
        
        getSIPR (tmp_array);
        printf("\r\nIP : %d.%d.%d.%d", tmp_array[0],tmp_array[1],tmp_array[2],tmp_array[3]);
        
        getSUBR(tmp_array);
        printf("\r\nSN : %d.%d.%d.%d", tmp_array[0],tmp_array[1],tmp_array[2],tmp_array[3]);
        
        getGAR(tmp_array);
        printf("\r\nGW : %d.%d.%d.%d", tmp_array[0],tmp_array[1],tmp_array[2],tmp_array[3]);
}
Esempio n. 4
0
/**
@brief	This function set the network option.
@return 	None.
*/
void SetSocketOption(uint8 option_type, uint16 option_value)
{
    switch(option_type) {
    case 0:
        setRTR(option_value); // set retry duration for data transmission, connection, closing ...
        break;
    case 1:
        setRCR((uint8)(option_value&0x00FF)); // set retry count (above the value, assert timeout interrupt)
        break;
    case 2:
        setIMR((uint8)(option_value&0x00FF)); // set interrupt mask.
        break;
    default:
        break;
    }
}
Esempio n. 5
0
void Set_network(void) {
    uint8 i;

    // MAC ADDRESS
    for (i = 0 ; i < 6; i++) Config_Msg.Mac[i] = MAC[i];

    // Local IP ADDRESS
    Config_Msg.Lip[0] = IP[0];
    Config_Msg.Lip[1] = IP[1];
    Config_Msg.Lip[2] = IP[2];
    Config_Msg.Lip[3] = IP[3];

    // GateWay ADDRESS
    Config_Msg.Gw[0] = GateWay[0];
    Config_Msg.Gw[1] = GateWay[1];
    Config_Msg.Gw[2] = GateWay[2];
    Config_Msg.Gw[3] = GateWay[3];

    // Subnet Mask ADDRESS
    Config_Msg.Sub[0] = SubNet[0];
    Config_Msg.Sub[1] = SubNet[1];

    Config_Msg.Sub[2] = SubNet[2];
    Config_Msg.Sub[3] = SubNet[3];

    setSHAR(Config_Msg.Mac);
    saveSUBR(Config_Msg.Sub);
    setSUBR();
    setGAR(Config_Msg.Gw);
    setSIPR(Config_Msg.Lip);

    // Set DHCP
    Config_Msg.DHCP = Enable_DHCP;
    //Destination IP address for TCP Client
    Chconfig_Type_Def.destip[0] = Dest_IP[0];
    Chconfig_Type_Def.destip[1] = Dest_IP[1];
    Chconfig_Type_Def.destip[2] = Dest_IP[2];
    Chconfig_Type_Def.destip[3] = Dest_IP[3];
    Chconfig_Type_Def.port = Dest_PORT;

    //Set PTR and RCR register
    setRTR(6000);
    setRCR(3);

    //Init. TX & RX Memory size
    sysinit(txsize, rxsize);
}
Esempio n. 6
0
// check if a leased IP is valid
int8_t check_leasedIP(uint8_t s, wiz_NetInfo *pWIZNETINFO)
{
#if 0
	iinchip_init();
	//delay 100
	Delay(10);
	
	Set_network();
	setRCR(1);

	socket(s, Sn_MR_UDP, REMOTE_CLIENT_PORT, 0x00);
	// Create UDP socket for network configuration
	//socket(SOCK_CONFIG, Sn_MR_UDP, REMOTE_CLIENT_PORT, 0x00);
	
//	jsiConsolePrintf("\r\ncheck leased IP \r\n");
	
	if (sendto(s, "CHECK_IP_CONFLICT", 17, (*pWIZNETINFO).ip, 5000) > 0)
	{
		send_DHCP_DECLINE(s);
		return 0;
	}
#endif	
	return 1;
}	
Esempio n. 7
0
void ethernetInit()
{

//	  uint8 mac[6]=ETHERNET_LOCAL_MAC;
//	  uint8 lip[4]=ETHERNET_SSN_SIP;
//	  uint8 sub[4]=ETHERNET_SSN_SN;
//	  uint8 gw[4]=ETHERNET_SSN_GW;
	  uint8 ip[4];

	  xprintfMsg("\r\nW5500 EVB initialization over.");

	  Reset_W5500();
	  WIZ_SPI_Init();
	  xprintfMsg("\r\nW5500 initialized!");

	  setSHAR(mac);
	  setSUBR(sub);
	  setGAR(gw);
	  setSIPR(lip);

	    //Init. TX & RX Memory size of w5500
	  sysinit(txsize, rxsize);

	  setRTR(2000);
	  setRCR(3);


	  getSIPR (ip);
	  xprintfMsg("IP : %d.%d.%d.%d\r\n", ip[0],ip[1],ip[2],ip[3]);
	  getSUBR(ip);
	  xprintfMsg("SN : %d.%d.%d.%d\r\n", ip[0],ip[1],ip[2],ip[3]);
	  getGAR(ip);
	  xprintfMsg("GW : %d.%d.%d.%d\r\n", ip[0],ip[1],ip[2],ip[3]);
	  xprintfMsg("Network is ready.\r\n");

}
Esempio n. 8
0
void wizchip_settimeout(wiz_NetTimeout* nettime)
{
   setRCR(nettime->retry_cnt);
   setRTR(nettime->time_100us);
}