/**********************************************************************
|
* Copyright: (C)2023 LingYun IoT System Studio
|
* Author: GuoWenxue<guowenxue@gmail.com> QQ: 281143292
|
* Description: ISKBoard W25Qxx SPI norflash Hardware Abstract Layer driver
|
*
|
* ChangeLog:
|
* Version Date Author Description
|
* V1.0.0 2023.04.3 GuoWenxue Release initial version
|
***********************************************************************/
|
#ifndef _w25Q32_H
|
#define _W25Q32_H
|
|
#include "stm32l4xx_hal.h"
|
|
typedef enum
|
{
|
W25Q80,
|
W25Q16,
|
W25Q32,
|
} w25q_chip_t;
|
|
typedef enum
|
{
|
REG_SR1=1,
|
REG_SR2,
|
REG_SR3,
|
} w25q_sreg_t;
|
|
typedef struct flash_info_s
|
{
|
char *name; /* Chip name */
|
uint32_t id; /* JEDEC ID */
|
uint32_t pagesize; /* page size */
|
uint32_t npages; /* page count */
|
uint32_t sectorsize; /* sector size */
|
uint32_t nsectors; /* sector count */
|
uint32_t blocksize; /* block size */
|
uint32_t nblocks; /* block count */
|
} flash_info_t;
|
|
extern flash_info_t *w25q;
|
|
int w25q_Init(void);
|
void w25q_EraseChip(void);
|
void w25q_EraseSector(uint32_t SectorAddr);
|
void w25q_EraseBlock(uint32_t BlockAddr);
|
|
uint32_t w25q_PageToSector(uint32_t PageAddress);
|
uint32_t w25q_PageToBlock(uint32_t PageAddress);
|
uint32_t w25q_SectorToBlock(uint32_t SectorAddress);
|
uint32_t w25q_SectorToPage(uint32_t SectorAddress);
|
uint32_t w25q_BlockToPage(uint32_t BlockAddress);
|
|
int w25q_IsEmptyPage(uint32_t Page_Address, uint32_t OffsetInByte, uint32_t NumByteToCheck_up_to_PageSize);
|
int w25q_IsEmptySector(uint32_t Sector_Address, uint32_t OffsetInByte, uint32_t NumByteToCheck_up_to_SectorSize);
|
int w25q_IsEmptyBlock(uint32_t Block_Address, uint32_t OffsetInByte, uint32_t NumByteToCheck_up_to_BlockSize);
|
|
void w25q_WriteByte(uint8_t pBuffer, uint32_t Bytes_Address);
|
void w25q_WritePage(uint8_t *pBuffer, uint32_t Page_Address, uint32_t OffsetInByte, uint32_t NumByteToWrite_up_to_PageSize);
|
void w25q_WriteSector(uint8_t *pBuffer, uint32_t Sector_Address, uint32_t OffsetInByte, uint32_t NumByteToWrite_up_to_SectorSize);
|
void w25q_WriteBlock(uint8_t *pBuffer, uint32_t Block_Address, uint32_t OffsetInByte, uint32_t NumByteToWrite_up_to_BlockSize);
|
|
void w25q_ReadByte(uint8_t *pBuffer, uint32_t Bytes_Address);
|
void w25q_ReadBytes(uint8_t *pBuffer, uint32_t ReadAddr, uint32_t NumByteToRead);
|
void w25q_ReadPage(uint8_t *pBuffer, uint32_t Page_Address, uint32_t OffsetInByte, uint32_t NumByteToRead_up_to_PageSize);
|
void w25q_ReadSector(uint8_t *pBuffer, uint32_t Sector_Address, uint32_t OffsetInByte, uint32_t NumByteToRead_up_to_SectorSize);
|
void w25q_ReadBlock(uint8_t *pBuffer, uint32_t Block_Address, uint32_t OffsetInByte, uint32_t NumByteToRead_up_to_BlockSize);
|
|
#endif
|