int main(void) { int temp = 5; //configures the priority grouping NVIC_PriorityGroupConfig(NVIC_PriorityGroup_3); //start time start_timer(); //configure spi SPI_Config(); //ETHERNET INITIALIZATION ETH_BSP_Config(); /* Initilaize the LwIP stack */ LwIP_Init(); //udp initialization if (!udp_echoserver_init()) return 1; while (1) { //PROCESSING OF PEREODIC TIMERS FOR LWIP LwIP_Periodic_Handle(gettime()); //PROCESSING OF INCOMING PACKET if (ETH_CheckFrameReceived()) { /* process received ethernet packet */ LwIP_Pkt_Handle(); } trans_Control((void*)&temp, sizeof(temp)); } }
/** * @brief Main program. * @param None * @retval None */ int main(void) { /*!< At this stage the microcontroller clock setting is already configured to 144 MHz, this is done through SystemInit() function which is called from startup file (startup_stm32f4xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f4xx.c file */ /*Initialize LCD and Leds */ LCD_LED_Init(); /* configure ethernet (GPIOs, clocks, MAC, DMA) */ ETH_BSP_Config(); /* Initilaize the LwIP stack */ LwIP_Init(); /* Initialize webserver demo */ http_server_socket_init(); #ifdef USE_DHCP /* Start DHCPClient */ xTaskCreate(LwIP_DHCP_task, (const signed char *) "DHCPClient", configMINIMAL_STACK_SIZE * 2, NULL,DHCP_TASK_PRIO, NULL); #endif /* Start toogleLed4 task : Toggle LED4 every 250ms */ xTaskCreate(ToggleLed4, (const signed char *) "LED4", configMINIMAL_STACK_SIZE, NULL, LED_TASK_PRIO, NULL); /* Start scheduler */ vTaskStartScheduler(); /* We should never get here as control is now taken by the scheduler */ for ( ;; ); }
/** * @brief Main program. * @param None * @retval None */ int main(void) { /* Setup STM32 system (clocks, Ethernet, GPIO, NVIC) and STM3210C-EVAL resources */ System_Setup(); /* Initilaize the LwIP satck */ LwIP_Init(); /* Initilaize the HelloWorld module */ HelloWorld_init(); /* Initilaize the webserver module */ httpd_init(); /* Initialize the TFTP server */ tftpd_init(); /* Infinite loop */ while (1) { /* Periodic tasks */ System_Periodic_Handle(); } }
/** * @brief Main task * @param pvParameters not used * @retval None */ void Main_task(void * pvParameters) { #ifdef SERIAL_DEBUG DebugComPort_Init(); #endif /* configure ethernet (GPIOs, clocks, MAC, DMA) */ ETH_BSP_Config(); /* Initialize the LwIP stack */ LwIP_Init(); /* Initialize tcp echo server */ //tcpecho_init(); /* Initialize udp echo server */ udpecho_init(); #ifdef USE_DHCP /* Start DHCPClient */ xTaskCreate(LwIP_DHCP_task, (int8_t *)"DHCP", configMINIMAL_STACK_SIZE * 2, NULL,DHCP_TASK_PRIO, NULL); #endif #if 0 /* Start toogleLed4 task : Toggle LED4 every 250ms */ xTaskCreate(ToggleLed4, (int8_t *)"LED4", configMINIMAL_STACK_SIZE, NULL, LED_TASK_PRIO, NULL); #endif for( ;; ) { vTaskDelete(NULL); } }
/*************************************************************************************************************************** **************************************************************************************************************************** MAIN PROGRAM **************************************************************************************************************************** ***************************************************************************************************************************/ int main(void) { NP2_boardinit(); Hardware_init(); Hardware_PWM_init(); /* Initilaize the LwIP stack */ LwIP_Init(); /* Create all tasks */ xTaskCreate( (void *) &PanTiltTask, (const signed char *) "PanTilt", PANTILTTASK_STACK_SIZE, NULL, PANTILTTASK_PRIORITY, &xPanTiltTask); xTaskCreate( (void *) &DistanceTask, (const signed char *) "Dist", DISTANCETASK_STACK_SIZE, NULL, DISTANCETASK_PRIORITY, &xDistanceTask); xTaskCreate( (void *) &CLITask, (const signed char *) "CLI", CLI_TASK_STACK_SIZE, NULL, CLI_PRIORITY, &xCLITask); /* Register all CMDs */ FreeRTOS_CLIRegisterCommand(&xTaskUsage); FreeRTOS_CLIRegisterCommand(&xEncode); FreeRTOS_CLIRegisterCommand(&xDecode); FreeRTOS_CLIRegisterCommand(&xLaser); FreeRTOS_CLIRegisterCommand(&xDistance); FreeRTOS_CLIRegisterCommand(&xTracking); /* Start scheduler */ vTaskStartScheduler(); return 0; }
/** * @brief Main program. * @param None * @retval None */ int main(void) { /*!< At this stage the microcontroller clock setting is already configured to 168 MHz, this is done through SystemInit() function which is called from startup file (startup_stm32f4xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f4xx.c file */ #ifdef SERIAL_DEBUG DebugComPort_Init(); #endif /*Initialize LCD and Leds */ LCD_LED_BUTTON_Init(); /* Configure ethernet (GPIOs, clocks, MAC, DMA) */ ETH_BSP_Config(); /* Initilaize the LwIP stack */ LwIP_Init(); /* Infinite loop */ while (1) { /* check if any packet received */ if (ETH_CheckFrameReceived()) { /* process received ethernet packet */ LwIP_Pkt_Handle(); } /* handle periodic timers for LwIP */ LwIP_Periodic_Handle(LocalTime); } }
void network_init() { LwIP_Init(); #if defined(USE_DHCP) caribou_thread_create("dhcp",LwIP_DHCP_task,NULL,NULL,stack_dhcp_thread,THREAD_STACK_SIZE,THREAD_PRIORITY); #endif }
void init_thread(void *param) { #if CONFIG_INIT_NET #if CONFIG_LWIP_LAYER /* Initilaize the LwIP stack */ LwIP_Init(); #endif #endif #if CONFIG_WLAN wifi_on(RTW_MODE_STA); #if CONFIG_AUTO_RECONNECT //setup reconnection flag wifi_set_autoreconnect(1); #endif printf("\n\r%s(%d), Available heap 0x%x\n\r", __FUNCTION__, __LINE__, xPortGetFreeHeapSize()); #endif #if CONFIG_INTERACTIVE_MODE /* Initial uart rx swmaphore*/ vSemaphoreCreateBinary(uart_rx_interrupt_sema); xSemaphoreTake(uart_rx_interrupt_sema, 1/portTICK_RATE_MS); start_interactive_mode(); #endif /* Kill init thread after all init tasks done */ vTaskDelete(NULL); }
int main(void) { struct b_pool* pbuf; struct head* h; init_pools_buffers(); //configure NVIC NVIC_Configuration(); //start time start_timer(); //configure adc ADC_config(); //configure pwm pwm_Config(); //ETHERNET INITIALIZATION ETH_BSP_Config(); /* Initilaize the LwIP stack */ LwIP_Init(); //enable clock /*__disable_irq(); clockHseInit(); __enable_irq();*/ /*Initilaize the PTP stack*/ PTPd_Init(); //udp initialization udp_echoserver_init(); //configure state //init_current_state(&cur); cur.status = STOP; cur.id_sig = 0; while (1) { //PROCESSING OF PEREODIC TASKS FOR LWIP LwIP_Periodic_Handle(gettime()); //PROCESSING OF PEREODIC TASKS FOR PTP ptpd_Periodic_Handle(gettime()); //PROCESSING OF QUEUING BUFFERS pbuf = pull_out_queue(); if(pbuf != NULL) { h = (struct head*)pbuf->pbuf; if(h->dst & SLAVE) { if(h->type == COMMAND) handl_command(pbuf); } else transPackage(pbuf, eth_write); free_buf(pbuf); } //PROCESSING OF DEBUG_INFO if(debug.time > 0) { if(debug.num == -1 || debug.num > 0) { debug_info(); } else debug.time = 0; if (debug.num > 0) debug.num --; } //PROCESSING OF TEMP BUFFER } }
int main(void) { SystemInit(); // initialize MCU clocks and registers TM_DELAY_Init(); // initialize Delay library TM_DELAY_SetTime(0); // Reset couter for systime Laser_GPIO_Conf(); // configure GPIO for laser control (to be able to enable/disable lasers via software TM_BKPSRAM_Init(); // initialize BKP RAM access library Laser_Update(); // load laser statuses saved in BKP RAM TM_USART_Init(OUTPUT_USART, OUTPUT_USART_PINS, OUTPUT_USART_SPEED); // initialize UART used for collected Data output TM_USART_Init(MENU_USART, MENU_USART_PINS, MENU_USART_SPEED); // initialize UART used for configuration TM_RTC_Init(TM_RTC_ClockSource_External); // initialize RTC library TM_GPIO_Init(GPIOD, GPIO_Pin_8, TM_GPIO_Mode_OUT, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_Low); // configure GPIO for GSM status indication (RED LED) TM_GPIO_Init(GPIOD, GPIO_Pin_9, TM_GPIO_Mode_OUT, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_Low); // configure GPIO for GSM status indication (GREEN LED) Laser_ADC_Init(); // initialize ADC peripherals Menu_Init(); // initialize CLI library sfpInit(); // configure GPIO for SFP modules gsm_Init(); // initialize GSM module /* configure and initialize Ethernet hardware and LwIP stack */ ETH_BSP_Config(); // configure ETH GPIOs printf("Ethernet MAC and PHY configured successfully!\n"); LwIP_Init(); // start LwIP stack printf("LwIP stack initialized successfully!\n"); UDP_Server_Init(); // start UDP Server printf("UDP Server initialized successfully!\n"); //start periodic tasks /* GSM Status update "task" */ GSM_Status_Update_Timer = TM_DELAY_TimerCreate(GSM_CHECK_INTERVAL, 1, 1, GSM_Status_Update_Timer_Task, NULL); printf("GSM status check task created!\n"); /* Print results from remote devices "task" */ Print_Results_Timer = TM_DELAY_TimerCreate(DATA_OUT_INTERVAL, 1, 1, Print_Results_Timer_Task, NULL); printf("Print collected data task created!\n"); /* LaserLock status update "task" */ LaserLock_Timer = TM_DELAY_TimerCreate(1000, 1, 1, LaserLock_Timer_Task, NULL); printf("Laser lock check task created!\n"); while (1) { /* CLI menu update */ Menu_Update(); /* check if any packet received */ if (ETH_CheckFrameReceived()) { /* process received ethernet packet */ LwIP_Pkt_Handle(); } /* handle periodic timers for LwIP */ LwIP_Periodic_Handle(LocalTime); /* update laser statuses */ Laser_Update(); /* remove SMS messages which were read by system */ delete_read_gsm_messages(); } }
/*-----------------------------------------------*/ extern "C" void MainTask(void* args) { /* configure Ethernet (GPIOs, clocks, MAC, DMA) */ ETH_BSP_Config(); /* Initialize the LwIP stack */ LwIP_Init(); xTaskCreate(ros_main, (const signed char*)"ROSMain", 128, NULL, 2, NULL); xTaskCreate(led_task, (const signed char*)"LedTask", 128, NULL, 2, NULL); vTaskDelete(NULL); }
/** * Initializes the Tekdaqc's Ethernet communications and lwIP stack. This is necessary for both * the main application functionality as well as the IAP update function. * * @param none * @retval none */ void Communication_Init(void) { for (uint_fast8_t i = 0; i < SIZE_TOSTRING_BUFFER; ++i) { TOSTRING_BUFFER[i] = '\0'; } /* Initialize the generic delay timer */ Timer_Config(); /* Configure ethernet (GPIOs, clocks, MAC, DMA) */ ETH_BSP_Config(); /* Initilaize the LwIP stack */ LwIP_Init(); }
int main(void) { SystemInit(); SSD1963_Init(); SSD1963_Clear(Red); Delay(100); SSD1963_Clear(Blue); Delay(100); SSD1963_Clear(Red); SSD1963_Fill(0, 0, 50, 50, Blue); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_CRC, ENABLE); GUI_Init(); GUI_SetColor(GUI_RED); GUI_Clear(); BSP_KeyInit( BSP_KEY1, BSP_KEY1_GPIO_PORT ); BSP_USART_Init( ); BSP_SPI_Init( ); BSP_SPI_CS_Init( ); //Debug_ShowRegister( GPIOA_BASE, (DebugPeripheralTypedef *)&DeBugGPIO ); //Debug_ShowRegister( BSP_USARTx_BASE, (DebugPeripheralTypedef *)&DeBugUART ); //Debug_ShowRegister( RCC_BASE, (DebugPeripheralTypedef *)&DeBugRCC ); //Debug_ShowSpecificRegister( RCC_BASE, (DebugPeripheralTypedef *)&DeBugRCC, "APB2ENR" ); /* 初始化LWIP协议栈*/ LwIP_Init(); /*初始化web server 显示网页程序*/ httpd_init(); /* 初始化telnet 远程控制 程序 */ CMD_init(); /* Infinite loop */ while ( 1 ) { /*轮询*/ LwIP_Periodic_Handle(LocalTime); } }
/** * @brief Main program. * @param None * @retval None */ int main(void) { SystemInit(); init_systick(); #ifdef SERIAL_DEBUG DebugComPort_Init(); #endif printf(" Artnet2WS2811 Receiver\r\n "); /*Initialize LCD and Leds */ LED_Init(); /* configure ethernet (GPIOs, clocks, MAC, DMA) */ ETH_BSP_Config(); /* Initilaize the LwIP stack */ LwIP_Init(); /* tcp echo server Init */ //tcp_echoserver_init(); telnetserver_init(); //artnet_init(); ws2812_init(); /* Initialize variables for ws2812 */ delay_ms(20); /* Infinite loop */ while (1) { /* check if any packet received */ if (ETH_CheckFrameReceived()) { /* process received ethernet packet */ LwIP_Pkt_Handle(); } /* handle periodic timers for LwIP */ LwIP_Periodic_Handle(system_time); DRAW_LED(); } }
/** * @brief Main program. * @param None * @retval None */ int main(void) { /*!< At this stage the microcontroller clock setting is already configured to 168 MHz, this is done through SystemInit() function which is called from startup file (startup_stm32f4xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f4xx.c file */ //add a long delay wait for DP83848 finish reset unsigned int i,j; for(i=0;i<50;i++) { for(j=0;j < 65500;j++); } #ifdef SERIAL_DEBUG DebugComPort_Init(); #endif /*Initialize LCD and Leds */ LCD_LED_Init(); /* configure ethernet (GPIOs, clocks, MAC, DMA) */ ETH_BSP_Config(); /* Initilaize the LwIP stack */ LwIP_Init(); /* Initialize tcp echo server */ tcpecho_init(); /* Initialize udp echo server */ udpecho_init(); #ifdef USE_DHCP /* Start DHCPClient */ xTaskCreate(LwIP_DHCP_task, "DHCPClient", configMINIMAL_STACK_SIZE * 2, NULL,DHCP_TASK_PRIO, NULL); #endif /* Start toogleLed4 task : Toggle LED4 every 250ms */ xTaskCreate(ToggleLed4, "LED4", configMINIMAL_STACK_SIZE, NULL, LED_TASK_PRIO, NULL); /* Start scheduler */ vTaskStartScheduler(); /* We should never get here as control is now taken by the scheduler */ for( ;; ); }
void UDP_Config(void) { if(ETH_BSP_Config() == ETH_ERROR) CriticalError(ERR_ETH_CONFIG); LwIP_Init(); delay(500); IP4_ADDR(&ip_addr_tx,192,9,206,251); if((pudp_pcb = udp_new()) == NULL) CriticalError(ERR_UDP_NEW); if((udp_bind(pudp_pcb,IP_ADDR_ANY,RX_PORT) != ERR_OK)) CriticalError(ERR_UDP_BIND); udp_recv(pudp_pcb,&udp_rx_handler,NULL); if(!(pOut = pbuf_alloc(PBUF_TRANSPORT,sizeof(tx_udp_msg),PBUF_RAM))) CriticalError(ERR_POUT_NEW); }
int TCP_CLIENT_Config(void) { if(ETH_BSP_Config() == ETH_ERROR) CriticalError(ERR_ETH_CONFIG); LwIP_Init(); delay(500); if((ptcp_pcb = tcp_new()) == NULL) CriticalError(ERR_UDP_NEW); IP4_ADDR(&ip_addr_tx,192,9,206,251); if(tcp_connect(ptcp_pcb,&ip_addr_tx,TX_PORT,tcp_echoclient_connected) == ERR_OK) { pbuf_free(ptcp_pcb->refused_data); return 0; } else return 1; }
/** * @brief Main program. * @param None * @retval None */ int main(void) { /*!< At this stage the microcontroller clock setting is already configured to 120 MHz, this is done through SystemInit() function which is called from startup file (startup_stm32f2xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f2xx.c file */ //add a long delay wait for DP83848 finish reset unsigned int i,j; for(i=0;i<36;i++) { for(j=0;j < 65500;j++); } #ifdef SERIAL_DEBUG DebugComPort_Init(); #endif /* Initialize LCD and Leds */ LCD_LED_Init(); /* Configure ethernet (GPIOs, clocks, MAC, DMA) */ ETH_BSP_Config(); /* Initilaize the LwIP stack */ LwIP_Init(); /* TFTP server Init */ tftpd_init(); /* Infinite loop */ while (1) { /* check if any packet received */ if (ETH_CheckFrameReceived()) { /* process received ethernet packet */ LwIP_Pkt_Handle(); } /* handle periodic timers for LwIP */ LwIP_Periodic_Handle(LocalTime); } }
/* The time between cycles of the 'check' task. */ int main( void ) { DISPLAY_RESOURCE_t display_source; bsp_init(); /* ³õʼ»¯LwIP */ vlwIPInit(); LwIP_Init(); display_source.xQueue = xQueueCreate(1, sizeof(char *)); /* Start the tasks defined within this file/specific to this demo. */ sys_thread_new("web_server", LwIPEntry, ( void * )NULL, 500, 5); xTaskCreate((pdTASK_CODE)app_dispaly_show_task, "app_display", mainLED_TASK_STACK_SIZE, &display_source, 6, NULL); xTaskCreate((pdTASK_CODE)app_led_task_blink, "app_led", mainLED_TASK_STACK_SIZE, &display_source, 3, NULL); /* Start the scheduler. */ vTaskStartScheduler(); return 0; }
/** * @brief LwIP_DHCP_Process_Handle * @param None * @retval None */ void LwIP_DHCP_task(void * pvParameters) { struct ip_addr ipaddr; struct ip_addr netmask; struct ip_addr gw; uint32_t IPaddress; uint8_t iptab[4]; uint8_t iptxt[20]; uint8_t DHCP_state; DHCP_state = DHCP_START; bool terminate=false; netif_set_status_callback(&xnetif, netif_status_callback); LwIP_Init(); while (!terminate) { switch (DHCP_state) { case DHCP_START: { dhcp_start(&xnetif); IPaddress = 0; DHCP_state = DHCP_WAIT_ADDRESS; syslog(SYSTEM_LVL,true,"DHCP_START"); } break; case DHCP_WAIT_ADDRESS: { IPaddress = xnetif.ip_addr.addr; /* Read the new IP address */ if (IPaddress!=0) { DHCP_state = DHCP_ADDRESS_ASSIGNED; /* Stop DHCP */ dhcp_stop(&xnetif); iptab[0] = (uint8_t)(IPaddress >> 24); iptab[1] = (uint8_t)(IPaddress >> 16); iptab[2] = (uint8_t)(IPaddress >> 8); iptab[3] = (uint8_t)(IPaddress); sprintf((char*)iptxt, " %d.%d.%d.%d", iptab[3], iptab[2], iptab[1], iptab[0]); syslog(SYSTEM_LVL,true,"DHCP_WAIT_ADDRESS reply %s",iptxt); } else { /* DHCP timeout */ if (xnetif.dhcp->tries > MAX_DHCP_TRIES) { DHCP_state = DHCP_TIMEOUT; /* Stop DHCP */ dhcp_stop(&xnetif); /* Static address used */ IP4_ADDR(&ipaddr, IP_ADDR0 ,IP_ADDR1 , IP_ADDR2 , IP_ADDR3 ); IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3); IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3); netif_set_addr(&xnetif, &ipaddr , &netmask, &gw); syslog(SYSTEM_LVL,true,"DHCP_TIMEOUT"); iptab[0] = IP_ADDR3; iptab[1] = IP_ADDR2; iptab[2] = IP_ADDR1; iptab[3] = IP_ADDR0; sprintf((char*)iptxt, " %d.%d.%d.%d", iptab[3], iptab[2], iptab[1], iptab[0]); syslog(SYSTEM_LVL,true,"DHCP_TIMEOUT activating static ip %s",iptxt); netif_status_callback(&xnetif); } } } break; case DHCP_ADDRESS_ASSIGNED: syslog(SYSTEM_LVL,true,"DHCP_ADDRESS_ASSIGNED"); netif_status_callback(&xnetif); terminate=true; break; default: break; }
/*------------------------------------------------------------------------------------------------*/ void Ethernet_Init(Bool_e UseConfIni) { Ethernet_t TmpThis; Status_e ReadStatus; _CONSOLE(LogId, "---------- CONF_ETHERNET INIT ----------\n"); //------------------------------------------------------ // Lecture des donnees flash //------------------------------------------------------ DatabaseEeprom_InitData(DatabaseEeprom_Ethernet, NULL, sizeof(Ethernet_t)); ReadStatus = DatabaseEeprom_Read(DatabaseEeprom_Ethernet, &TmpThis); DatabaseEeprom_Display(DatabaseEeprom_Ethernet, &TmpThis); if (ReadStatus == Status_KO) { _CONSOLE(LogId, "Invalid Eeprom Read: Default restored\n"); DatabaseEeprom_Write(DatabaseEeprom_Ethernet, &This); memcpy(&TmpThis, &This, sizeof(Ethernet_t)); This.Cfg_Restored = TRUE; } else { _CONSOLE(LogId, "Valid Eeprom Read \n"); memcpy(&This, &TmpThis, sizeof(Ethernet_t)); This.Cfg_Restored = FALSE; } //------------------------------------------------------ // Comparaison avec fichier ini //------------------------------------------------------ if ((ConfIni_Get()->IsValide == TRUE) && (UseConfIni == TRUE)) { _CONSOLE(LogId, "Check SD cfg\n"); memcpy(This.Cfg_IP_Adresse, ConfIni_Get()->ETH_IP_Adresse, 4); memcpy(This.Cfg_IP_Masque, ConfIni_Get()->ETH_IP_Masque, 4); memcpy(This.Cfg_IP_Passerelle, ConfIni_Get()->ETH_IP_Passerelle, 4); memcpy(This.Cfg_MAC_Adresse, ConfIni_Get()->ETH_MAC_Adresse, 6); This.Cfg_DHCP_Actif = ConfIni_Get()->ETH_DHCP_Actif; if (memcmp(&TmpThis, &This, sizeof(Ethernet_t)) != 0) { _CONSOLE(LogId, "Cfg SD copied\n"); DatabaseEeprom_Write(DatabaseEeprom_Ethernet, &This); } else { _CONSOLE(LogId, "Cfg unchanged\n"); } } //------------------------------------------------------ // Affichage de la configuration //------------------------------------------------------ _CONSOLE(LogId, "IP_Adresse = %d.%d.%d.%d\n", This.Cfg_IP_Adresse[0], This.Cfg_IP_Adresse[1], This.Cfg_IP_Adresse[2], This.Cfg_IP_Adresse[3]); _CONSOLE(LogId, "IP_Masque = %d.%d.%d.%d\n", This.Cfg_IP_Masque[0], This.Cfg_IP_Masque[1], This.Cfg_IP_Masque[2], This.Cfg_IP_Masque[3]); _CONSOLE(LogId, "IP_Passerelle = %d.%d.%d.%d\n", This.Cfg_IP_Passerelle[0], This.Cfg_IP_Passerelle[1], This.Cfg_IP_Passerelle[2], This.Cfg_IP_Passerelle[3]); _CONSOLE(LogId, "MAC_Adresse = %d:%d:%d:%d:%d:%d\n", This.Cfg_MAC_Adresse[0], This.Cfg_MAC_Adresse[1], This.Cfg_MAC_Adresse[2], This.Cfg_MAC_Adresse[3], This.Cfg_MAC_Adresse[4], This.Cfg_MAC_Adresse[5]); _CONSOLE(LogId, "DHCP_Actif = %d\n", This.Cfg_DHCP_Actif ); //------------------------------------------------------ // Application de la configuration //------------------------------------------------------ ETH_BSP_Config(); // Configure ethernet (GPIOs, clocks, MAC, DMA) LwIP_Init(This.Cfg_IP_Adresse, This.Cfg_IP_Masque, This.Cfg_IP_Passerelle, This.Cfg_DHCP_Actif, This.Cfg_MAC_Adresse); // Initilaize the LwIP stack tftpd_init(); // TFTP server Init //httpd_init(); // Http webserver Init Telnet_Init(); }
/** * @brief Main program. * @param None * @retval None */ int main(void) { FlagStatus status; uint16_t bak_dr10; //uint16_t bak_dr9; //RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); //PWR_BackupAccessCmd(ENABLE); //bak_dr10 = BKP_ReadBackupRegister(BKP_DR10); //bak_dr9 = BKP_ReadBackupRegister(BKP_DR9); //BKP_WriteBackupRegister(BKP_DR10, 0x0707); //BKP_WriteBackupRegister(BKP_DR9, 0x0001); /* Test if Key push-button on STM3210C-EVAL Board is not pressed */ //if((bak_dr10 == 0x0707) /*&& (bak_dr9 != 0x0000)*/) if(1) { /* Setup STM32 system (clocks, Ethernet, GPIO, NVIC) and STM3210C-EVAL resources */ System_Setup(); Delay(1000); //可添加延时, 用以确保DM9000启动时电压满足芯片要求 //"nRST must not go high until after the VDDIO and VDD_CORE supplies are stable" 手册P51 GPIO_WriteBit(ETH_RESET, Bit_SET); //拉高DM9000 nRST, 复位启动 /* Configure the Ethernet peripheral */ Ethernet_Configuration(); /* //判断设备是否是初次上电, 如果'是', 重启一次, 确保以太网初始化正常 status = RCC_GetFlagStatus(RCC_FLAG_SFTRST); RCC_ClearFlag(); if(!status) { Delay(10); NVIC_SystemReset(); } */ /* Initilaize the LwIP stack */ LwIP_Init(); #ifdef USE_IAP_HTTP /* Initilaize the webserver module */ IAP_httpd_init(); #endif #ifdef USE_IAP_TFTP /* Initialize the TFTP server */ IAP_tftpd_init(); #endif /* Infinite loop */ while (1) { /* check if any packet received */ if (ETH_GetRxPktSize()!=0) { /* process received eth packet */ LwIP_Pkt_Handle(); } /* Periodic tasks */ System_Periodic_Handle(); } } /* enter in IAP mode */ else { /* Key push-button not pressed: jump to user application */ /* Check if valid stack address (RAM address) then jump to user application */ if (((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFE0000 ) == 0x20000000) { /* Jump to user application */ JumpAddress = *(__IO uint32_t*) (USER_FLASH_FIRST_PAGE_ADDRESS + 4); Jump_To_Application = (pFunction) JumpAddress; /* Initialize user application's Stack Pointer */ __set_MSP(*(__IO uint32_t*) USER_FLASH_FIRST_PAGE_ADDRESS); Jump_To_Application(); } else {/* Otherwise, do nothing */ /* LED3 (RED) ON to indicate bad software (when not valid stack address) */ //STM_EVAL_LEDInit(LED3); //STM_EVAL_LEDOn(LED3); /* do nothing */ while(1); } } return 0; }
int main(void) { NVIC_SetPriorityGrouping(3); /* enable GPIO */ RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN; RCC->AHB1ENR |= RCC_AHB1ENR_GPIOBEN; RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN; RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN; RCC->AHB1ENR |= RCC_AHB1ENR_GPIOEEN; act::mode(GPIO_OUTPUT); stat::mode(GPIO_OUTPUT); error::mode(GPIO_OUTPUT); error::high(); estop::mode(GPIO_INPUT); /* setup ethernet */ phy_rst::mode(GPIO_OUTPUT_2MHz); phy_rst::high(); // release reset line eth_mii_crs::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_rx_clk::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mdio::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_col::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_rx_dv::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_rxd2::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_rxd3::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_rx_er::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_tx_en::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_txd0::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_txd1::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mdc::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_txd2::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_tx_clk::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_rxd0::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_rxd1::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_txd3::mode(GPIO_ALTERNATE | GPIO_AF_ETH); /* Initialize Table */ register_table.model_number = 302; register_table.version = 0; register_table.id = 253; register_table.baud_rate = 34; // 57600???? register_table.last_packet = 0; register_table.system_time = 0; register_table.led = 0; dynamixel_init(); /* setup analog */ RCC->APB2ENR |= RCC_APB2ENR_ADC1EN | RCC_APB2ENR_ADC2EN | RCC_APB2ENR_ADC3EN; adc1.init(VOLTAGE_SENSE_ANALOG_CHANNEL, CURRENT_SENSE_ANALOG_CHANNEL); voltage_sense::mode(GPIO_INPUT_ANALOG); current_sense::mode(GPIO_INPUT_ANALOG); /* setup systick */ SysTick_Config(SystemCoreClock/1000); NVIC_SetPriority(SysTick_IRQn,2); NVIC_EnableIRQ(SysTick_IRQn); Ethernet_Init(); LwIP_Init(); if (!netapp_init()) while(1); __enable_irq(); /* done with setup, turn off err led */ error::low(); while(1) { /* check if any packet received */ if (ETH_CheckFrameReceived()) { /* process received ethernet packet */ LwIP_Pkt_Handle(); } LwIP_Periodic_Handle(register_table.system_time); } }
/** * @brief Draw the Ethernet page backgound * @param None * @retval None */ static void InitEthernet(void) { uint8_t temp[45]; uint8_t buf[30]; if( EthernetSettings.InitDone == 0) { MOD_GetParam(3 , &EthCfg.d32); EthernetSettings.InitDone = 1; if(EthernetSettings.WebserverEnabled == 1) { EthernetCurrentPage = EthernetWebServerPage; } else if(EthernetSettings.DistantControlEnabled == 1) { EthernetCurrentPage = EthernetDistantControlPage; } if(TCPIP_Task_Handle != NULL) { if(xTaskIsTaskSuspended(TCPIP_Task_Handle) == pdTRUE) { vTaskResume(TCPIP_Task_Handle); } } if (EthernetSettings.BackgroundEnabled == 0) { memset (temp, ' ', 45); if(EthStatus == 0) { ETH_BSP_Config(); if(EthStatus == 1) /* Network cable is connected */ { EthLinkStatus = 0; RefreshLabel(EthernetCurrentPage, 3, temp); RefreshLabel(EthernetCurrentPage, 3, (uint8_t *)"Ethernet initialization..OK"); LastInitMessageIndex = 1; } else /* Network cable is unplugged */ { RefreshLabel(EthernetCurrentPage, 3, temp); RefreshLabel(EthernetCurrentPage, 4, temp); RefreshLabel(EthernetCurrentPage, 5, temp); RefreshLabel(EthernetCurrentPage, 3, (uint8_t *)"Ethernet initialization failed, Please"); RefreshLabel(EthernetCurrentPage, 4, (uint8_t *)"verify if the Ethernet cable is connected"); RefreshLabel(EthernetCurrentPage, 5, (uint8_t *)"and try again."); LastInitMessageIndex = 2; return; } } if(EthLinkStatus == 0) /* Network Cable is connected */ { ETHERNET_UpdateIcon(ethernet_conn_icon); sprintf((char*)buf, "Ethernet Speed: %d.0Mbps", (int)EthSpeed); RefreshLabel(EthernetCurrentPage, 3, temp); RefreshLabel(EthernetCurrentPage, 3, buf); LastInitMessageIndex = 3; } else { ETHERNET_UpdateIcon(ethernet_disconn_icon); RefreshLabel(EthernetCurrentPage, 4, temp); RefreshLabel(EthernetCurrentPage, 5, temp); RefreshLabel(EthernetCurrentPage, 4, (uint8_t *)"Please verify if the Ethernet cable "); RefreshLabel(EthernetCurrentPage, 5, (uint8_t *)"is connected and try again. "); LastInitMessageIndex = 4; return; } LwIP_Init(); http_init(); if(EthCfg.b.DHCPEnable == 1) { if(DHCP_Task_Handle == NULL) { xTaskCreate(LwIP_DHCP_task, (signed char const*)"DHCP_P", DHCP_THREAD_STACK_SIZE, NULL, DHCP_THREAD_PRIO, &DHCP_Task_Handle); } } else { vTaskPrioritySet(Task_Handle, (configMAX_PRIORITIES - 7));//5//7 } if(EthernetSettings.WebserverEnabled == 1) { if(EthCfg.b.SelectedImageFormat == 1) { IPCAM_ImageBuffer.ImageFormat = BMP_QQVGA; } else if(EthCfg.b.SelectedImageFormat == 2) { IPCAM_ImageBuffer.ImageFormat = BMP_QVGA; } else { IPCAM_ImageBuffer.ImageFormat = BMP_QQVGA; } IPCAM_ImageCaptureInit(); } } else { LastInitMessageIndex = 5; RefreshLabel(EthernetCurrentPage, 4, temp); RefreshLabel(EthernetCurrentPage, 4, DHCPStatus[DHCPStatusIndex]); RefreshLabel(EthernetCurrentPage, 5, temp); RefreshLabel(EthernetCurrentPage, 5, IPAddressAssigned); if (EthernetSettings.DistantControlEnabled == 1) { vTaskDelay(1000); EthernetSettings.BackgroundEnabled = 1; ETHERNET_SwitchPage(EthernetDistantControlPage, PAGE_MENU); EthernetDistantControlPage = NULL; } } } else { switch(LastInitMessageIndex) { case 1: RefreshLabel(EthernetCurrentPage, 3, (uint8_t *)" "); RefreshLabel(EthernetCurrentPage, 3, (uint8_t *)"Ethernet initialization..OK"); break; case 2: RefreshLabel(EthernetCurrentPage, 3, (uint8_t *)" "); RefreshLabel(EthernetCurrentPage, 4, (uint8_t *)" "); RefreshLabel(EthernetCurrentPage, 5, (uint8_t *)" "); RefreshLabel(EthernetCurrentPage, 3, (uint8_t *)"Ethernet initialization failed, Please"); RefreshLabel(EthernetCurrentPage, 4, (uint8_t *)"verify if the Ethernet cable is connected"); RefreshLabel(EthernetCurrentPage, 5, (uint8_t *)"and try again."); break; case 3: ETHERNET_UpdateIcon(ethernet_conn_icon); sprintf((char*)buf, "Ethernet Speed: %d.0Mbps", (int)EthSpeed); RefreshLabel(EthernetCurrentPage, 3, (uint8_t *)" "); RefreshLabel(EthernetCurrentPage, 3, buf); break; case 4: ETHERNET_UpdateIcon(ethernet_disconn_icon); RefreshLabel(EthernetCurrentPage, 4, (uint8_t *)" "); RefreshLabel(EthernetCurrentPage, 5, (uint8_t *)" "); RefreshLabel(EthernetCurrentPage, 4, (uint8_t *)"Please verify if the Ethernet cable "); RefreshLabel(EthernetCurrentPage, 5, (uint8_t *)"is connected and try again. "); break; case 5: RefreshLabel(EthernetCurrentPage, 4, (uint8_t *)" "); RefreshLabel(EthernetCurrentPage, 4, DHCPStatus[DHCPStatusIndex]); RefreshLabel(EthernetCurrentPage, 5, (uint8_t *)" "); RefreshLabel(EthernetCurrentPage, 5, IPAddressAssigned); if(IPaddress !=0) { sprintf((char*)temp, "%s",IPAddressAssigned); ETHERNET_UpdateDHCPState(4,temp); ETHERNET_UpdateIcon(ethernet_conn_icon); } break; case 6: RefreshLabel(EthernetCurrentPage ,6 , (uint8_t *)"Network Cable is unplugged !!!"); break; case 7: RefreshLabel(EthernetCurrentPage, 6, (uint8_t *)"Network Cable is now connected"); break; } } }
int main(void) { int i; unsigned char add[5]={110,110,8,110,110}; /*!< At this stage the microcontroller clock setting is already configured to 120 MHz, this is done through SystemInit() function which is called from startup file (startup_stm32f2xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f2xx.c file */ #ifdef SERIAL_DEBUG DebugComPort_Init(); #endif initLED(); init_Timer(); //while(1); /*Initialize LCD and Leds */ //LCD_LED_Init(); delay_ms(500); for(i=0;i<100;i++) { setNumber(i); delay_ms(10); } beep(40); offSegment(3); delay_ms(100); setNumber(0); delay_ms(100); beep(40); offSegment(3); delay_ms(100); setNumber(0); delay_ms(100); beep(40); //USART2_Init(); //USART3_Init(); init_NRF1_IO(); init_NRF2_IO(); SPI1_Config(); SPI3_Config(); SPI_Cmd(SPI1, ENABLE); SPI_Cmd(SPI3, ENABLE); nrf24l01_initialize_debug(false, TX_PAYLOAD_SIZE, false); nrf24l01_clear_flush(); add[2]=8; nrf24l01_set_tx_addr(add , 5); add[2]=30; nrf24l01_set_rx_addr(add,5,0); nrf24l01_set_rf_ch(tx_channel); nrf24l02_initialize_debug(false, RX_PAYLOAD_SIZE, false); nrf24l02_clear_flush(); add[2]=8; nrf24l02_set_tx_addr(add , 5); add[2]=30; nrf24l02_set_rx_addr(add,5,0); nrf24l02_set_rf_ch(rx_channel); nrf24l02_set_as_rx(true); /* configure ethernet */ ETH_BSP_Config(); /* Initilaize the LwIP stack */ LwIP_Init(); /* UDP echoserver */ udp_echoserver_init(); /* Infinite loop */ while (1) { /* check if any packet received */ if (ETH_CheckFrameReceived()) { /* process received ethernet packet */ LwIP_Pkt_Handle(); } /* handle periodic timers for LwIP */ LwIP_Periodic_Handle(LocalTime); process_incoming_rf(); if(firstPacketRecieved==0) { demo(); setNumber(22); } } }
int main(void) { sys_time = 0; NVIC_SetPriorityGrouping(3); // enable GPIO RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN; RCC->AHB1ENR |= RCC_AHB1ENR_GPIOBEN; RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN; RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN; RCC->AHB1ENR |= RCC_AHB1ENR_GPIOEEN; act::mode(GPIO_OUTPUT); stat::mode(GPIO_OUTPUT); error::mode(GPIO_OUTPUT); estop::mode(GPIO_INPUT); // setup ethernet phy_rst::mode(GPIO_OUTPUT_2MHz); phy_rst::high(); // release reset line eth_mii_crs::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_rx_clk::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mdio::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_col::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_rx_dv::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_rxd2::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_rxd3::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_rx_er::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_tx_en::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_txd0::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_txd1::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mdc::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_txd2::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_tx_clk::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_rxd0::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_rxd1::mode(GPIO_ALTERNATE | GPIO_AF_ETH); eth_mii_txd3::mode(GPIO_ALTERNATE | GPIO_AF_ETH); /* setup usarts RCC->APB2ENR |= RCC_APB2ENR_USART1EN; // APB2 also has USART6 RCC->APB1ENR |= RCC_APB1ENR_USART2EN; // ABP1 also has USART3, UART4/5 */ RCC->APB1ENR |= RCC_APB1ENR_USART3EN; usart3_tx::mode(GPIO_ALTERNATE | GPIO_AF_USART3); usart3_rx::mode(GPIO_ALTERNATE | GPIO_AF_USART3); usart3_en::mode(GPIO_OUTPUT); //NVIC_EnableIRQ(USART3_IRQn); // setup systick SysTick_Config(SystemCoreClock/1000); NVIC_EnableIRQ(SysTick_IRQn); //NVIC_SetPriority(SysTick_IRQn,2); Ethernet_Init(); LwIP_Init(); if (!netapp_init()) while(1) { error::high(); delay_ms(50); error::low(); delay_ms(1000); } __enable_irq(); while(1) { /* check if any packet received */ if (ETH_CheckFrameReceived()) { /* process received ethernet packet */ LwIP_Pkt_Handle(); } LwIP_Periodic_Handle(sys_time); /* process devices */ } }
void ETH_Config(void) { //info_ini.at24_error = AT24_Read(0,(uint8_t*)ð_ini_dat,sizeof(ethernet_initial_struct)); if(crc32(ð_ini_dat,sizeof(eth_ini_dat)-4,sizeof(eth_ini_dat)-4) != eth_ini_dat.crc) { eth_ini_dat.IP_ADR[0] = IP_ADDR0; eth_ini_dat.IP_ADR[1] = IP_ADDR1; eth_ini_dat.IP_ADR[2] = IP_ADDR2; eth_ini_dat.IP_ADR[3] = IP_ADDR3; eth_ini_dat.GW_ADR[0] = GW_ADDR0; eth_ini_dat.GW_ADR[1] = GW_ADDR1; eth_ini_dat.GW_ADR[2] = GW_ADDR2; eth_ini_dat.GW_ADR[3] = GW_ADDR3; eth_ini_dat.MASK[0] = NETMASK_ADDR0; eth_ini_dat.MASK[1] = NETMASK_ADDR1; eth_ini_dat.MASK[2] = NETMASK_ADDR2; eth_ini_dat.MASK[3] = NETMASK_ADDR3; eth_ini_dat.MAC_ADR[0] = MAC_ADDR0; eth_ini_dat.MAC_ADR[1] = MAC_ADDR1; eth_ini_dat.MAC_ADR[2] = MAC_ADDR2; eth_ini_dat.MAC_ADR[3] = MAC_ADDR3; eth_ini_dat.MAC_ADR[4] = MAC_ADDR4; eth_ini_dat.MAC_ADR[5] = MAC_ADDR5; for(int i = 0; i < MAX_UDP_SOCK; i++) { switch(i) { case 0: eth_ini_dat.UDP_RX_PORT[i] = PORT_RX0_UDP; eth_ini_dat.UDP_TX_PORT[i] = PORT_TX0_UDP; IP4_ADDR(ð_ini_dat.addr[i],ADR0_TX0_UDP, ADR1_TX0_UDP, ADR2_TX0_UDP, ADR3_TX0_UDP); break; case 1: eth_ini_dat.UDP_RX_PORT[i] = PORT_RX1_UDP; eth_ini_dat.UDP_TX_PORT[i] = PORT_TX1_UDP; IP4_ADDR(ð_ini_dat.addr[i],ADR0_TX1_UDP, ADR1_TX1_UDP, ADR2_TX1_UDP, ADR3_TX1_UDP); break; case 2: eth_ini_dat.UDP_RX_PORT[i] = PORT_RX2_UDP; eth_ini_dat.UDP_TX_PORT[i] = PORT_TX2_UDP; IP4_ADDR(ð_ini_dat.addr[i],ADR0_TX2_UDP, ADR1_TX2_UDP, ADR2_TX2_UDP, ADR3_TX2_UDP); break; } } } if(ETH_BSP_Config() == ETH_ERROR) { t_info.eth_bsp_error = 1; } else { LwIP_Init(); UDP_Config(); } }
/** @req SOAD193 */ void TcpIp_Init(void) { LwIP_Init(); pi_printf("infor: lwip initialized\r\n"); }
int main(void) { /*!< At this stage the microcontroller clock setting is already configured to 168 MHz, this is done through SystemInit() function which is called from startup file (startup_stm32f4xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f4xx.c file */ char pase = 0; char pase1 = 0; uint16_t duty = 0; char led = 0; int i; uint8_t valor_web=0; RCC_GetClocksFreq(&RCC_Clocks); #ifdef SERIAL_DEBUG DebugComPort_Init(); printf("STM32DISCOVERY is booting...\r\n"); #endif /* configure ethernet (GPIOs, clocks, MAC, DMA) */ ETH_BSP_Config(); /* Initilaize the LwIP stack */ LwIP_Init(); /* Http webserver Init */ httpd_init(); /*Se inicializa la placa de expansion*/ STM_EVAL_EXP_INIT(); /* Infinite loop */ while (1) { /* check if any packet received */ if (ETH_CheckFrameReceived()) { /* process received ethernet packet */ LwIP_Pkt_Handle(); } /* handle periodic timers for LwIP */ LwIP_Periodic_Handle(LocalTime); if (LocalTime % 20 == 0) { if (!pase1) { pase1 = 1; if (LocalTime % 100 == 0) { // escalera Led STM_EVAL_EXP_LED_TOGGLE(led); led++; if (led > 7) led = 0; } } } else { pase1 = 0; } } return 0; }
int main(void) { char s[] = "1442936700,0,1,4,#2346W,3,#0800O#1900C#0900O#1800C"; // for str_processing test RCC_ClocksTypeDef RCC_Clocks; /* SysTick end of count event each 10ms */ RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(RCC_Clocks.HCLK_Frequency / 100); RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_RNG, ENABLE); RNG_Cmd(ENABLE); /* Initialize the timer for dht11 */ tim_init(TIM2); /* Initialize the SRAM ****************************************************/ PSRAM_Init(); /* Initialize the LCD *****************************************************/ LCD_Init(); LCD_LOG_Init(); LCD_LOG_SetHeader((uint8_t*)" Ethernet test"); LCD_LOG_SetFooter ((uint8_t*)" localtime: "); /* Add your application code here */ /* Configure ethernet (GPIOs, clocks, MAC, DMA) */ ETH_BSP_Config(); /* Initilaize the LwIP stack */ LwIP_Init(); schedule_init(&schedule_got,schedule_string); // schedule string store in schedule_string DNS_Init(); //while(!schedule_got); // wait until string got LCD_DisplayStringLine(Line2, (uint8_t*)schedule_string); LCD_DisplayStringLine(Line3, (uint8_t*)"0"); /* Main Loop */ //process ste str form internet Str_Split(s, Init_time); // s is temp string RTC_Config(); Time_Date_Setting(Init_time->year, Init_time->mon, Init_time->day, Init_time->hour +3, Init_time->min, Init_time->sec); while (1) { uint8_t year, mon, day; uint8_t hour, min, sec; RTC_TimeTypeDef RTC_TimeStruct_main; RTC_DateTypeDef RTC_DateStruct_main; RTC_GetDate(RTC_Format_BIN, &RTC_DateStruct_main); RTC_GetTime(RTC_Format_BIN, &RTC_TimeStruct_main); year = RTC_DateStruct_main.RTC_Year; mon = RTC_DateStruct_main.RTC_Month; day = RTC_DateStruct_main.RTC_Date; hour = RTC_TimeStruct_main.RTC_Hours; min = RTC_TimeStruct_main.RTC_Minutes; sec = RTC_TimeStruct_main.RTC_Seconds; //detect whether it is time to turn on Motor and LED, then execute it. Soak(day, hour, min ); Water(day, hour, min, sec); Light(mon, day, hour, min); //detect over /* check if any packet received */ if (ETH_CheckFrameReceived()) { /* process received ethernet packet */ LwIP_Pkt_Handle(); } /* handle periodic timers for LwIP */ LwIP_Periodic_Handle(LocalTime); } }