/**
  ******************************************************************************
  * @file    W25Q_Flash.h
  * @author  SINOMCU-AE
  * @brief   Header file of W25Q_Flash.c file.
  * 
  *          This file describes the w25Q macro definitions used:
  *              DeviceID, opration commands.
  * 
  ******************************************************************************
  * @attention 
  *                           DISCLAIMER
  * The present firmware which is for guidance only aims at providing customers
  * with coding information regarding their products in order for them to save
  * time. As a result, SinoMCU shall not be held liable for any direct,indirect
  * or consequential damages with respect to any claims arising from the content 
  * of such firmware and/or the use made by customers of the coding information 
  * contained herein in connection with their products.
  *
  * <h2><center>&copy; Copyright (c) 2021 sinomcu All rights reserved.</center></h2>
  *
  ******************************************************************************
  */

#ifndef __W25Q_FLASH_H
#define __W25Q_FLASH_H

#include "ms32f0xx.h"

#define DeviceID_W25Q80        0xEF13
#define DeviceID_W25Q16        0xEF14
#define DeviceID_W25Q32        0xEF15
#define DeviceID_W25Q64        0xEF16
#define DeviceID_W25Q128       0xEF17

//W25Q opration commands
#define W25X_WriteEnable       0x06 
#define W25X_WriteDisable      0x04 
#define W25X_ReadStatusReg     0x05 
#define W25X_WriteStatusReg    0x01 
#define W25X_ReadData          0x03 
#define W25X_FastReadData      0x0B 
#define W25X_PageProgram       0x02 
#define W25X_BlockErase        0xD8 
#define W25X_SectorErase       0x20 
#define W25X_ChipErase         0xC7 
#define W25X_PowerDown         0xB9 
#define W25X_ReleasePowerDown  0xAB 
#define W25X_DeviceID          0xAB 
#define W25X_ManufactDeviceID  0x90 
#define W25X_JedecDeviceID     0x9F 
//#define W25X_FastReadDual    0x3B 

// starus register busy bit
#define SPI_FLASH_SR_BUSY_POS   0x00
#define SPI_FLASH_SR_BUSY_MASK  (0x01 << SPI_FLASH_SR_BUSY_POS)

uint16_t SPI_Flash_ReadID(void);
void SPI_FLASH_Read(uint32_t ReadAddr,uint8_t* pBuffer,uint16_t NumByteToRead);  
void SPI_FLASH_Write_Page(uint32_t WriteAddr,uint8_t* pBuffer,uint8_t NumByteToWrite);
void SPI_FLASH_Erase_Sector(uint32_t Sector_Addr); 

#endif /* __W25Q_FLASH_H */ 

/******************************** END OF FILE *********************************/
