56 lines
1.6 KiB
C
56 lines
1.6 KiB
C
/*
|
||
*********************************************************************************************************
|
||
* IAR Development Kits
|
||
* on the
|
||
*
|
||
* M451
|
||
*
|
||
* Filename : spi_flash.h
|
||
* Version : V1.00
|
||
* Programmer(s) : Qian Xianghong
|
||
*********************************************************************************************************
|
||
*/
|
||
|
||
#ifndef USER_SPI_FLASH_PRESENT
|
||
#define USER_SPI_FLASH_PRESENT
|
||
|
||
#include "type.h"
|
||
|
||
// Flash存储规划如下:
|
||
// 0~7K: boot-loader,解压程序,由LDROM调入内存执行
|
||
// 8~11K: 配置数据(2K+2K,双份存储)
|
||
// 12~15K:保留
|
||
// 16~255K: 保留(以后可能用于存放16点阵的字库,现为了烧录方便,是放在程序里面)
|
||
// 256~511K:升级包
|
||
// 512K~8M: 保留(以后可能用于存放GPRS采集数据,现放在铁电里面)
|
||
|
||
// 配置数据起始地址:8K(大小为4K)
|
||
#define SFLASH_CONFIG_BASE 0x2000
|
||
// 升级包起始地址:256K(大小为256K)
|
||
#define SFLASH_UPGRADE_BASE 0x40000ul
|
||
|
||
// Flash存储容量: 8M bytes
|
||
#define SFLASH_SIZE 0x800000ul
|
||
#define SFLASH_PAGE_SIZE 256
|
||
#define SFLASH_ERASE_SIZE 256 // Page erase size
|
||
|
||
// 初始化引脚
|
||
void SFlash_Init();
|
||
|
||
// 打开设备和允许中断
|
||
void SFlash_Open();
|
||
|
||
void SFlash_ReadID();
|
||
uint8_t SFlash_UnlockBPR();
|
||
uint8_t SFlash_WriteEN();
|
||
void SFlash_ChipErase();
|
||
void SFlash_SectorErase(uint32_t Addr);
|
||
void SFlash_PageErase(uint32_t Addr);
|
||
uint32_t SFlash_BufferWrite(uint32_t Addr, uint8_t *buf, uint32_t nbytes);
|
||
uint32_t SFlash_BufferRead(uint32_t Addr, uint8_t *buf, uint32_t nbytes);
|
||
uint32_t SFlash_BufferVerify(uint32_t Addr, uint8_t *buf, uint32_t nbytes);
|
||
|
||
uint16_t do_sflash_crc(unsigned long base_addr, long len);
|
||
|
||
#endif
|