int main(int argc, char* argv[]) { int ret; RCC_Configuration(); LED_Init(LED1); LED_Init(LED2); LED_On(LED1); LED_Off(LED2); BOOT_Pin_Init(); USART1_Configuration(); #if defined(MULTIFLASH_ENABLE) probe_flash(); #endif /* Load Configure Infomation */ load_S2E_Packet_from_storage(); /* Check MAC Address */ check_mac_address(); W5500_SPI_Init(); W5500_Init(); Timer_Configuration(); Net_Conf(); TFTP_init(SOCK_TFTP, socket_buf); ret = application_update(); if((get_bootpin_Status() == 0) && (ret != TFTP_FAIL)) { uint32_t tmp; #if !defined(MULTIFLASH_ENABLE) tmp = *(volatile uint32_t *)APP_BASE; #else tmp = *(volatile uint32_t *)flash.flash_app_base; #endif if((tmp & 0xffffffff) != 0xffffffff) { application_jump(); } } while (1) { do_udp_config(SOCK_CONFIG); } }
void main() { int i=0; char mymac[6]={0x74,0xf7,0x26,0x00,0x00,0x01}; unsigned char data[]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x04,0x74,0xf7,0x26,0x00,0x00,0x01,0x65,0x00,0x00,0x0a,0x05,0x00,0x01,0x02,0x03,0x05,0x06,0x07,0x08,0x09}; bowler4_header bh; for (i=0; i<sizeof(bowler4_header); i++) bh.bytes[i]=0; bh.fields.version=0x04; bh.fields.affect=setPriority(5,setState(setAsync(bh.fields.affect))); bh.fields.payloadLength=10; bh.fields.payloadType=0; set_mac_address(mymac,&bh); calculate_checksum(&bh); printf("Verify?\t%d\n",verify_checksum(&bh)); printf("Verify?\t%d\n",verify_checksum(&bh)); printf("%X\n",check_mac_address(mymac,&bh) ); printHeader(bh); V4MicroParser_state parser; parser.state=align; parser.macaddr=&mymac; fifoInit(&parser.fifo); fifoPrint(&parser.fifo); for (i=0; i<sizeof(data); i++){ fifoPush(&parser.fifo,data[i]); int delta=parser.fifo.inPointer; printf("Pushing:\t%i\n",i); /*fifoPrint(&parser.fifo);*/ runParserSM(&parser); if (parser.fifo.inPointer!=delta) {printf("\nNew Contents of FIFO:");fifoPrint(&parser.fifo);} printf("===================\n"); } /* fifoPull(&fifo,15); */ /* fifoPrint(&fifo); */ }
/** * @brief Main program * @param None * @retval None */ int main() { //uint8_t tx_size[8] = { 2, 2, 2, 2, 2, 2, 2, 2 }; //uint8_t rx_size[8] = { 2, 2, 2, 2, 2, 2, 2, 2 }; //uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x11, 0x22, 0x33}; //uint8_t src_addr[4] = {192, 168, 0, 80}; //uint8_t gw_addr[4] = {192, 168, 0, 1}; //uint8_t sub_addr[4] = {255, 255, 255, 0}; //uint8_t dns_server[4] = {8, 8, 8, 8}; // for Example domain name server //uint8_t tmp[8]; //int ret; int i; #if defined (_MAIN_DEBUG_) && defined (_USE_SDCARD_) int ret; #endif #if defined(F_APP_FTP) wiz_NetInfo gWIZNETINFO; #endif #if defined(F_APP_DHCP) || defined(F_APP_DNS) S2E_Packet *value = get_S2E_Packet_pointer(); #endif #if defined(F_APP_DNS) uint8_t dns_server_ip[4]; #endif /* External Clock */ CRG_PLL_InputFrequencySelect(CRG_OCLK); /* Set System init */ SystemInit(); /* UART Init */ UART_StructInit(&UART_InitStructure); UART_Init(UART_DEBUG,&UART_InitStructure); /* SysTick_Config */ SysTick_Config((GetSystemClock()/1000)); /* Set WZ_100US Register */ setTIC100US((GetSystemClock()/10000)); //getTIC100US(); //printf(" GetSystemClock: %X, getTIC100US: %X, (%X) \r\n", // GetSystemClock, getTIC100US(), *(uint32_t *)TIC100US); LED_Init(LED1); LED_Init(LED2); LED_Init(LED3); LED_Off(LED1); LED_Off(LED2); LED_Off(LED3); g_sdcard_done = 0; BOOT_Pin_Init(); Board_factory_Init(); EXTI_Configuration(); /* Load Configure Information */ load_S2E_Packet_from_storage(); UART_Configuration(); /* Check MAC Address */ check_mac_address(); Timer0_Configuration(); // ADC initialize ADC_Init(); #ifdef _MAIN_DEBUG_ uint8_t tmpstr[6] = {0,}; ctlwizchip(CW_GET_ID,(void*)tmpstr); printf("\r\n============================================\r\n"); printf(" WIZnet %s EVB Demo v%d.%.2d\r\n", tmpstr, VER_H, VER_L); printf("============================================\r\n"); printf(" WIZwiki Platform based WEBBoot Example\r\n"); printf("============================================\r\n"); #endif #ifdef __DEF_USED_IC101AG__ //For using IC+101AG *(volatile uint32_t *)(0x41003068) = 0x64; //TXD0 - set PAD strengh and pull-up *(volatile uint32_t *)(0x4100306C) = 0x64; //TXD1 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003070) = 0x64; //TXD2 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003074) = 0x64; //TXD3 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003050) = 0x64; //TXE - set PAD strengh and pull-up #endif #ifdef __DEF_USED_MDIO__ /* mdio Init */ mdio_init(GPIOB, MDC, MDIO ); /* PHY Link Check via gpio mdio */ while( link() == 0x0 ) { printf("."); delay(500); } printf("PHY is linked. \r\n"); #else delay(1000); delay(1000); #endif Mac_Conf(); #if defined(F_APP_DHCP) if(value->options.dhcp_use) // DHCP { uint32_t ret; uint8_t dhcp_retry = 0; #ifdef _MAIN_DEBUG_ printf(" - DHCP Client running\r\n"); #endif DHCP_init(SOCK_DHCP, TX_BUF); reg_dhcp_cbfunc(w5500_dhcp_assign, w5500_dhcp_assign, w5500_dhcp_conflict); while(1) { ret = DHCP_run(); if(ret == DHCP_IP_LEASED) { #ifdef _MAIN_DEBUG_ printf(" - DHCP Success: DHCP Leased time : %ld Sec.\r\n\r\n", getDHCPLeasetime()); #endif break; } else if(ret == DHCP_FAILED) { dhcp_retry++; #ifdef _MAIN_DEBUG_ if(dhcp_retry <= 3) printf(" - DHCP Timeout occurred and retry [%d]\r\n", dhcp_retry); #endif } if(dhcp_retry > 3) { #ifdef _MAIN_DEBUG_ printf(" - DHCP Failed\r\n\r\n"); #endif value->options.dhcp_use = 0; Net_Conf(); break; } do_udp_config(SOCK_CONFIG); } } else // Static { Net_Conf(); } #else Net_Conf(); #endif #ifdef _MAIN_DEBUG_ display_Net_Info(); #endif #if defined(F_APP_ATC) atc_init(&rxring, &txring); op_mode = OP_DATA; #endif TFTP_init(SOCK_TFTP, socket_buf); ret = application_update(); printf("[DEBUG] check trigger:%d ret:%d \r\n", get_bootpin_Status(), ret); if((get_bootpin_Status() == 1) && (ret != TFTP_FAIL)) { uint32_t tmp; #if !defined(MULTIFLASH_ENABLE) tmp = *(volatile uint32_t *)APP_BASE; #else tmp = *(volatile uint32_t *)flash.flash_app_base; #endif if((tmp & 0xffffffff) != 0xffffffff) { printf("[DEBUG] application_jump\r\n"); application_jump(); } } #ifdef _USE_SDCARD_ // SD card Initialization ret = mmc_mount(); if(ret <= 0) { #ifdef _MAIN_DEBUG_ printf("\r\n - Can't mount SD card: Please Reboot WIZ750WEB Board or Insert SD card\r\n"); #endif //while(!(ret = mmc_mount())); } if(ret > 0) { #ifdef _MAIN_DEBUG_ display_SDcard_Info(ret); #endif } #endif httpServer_init(TX_BUF, RX_BUF, MAX_HTTPSOCK, socknumlist); #ifdef _USE_WATCHDOG_ reg_httpServer_cbfunc(NVIC_SystemReset, IWDG_ReloadCounter); // Callback: STM32 MCU Reset / WDT Reset (IWDG) #else reg_httpServer_cbfunc(NVIC_SystemReset, NULL); // Callback: STM32 MCU Reset #endif IO_status_init(); #if defined(F_APP_FTP) ctlnetwork(CN_GET_NETINFO, (void*) &gWIZNETINFO); ftpd_init(gWIZNETINFO.ip); // Added by James for FTP #endif #ifdef _USE_WATCHDOG_ // IWDG Initialization: STM32 Independent WatchDog IWDG_Configureation(); #endif while (1) { #ifdef _USE_WATCHDOG_ IWDG_ReloadCounter(); // Feed IWDG #endif #if defined(F_APP_ATC) atc_run(); #endif if(g_op_mode == NORMAL_MODE) { do_udp_config(SOCK_CONFIG); } else { if(TFTP_run() != TFTP_PROGRESS) g_op_mode = NORMAL_MODE; } #if defined(F_APP_DHCP) if(value->options.dhcp_use) DHCP_run(); #endif for(i = 0; i < MAX_HTTPSOCK; i++) httpServer_run(i); // HTTP server handler #if defined(F_APP_FTP) ftpd_run(FTP_DBUF); #endif #ifdef _USE_WATCHDOG_ IWDG_ReloadCounter(); // Feed IWDG #endif } return 0; }
/** * @brief Main program * @param None * @retval None */ int main() { //uint8_t tx_size[8] = { 2, 2, 2, 2, 2, 2, 2, 2 }; //uint8_t rx_size[8] = { 2, 2, 2, 2, 2, 2, 2, 2 }; //uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x11, 0x22, 0x33}; //uint8_t src_addr[4] = {192, 168, 0, 80}; //uint8_t gw_addr[4] = {192, 168, 0, 1}; //uint8_t sub_addr[4] = {255, 255, 255, 0}; //uint8_t dns_server[4] = {8, 8, 8, 8}; // for Example domain name server //uint8_t tmp[8]; //int ret; /* External Clock */ CRG_PLL_InputFrequencySelect(CRG_OCLK); /* Set System init */ SystemInit(); /* UART Init */ UART_StructInit(&UART_InitStructure); UART_Init(UART_DEBUG,&UART_InitStructure); /* SysTick_Config */ SysTick_Config((GetSystemClock()/1000)); /* Set WZ_100US Register */ setTIC100US((GetSystemClock()/10000)); //getTIC100US(); //printf(" GetSystemClock: %X, getTIC100US: %X, (%X) \r\n", // GetSystemClock, getTIC100US(), *(uint32_t *)TIC100US); LED_Init(LED1); LED_Init(LED2); LED_On(LED1); LED_Off(LED2); BOOT_Pin_Init(); /* Load Configure Information */ load_S2E_Packet_from_storage(); UART_Configuration(); /* Check MAC Address */ check_mac_address(); Timer0_Configuration(); #ifdef _MAIN_DEBUG_ uint8_t tmpstr[6] = {0,}; ctlwizchip(CW_GET_ID,(void*)tmpstr); printf("\r\n============================================\r\n"); printf(" WIZnet %s EVB Demo v%d.%.2d\r\n", tmpstr, VER_H, VER_L); printf("============================================\r\n"); printf(" WIZwiki Platform based TFTP App Example\r\n"); printf("============================================\r\n"); #endif #ifdef __DEF_USED_IC101AG__ //For using IC+101AG *(volatile uint32_t *)(0x41003068) = 0x64; //TXD0 - set PAD strengh and pull-up *(volatile uint32_t *)(0x4100306C) = 0x64; //TXD1 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003070) = 0x64; //TXD2 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003074) = 0x64; //TXD3 - set PAD strengh and pull-up *(volatile uint32_t *)(0x41003050) = 0x64; //TXE - set PAD strengh and pull-up #endif #ifdef __DEF_USED_MDIO__ /* mdio Init */ mdio_init(GPIOB, MDC, MDIO ); /* PHY Link Check via gpio mdio */ while( link() == 0x0 ) { printf("."); delay(500); } printf("PHY is linked. \r\n"); #else delay(1000); delay(1000); #endif #if 0 /* Network Configuration */ setSHAR(mac_addr); setSIPR(src_addr); setGAR(gw_addr); setSUBR(sub_addr); getSHAR(tmp); printf("MAC ADDRESS : %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\r\n",tmp[0],tmp[1],tmp[2],tmp[3],tmp[4],tmp[5]); getSIPR(tmp); printf("IP ADDRESS : %.3d.%.3d.%.3d.%.3d\r\n",tmp[0],tmp[1],tmp[2],tmp[3]); getGAR(tmp); printf("GW ADDRESS : %.3d.%.3d.%.3d.%.3d\r\n",tmp[0],tmp[1],tmp[2],tmp[3]); getSUBR(tmp); printf("SN MASK: %.3d.%.3d.%.3d.%.3d\r\n",tmp[0],tmp[1],tmp[2],tmp[3]); /* Set Network Configuration */ //wizchip_init(tx_size, rx_size); #else Net_Conf(); #endif //TFTP_init(SOCK_TFTP, socket_buf); while (1) { if(g_op_mode == NORMAL_MODE) { do_udp_config(SOCK_CONFIG); } else { if(TFTP_run() != TFTP_PROGRESS) g_op_mode = NORMAL_MODE; } } return 0; }