
/*
 * @file hv_drv_FlashDB.h
 * @brief flash config parameter.
 *
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * (+) Use ()
 *
 * @endverbatim
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2023-06-19
 */


#ifndef _FLASH_DB_H
#define _FLASH_DB_H

#include "hv_comm_Define.h"
/* One Sector Erase is 4K.*/

/**************************N25Q Command and Attribute****************/
#define N25Q_ReadIDCmd                    0x9F
#define N25Q_MultiReadIDCmd               0xAF
#define N25Q_SectorErase                  0x20
#define N25Q_MultiSectorErase             0xD8
#define N25Q_ChipErase                    0xC7
#define N25Q_PageProg                     0x02
#define N25Q_PageProgDual                 0xA2
#define N25Q_PageProgQuad                 0x32
#define N25Q_PageProgQpi                  0x00
#define N25Q_PageRead                     0x03
#define N25Q_PageReadDual                 0x3B
#define N25Q_PageReadQuad                 0x6B
#define N25Q_PageReadQpi                  0x00
#define N25Q_Flash_ReadStatus             0x05
#define N25Q_Flash_WriteEn                0x06
#define N25Q_Flash_InstruWidth            0x08
#define N25Q_Flash_WaitBusyFlag           0x01
#define N25Q_Flash_WaitCycleDual          0x08
#define N25Q_Flash_WaitCycleQpi           0x0A
#define N25Q_Flash_WaitCycleFastDual      0x08
#define N25Q_Flash_WaitCycleFastQuad      0x08
#define N25Q_Flash_ReadBusyCompltWait     200


/**************************NMT25 Command and Attribute****************/
#define MT25_ReadIDCmd                    0x9F
#define MT25_MultiReadIDCmd               0xAF
#define MT25_SectorErase                  0x20
#define MT25_MultiSectorErase             0xD8
#define MT25_ChipErase                    0xC7
#define MT25_PageProg                     0x02
#define MT25_PageProgDual                 0xA2
#define MT25_PageProgQuad                 0x32
#define MT25_PageProgQpi                  0x00
#define MT25_PageRead                     0x03
#define MT25_PageReadDual                 0x3B
#define MT25_PageReadQuad                 0x6B
#define MT25_PageReadQpi                  0x00
#define MT25_Flash_ReadStatus             0x05
#define MT25_Flash_WriteEn                0x06
#define MT25_Flash_InstruWidth            0x08
#define MT25_Flash_WaitBusyFlag           0x01
#define MT25_Flash_WaitCycleDual          0x08
#define MT25_Flash_WaitCycleQpi           0x0A
#define MT25_Flash_WaitCycleFastDual      0x08
#define MT25_Flash_WaitCycleFastQuad      0x08
#define MT25_Flash_ReadBusyCompltWait     50


/**************************P25Q Command and Attribute****************/
#define P25Q_ReadIDCmd                    0x9F
#define P25Q_ReadIDDual                   0x92
#define P25Q_ReadIDQuad                   0x94
#define P25Q_SectorErase                  0x20
#define P25Q_ChipErase                    0xC7
#define P25Q_PageProg                     0x02
#define P25Q_PageProgDual                 0xA2
#define P25Q_PageProgQuad                 0x32
#define P25Q_PageProgQpi                  0x00
#define P25Q_PageRead                     0x03
#define P25Q_PageReadDual                 0x3B
#define P25Q_PageReadQuad                 0x6B
#define P25Q_PageReadQpi                  0x00
#define P25Q_Flash_ReadStatus             0x05
#define P25Q_Flash_WriteEn                0x06
#define P25Q_Flash_InstruWidth            0x08
#define P25Q_Flash_WaitBusyFlag           0x01
#define P25Q_Flash_WaitCycleDual          0x02
#define P25Q_Flash_WaitCycleQpi           0x02
#define P25Q_Flash_WaitCycleFastDual      0x08
#define P25Q_Flash_WaitCycleFastQuad      0x08
#define P25Q_Flash_QuadEnable             0x00
#define P25Q_Flash_QuadDisable            0x00
#define P25Q_Flash_ReadBusyCompltWait     20


/**************************W25Q Command and Attribute****************/
#define W25Q_ReadIDCmd                    0x9F
#define W25Q_ReadIDDual                   0x92
#define W25Q_ReadIDQuad                   0x94
#define W25Q_SectorErase                  0x20
#define W25Q_MultiSectorErase             0xD8
#define W25Q_ChipErase                    0xC7
#define W25Q_PageProg                     0x02
#define W25Q_PageProgDual                 0x00
#define W25Q_PageProgQuad                 0x32
#define W25Q_PageProgQpi                  0x00
#define W25Q_PageRead                     0x03
#define W25Q_PageReadDual                 0x3B
#define W25Q_PageReadQuad                 0x6B
#define W25Q_PageReadQpi                  0x00
#define W25Q_Flash_ReadStatus             0x05
#define W25Q_Flash_WriteEn                0x06
#define W25Q_Flash_InstruWidth            0x08
#define W25Q_Flash_WaitBusyFlag           0x01
#define W25Q_Flash_WaitCycleDual          0x02
#define W25Q_Flash_WaitCycleQpi           0x02
#define W25Q_Flash_WaitCycleFastDual      0x08
#define W25Q_Flash_WaitCycleFastQuad      0x08
#define W25Q_Flash_QuadEnable             0x00
#define W25Q_Flash_QuadDisable            0x00
#define W25Q_Flash_ReadBusyCompltWait     400

/**************************GD25 Command and Attribute****************/
#define GD25_ReadIDCmd                    0x9F
#define GD25_SectorErase                  0x20
#define GD25_MultiSectorErase             0xD8
#define GD25_ChipErase                    0xC7
#define GD25_PageProg                     0x02
#define GD25_PageProgDual                 0x00
#define GD25_PageProgQuad                 0x32
#define GD25_PageProgQpi                  0x02
#define GD25_PageRead                     0x03
#define GD25_PageReadDual                 0x3B
#define GD25_PageReadQuad                 0x6B
#define GD25_PageReadQpi                  0x00
#define GD25_Flash_ReadStatus             0x05
#define GD25_Flash_WriteEn                0x06
#define GD25_Flash_InstruWidth            0x08
#define GD25_Flash_WaitBusyFlag           0x01
#define GD25_Flash_WaitCycleDual          0x00
#define GD25_Flash_WaitCycleQpi           0x00
#define GD25_Flash_WaitCycleFastDual      0x08
#define GD25_Flash_WaitCycleFastQuad      0x08
#define GD25_Flash_QuadEnable             0x00
#define GD25_Flash_QuadDisable            0x00
#define GD25_Flash_ReadBusyCompltWait     200


/**************************GD25 Command and Attribute****************/
#define MX25_ReadIDCmd                    0x9F
#define MX25_SectorErase                  0x20
#define MX25_SectorErase_4ByteAddr        0x21
#define MX25_MultiSectorErase             0xD8
#define MX25_MultiSectorErase_4ByteAddr   0xDC
#define MX25_ChipErase                    0xC7
#define MX25_PageProg                     0x02
#define MX25_PageProg_4ByteAddr           0x12
#define MX25_PageProgDual                 0x00
#define MX25_PageProgQuad                 0x00
#define MX25_PageProgQpi                  0x02
#define MX25_PageProgQpi_4ByteAddr        0x12
#define MX25_PageProg4xIo                 0x38
#define MX25_PageProg4xIo_4ByteAddr       0x3E

#define MX25_PageRead                     0x03
#define MX25_PageRead_4ByteAddr           0x13
#define MX25_PageReadDual                 0x3B
#define MX25_PageReadDual_4ByteAddr       0x3C
#define MX25_PageReadQuad                 0x6B
#define MX25_PageReadQpi                  0xEB
#define MX25_PageReadQpi_4ByteAddr        0xEC
#define MX25_PageRead4xIo                 0xEB
#define MX25_PageRead4xIo_4ByteAddr       0xEC

#define MX25_Flash_ReadStatus             0x05
#define MX25_Flash_WriteEn                0x06
#define MX25_Flash_InstruWidth            0x08
#define MX25_Flash_WaitBusyFlag           0x01
#define MX25_Flash_WaitCycleDual          0x00
#define MX25_Flash_WaitCycleQpi           0x06
#define MX25_Flash_WaitCycle4xIo          0x06
#define MX25_Flash_WaitCycleFastDual      0x08
#define MX25_Flash_WaitCycleFastQuad      0x08
#define MX25_Flash_QuadEnable             0x00
#define MX25_Flash_QuadDisable            0x00
#define MX25_Flash_QpiEnable              0x35
#define MX25_Flash_QpiDisable             0xf5
#define MX25_Flash_ReadBusyCompltWait     20

Status Hv_Drv_FlashDB_GetAttribute(FlashAttribute* pstFlashAttr, FlashModel enFlashModel);

#endif


