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
Revision 2:6f8ab876b516, committed 2011-03-02
- Comitter:
- s_ain
- Date:
- Wed Mar 02 16:09:09 2011 +0000
- Parent:
- 1:385965a14c7c
- Commit message:
- change SPI interface
Changed in this revision
--- a/ISPI.h Wed Mar 02 00:28:03 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-#pragma once
-
-class ISPI
-{
-public:
- enum PinLevel
- {
- High,
- Low
- };
-
- virtual ~ISPI() {}
- virtual void SetFrequency(int frequency) = 0;
- virtual void ChangeCS(PinLevel pl) = 0;
- virtual void Write(int value) = 0;
- virtual int Read(void) = 0;
- virtual void Write(const void* buffer, int length) = 0;
- virtual void Read(void* buffer, int length) = 0;
-};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ISPICommand.h Wed Mar 02 16:09:09 2011 +0000
@@ -0,0 +1,14 @@
+#pragma once
+
+class ISPICommand
+{
+public:
+
+ virtual ~ISPICommand() {}
+ virtual void SetMaxFrequency(int frequency) = 0;
+
+ virtual void Write(int command) = 0;
+ virtual void Write(int command, const void* pParam, int length) = 0;
+ virtual void Read(int command, void* pReaded, int readLength) = 0;
+ virtual void Read(int command, const void* pParam, int paramLength, void* pReaded, int readLength) = 0;
+};
--- a/M25PDevice.cpp Wed Mar 02 00:28:03 2011 +0000
+++ b/M25PDevice.cpp Wed Mar 02 16:09:09 2011 +0000
@@ -2,14 +2,14 @@
#include "M25PDeviceImpl.h"
#include "M25PDevice.h"
-bool M25PDevice::IsSupported(ISPI* pSPI)
+bool M25PDevice::IsSupported(ISPICommand* pSPICommand)
{
- return M25PDeviceImpl::IsSupported(pSPI);
+ return M25PDeviceImpl::IsSupported(pSPICommand);
}
-M25PDevice* M25PDevice::Create(ISPI* pSPI)
+M25PDevice* M25PDevice::Create(ISPICommand* pSPICommand)
{
- M25PDeviceImpl* pImpl = M25PDeviceImpl::Create(pSPI);
+ M25PDeviceImpl* pImpl = M25PDeviceImpl::Create(pSPICommand);
if (pImpl == NULL)
{
return NULL;
--- a/M25PDevice.h Wed Mar 02 00:28:03 2011 +0000
+++ b/M25PDevice.h Wed Mar 02 16:09:09 2011 +0000
@@ -4,14 +4,14 @@
#include <string>
#include "ISerialFlashDevice.h"
-class ISPI;
+class ISPICommand;
class M25PDeviceImpl;
class M25PDevice : public ISerialFlashDevice
{
public:
- static M25PDevice* Create(ISPI* pSPI);
- static bool IsSupported(ISPI* pSPI);
+ static M25PDevice* Create(ISPICommand* pSPICommand);
+ static bool IsSupported(ISPICommand* pSPICommand);
virtual std::string GetDeviceName(void) const;
virtual int GetCapacity(void) const;
--- a/M25PDeviceImpl.cpp Wed Mar 02 00:28:03 2011 +0000
+++ b/M25PDeviceImpl.cpp Wed Mar 02 16:09:09 2011 +0000
@@ -1,13 +1,13 @@
-#include "ISPI.h"
+#include "ISPICommand.h"
#include <string.h>
#include "M25PDeviceImpl.h"
-const M25PDeviceImpl::DeviceProperty* M25PDeviceImpl::findMatchDevice(ISPI* pSPI)
+const M25PDeviceImpl::DeviceProperty* M25PDeviceImpl::findMatchDevice(ISPICommand* pSPICommand)
{
int manufacturerId;
int memoryType;
int memoryCapacity;
- readId(pSPI, manufacturerId, memoryType, memoryCapacity);
+ readId(pSPICommand, manufacturerId, memoryType, memoryCapacity);
struct SupportedDevice
{
@@ -46,26 +46,25 @@
return NULL;
}
-bool M25PDeviceImpl::IsSupported(ISPI* pSPI)
+bool M25PDeviceImpl::IsSupported(ISPICommand* pSPICommand)
{
- return findMatchDevice(pSPI) != NULL;
+ return findMatchDevice(pSPICommand) != NULL;
}
-M25PDeviceImpl* M25PDeviceImpl::Create(ISPI* pSPI)
+M25PDeviceImpl* M25PDeviceImpl::Create(ISPICommand* pSPICommand)
{
- const DeviceProperty* property = findMatchDevice(pSPI);
+ const DeviceProperty* property = findMatchDevice(pSPICommand);
if (property == NULL)
{
return NULL;
}
- return new M25PDeviceImpl(pSPI, *property);
+ return new M25PDeviceImpl(pSPICommand, *property);
}
-M25PDeviceImpl::M25PDeviceImpl(ISPI* pSPI, const DeviceProperty& property)
- : _pSPI(pSPI)
+M25PDeviceImpl::M25PDeviceImpl(ISPICommand* pSPICommand, const DeviceProperty& property)
+ : _pSPICommand(pSPICommand)
, _property(property)
{
- pSPI->ChangeCS(ISPI::High);
clearBlockProtection();
}
@@ -74,48 +73,39 @@
}
-void M25PDeviceImpl::readId(ISPI* pSPI, int& manufacturerId, int& memoryType, int& memoryCapacity)
+void M25PDeviceImpl::readId(ISPICommand* pSPICommand, int& manufacturerId, int& memoryType, int& memoryCapacity)
{
const static int DefaultOperationFrequency = 20000000;
- pSPI->SetFrequency(DefaultOperationFrequency);
+ pSPICommand->SetMaxFrequency(DefaultOperationFrequency);
- pSPI->ChangeCS(ISPI::Low);
- pSPI->Write(0x9f);
- manufacturerId = pSPI->Read();
- memoryType = pSPI->Read();
- memoryCapacity = pSPI->Read();
- pSPI->ChangeCS(ISPI::High);
+ unsigned char id[3];
+ pSPICommand->Read(0x9f, id, sizeof(id));
+ manufacturerId = id[0];
+ memoryType = id[1];
+ memoryCapacity = id[2];
}
int M25PDeviceImpl::readStatusRegister(void)
{
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0x05);
- int result = _pSPI->Read();
- _pSPI->ChangeCS(ISPI::High);
- return result;
+ unsigned char status;
+ _pSPICommand->Read(0x05, &status, 1);
+ return status;
}
void M25PDeviceImpl::writeStatusRegister(int value)
{
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0x01);
- _pSPI->Write(value);
- _pSPI->ChangeCS(ISPI::High);
+ char vb = static_cast<char>(value);
+ _pSPICommand->Write(0x01, &vb, 1);
}
void M25PDeviceImpl::writeEnable()
{
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0x06);
- _pSPI->ChangeCS(ISPI::High);
+ _pSPICommand->Write(0x06);
}
void M25PDeviceImpl::writeDisable()
{
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0x04);
- _pSPI->ChangeCS(ISPI::High);
+ _pSPICommand->Write(0x04);
}
void M25PDeviceImpl::clearBlockProtection(void)
@@ -152,15 +142,19 @@
return 0;
}
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0x0b);
- writeAddress(address);
- _pSPI->Write(0xff);
- _pSPI->Read(buffer, length);
- _pSPI->ChangeCS(ISPI::High);
+ char param[] = { 0, 0, 0, 0xff };
+ fillAddress(param, address);
+ _pSPICommand->Read(0x0b, param, sizeof(param), buffer, length);
return length;
}
+void M25PDeviceImpl::fillAddress(char* pBuffer, int address)
+{
+ *(pBuffer + 0) = (address & 0xff0000) >> 16;
+ *(pBuffer + 1) = (address & 0x00ff00) >> 8;
+ *(pBuffer + 2) = (address & 0x0000ff);
+}
+
int M25PDeviceImpl::Write(int address, const void* buffer, int length)
{
if (address >= GetCapacity())
@@ -221,32 +215,22 @@
{
writeEnable();
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0xc7);
- _pSPI->ChangeCS(ISPI::High);
-
+ _pSPICommand->Write(0xc7);
+
while (readStatusRegister() & 0x01)
;
clearBlockProtection();
}
-void M25PDeviceImpl::writeAddress(int address)
-{
- _pSPI->Write((address & 0xff0000) >> 16);
- _pSPI->Write((address & 0xff00) >> 8);
- _pSPI->Write(address & 0xff);
-}
-
void M25PDeviceImpl::pageProgram(int address, const void* buffer)
{
writeEnable();
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0x02);
- writeAddress(address);
- _pSPI->Write(buffer, 256);
- _pSPI->ChangeCS(ISPI::High);
+ char param[256 + 3];
+ fillAddress(param, address);
+ memcpy(param + 3, buffer, 256);
+ _pSPICommand->Write(0x02, param, sizeof(param));
while (readStatusRegister() & 0x01)
;
--- a/M25PDeviceImpl.h Wed Mar 02 00:28:03 2011 +0000
+++ b/M25PDeviceImpl.h Wed Mar 02 16:09:09 2011 +0000
@@ -2,13 +2,13 @@
#include <string>
-class ISPI;
+class ISPICommand;
class M25PDeviceImpl
{
public:
- static bool IsSupported(ISPI* pSPI);
- static M25PDeviceImpl* Create(ISPI* pSPI);
+ static bool IsSupported(ISPICommand* pSPICommand);
+ static M25PDeviceImpl* Create(ISPICommand* pSPICommand);
~M25PDeviceImpl(void);
std::string GetDeviceName() const;
@@ -18,7 +18,7 @@
void BulkErase(void);
private:
- ISPI* _pSPI;
+ ISPICommand* _pSPICommand;
int _operationFrequency;
struct DeviceProperty
{
@@ -26,11 +26,11 @@
int capacity;
int blockProtectionMask;
} const& _property;
- static const DeviceProperty* findMatchDevice(ISPI* pSPI);
+ static const DeviceProperty* findMatchDevice(ISPICommand* pSPI);
- M25PDeviceImpl(ISPI* pSPI, const DeviceProperty& property);
- void writeAddress(int address);
- static void readId(ISPI* pSPI, int& manufacturerId, int& memoryType, int& memoryCapacity);
+ M25PDeviceImpl(ISPICommand* pSPICommand, const DeviceProperty& property);
+ static void readId(ISPICommand* pSPICommand, int& manufacturerId, int& memoryType, int& memoryCapacity);
+ static void fillAddress(char* pBuffer, int address);
int readStatusRegister(void);
void clearBlockProtection(void);
--- a/SST25Device.cpp Wed Mar 02 00:28:03 2011 +0000
+++ b/SST25Device.cpp Wed Mar 02 16:09:09 2011 +0000
@@ -2,14 +2,14 @@
#include "SST25DeviceImpl.h"
#include "SST25Device.h"
-bool SST25Device::IsSupported(ISPI* pSPI)
+bool SST25Device::IsSupported(ISPICommand* pSPICommand)
{
- return SST25DeviceImpl::IsSupported(pSPI);
+ return SST25DeviceImpl::IsSupported(pSPICommand);
}
-SST25Device* SST25Device::Create(ISPI* pSPI)
+SST25Device* SST25Device::Create(ISPICommand* pSPICommand)
{
- SST25DeviceImpl* pImpl = SST25DeviceImpl::Create(pSPI);
+ SST25DeviceImpl* pImpl = SST25DeviceImpl::Create(pSPICommand);
if (pImpl == NULL)
{
return NULL;
--- a/SST25Device.h Wed Mar 02 00:28:03 2011 +0000
+++ b/SST25Device.h Wed Mar 02 16:09:09 2011 +0000
@@ -4,14 +4,14 @@
#include <string>
#include "ISerialFlashDevice.h"
-class ISPI;
+class ISPICommand;
class SST25DeviceImpl;
class SST25Device : public ISerialFlashDevice
{
public:
- static SST25Device* Create(ISPI* pSPI);
- static bool IsSupported(ISPI* pSPI);
+ static SST25Device* Create(ISPICommand* pSPICommand);
+ static bool IsSupported(ISPICommand* pSPICommand);
virtual std::string GetDeviceName(void) const;
virtual int GetCapacity(void) const;
--- a/SST25DeviceImpl.cpp Wed Mar 02 00:28:03 2011 +0000
+++ b/SST25DeviceImpl.cpp Wed Mar 02 16:09:09 2011 +0000
@@ -1,12 +1,12 @@
-#include "ISPI.h"
+#include "ISPICommand.h"
#include <string.h>
#include "SST25DeviceImpl.h"
-const SST25DeviceImpl::DeviceProperty* SST25DeviceImpl::findMatchDevice(ISPI* pSPI)
+const SST25DeviceImpl::DeviceProperty* SST25DeviceImpl::findMatchDevice(ISPICommand* pSPICommand)
{
int manufacturersId;
int deviceId;
- readId(pSPI, manufacturersId, deviceId);
+ readId(pSPICommand, manufacturersId, deviceId);
struct SupportedDevice
{
@@ -56,7 +56,7 @@
0xe3,
1,
&SST25DeviceImpl::writeAAIWord,
- 46000000
+ 50000000
},
},
//SST25xF080B 8MBit (1MByte)
@@ -67,7 +67,7 @@
0xe3,
1,
&SST25DeviceImpl::writeAAIWord,
- 46000000
+ 50000000
},
},
//SST25xF016B 16MBit (2MByte)
@@ -78,7 +78,7 @@
0xe3,
1,
&SST25DeviceImpl::writeAAIWord,
- 46000000
+ 50000000
},
},
//SST25xF032B 32MBit (4MByte)
@@ -89,7 +89,7 @@
0xc3,
1,
&SST25DeviceImpl::writeAAIWord,
- 46000000
+ 50000000
},
},
//SST25xF064C 64MBit (8MByte)
@@ -100,7 +100,7 @@
0xc3,
256,
&SST25DeviceImpl::writePage,
- 46000000
+ 50000000
},
}
};
@@ -116,27 +116,26 @@
return NULL;
}
-bool SST25DeviceImpl::IsSupported(ISPI* pSPI)
+bool SST25DeviceImpl::IsSupported(ISPICommand* pSPICommand)
{
- return findMatchDevice(pSPI) != NULL;
+ return findMatchDevice(pSPICommand) != NULL;
}
-SST25DeviceImpl* SST25DeviceImpl::Create(ISPI* pSPI)
+SST25DeviceImpl* SST25DeviceImpl::Create(ISPICommand* pSPICommand)
{
- const DeviceProperty* property = findMatchDevice(pSPI);
+ const DeviceProperty* property = findMatchDevice(pSPICommand);
if (property == NULL)
{
return NULL;
}
- return new SST25DeviceImpl(pSPI, *property);
+ return new SST25DeviceImpl(pSPICommand, *property);
}
-SST25DeviceImpl::SST25DeviceImpl(ISPI* pSPI, const DeviceProperty& property)
- : _pSPI(pSPI)
+SST25DeviceImpl::SST25DeviceImpl(ISPICommand* pSPICommand, const DeviceProperty& property)
+ : _pSPICommand(pSPICommand)
, _property(property)
{
- _pSPI->ChangeCS(ISPI::High);
- _pSPI->SetFrequency(_property.operationClkHz);
+ _pSPICommand->SetMaxFrequency(_property.operationClkHz);
}
SST25DeviceImpl::~SST25DeviceImpl(void)
@@ -144,40 +143,32 @@
}
-void SST25DeviceImpl::readId(ISPI* pSPI, int& manufacturersId, int& deviceId)
+void SST25DeviceImpl::readId(ISPICommand* pSPICommand, int& manufacturersId, int& deviceId)
{
const static int DefaultOperationFrequency = 20000000;
- pSPI->SetFrequency(DefaultOperationFrequency);
+ pSPICommand->SetMaxFrequency(DefaultOperationFrequency);
- pSPI->ChangeCS(ISPI::Low);
- pSPI->Write(0x90);
- pSPI->Write(0x00);
- pSPI->Write(0x00);
- pSPI->Write(0x00);
- manufacturersId = pSPI->Read();
- deviceId = pSPI->Read();
- pSPI->ChangeCS(ISPI::High);
+ unsigned char read[2];
+ char param[3];
+ fillAddress(param, 0x000000);
+ pSPICommand->Read(0x90, param, sizeof(param), read, sizeof(read));
+ manufacturersId = read[0];
+ deviceId = read[1];
}
int SST25DeviceImpl::readStatusRegister(void)
{
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0x05);
- int result = _pSPI->Read();
- _pSPI->ChangeCS(ISPI::High);
- return result;
+ unsigned char read;
+ _pSPICommand->Read(0x05, &read, 1);
+ return read;
}
void SST25DeviceImpl::writeStatusRegister(int value)
{
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0x50);
- _pSPI->ChangeCS(ISPI::High);
+ _pSPICommand->Write(0x50);
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0x01);
- _pSPI->Write(value);
- _pSPI->ChangeCS(ISPI::High);
+ char vb = static_cast<char>(value);
+ _pSPICommand->Write(0x01, &vb, sizeof(vb));
}
void SST25DeviceImpl::writeEnable()
@@ -185,17 +176,12 @@
int status = readStatusRegister();
status &= _property.blockProtectionMask;
writeStatusRegister(status);
-
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0x06);
- _pSPI->ChangeCS(ISPI::High);
+ _pSPICommand->Write(0x06);
}
void SST25DeviceImpl::writeDisable()
{
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0x04);
- _pSPI->ChangeCS(ISPI::High);
+ _pSPICommand->Write(0x04);
}
void SST25DeviceImpl::waitForReady()
@@ -229,14 +215,11 @@
return 0;
}
- _pSPI->SetFrequency(_property.operationClkHz);
+ _pSPICommand->SetMaxFrequency(_property.operationClkHz);
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0x0b);
- writeAddress(address);
- _pSPI->Write(0xff);
- _pSPI->Read(buffer, length);
- _pSPI->ChangeCS(ISPI::High);
+ char param[] = { 0, 0, 0, 0xff };
+ fillAddress(param, address);
+ _pSPICommand->Read(0x0b, param, sizeof(param), buffer, length);
return length;
}
@@ -260,104 +243,89 @@
void SST25DeviceImpl::ChipErase()
{
- _pSPI->SetFrequency(_property.operationClkHz);
+ _pSPICommand->SetMaxFrequency(_property.operationClkHz);
writeEnable();
-
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0x60);
- _pSPI->ChangeCS(ISPI::High);
+ _pSPICommand->Write(0x60);
waitForReady();
}
void SST25DeviceImpl::byteProgram(int address, int value)
{
- _pSPI->SetFrequency(_property.operationClkHz);
+ _pSPICommand->SetMaxFrequency(_property.operationClkHz);
writeEnable();
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0x02);
- writeAddress(address);
- _pSPI->Write(value);
- _pSPI->ChangeCS(ISPI::High);
+ char param[] = { 0, 0, 0, value };
+ fillAddress(param, address);
+ _pSPICommand->Write(0x02, param, sizeof(param));
+
waitForReady();
}
void SST25DeviceImpl::beginAAIProgram(int address, int data)
{
- _pSPI->SetFrequency(_property.operationClkHz);
+ _pSPICommand->SetMaxFrequency(_property.operationClkHz);
writeEnable();
+
+ char param[] = { 0, 0, 0, data };
+ fillAddress(param, address);
+ _pSPICommand->Write(0xaf, param, sizeof(param));
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0xaf);
- writeAddress(address);
- _pSPI->Write(data);
- _pSPI->ChangeCS(ISPI::High);
waitForReady();
}
void SST25DeviceImpl::nextAAIProgram(int data)
{
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0xaf);
- _pSPI->Write(data);
- _pSPI->ChangeCS(ISPI::High);
+ char param = static_cast<char>(data);
+ _pSPICommand->Write(0xaf, ¶m, 1);
+
waitForReady();
}
void SST25DeviceImpl::endAAIProgram(void)
{
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0x04);
- _pSPI->ChangeCS(ISPI::High);
+ _pSPICommand->Write(0x04);
waitForReady();
}
void SST25DeviceImpl::beginAAIWordProgram(int address, int data)
{
- _pSPI->SetFrequency(_property.operationClkHz);
+ _pSPICommand->SetMaxFrequency(_property.operationClkHz);
writeEnable();
-
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0xad);
- writeAddress(address);
- _pSPI->Write((data & 0xff00) >> 8);
- _pSPI->Write(data & 0xff);
- _pSPI->ChangeCS(ISPI::High);
+ char param[] = { 0, 0, 0, (data & 0xff00) >> 8, data & 0xff };
+ fillAddress(param, address);
+ _pSPICommand->Write(0xad, param, sizeof(param));
waitForReady();
}
void SST25DeviceImpl::nextAAIWordProgram(int data)
{
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0xad);
- _pSPI->Write((data & 0xff00) >> 8);
- _pSPI->Write(data & 0xff);
- _pSPI->ChangeCS(ISPI::High);
+ char param[] = { (data & 0xff00) >> 8, data & 0xff };
+ _pSPICommand->Write(0xad, param, sizeof(param));
waitForReady();
}
-void SST25DeviceImpl::writeAddress(int address)
+void SST25DeviceImpl::fillAddress(char* pBuffer, int address)
{
- _pSPI->Write((address & 0xff0000) >> 16);
- _pSPI->Write((address & 0xff00) >> 8);
- _pSPI->Write(address & 0xff);
+ *(pBuffer + 0) = (address & 0xff0000) >> 16;
+ *(pBuffer + 1) = (address & 0x00ff00) >> 8;
+ *(pBuffer + 2) = (address & 0x0000ff);
}
void SST25DeviceImpl::pageProgram(int address, const void* buffer)
{
- _pSPI->SetFrequency(_property.operationClkHz);
+ _pSPICommand->SetMaxFrequency(_property.operationClkHz);
writeEnable();
- _pSPI->ChangeCS(ISPI::Low);
- _pSPI->Write(0x02);
- writeAddress(address);
- _pSPI->Write(buffer, 256);
- _pSPI->ChangeCS(ISPI::High);
+ char param[256 + 3];
+ fillAddress(param, address);
+ memcpy(param + 3, buffer, 256);
+ _pSPICommand->Write(0x02, param, sizeof(param));
+
waitForReady();
}
--- a/SST25DeviceImpl.h Wed Mar 02 00:28:03 2011 +0000
+++ b/SST25DeviceImpl.h Wed Mar 02 16:09:09 2011 +0000
@@ -2,13 +2,13 @@
#include <string>
-class ISPI;
+class ISPICommand;
class SST25DeviceImpl
{
public:
- static bool IsSupported(ISPI* pSPI);
- static SST25DeviceImpl* Create(ISPI* pSPI);
+ static bool IsSupported(ISPICommand* pSPICommand);
+ static SST25DeviceImpl* Create(ISPICommand* pSPICommand);
~SST25DeviceImpl(void);
std::string GetDeviceName() const;
@@ -18,7 +18,7 @@
void ChipErase(void);
private:
- ISPI* const _pSPI;
+ ISPICommand* const _pSPICommand;
int _operationFrequency;
struct DeviceProperty
{
@@ -30,11 +30,11 @@
int operationClkHz;
} const& _property;
- static const DeviceProperty* findMatchDevice(ISPI* pSPI);
+ static const DeviceProperty* findMatchDevice(ISPICommand* pSPICommand);
- SST25DeviceImpl(ISPI* pSPI, const DeviceProperty& property);
- void writeAddress(int address);
- static void readId(ISPI* pSPI, int& manufacturersId, int& deviceId);
+ SST25DeviceImpl(ISPICommand* pSPICommand, const DeviceProperty& property);
+ static void readId(ISPICommand* pSPICommand, int& manufacturersId, int& deviceId);
+ static void fillAddress(char* pBuffer, int address);
int readStatusRegister(void);
void writeStatusRegister(int value);
--- a/SerialFlashDeviceCreator.cpp Wed Mar 02 00:28:03 2011 +0000
+++ b/SerialFlashDeviceCreator.cpp Wed Mar 02 16:09:09 2011 +0000
@@ -3,15 +3,15 @@
#include "M25PDevice.h"
#include "SerialFlashDeviceCreator.h"
-ISerialFlashDevice* SerialFlashDeviceCreator::Create(ISPI* pSPI)
+ISerialFlashDevice* SerialFlashDeviceCreator::Create(ISPICommand* pSPICommand)
{
- if (M25PDevice::IsSupported(pSPI))
+ if (M25PDevice::IsSupported(pSPICommand))
{
- return M25PDevice::Create(pSPI);
+ return M25PDevice::Create(pSPICommand);
}
- if (SST25Device::IsSupported(pSPI))
+ if (SST25Device::IsSupported(pSPICommand))
{
- return SST25Device::Create(pSPI);
+ return SST25Device::Create(pSPICommand);
}
return NULL;
}
--- a/SerialFlashDeviceCreator.h Wed Mar 02 00:28:03 2011 +0000
+++ b/SerialFlashDeviceCreator.h Wed Mar 02 16:09:09 2011 +0000
@@ -2,10 +2,10 @@
#include "ISerialFlashDevice.h"
-class ISPI;
+class ISPICommand;
class SerialFlashDeviceCreator
{
public:
- static ISerialFlashDevice* Create(ISPI* pSPI);
+ static ISerialFlashDevice* Create(ISPICommand* pSPICommand);
};
