/*------------------------------------------------------------ * Function Name : UDP_Update * Description : UDPÉý¼¶ * Input : None * Output : None * Return : None *------------------------------------------------------------*/ ErrorStatus UDP_Update( void ) { char version[50]; lcd_clear(COLOR_BACK); lcd_font24(udp_lcd_x,udp_lcd_y,COLOR_POINT,COLOR_BACK,"========================================",UPDATE_FONT); udp_lcd_y += UPDATE_WORD_SIZE + UPDATE_ROW_DISTANCE; lcd_font24(udp_lcd_x,udp_lcd_y,COLOR_POINT,COLOR_BACK," > »¶ÓʹÓÃÒÔÌ«ÍøÉý¼¶ÏµÍ³ <",UPDATE_FONT); udp_lcd_y += UPDATE_WORD_SIZE + UPDATE_ROW_DISTANCE; strcpy(version," > "); strcat(version,SOFT_VERSION); lcd_font24(udp_lcd_x,udp_lcd_y,COLOR_POINT,COLOR_BACK,version,UPDATE_FONT); udp_lcd_y += UPDATE_WORD_SIZE + UPDATE_ROW_DISTANCE; lcd_font24(udp_lcd_x,udp_lcd_y,COLOR_POINT,COLOR_BACK,"========================================",UPDATE_FONT); udp_lcd_y += UPDATE_WORD_SIZE + UPDATE_ROW_DISTANCE; lcd_font24(udp_lcd_x,udp_lcd_y,COLOR_POINT,COLOR_BACK,"> ÕýÔÚ³¢ÊÔÁ¬½ÓµçÄÔ...",UPDATE_FONT); udp_lcd_y += UPDATE_WORD_SIZE + UPDATE_ROW_DISTANCE; #ifdef USE_IAP_HTTP /* Initialize the webserver module */ IAP_httpd_init(); #endif #ifdef USE_IAP_TFTP /* Initialize the TFTP server */ IAP_tftpd_init(); #endif while (1) { if (GetEthLinkStatus() == YES) { lcd_font24(udp_lcd_x,udp_lcd_y,COLOR_POINT,COLOR_BACK,"> Á¬½ÓµçÄԳɹ¦¡£Çëµã»÷µçÄÔ¶Ë Put °´Å¥£¬Íê³ÉÉý¼¶£¡",UPDATE_FONT); udp_lcd_y += UPDATE_WORD_SIZE + UPDATE_ROW_DISTANCE; break; } } while (1) { if (uPdateFinish == YES) { lcd_font24(udp_lcd_x,udp_lcd_y,COLOR_POINT,COLOR_BACK,"> Éý¼¶³É¹¦£¡",UPDATE_FONT); udp_lcd_y += UPDATE_WORD_SIZE + UPDATE_ROW_DISTANCE; AutoEnterSystemCue(udp_lcd_x,udp_lcd_y,COLOR_POINT,COLOR_BACK,UPDATE_FONT); break; } /* ÒÔÌ«ÍøÑ»·ÈÎÎñ */ LwIP_Periodic_Handle(bsp_GetRunTime()); } return SUCCESS; }
/** * @brief Main program * @param None * @retval None */ int main(void) { /* Configure Key Button */ BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO); /* Test if Key push-button is not pressed */ if (BSP_PB_GetState(BUTTON_KEY) != 0x00) { /* 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(); /* do nothing */ while(1); } else {/* Otherwise, do nothing */ /* LED3 (RED) ON to indicate bad software (when not valid stack address) */ BSP_LED_Init(LED3); BSP_LED_On(LED3); /* do nothing */ while(1); } } /* Enter in IAP mode */ else { /* STM32F4xx HAL library initialization: - Configure the Flash prefetch, instruction and Data caches - Configure the Systick to generate an interrupt each 1 msec - Set NVIC Group Priority to 4 - Global MSP (MCU Support Package) initialization */ HAL_Init(); /* Configure the system clock to 168 MHz */ SystemClock_Config(); /* Configure the BSP */ BSP_Config(); /* Initialize the LwIP stack */ lwip_init(); /* Configure the Network interface */ Netif_Config(); #ifdef USE_IAP_HTTP /* Initialize the webserver module */ IAP_httpd_init(); #endif #ifdef USE_IAP_TFTP /* Initialize the TFTP server */ IAP_tftpd_init(); #endif /* Notify user about the network interface config */ User_notification(&gnetif); /* Infinite loop */ while (1) { /* Read a received packet from the Ethernet buffers and send it to the lwIP for handling */ ethernetif_input(&gnetif); /* Handle timeouts */ sys_check_timeouts(); #ifdef USE_DHCP /* handle periodic timers for LwIP */ DHCP_Periodic_Handle(&gnetif); #endif } } }
/** * @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; }