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]); }
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]); }
/** @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; } }
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); }
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"); }
void wizchip_settimeout(wiz_NetTimeout* nettime) { setRCR(nettime->retry_cnt); setRTR(nettime->time_100us); }
RxPDORTR(unsigned int nodeId, unsigned int smid): CANOpenMsg(0x700+nodeId, smid) { setRTR(1); setFlag(1); };
void APP_Tasks(void) { /* Check if device is configured. See if it is configured with correct * configuration value */ switch (appData.state) { case APP_STATE_INIT: /* Open the device layer */ appData.usbDevHandle = USB_DEVICE_Open(USB_DEVICE_INDEX_0, DRV_IO_INTENT_READWRITE); if (appData.usbDevHandle != USB_DEVICE_HANDLE_INVALID) { /* Register a callback with device layer to get event notification (for end point 0) */ USB_DEVICE_EventHandlerSet(appData.usbDevHandle, APP_USBDeviceEventHandler, 0); appData.state = APP_STATE_WAIT_FOR_CONFIGURATION; } else { /* The Device Layer is not ready to be opened. We should try * again later. */ } break; case APP_STATE_WAIT_FOR_CONFIGURATION: if (appData.deviceConfigured == true) { /* Device is ready to run the main task */ appData.hidDataReceived = false; appData.hidDataTransmitted = true; appData.state = APP_STATE_MAIN_TASK; /* Place a new read request. */ USB_DEVICE_HID_ReportReceive(USB_DEVICE_HID_INDEX_0, &appData.rxTransferHandle, appData.receiveDataBuffer, 64); } break; case APP_STATE_MAIN_TASK: if (!appData.deviceConfigured) { /* Device is not configured */ appData.state = APP_STATE_WAIT_FOR_CONFIGURATION; } else if (appData.hidDataReceived) { /* Look at the data the host sent, to see what * kind of application specific command it sent. */ switch (appData.receiveDataBuffer[0]) { case 0x80: /* Toggle on board LED1 to LED2. */ BSP_LEDToggle(APP_USB_LED_1); BSP_LEDToggle(APP_USB_LED_2); setRTR(); break; case 0x81: if (appData.hidDataTransmitted) { /* Echo back to the host PC the command we are fulfilling in * the first byte. In this case, the Get Push-button State * command. */ appData.transmitDataBuffer[0] = 0x81; appData.transmitDataBuffer[1] = 0b1 & BSP_SwitchStateGet(APP_USB_SWITCH_1); appData.transmitDataBuffer[2] = 111; setRTS(); setRTR(); } break; case 0x82: if (!appData.numTX || _CP0_GET_COUNT() > 200000) { //prepare new data to send acc_read_register(OUT_X_L_A, (unsigned char *) appData.accels, 6); appData.transmitDataBuffer[0] = 1; //we have data to send appData.transmitDataBuffer[1] = appData.accels[0] >> 8; //x high byte appData.transmitDataBuffer[2] = appData.accels[0] & 0xFF; //x low byte appData.transmitDataBuffer[3] = appData.accels[1] >> 8; //y high byte appData.transmitDataBuffer[4] = appData.accels[1] & 0xFF; //y low byte appData.transmitDataBuffer[5] = appData.accels[2] >> 8; //z high byte appData.transmitDataBuffer[6] = appData.accels[2] & 0xFF; //z low byte // reset core timer for 100 hz _CP0_SET_COUNT(0); appData.numTX++; } else { appData.transmitDataBuffer[0] = 0; // we don't have new data } setRTS(); setRTR(); break; case 0x83: // prepare for a bout of sending accel data //parse incoming data to screen oled_clear_buffer(); int row = appData.receiveDataBuffer[1]; char * msg; msg = &appData.receiveDataBuffer[2]; oled_draw_string(0, row, msg, 1); oled_update(); // clear buffered accel data so we read new data to send acc_read_register(OUT_X_L_A, (unsigned char *) appData.accels, 6); appData.numTX = 0; //we're starting over setRTR(); break; case 0x84: // done asking for data oled_draw_string(0, 55, "Done!", 1); oled_update(); setRTR(); break; default: setRTR(); break; } }