|
/******************************************************************************
|
* Copyright (C) 2014-2015 HangZhou SiZhu Co.,LTD.
|
*
|
*-----------------------------------------------------------------------------
|
* File: W25X40BV.h
|
* Description: head file of W25X40BV.c used for flash operation
|
* Author: Lishoujian (867693272@qq.com)
|
* Date: Jan 8, 2015
|
*****************************************************************************/
|
|
/* ----------------------- Platform includes --------------------------------*/
|
|
#ifndef __W25X40BV_H
|
#define __W25X40BV_H
|
#include "sys.h"
|
|
//op cmd
|
#define FLASH_WREN 0x06 //write enable
|
#define FLASH_WRDI 0x04 //write disable
|
#define FLASH_RDSR 0x05 //read status register
|
#define FLASH_WRSR 0x01 //write status register
|
#define FLASH_READ 0x03 //read fram memory data
|
#define FLASH_FSTRD 0x0b //fast read fram memory data
|
#define FLASH_WRITE 0x02 //write fram memory data
|
#define FLASH_POWERDOWN 0xb9 //go to power-down mode
|
#define FLASH_WKUP 0xab //release from power-down mode
|
#define FLASH_RDID 0x90 //read Manufacturer ID/Devive ID 16bit
|
#define FLASH_BlockErase 0xD8 //erase 64KB block
|
#define FLASH_SectorErase 0x20 //erase 4KB sector
|
#define FLASH_ChipErase 0xC7 //erase all chip 512KB
|
|
#define FLASH_CS_LOW GPIO_ResetBits(GPIOB,GPIO_Pin_7)//CS = 0
|
#define FLASH_CS_HIGH GPIO_SetBits(GPIOB,GPIO_Pin_7) //CS = 1
|
|
#define FLASH_ReadWriteByte(dat) SPI3_ReadWriteByte(dat)
|
#define FLASH_ioconfig() SPI2_ioconfig()
|
|
u8 Flash_ReadSR(void);
|
void FLASH_Write_SR(u8 sr);
|
void FLASH_Write_Enable(void);
|
void FLASH_Write_Disable(void);
|
u16 Flash_ReadID(void);
|
void Flash_Read(uint8* pBuffer,uint32 ReadAddr,uint16 NumByteToRead);
|
void Flash_Write_Page(u8* pBuffer,u32 WriteAddr,u16 NumByteToWrite);
|
//void Flash_Write_NoCheck(uint8* pBuffer,uint32 WriteAddr,uint16 NumByteToWrite);
|
void Flash_Write(u8* pBuffer,u32 WriteAddr,u16 NumByteToWrite);
|
void Flash_Erase_Chip(void);
|
void Flash_Erase_Sector(u32 Dst_Addr);
|
void Flash_Wait_Busy(void);
|
void Flash_PowerDown(void);
|
void Flash_WAKEUP(void);
|
|
#endif
|