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 SerialFlash by
SST25DeviceImpl.h@2:6f8ab876b516, 2011-03-02 (annotated)
- Committer:
- s_ain
- Date:
- Wed Mar 02 16:09:09 2011 +0000
- Revision:
- 2:6f8ab876b516
- Parent:
- 0:d0117f54a7ee
change SPI interface
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| s_ain | 0:d0117f54a7ee | 1 | #pragma once |
| s_ain | 0:d0117f54a7ee | 2 | |
| s_ain | 0:d0117f54a7ee | 3 | #include <string> |
| s_ain | 0:d0117f54a7ee | 4 | |
| s_ain | 2:6f8ab876b516 | 5 | class ISPICommand; |
| s_ain | 0:d0117f54a7ee | 6 | |
| s_ain | 0:d0117f54a7ee | 7 | class SST25DeviceImpl |
| s_ain | 0:d0117f54a7ee | 8 | { |
| s_ain | 0:d0117f54a7ee | 9 | public: |
| s_ain | 2:6f8ab876b516 | 10 | static bool IsSupported(ISPICommand* pSPICommand); |
| s_ain | 2:6f8ab876b516 | 11 | static SST25DeviceImpl* Create(ISPICommand* pSPICommand); |
| s_ain | 0:d0117f54a7ee | 12 | ~SST25DeviceImpl(void); |
| s_ain | 0:d0117f54a7ee | 13 | |
| s_ain | 0:d0117f54a7ee | 14 | std::string GetDeviceName() const; |
| s_ain | 0:d0117f54a7ee | 15 | int GetCapacity() const; |
| s_ain | 0:d0117f54a7ee | 16 | int Read(int address, void* buffer, int length); |
| s_ain | 0:d0117f54a7ee | 17 | int Write(int address, const void* buffer, int length); |
| s_ain | 0:d0117f54a7ee | 18 | void ChipErase(void); |
| s_ain | 0:d0117f54a7ee | 19 | |
| s_ain | 0:d0117f54a7ee | 20 | private: |
| s_ain | 2:6f8ab876b516 | 21 | ISPICommand* const _pSPICommand; |
| s_ain | 0:d0117f54a7ee | 22 | int _operationFrequency; |
| s_ain | 0:d0117f54a7ee | 23 | struct DeviceProperty |
| s_ain | 0:d0117f54a7ee | 24 | { |
| s_ain | 0:d0117f54a7ee | 25 | std::string deviceName; |
| s_ain | 0:d0117f54a7ee | 26 | int capacity; |
| s_ain | 0:d0117f54a7ee | 27 | int blockProtectionMask; |
| s_ain | 0:d0117f54a7ee | 28 | int pageSize; |
| s_ain | 0:d0117f54a7ee | 29 | void (SST25DeviceImpl::*pfnWriter)(int address, const void* buffer, int length); |
| s_ain | 0:d0117f54a7ee | 30 | |
| s_ain | 0:d0117f54a7ee | 31 | int operationClkHz; |
| s_ain | 0:d0117f54a7ee | 32 | } const& _property; |
| s_ain | 2:6f8ab876b516 | 33 | static const DeviceProperty* findMatchDevice(ISPICommand* pSPICommand); |
| s_ain | 0:d0117f54a7ee | 34 | |
| s_ain | 2:6f8ab876b516 | 35 | SST25DeviceImpl(ISPICommand* pSPICommand, const DeviceProperty& property); |
| s_ain | 2:6f8ab876b516 | 36 | static void readId(ISPICommand* pSPICommand, int& manufacturersId, int& deviceId); |
| s_ain | 2:6f8ab876b516 | 37 | static void fillAddress(char* pBuffer, int address); |
| s_ain | 0:d0117f54a7ee | 38 | |
| s_ain | 0:d0117f54a7ee | 39 | int readStatusRegister(void); |
| s_ain | 0:d0117f54a7ee | 40 | void writeStatusRegister(int value); |
| s_ain | 0:d0117f54a7ee | 41 | void writeEnable(void); |
| s_ain | 0:d0117f54a7ee | 42 | void writeDisable(void); |
| s_ain | 0:d0117f54a7ee | 43 | void waitForReady(void); |
| s_ain | 0:d0117f54a7ee | 44 | |
| s_ain | 0:d0117f54a7ee | 45 | void byteProgram(int address, int value); |
| s_ain | 0:d0117f54a7ee | 46 | void pageProgram(int address, const void* buffer); |
| s_ain | 0:d0117f54a7ee | 47 | void beginAAIProgram(int address, int data); |
| s_ain | 0:d0117f54a7ee | 48 | void nextAAIProgram(int data); |
| s_ain | 0:d0117f54a7ee | 49 | void endAAIProgram(void); |
| s_ain | 0:d0117f54a7ee | 50 | void beginAAIWordProgram(int address, int data); |
| s_ain | 0:d0117f54a7ee | 51 | void nextAAIWordProgram(int data); |
| s_ain | 0:d0117f54a7ee | 52 | |
| s_ain | 0:d0117f54a7ee | 53 | void writeBytes(int address, const void* buffer, int length); |
| s_ain | 0:d0117f54a7ee | 54 | void writeAAI(int address, const void* buffer, int length); |
| s_ain | 0:d0117f54a7ee | 55 | void writeAAIWord(int address, const void* buffer, int length); |
| s_ain | 0:d0117f54a7ee | 56 | void writePage(int address, const void* buffer, int length); |
| s_ain | 0:d0117f54a7ee | 57 | }; |
