50 lines
1.8 KiB
C
50 lines
1.8 KiB
C
#ifndef SPI_FLASH_H /* Guard against multiple inclusion */
|
|
#define SPI_FLASH_H
|
|
|
|
#define SPI_FLASH_READ 0x03
|
|
#define SPI_FLASH_HI_SPEED_READ 0x0b
|
|
#define SPI_FLASH_4KB_SECOTR_ERASE 0x20
|
|
#define SPI_FLASH_32KB_BLOCK_ERASE 0x52
|
|
#define SPI_FLASH_64KB_BLOCK_ERASE 0xd8
|
|
#define SPI_FLASH_CHIP_ERASE 0x60
|
|
#define SPI_FLASH_BYTE_PROGRAM 0x02
|
|
#define SPI_FLASH_AAI_WORD_PROGRAM 0xad
|
|
#define SPI_FLASH_READ_STATUS_REG 0x05
|
|
#define SPI_FLASH_ENABLE_WRITE_STATUS_REG 0x50
|
|
#define SPI_FLASH_WRITE_STATUS_REG 0x01
|
|
#define SPI_FLASH_WRITE_ENABLE 0x06
|
|
#define SPI_FLASH_WRITE_DISABLE 0x04
|
|
#define SPI_FLASH_READ_ID 0x90
|
|
#define SPI_FLASH_READ_JEDEC_ID 0x9f
|
|
#define SPI_FLASH_ENABLE_SO_BUSY 0x70
|
|
#define SPI_FLASH_DISABLE_SO_BUSY 0x80
|
|
|
|
|
|
#define SPI_FLASH_BUSY_MASK 0x01
|
|
|
|
#define SPI_FLASH_VENDOR_ID 0xBF
|
|
#define SPI_FLASH_CHIP_ID 0x41
|
|
#define SPI_FLASH_MAX_ADDRESS 0x1FFFFF
|
|
#define SPI_FLASH_SECTOR_SIZE 0x1000
|
|
#define SPI_FLASH_64K_SECTOR_SIZE 0x10000
|
|
#define SPI_NB_SECTORS 0x1FF //511 sectors = SPI_FLASH_MAX_ADDRESS / SPI_FLASH_SECTOR_SIZE
|
|
|
|
|
|
int InitSPIFlash();
|
|
int SPIFlashCheckChipID();
|
|
unsigned char SPIFlashReadStatusReg(int print);
|
|
int SPIFlashCheckAndConfigure();
|
|
int SPIFlashReadBuffer(unsigned char *Buf, int Size, int StartAddress);
|
|
int SPIFlashCheckBusy();
|
|
int SPIFlashWriteEnable();
|
|
int SPIFlashEraseSector(int SectorAddress);
|
|
int SPIFlashErase64KSector(int SectorAddress, int Blocking);
|
|
int SPIFlashWriteSectorWorkingBuffer(int SectorAddress, int Erase);
|
|
int SPIFlashWriteBuffer(unsigned char *Buf, int Size, int StartAddress);
|
|
int SPIFlashWriteByte(unsigned int ByteAddress, char byte, int blocking);
|
|
int SPIFlashIsPresent();
|
|
|
|
|
|
#endif /* SPI_FLASH_H */
|
|
|