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.
Dependents: SPI_SRAM_READ_WRITE
S2568FBLL.h
00001 // S2568FBLL.h 00002 00003 //Instruction Name Instruction Format Hex 00004 //Code Description 00005 //READ 0000 0011 0x03 Read data from memory array beginning at selected address 00006 //WRITE 0000 0010 0x02 Write data to memory array beginning at selected address 00007 //ESDI 0011 1011 0x3B Enter SDI mode 00008 //ESQI 0011 1000 0x38 Enter SQI mode 00009 //RSTDQI 1111 1111 0xFF Reset SDI/SQI mode 00010 //RDMR 0000 0101 0x05 Read Mode Register 00011 //WRMR 0000 0001 0x01 Write Mode Register 00012 00013 #ifndef S2568FBLL_H 00014 #define S2568FBLL_H 00015 00016 #include "mbed.h" 00017 #include <string> 00018 00019 #define SPI_FREQ 5000000 //Change SPI Frequency Here 00020 #define SPI_MODE 0 // SPI Mode can be 0 or 3 . see data sheet 00021 #define SPI_NBIT 8 // Number of bits 8. 00022 00023 00024 00025 #define DUMMY_ADDR 0x00 00026 #define WAIT_TIME 1 00027 00028 #define ADDR_BMASK3 0xff000000 00029 #define ADDR_BMASK2 0x00ff0000 00030 #define ADDR_BMASK1 0x0000ff00 00031 #define ADDR_BMASK0 0x000000ff 00032 00033 #define ADDR_BSHIFT3 24 00034 #define ADDR_BSHIFT2 16 00035 #define ADDR_BSHIFT1 8 00036 #define ADDR_BSHIFT0 0 00037 00038 #define READ 0x03 // Read data from memory array beginning at selected address 00039 #define WRITE 0x02 //Write data to memory array beginning at selected address 00040 #define ESDI 0x3B //Enter SDI mode 00041 #define ESQI 0x38 //Enter SQI mode 00042 #define RSTDQI 0xFF //Reset SDI/SQI mode 00043 #define RDMR 0x05 //Read Mode Register 00044 #define WRMR 0x01 //Write Mode Register 00045 00046 #define RWMODE_BYTE 0x00 //7th bit=0 and 6th bit =0 Byte mode 5 TO 0 BITS ARE RESERVED FOR FUTURE 00047 #define RWMODE_PAGE 0x80 // 1 0 Page mode 00048 #define RWMODE_SEQ 0x40 // 0 1= Sequential mode (default operation) 00049 00050 00051 00052 class S2568FBLL: public SPI { 00053 public: 00054 S2568FBLL(PinName mosi, PinName miso, PinName sclk, PinName cs,PinName hold); 00055 00056 int readByte(int addr); // takes a 24-bit (3 bytes) address and returns the data (1 byte) at that location 00057 void readStream(int addr, char* buf, int count); // takes a 24-bit address, reads count bytes, and stores results in buf 00058 void writeByte(int addr, int data); // takes a 24-bit (3 bytes) address and a byte of data to write at that location 00059 void writeStream(int addr, char* buf, int count); // write count bytes of data from buf to memory, starting at addr 00060 void writeString(int add, string str); 00061 long raedLong(int addr); 00062 void writeLong(int addr, long value); 00063 uint8_t readRegister(void); // Write Long Integer Number 00064 private: 00065 00066 void writeRegister(uint8_t regValue); 00067 void chipEnable(); // chip enable 00068 void chipDisable(); 00069 void holdEnable(); 00070 void holdDisable(); 00071 // chip disable 00072 00073 // SPI _spi; 00074 DigitalOut _cs; 00075 DigitalOut _hold; 00076 }; 00077 00078 #endif
Generated on Wed Jul 27 2022 03:44:01 by
1.7.2