|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2015-3-17 17:52:34
|
显示全部楼层
- FRESULT res;
- FRESULT ceshi;
- char folder[255] = "";
- uint32_t addr,ii;
- uint32_t u32Status;
- res = (FRESULT)SD_Init();
- if(res == FALSE)
- {
- printf("sd init error.\n\r");
- LCD_ShowString(10,26,200,16,16,"Has no SD found!");
- }
- else
- {
- LCD_ShowString(10,26,608,16,16,"Press any key to updata system in 3S:");
- // LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"10S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
- // LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"09S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
- // LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"08S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
- // LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"07S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
- // LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"06S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
- // LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"05S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
- // LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"04S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
- LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"03S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
- LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"02S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
- LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"01S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
- LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"00S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
- return;
- updata_APP:
- updata_num=1;
- SystemCoreClockUpdate();
-
- LCD_ShowString(10,42,200,16,16,"Updata APP:");LCD_FillRectangle (LCD_PANEL_UPPER,176,376,42,58,skyblue);
- res = f_mount(&fs,"0:", 1);
- if(res != FR_OK){printf("f_mount error = %d\n\r",res);}
-
- ceshi=f_open (&file, "UNIGBK.BIN", FA_READ); RES_FALT(ceshi);
- SIZE_UNIGBK=file.fsize;
- printf("\n UNIGBK.BIN ÎļþËùÕ¼´óС£º%d×Ö½Ú \n",file.fsize);
- ceshi=f_read(&file, UNIGBK, SIZE_UNIGBK, &br); RES_FALT(ceshi);
- printf("\nbr 掙朧%d\n",br);printf("\n");
- f_close(&file);br=0;//////////////////////////////////////////////¹Ø±ÕÎļþ
- LCD_FillRectangle (LCD_PANEL_UPPER,176,186,42,58,NavyBlue);
-
- scan_files(folder); //±éÀúSD¿¨Îļþ
- LCD_FillRectangle (LCD_PANEL_UPPER,186,190,42,58,NavyBlue);
-
- SysTick->CTRL=0;//¹Øµôϵͳ¶¨Ê±Æ÷·ÀÖ¹Ó°ÏìºóÃæ²Á³ý²Ù×÷
- NVIC_DisableIRQ(UART0_IRQn);
- if ((u32IAP_PrepareSectors(10, 21) == IAP_STA_CMD_SUCCESS) &&(u32IAP_EraseSectors (10, 21) == IAP_STA_CMD_SUCCESS))
- {LCD_ShowString(10,58,200,16,16,"Erase Done!"); LCD_FillRectangle (LCD_PANEL_UPPER,190,200,42,58,NavyBlue);}
- else {LCD_ShowString(10,58,200,16,16,"Erase FAILED!");return;}
-
- ceshi=f_open (&file, "APP.bin", FA_READ); RES_FALT(ceshi);
- printf("\n APP.binÎļþËùÕ¼´óС£º%d×Ö½Ú \n\r",file.fsize);addr=0;
- for(ii=0;ii<((file.fsize)/512+1);ii++)
- {
- ceshi = f_read(&file, APP_CODE_ADDR, 512, &br); RES_FALT(ceshi);
- NVIC_DisableIRQ(DMA_IRQn);
- if ((ceshi == FR_OK) || (br == 512))
- {
- printf("\n %d ",br);
- u32Status=u32IAP_PrepareSectors(10, 21);printf(" PrepareSectors:%d ",u32Status);
- u32Status=u32IAP_CopyRAMToFlash(APP_START_SECTOR+addr,(uint32_t)APP_CODE_ADDR,512);printf(" CopyRAMToFlash:%d \n\r",u32Status);
- addr += 512;
- LCD_FillRectangle (LCD_PANEL_UPPER,200,200+ii*176/((file.fsize)/512),42,58,NavyBlue);
- }
- NVIC_EnableIRQ(DMA_IRQn);
- }f_close(&file);br=0;
- //SysTick_Init();NVIC_EnableIRQ(UART0_IRQn);
- // NVIC_DisableIRQ(DMA_IRQn);
- }
- return;
- }
复制代码 |
|