/** * It executes example program such as loopback_tcps(), loopback_tcpc(), and loopback_udp(). */ int main() { uint8 tx_mem_conf[8] = {8,8,8,8,8,8,8,8}; // for setting TMSR regsiter uint8 rx_mem_conf[8] = {8,8,8,8,8,8,8,8}; // for setting RMSR regsiter uint8 * data_buf = (uint8 *) 0xA10E0000; // buffer for loopack data uint8 ip[4] = {192,168,111,200}; // for setting SIP register uint8 gw[4] = {192,168,111,1}; // for setting GAR register uint8 sn[4] = {255,255,255,0}; // for setting SUBR register uint8 mac[6] = {0x00,0x08,0xDC,0x00,111,200}; // for setting SHAR register uint8 serverip[4] = {192,168,111,78}; // "TCP SERVER" IP address for loopback_tcpc() status.terminalSpeed = SERIAL_SPEED; status.downloadSpeed = SERIAL_DOWNLOAD_SPEED; data_buf = (uint8*)0xA10F0000; //InitXHyper255A(); // initiate MCU //SerialInit(status.terminalSpeed); // initiate serial port /* initiate W5300 */ printf("BBB");fflush(stdout); iinchip_init(); printf("CCC");fflush(stdout); /* allocate internal TX/RX Memory of W5300 */ if(!sysinit(tx_mem_conf,rx_mem_conf)) { printf("MEMORY CONFIG ERR.\r\n"); while(1); } //setMR(getMR()|MR_FS); // If Little-endian, set MR_FS. setSHAR(mac); // set source hardware address #ifdef __DEF_IINCHIP_PPP__ if(pppinit((uint8*)"test01", 6, (uint8*)"pppoe1000", 9)!=1) { printf("PPPoE fail.\r\n"); while(1); } close(0); #else /* configure network information */ setGAR(gw); // set gateway IP address setSUBR(sn); // set subnet mask address setSIPR(ip); // set source IP address #endif /* verify network information */ getSHAR(mac); // get source hardware address getGAR(gw); // get gateway IP address getSUBR(sn); // get subnet mask address getSIPR(ip); // get source IP address printf("SHAR : %02x:%02x:%02x:%02x:%02x:%02x\r\n",mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]); printf("GWR : %d.%d.%d.%d\r\n",gw[0],gw[1],gw[2],gw[3]); printf("SUBR : %d.%d.%d.%d\r\n",sn[0],sn[1],sn[2],sn[3]); printf("SIPR : %d.%d.%d.%d\r\n",ip[0],ip[1],ip[2],ip[3]); while(1) { loopback_tcps(0,5000,data_buf,0); loopback_tcps(1,5000,data_buf,0); loopback_tcps(2,5000,data_buf,0); loopback_tcps(3,5000,data_buf,0); loopback_tcps(4,5000,data_buf,0); loopback_tcps(5,5000,data_buf,0); loopback_tcpc(6,serverip, 3000, data_buf,0); loopback_udp(7,3000,data_buf,0); } #ifdef __DEF_IINCHIP_PPP__ { uint8 ppp_mac[6]; getPDHAR(ppp_mac); pppterm(ppp_mac, getPSIDR()); } #endif while(1); }
int main(void){ sysInit(); SPCR = (1 << SPE) | (1 << MSTR) | (0 << CPOL) | (0 << CPHA) | (0 << SPR1); SPSR = (1<<SPI2X); W5500_Init(); _delay_ms(10); sprintf(gPtrintBuff, "Version: %u\n",getVERSIONR()); uartPuts(gPtrintBuff); //i2cScanner(); si70xx_init(); uartPutsP("\nInto Loop\n"); while (1){ if(milis() - loopTime >= 50){ hsv2rgb(hue_value,255,80, &Rpwm, &Gpwm, &Bpwm, 250); OCR1A = Rpwm; OCR1B = Gpwm; OCR1C = Bpwm; hue_value++; if(hue_value > 359){ hue_value = 0; } float temperature = si70xx_get_temperature(); float humidity = si70xx_get_humidity(); /* while(getSn_SR(SOCK_ID_TCP) != SOCK_ESTABLISHED){ loopback_tcpc(SOCK_ID_TCP, dIP, dport); } */ sprintf(gDATABUF, "%u | Temp: %.2f RH: %.2f \n\0", i , temperature, humidity); retVal = send(SOCK_ID_TCP, gDATABUF, sizeof(gDATABUF)); //close(SOCK_ID_TCP); sprintf(gPtrintBuff, "%u | Sent: %i Sizeof: %u\n", i , retVal, sizeof(gDATABUF)); uartPuts(gPtrintBuff); i++; loopTime = milis(); } loopback_tcpc(SOCK_ID_TCP, dIP, dport); //send(TCP_) char temp = uartGetc(); if(temp == 'S'){ printNetInfo(); //uartPutc(temp); } if(temp == 's'){ send(SOCK_ID_TCP, 'a', sizeof('a')); //uartPutc(temp); } } }