97 lines
3.5 KiB
C
97 lines
3.5 KiB
C
/*******************************************************************************
|
||
版权所有 (C), 2018,中颖电子股份有限公司
|
||
********************************************************************************/
|
||
#ifndef __FLASH_H__
|
||
#define __FLASH_H__
|
||
#include "C51_TYPE.H"
|
||
|
||
#define MCU_TYPE_CODE 0x00
|
||
#define MCU_TYPE_E2P 0x01
|
||
|
||
#define BOOT_PGR_OK 0x00
|
||
#define BOOT_PGR_ERASE_ERR 0x01
|
||
#define BOOT_PGR_WR_ERR 0x02
|
||
|
||
#define BootMcuWdtClear() RSTSTAT &= 0xF8; //清看门狗
|
||
/******************************************************************************
|
||
MCU 程序区共计64K
|
||
Boot区占用4K (0x0000~0x0FFF)
|
||
App运行区占用29K (0x1000~0x83FF)
|
||
App备份区占用30K (0x8400~0xFBFF) CODE和参数都缓存在CODE区
|
||
App备份参数区占用1K (0xFC00~0xFFFF)
|
||
*******************************************************************************/
|
||
#define MCU_CODE_SECTOR_SIZE ((U32)0x200)
|
||
|
||
#define BOOT_CODE_START_ADDR ((U32)0x0000) //BOOT程序区起始地址
|
||
#define BOOT_CODE_SIZE ((U32)4*1024) //BOOT程序区起始地址
|
||
|
||
#define IAP_CODE_START_ADDR ((U32)BOOT_CODE_START_ADDR+BOOT_CODE_SIZE)//APP程序区起始地址
|
||
#define IAP_CODE_SIZE ((U32)29*1024) //APP程序区长度29K
|
||
#define IAP_CODE_END_ADDR ((U32)IAP_CODE_START_ADDR+IAP_CODE_SIZE-1)
|
||
|
||
#define IAP_BK_CODE_START_ADDR ((U32)IAP_CODE_START_ADDR+IAP_CODE_SIZE) //APP程序备份区起始地址
|
||
#define IAP_BK_CODE_SIZE ((U32)30*1024) //APP程序备份区结束地址
|
||
#define IAP_BK_CODE_END_ADDR ((U32)IAP_BK_CODE_START_ADDR+IAP_BK_CODE_SIZE-1)
|
||
|
||
#define APP_PARA_START_ADDR ((U32)0x0000) //参数区起始地址--EEPROM地址从0开始
|
||
#define APP_PARA_SIZE ((U32)1*1024) //参数区长度1K
|
||
|
||
#define BOOT_FLG_START_ADDR ((U32)BOOT_CODE_START_ADDR+BOOT_CODE_SIZE-MCU_CODE_SECTOR_SIZE)//存放在BOOT区最后1个Sector
|
||
#define BOOT_FLG_IAP_ADDR ((U32)BOOT_FLG_START_ADDR+MCU_CODE_SECTOR_SIZE-1) //IAP标志存放在标志Sector的最后一个字节
|
||
#define BOOT_FLG_ISP_ADDR ((U32)BOOT_FLG_START_ADDR+MCU_CODE_SECTOR_SIZE-1) //IAP标志存放在标志Sector的最后一个字节
|
||
|
||
#define ISP_CODE_START_ADDR ((U32)IAP_CODE_START_ADDR) //APP程序区起始地址
|
||
#define ISP_CODE_SIZE ((U32)59*1024) //APP程序区长度59K(含1K的参数)
|
||
|
||
extern U8 ucMcuFlashWrValid;
|
||
|
||
extern U8 McuFlashRdOneByte(U32 xdata McuFlashAddr, U8 xdata McuType);
|
||
extern void McuFlashEraseSector(U32 xdata McuFlashAddr, U8 xdata McuType);
|
||
extern BOOL McuFlashBlankCheck(U32 xdata McuFlashAddr, U8 xdata McuType);
|
||
extern void McuFlashWrOneByte(U32 xdata McuFlashAddr, U8 xdata WrData, U8 xdata McuType);
|
||
extern BOOL BootUpgradeCode(void);
|
||
|
||
|
||
|
||
|
||
#endif
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
//#define MCU_CODE_SECTOR_SIZE ((U32)0x200)
|
||
|
||
//#define BOOT_CODE_START_ADDR ((U32)0x0000) //BOOT程序区起始地址
|
||
//#define BOOT_CODE_SIZE ((U32)4*1024) //BOOT程序区起始地址
|
||
|
||
//#define IAP_CODE_START_ADDR (0x0000+4096)//APP程序区起始地址
|
||
//#define IAP_CODE_SIZE ((U32)29*1024) //APP程序区长度29K
|
||
//#define IAP_CODE_END_ADDR (4096+29K-1)
|
||
|
||
//#define IAP_BK_CODE_START_ADDR (4096+29K) //APP程序备份区起始地址
|
||
//#define IAP_BK_CODE_SIZE ((U32)30*1024) //APP程序备份区结束地址
|
||
//#define IAP_BK_CODE_END_ADDR (33K+30K-1)
|
||
|
||
//#define APP_PARA_START_ADDR ((U32)0x0000) //参数区起始地址--EEPROM地址从0开始
|
||
//#define APP_PARA_SIZE ((U32)1*1024) //参数区长度1K
|
||
|
||
//#define BOOT_FLG_START_ADDR (0x0000+4096-0x200)//存放在BOOT区最后1个Sector
|
||
//#define BOOT_FLG_IAP_ADDR (3.5K+0x200-1) //IAP标志存放在标志Sector的最后一个字节
|
||
//#define BOOT_FLG_ISP_ADDR (3.5K+0x200-1) //IAP标志存放在标志Sector的最后一个字节
|
||
|
||
//#define ISP_CODE_START_ADDR (4096) //APP程序区起始地址
|
||
//#define ISP_CODE_SIZE ((U32)59*1024) //APP程序区长度60K(含1K的参数区)
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|