HAL_Project/Project -APP-V1.0/Hardware/W25QXX/w25qxx.h

37 lines
1.5 KiB
C
Raw 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.

#ifndef __W25QXX_H
#define __W25QXX_H
#include "main.h"
#define Flash_CS_Pin GPIO_PIN_4
#define Flash_CS_Port GPIOA
#define CS_DISENABLE HAL_GPIO_WritePin(Flash_CS_Port, Flash_CS_Pin, GPIO_PIN_SET); //CS无效信号
#define CS_ENABLE HAL_GPIO_WritePin(Flash_CS_Port, Flash_CS_Pin, GPIO_PIN_RESET); //CS有效信号
#define W25QxxID 0XEF16 //W25Qxx ID
#define W25Qxx_WriteEnable 0x06 //写使能
#define W25Qxx_WriteDisable 0x04 //写禁止
#define W25Qxx_ReadStatusReg1 0x05 //读状态寄存器1指令
#define W25Qxx_SectorErase 0x20 //扇区4KB擦除指令
#define W25Qxx_BlockErase 0xD8 //块64KB擦除指令
#define W25Qxx_PageProgram 0x02 //页256B写入指令
#define W25Qxx_ReadData 0x03 //读数据指令
#define W25Qxx_Powerdown 0xB9 //Powerdown指令
void w25qxxInit(void); //函数声明初始化W25Qxx
void w25qxxWriteEnable(void); //函数声明W25Qxx擦写使能
void w25qxxWrite_Disable(void); //函数声明W25Qxx擦写禁止
uint16_t w25qxxReadID(void); //函数声明读取W25Qxx芯片ID
void w25qxxWaitBusy(void); //函数声明W25Qxx等待空闲
void w25qxxErase_Sector(uint16_t); //函数声明W25Qxx擦除一个扇区4KB
void w25qxxErase_Block(uint8_t); //函数声明W25Qxx擦除一个块64KB
void w25qxxWrite_Page(uint8_t*, uint16_t); //函数声明W25Qxx写入一页数据256字节
void w25qxxRead(uint8_t*,uint32_t,uint32_t); //函数声明W25Qxx读取数据
#endif