22 #ifndef __MODULE_WINDBOND32_H 
   23 #define __MODULE_WINDBOND32_H 
   30 #include "simplefs_config.h" 
   46 #define MEMORY_MANUFACTURER_WINBOND     0xEF 
   47 #define MEMORY_MANUFACTURER_MICRON      0x20 
   48 #define MEMORY_MANUFACTURER_CYPRESS     0x01 
   51 #define W_SR        0x01    //write status reg 
   52 #define PAGE_PGM    0x02    //page program 
   54 #define W_DE        0x04    //write disable 
   55 #define R_SR1       0x05    //read status reg 1 
   56 #define W_EN        0x06    //write enable 
   57 #define FAST_READ   0x0b 
   58 #define SECTOR_E    0x20    //sector erase 4KB 
   59 #define QPAGE_PGM   0x32    //quad input page program 
   60 #define READ_DSPI   0x3B 
   61 #define R_SR2       0x35    //read status reg 2 
   62 #define R_UNIQUE_ID 0x4b    //read unique ID (suggested) 
   63 #define W_SR_ENABLE 0x50 
   64 #define CHIP_ERASE2 0x60    //=CHIP_ERASE 
   65 #define BLK_E_32K   0x52    //block erase 32KB 
   66 #define E_SUSPEND   0x75    //erase suspend 
   67 #define E_RESUME    0x7a    //erase resume 
   68 #define R_MANUF_ID  0x90    //read Manufacturer and Dev ID (deprecated) 
   69 #define R_JEDEC_ID  0x9f    //read JEDEC ID = Manuf+ID (suggested) 
   70 #define HIGH_PERF_M 0xa3    //high performance mode 
   71 #define RELEASE     0xab    //release power down or HPM/Dev ID (deprecated) 
   72 #define PDWN        0xb9    //power down 
   73 #define CHIP_ERASE  0xc7    //chip erase 
   74 #define BLK_E_64K   0xD8    //block erase 64KB 
   75 #define CONT_R_RST  0xff    //continuous read mode reset 
   78 #define SR1_BUSY_MASK   0x01 
   79 #define SR1_WEN_MASK    0x02 
   80 #define WINBOND_MANUF   0xef 
   81 #define DEFAULT_TIMEOUT 200 
   82 #define WINBOND_32_PAGE     256 
   84 #define WINBOND_32_SECTOR_SIZE   WINBOND_32_PAGE*16 
   85 #define WINBOND_32_SECTOR_COUNT   1024 
   90 typedef enum __winbond_status_mem_ {
 
   95 } Winbond_memoryStatus;
 
   98 #if USE_SPI_INTERFACE == NO_SPI 
  101 #if USE_SPI_INTERFACE == USE_SPI 
  103         SPI_HandleTypeDef *spi;
 
  108 #if USE_SPI_INTERFACE == USE_QSPI 
  110         QSPI_HandleTypeDef *spi;
 
  116         GPIO_TypeDef* PortCS;
 
  126 #if USE_SPI_INTERFACE == NO_SPI 
  129 #if USE_SPI_INTERFACE == USE_SPI 
  130 uint8_t 
winbond_init(
void *hspi, 
void *GPIOx, uint16_t GPIO_Pin);
 
  132 #if USE_SPI_INTERFACE == USE_QSPI 
  137 uint8_t winbond_isBusy(
void);
 
  138 uint16_t winbond_readSR(
void);
 
  139 uint8_t winbond_readManufacturer(
void);
 
  140 uint64_t winbond_readUniqueID();
 
  141 uint8_t winbond_readMemoryType(
void);
 
  142 uint8_t winbond_readCapacity(
void);
 
  143 uint16_t winbond_read(uint32_t addr,uint8_t *buf,uint16_t n);
 
  144 uint16_t winbond_read_DMA(uint32_t addr,uint8_t *buf,uint16_t n);
 
  145 uint16_t winbond_write(uint32_t addr,uint8_t *buf,int32_t n);
 
  146 uint8_t winbond_powerDown(
void);
 
  147 uint8_t winbond_powerUp(
void);
 
  148 uint8_t winbond_eraseSector(uint32_t addr_start);
 
  149 uint8_t winbond_eraseAll(
void);
 
  150 Winbond_memoryStatus winbond_checkSector(uint16_t sector_index);
 
  151 uint8_t winbond_writeToMemory(uint32_t address, uint8_t *buf,uint16_t n);
 
  152 uint8_t *winbond_readChipInfo(
void);
 
  153 void winbond_dump(
void);
 
  155 uint8_t winbond_dma_cmplt();
 
  156 uint8_t winbond_dma_half();