/*
 * spi_flash.h
 *
 *  Created on: 2024年12月4日
 *      Author: yongchaoz
 */

#ifndef DRIVER_SRC_SPI_FLASH_H_
#define DRIVER_SRC_SPI_FLASH_H_

#define EN25XX_WriteEnable             0x06
#define EN25XX_WriteDisable            0x04
#define EN25XX_ReadStatusReg           0x05
#define EN25XX_WriteStatusReg          0x01
#define EN25XX_ReadStatusReg2          0x35
#define EN25XX_WriteStatusReg2         0x31
#define EN25XX_ReadData                0x03
#define EN25XX_FastReadData            0x0B
#define EN25XX_FastReadDual            0x3B
#define EN25XX_FastReadQuad            0x6B
#define EN25XX_PageProgram             0x02
#define EN25XX_BlockErase              0xD8
#define EN25XX_SectorErase             0x20
#define EN25XX_ChipErase               0xC7
#define EN25XX_PowerDown               0xB9
#define EN25XX_ReleasePowerDown        0xAB
#define EN25XX_DeviceID                0xAB
#define EN25XX_ManufactDeviceID        0x90
#define EN25XX_JedecDeviceID           0x9F

#define EN25XX_EnterQPI                0x38
#define EN25XX_ExitQPI                 0xFF

void SPI_Flash_Init(void);
void EN25QXX_EraseSector(uint32_t addr);
void EN25QXX_WritePage(uint8_t* pBuffer,uint32_t WriteAddr,uint16_t NumByteToWrite);
uint32_t read_flash(uint32_t flash_addr,uint8_t* buff,uint32_t len);
__ILM uint32_t save_flash(uint32_t flash_addr,uint8_t* buff,uint32_t len);
#endif /* DRIVER_SRC_SPI_FLASH_H_ */
