Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of W25Q64FVSSIG by
W25Q64FV.h
00001 #include <mbed.h> 00002 #include <stdint.h> 00003 00004 #define CMD_WREN 0x06 00005 #define CMD_WR_DISABLE 0x04 00006 #define CMD_RDSR1 0x05 00007 #define CMD_RDSR2 0x35 00008 #define CMD_WRSR1 0x01 //write status register 00009 #define CMD_PAGEPROG 0x02 00010 00011 #define CMD_ERASE_SECTOR 0x20 00012 #define CMD_ERASE_BLOCK32 0x52 00013 #define CMD_ERASE_BLOCK64 0xD8 00014 #define CMD_ERASE_CHIP 0x60 00015 00016 #define CMD_PROG_SUSPEND 0x75 00017 #define CMD_PROG_RESUME 0x7A 00018 #define CMD_PWR_DOWN 0xB9 00019 00020 #define CMD_READ_DATA 0x03 00021 #define CMD_READ_HS 0x0B 00022 00023 #define CMD_MANU_ID 0x90 00024 #define CMD_JEDEC_ID 0x9F // Read Manufacturer and JDEC Device ID 00025 #define CMD_UNIQUE_ID 0x4B 00026 00027 #define CMD_READ_SFDP 0x5A 00028 #define CMD_ERASE_SEC_REG 0x44 00029 #define CMD_PROG_SEC_REG 0x42 00030 #define CMD_READ_SEC_REG 0x48 00031 #define CMD_ENABLE_RES 0x66 00032 #define CMD_RESET 0x99 00033 00034 #define DUMMY 0x00 // Dummy byte which can be changed to any value 00035 00036 00037 class W25Q64FV 00038 { 00039 public: 00040 00041 static const int SID_LEN = 32; 00042 static const int SECTOR_LEN = 4096; 00043 static const int PAGE_LEN = 256; 00044 static const int MAX_ADDR = 0x7FFFFF; 00045 00046 private: 00047 00048 SPI* spi; 00049 DigitalOut* cs; 00050 00051 int frequency; 00052 static uint8_t sector_buffer[SECTOR_LEN]; 00053 00054 00055 public: 00056 W25Q64FV(PinName mosi, PinName miso, PinName sclk, PinName cs, int frequency=10000000); 00057 ~W25Q64FV(); 00058 00059 uint16_t Id(); 00060 uint32_t JEDECId(); 00061 void W25Q64_readManufacturer(uint8_t* d); 00062 00063 // Read Status Register 00064 // bit 0 BUSY 1=Write in progress 00065 // bit 1 WEL 1=Write Enabled 00066 // bit 2 BP0 block write protection 00067 // bit 3 BP1 block write protection 00068 // bit 4 BP2 block write protection 00069 // bit 5 BP3 block write protection 00070 // bit 6 SEC 1=Security ID space locked 00071 // bit 7 BPL 1=BP0..BP3 are read-only, 0=r/w 00072 uint8_t readStatus(); 00073 void writeStatusReg(int addr); // Write Status Register 00074 00075 void writeEnable(); // Write Enable 00076 void writeDisable(); // Write Disable 00077 00078 void writeSecurityReg(int addr); 00079 00080 uint8_t wait_while_busy(void); 00081 00082 uint8_t readByte(int32_t addr); 00083 bool read(uint32_t addr, uint8_t* dst, uint32_t len); 00084 00085 void hsread(uint32_t addr, uint8_t* dst, uint32_t len, int frequency); 00086 00087 00088 uint8_t readSFDP(int addr); 00089 00090 void sector_erase_4k(uint32_t addr); 00091 void block_erase_32k(uint32_t addr); 00092 void block_erase_64k(uint32_t addr); 00093 void chip_erase(); 00094 00095 bool page_program(uint32_t addr, uint8_t* write_buffer, uint8_t len); 00096 00097 bool write(int32_t addr, uint8_t* write_buffer, int32_t len); 00098 00099 void writeArray(uint32_t address, uint8_t* pData, uint32_t arrayLength); 00100 void readArray(uint32_t address, uint8_t* pData, uint32_t arrayLength); 00101 00102 00103 };
Generated on Fri Jul 15 2022 19:23:23 by
