📄 44bmain.c
字号:
/*************************************************************************
* FILE NAME VERSION
*
* 44bmain.c 1.0
*
* COMPONENT
*
* Flash Operation such as erase/program
*
************************************************************************/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include "..\inc\def.h"
#include "..\inc\29lvflash.h"
#include "..\inc\option.h"
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
/*根据实际情况修改*/
#define FLASH_START_ADDR 0x00000000 /* FLASH 地址映射 */
#define PROG_BUFFER_ADDR 0x0c100000 /* 目标码缓存地址 */
#define PROG_LENGTH 100000 /* 目标码长度 */
int main(void)
{
int result=0;
/**** SYSTEM INITIALIZE */
/* disable system cache */
rSYSCFG = 0;
//__rt_lib_init();
Port_Init();
/**** FLASH OPERATION */
/* 1 - get flash'ID, if it work well, at least our hardware is good */
Flash_ReadID();
/* 2 - erase the whole chip, also you can erase it sector by sector */
Flash_Erase_Chip();
/* 3 - write into flash from a temporary buffer */
Flash_Write(FLASH_START_ADDR, (char *)PROG_BUFFER_ADDR, PROG_LENGTH);
/* 4 - verify (Optional) */
result=Flash_Verify(FLASH_START_ADDR, (char *)PROG_BUFFER_ADDR, PROG_LENGTH);
printf("OK");
/* Program OVER */
if(result==0) goto ok;
else goto error;
ok:
while(1)
{
Led_Display(3);
Delay(1000);
Led_Display(0);
Delay(10000);
}
error:
while(1)
{
Led_Display(0);
Delay(1000);
Led_Display(3);
Delay(10000);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -