43 lines
1.6 KiB
C
43 lines
1.6 KiB
C
// File: w25q128.h
|
||
#ifndef __W25Q128_H
|
||
#define __W25Q128_H
|
||
|
||
#include <stdint.h>
|
||
#include "at32f403a_407.h"
|
||
|
||
// W25Q128 指令集
|
||
#define W25X_WriteEnable 0x06
|
||
#define W25X_WriteDisable 0x04
|
||
#define W25X_ReadStatusReg1 0x05
|
||
#define W25X_ReadStatusReg2 0x35
|
||
#define W25X_WriteStatusReg 0x01
|
||
#define W25X_PageProgram 0x02
|
||
#define W25X_QuadPageProgram 0x32
|
||
#define W25X_BlockErase64KB 0xD8
|
||
#define W25X_BlockErase32KB 0x52
|
||
#define W25X_SectorErase 0x20
|
||
#define W25X_ChipErase 0xC7
|
||
#define W25X_ChipErase2 0x60 // 另一种全片擦除命令
|
||
#define W25X_ReadData 0x03
|
||
#define W25X_FastRead 0x0B
|
||
#define W25X_ReadManufactID 0x90
|
||
#define W25X_ReleasePowerDown 0xAB
|
||
#define W25X_DeviceID 0xAB
|
||
#define W25X_ManufactDeviceID 0x90
|
||
#define W25X_JedecDeviceID 0x9F
|
||
#define W25X_ReadUniqueID 0x4B
|
||
#define W25X_EnterQPI 0x38
|
||
#define W25X_ExitQPI 0xFF
|
||
#define W25X_EnableReset 0x66
|
||
#define W25X_ResetDevice 0x99
|
||
|
||
// 函数声明
|
||
void W25Q128_Init(void); // 初始化(调用SPI初始化)
|
||
uint16_t W25Q128_ReadID(void); // 读取ID,用于验证通信
|
||
void W25Q128_Read(uint8_t* pBuf, uint32_t ReadAddr, uint16_t NumByteToRead); // 读取数据
|
||
void W25Q128_Write(uint8_t* pBuf, uint32_t WriteAddr, uint16_t NumByteToWrite); // 写入数据(自动处理页写和擦除)
|
||
void W25Q128_Erase_Sector(uint32_t SectorAddr); // 擦除扇区(4KB)
|
||
void W25Q128_Erase_Chip(void); // 擦除整个芯片
|
||
void W25Q128_WriteSector_4K(uint8_t* buf, uint32_t addr,uint32_t len);
|
||
#endif
|