// cpu内部Flash驱动
// 杭州秒寻科技有限公司
// 周涛
// 2023-09-26

#ifndef __DRIVER_CPUFLASH_H__
#define __DRIVER_CPUFLASH_H__

#include "sysdef.h"

// 扇区0，16KB
#define DRIVERCPUFLASH_SECTOR0_START_ADDRESS 0x08000000
#define DRIVERCPUFLASH_SECTOR0_STOP_ADDRESS 0x08003FFF

// 扇区1，16KB
#define DRIVERCPUFLASH_SECTOR1_START_ADDRESS 0x08004000
#define DRIVERCPUFLASH_SECTOR1_STOP_ADDRESS 0x08007FFF

// 扇区2，16KB
#define DRIVERCPUFLASH_SECTOR2_START_ADDRESS 0x08008000
#define DRIVERCPUFLASH_SECTOR2_STOP_ADDRESS 0x0800BFFF

// 扇区3，16KB
#define DRIVERCPUFLASH_SECTOR3_START_ADDRESS 0x0800C000
#define DRIVERCPUFLASH_SECTOR3_STOP_ADDRESS 0x0800FFFF

// 扇区4，64KB
#define DRIVERCPUFLASH_SECTOR4_START_ADDRESS 0x08010000
#define DRIVERCPUFLASH_SECTOR4_STOP_ADDRESS 0x0801FFFF

// 扇区5，128KB
#define DRIVERCPUFLASH_SECTOR5_START_ADDRESS 0x08020000
#define DRIVERCPUFLASH_SECTOR5_STOP_ADDRESS 0x0803FFFF

// 扇区6，128KB
#define DRIVERCPUFLASH_SECTOR6_START_ADDRESS 0x08040000
#define DRIVERCPUFLASH_SECTOR6_STOP_ADDRESS 0x0805FFFF

// 扇区7，128KB
#define DRIVERCPUFLASH_SECTOR7_START_ADDRESS 0x08060000
#define DRIVERCPUFLASH_SECTOR7_STOP_ADDRESS 0x0807FFFF

// 扇区8，128KB
#define DRIVERCPUFLASH_SECTOR8_START_ADDRESS 0x08080000
#define DRIVERCPUFLASH_SECTOR8_STOP_ADDRESS 0x0809FFFF

// 扇区9，128KB
#define DRIVERCPUFLASH_SECTOR9_START_ADDRESS 0x080A0000
#define DRIVERCPUFLASH_SECTOR9_STOP_ADDRESS 0x080BFFFF

// 扇区10，128KB
#define DRIVERCPUFLASH_SECTOR10_START_ADDRESS 0x080C0000
#define DRIVERCPUFLASH_SECTOR10_STOP_ADDRESS 0x080DFFFF

// 扇区11，128KB
#define DRIVERCPUFLASH_SECTOR11_START_ADDRESS 0x080E0000
#define DRIVERCPUFLASH_SECTOR11_STOP_ADDRESS 0x080FFFFF

// 供外部使用的接口
uint8 driver_cpuflash_read_word_data(uint32 dwAddress, uint16 wLen, uint32 *pdwData);
uint8 driver_cpuflash_write_word_data(uint32 dwAddress, uint32 *pdwData, uint32 dwLen);

// 内部使用接口
uint8 driver_cpuflash_get_sector(uint32 dwAddress, uint8 *pbySector);
uint8 driver_cpuflash_erase_sector(uint8 bySector);

#endif
