#include #include #include #include #include #include "sdrv_rstgen.h" #include "interface_config.h" uint16_t FrameHeader = 0;//Ö¡Í· bool boot_can_flag = false;//Ö¡Í· bool boot_eth_flag = false;//Ö¡Í· SystemDataRecord g_systemDataRecord = {0,0,0,0}; bool WDTReFresh_flag = false;// Timer boot_timer_interface; void bootmian(void *signal_id) { static uint16_t bootmianSTT = 0; // uint32_t time_boot = getCurrentTime();//¼Ç¼µ±Ç°Ê±¼ä //------------------------------------------------------------------------------ (void)signal_id; // ±ê¼Ç±äÁ¿ÎªÒÑʹÓ㬱ÜÃâ±àÒëÆ÷¾¯¸æ if( (true == boot_can_flag) || (true == boot_eth_flag) )//ÖØÆô±êÖ¾£¬ÔÚÖжÏÖнÓÊÕºóÖÃ1 { boot_can_flag = false; boot_eth_flag = false; if(EXCUTE_APP == FrameHeader)//д±êÖ¾0£¬ÖØÆô½øÈëAPP { printf("go to app!\r\n"); wrbyte_24c02(Update_Flg_E2adr,NORMAL_ON); //д±ê־λΪ0£¬ÖØÆô£¬ÏÂÒ»´Î³ÌÐòÖ±½Ó½øÈëapp // udelay(3000);//ÑÓʱ3ms g_systemDataRecord.canBootloaderUpgrade = rdbyte_24c02(Update_Flg_E2adr); //¸üÐÂÊý¾Ý·½±ãι¹· // sdrv_rstgen_global_reset(&rstctl_glb); for(;;) { printf("Restart!\r\n"); } } else if(ENTER_UPDATE_MODE == FrameHeader)//д±êÖ¾1£¬ÖØÆô½øÈëboot { ssdk_printf(SSDK_INFO, "go to boot!\r\n"); wrbyte_24c02(Update_Flg_E2adr,CAN_BOOTLOADER_UPGRADE); //д±êÖ¾ÖØÆô // udelay(3000);//ÑÓʱ3ms wrbyte_24c02(BOOT_DES_IP, ethernet_parameter.download_ip[0]); wrbyte_24c02(BOOT_DES_IP+1, ethernet_parameter.download_ip[1]); wrbyte_24c02(BOOT_DES_IP+2, ethernet_parameter.download_ip[2]); wrbyte_24c02(BOOT_DES_IP+3, ethernet_parameter.download_ip[3]); // sdrv_rstgen_global_reset(&rstctl_glb); for(;;) { printf("Restart!\r\n"); } } } //ÅжϴÓe2¶ÁÈ¡boot±êÖ¾ºó£¬¾ö¶¨ÊÇ·ñÓÉAPP¶¨Ê±Î¹¹· if( CAN_BOOTLOADER_UPGRADE == (g_systemDataRecord.canBootloaderUpgrade) )//boot±êÖ¾ { //boot±ê־Ϊ1£¬ÉÏµç½øboot£¬ÓÉÉÏλ»úι¹· if(true == WDTReFresh_flag)//½ÓÊÕµ½ID²Å¸üÐÂWDT ½ÓÊÕµ½±êÖ¾²Åι¹· { feedWatchdog();//ι¹· WDTReFresh_flag = false; } } else//APP×Ô¼ºÎ¹¹· { bootmianSTT ++; if(bootmianSTT >= 5)//5*1000*100us = 500ms { bootmianSTT = 0; feedWatchdog();//ι¹· } } timerStart(&boot_timer_interface, 100,0); // printf("bootAPP spend time:%d\n",getCurrentTime() - time_boot);//¼ì²éappÓÃÁ˶೤ʱ¼ä } static uint32_t time_wdt = 0; // ι¹· void feedWatchdog(void) { sdrv_gpio_toggle_pin_output_level(WDTGPIO); //Íⲿwdtι¹· printf("WDT:%d \n",getCurrentTime() - time_wdt); time_wdt = getCurrentTime(); } // APPÄ£¿éµÄ³õʼ»¯ void bootInterfaceInit(void) { // ³õʼ»¯¶¨Ê±Æ÷ timerInit(&boot_timer_interface); // ¶©ÔĶ¨Ê±Æ÷Ðźţ¬ÓÃÓÚ¶¨Ê±²É¼¯ subscribe(&boot_timer_interface, bootmian); timerStart(&boot_timer_interface, 100,0); //100ms feedWatchdog();//ι¹·,³õʼ»¯Íê±ÏÏÈιһ´Î printf("bootInterface: initial OK %d\n",getCurrentTime()); }