#ifndef _FLASH_SECTOR_H_
#define _FLASH_SECTOR_H_
#include "stdint.h"
#define SPI_FLASH_MAX_SIZE 0x800000//8M内存8*1024*1024
#define SPI_FLASH_USER_START_ADDR 0x1000 //
#define SPI_FLASH_USER_INFO_ADDR 0x2000 //
#define OTA_START_ADDR 0x180000 //1.5M start
#define ERR_START_ADDR 0x200000 // 2M start
#define ERR_END_ADDR SPI_FLASH_MAX_SIZE
extern uint32_t sysCfgAddr;
extern uint32_t sysInfoAddr;
extern uint32_t permiListBootAddr;
extern uint32_t permiListDataAddr;
extern uint32_t openLogDataAddr;
extern uint32_t passwordBootAddr;
extern uint32_t passwordDataAddr;
#define SYS_CNT_ADDR sysCfgAddr
#define SYS_INFO_ADDR sysInfoAddr
#define PERMI_LIST_BOOT_ADDR permiListBootAddr
#define PERMI_LIST_DATA_ADDR permiListDataAddr
#define OPEN_LOG_DATA_ADDRE openLogDataAddr
#define PASSWORD_BOOT_ADDR passwordBootAddr
#define PASSWORD_DATA_ADDR passwordDataAddr
void flash_sector_init( void );
#endif
uint32_t sysCfgAddr = 0;
uint32_t sysInfoAddr;
uint32_t permiListBootAddr = 0;
uint32_t permiListDataAddr = 0;
uint32_t openLogDataAddr = 0;
uint32_t passwordBootAddr = 0;
uint32_t passwordDataAddr = 0;
uint32_t endFlashAddr = 0;//
void flash_sector_init( void )
{
sysCfgAddr = SPI_FLASH_USER_START_ADDR;
sysInfoAddr = SPI_FLASH_USER_INFO_ADDR;
permiListBootAddr = sysInfoAddr + ((sizeof(SystemInfoType)/FLASH_SPI_BLOCKSIZE)+1)*FLASH_SPI_BLOCKSIZE;
permiListDataAddr = permiListBootAddr + ((PERMI_LIST_MAX*PERMI_LISD_INDEX_SIZE/FLASH_SPI_BLOCKSIZE)+1)*FLASH_SPI_BLOCKSIZE;
openLogDataAddr = permiListDataAddr+ (((PERMI_LIST_SIZE*PERMI_LIST_MAX)/FLASH_SPI_BLOCKSIZE)+1)*FLASH_SPI_BLOCKSIZE;
passwordBootAddr = openLogDataAddr + (((LOG_SIZE*LOG_MAX)/FLASH_SPI_BLOCKSIZE)+1)*FLASH_SPI_BLOCKSIZE;
passwordDataAddr = passwordBootAddr + + ((PWD_MAX_NUM*PWD_INDEX_SIZE/FLASH_SPI_BLOCKSIZE)+1)*FLASH_SPI_BLOCKSIZE;
endFlashAddr = passwordDataAddr + (((PWD_SIZE*PERMI_LIST_MAX)/FLASH_SPI_BLOCKSIZE)+1)*FLASH_SPI_BLOCKSIZE;
if( endFlashAddr >= OTA_START_ADDR)
{
log_err("数据存储区已越界\n");
}
}
//INIT_EXPORT(flash_sector_init , "Flash存")