📄 download.c
字号:
#include <string.h>#include <stdio.h>#include <stdlib.h>#include "..\inc\option.h"#include "..\inc\def.h"#include "..\inc\44b.h"#include "..\inc\44blib.h"#include "..\inc\flash.h"#include "..\inc\download.h"#include "..\inc\file.h"#include "..\inc\usb.h"extern U8 tx_buf[16*1024];extern U8 Page_Buf[528];extern unsigned char *downPt;extern unsigned int fileSize;static void (*run)(void)=(void (*)(void))DOWNLOAD_ADDRESS;U8 DEMO1_CODE[] ={'D','E','M','O','1',' ',' ',' ','B','I','N'};U8 DEMO2_CODE[] ={'D','E','M','O','2',' ',' ',' ','B','I','N'};U8 DEMO3_CODE[] ={'D','E','M','O','3',' ',' ',' ','B','I','N'};U8 SYSTEM_CODE[] ={'S','Y','S','T','E','M',' ',' ','B','I','N'};U8 CHINESE_LIB_NAME[]={'H','Z','K','1','6',' ',' ',' ','D','A','T'};U8 CHINESE_LIB[8704][32]; //8704*32=272KB=17 BLOCKvoid LOAD_DEMO1_CODE(void){ U32 i,POINTER,root_location; root_location=find_file(DEMO1_CODE); //get the file first cluster// current_block=root_buf[root_location][27]*256+root_buf[root_location][26]; if(root_location==FILE_NO_FOUND) Uart_Printf("\nDEMO1.BIN no found!"); else { Uart_Printf("\n%d",current_block); Uart_Printf("\nLoading DEMO1.BIN..."); while(1) { read_file(tx_buf); for(i=0;i<BLOCK_SIZE;i++) { *((unsigned char *)(DOWNLOAD_ADDRESS+POINTER))=tx_buf[i]; POINTER++; } current_block=Page_Buf[512+14]*256+Page_Buf[512+15]; if(current_block==LAST_BLOCK) break; } Uart_Printf("\nDEMO1.BIN loading finished!"); //disable usb// write_usb(0x00,0x01); //写 0x01 到 MCNTRL// //INTOC(1-0)=00 :禁止中断输出 // //NAT=0 :禁止被USB总线检测 // //VEG=0 :禁止内部3.3V稳压 // //SRST=1 :进行软件复位 // run(); }}void LOAD_SYSTEM_CODE(void){ U32 i,POINTER=0,root_location; root_location=find_file(SYSTEM_CODE); //get the file first cluster// current_block=root_buf[root_location][27]*256+root_buf[root_location][26]; if(root_location==FILE_NO_FOUND){ Uart_Printf("\nSYSTEM.BIN no found!"); LCD_printf("SYSTEM.BIN no found!\n"); } else { Uart_Printf("\n%d",current_block); Uart_Printf("\nLoading SYSTEM.BIN..."); LCD_printf("Loading SYSTEM.BIN...\n"); while(1) { read_file(tx_buf); for(i=0;i<BLOCK_SIZE;i++) { *((unsigned char *)(DOWNLOAD_ADDRESS+POINTER))=tx_buf[i]; POINTER++; } current_block=Page_Buf[512+14]*256+Page_Buf[512+15]; if(current_block==LAST_BLOCK) break; } Uart_Printf("\nSYSTEM.BIN loading finished!"); LCD_printf("SYSTEM.BIN loading finished!\n"); LCD_printf("starting System...\n"); //disable usb// write_usb(0x00,0x01); //写 0x01 到 MCNTRL// //INTOC(1-0)=00 :禁止中断输出 // //NAT=0 :禁止被USB总线检测 // //VEG=0 :禁止内部3.3V稳压 // //SRST=1 :进行软件复位 // Delay(8000); run(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -