📄 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_LENGTH1 0x60000 //10000 /* 15c目标码长度 */
#define PROG_LENGTH2 0x1000 //10000 /* boot目标码长度 */
#define PROG_LENGTH3 0x10000 //10000 /* 15a目标码长度 */
int main(void)
{
int result=0;
unsigned int len;
unsigned short tmp;
/**** SYSTEM INITIALIZE */
len = PROG_LENGTH1;
/* disable system cache */
rSYSCFG = 0;
//__rt_lib_init();
Port_Init();
result = GetFlashID();
SectorProg(FLASH_START_ADDR, (unsigned short *)PROG_BUFFER_ADDR, len);
// printf("OK");
//while (1) {
// tmp = *(volatile unsigned short *)0x000000;
// tmp = *(volatile unsigned short *)0x1ffffe;`
//}
/**** 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 + -