20260324
This commit is contained in:
50
IAPV1.1/main/main.c
Normal file
50
IAPV1.1/main/main.c
Normal file
@ -0,0 +1,50 @@
|
||||
#include "bsp.h"
|
||||
int main(void)
|
||||
{
|
||||
|
||||
u32 size_txt=0,pagenumber=0;
|
||||
u8 IAP_Flag[2]={'\0'};
|
||||
bsp_init();
|
||||
//if(EEPROM_ReadBytes())
|
||||
while(1)
|
||||
{
|
||||
IAP_Flag[0]=0x31;
|
||||
size_txt = txt_size_read("APP.bin");
|
||||
if(size_txt>1000)//
|
||||
{
|
||||
DIS_INT;
|
||||
//u5_printf("APP Size is:%ld\r\n",size_txt);
|
||||
pagenumber=1+size_txt/256;
|
||||
Flash_Erase_Pages(256,pagenumber);
|
||||
/* Check if erase operation is OK */
|
||||
if ((uint32_t)(*(uint32_t *)APP_ADDR) != 0x00)
|
||||
{
|
||||
//u5_printf("erase fail!!!!!!\r\n second erase!!!\r\n");
|
||||
Flash_Erase_Pages(256,pagenumber);
|
||||
}
|
||||
//u5_printf("read <<APP.bin>>........\r\n");
|
||||
FATFS_Read_TF("APP.bin",0,size_txt);
|
||||
//u5_printf("read end.....\r\n");
|
||||
Fil_delete("APP.bin");
|
||||
//u5_printf("iap_load_app sucess!!!\r\n");
|
||||
//<2F><><EFBFBD><EFBFBD>EEPROM
|
||||
DATA_EEPROM_Unlock();
|
||||
DATA_EEPROM_EraseByte(EEPROM_BASE_ADDR+188);
|
||||
DATA_EEPROM_Lock();
|
||||
//д<><D0B4>eeprom
|
||||
DATA_EEPROM_Unlock();
|
||||
DATA_EEPROM_FastProgramByte(EEPROM_BASE_ADDR+188,0x31);
|
||||
DATA_EEPROM_Lock();
|
||||
//u5_printf("IAP_Flag is :%x\r\n",IAP_Flag[0]);
|
||||
//u5_printf("jump to app\r\n");
|
||||
iap_load_app(APP_ADDR);
|
||||
|
||||
}
|
||||
//u5_printf("APP is not find!!!!!\r\n");
|
||||
iap_load_app(APP_ADDR);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user