ZNY_Pakistan/Anjiehui7_Set_ZNY/User/spi_Flash.h

56 lines
1.6 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
*********************************************************************************************************
* 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