Skip to content

Commit

Permalink
Rev.G. Add SRAM device and update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
robsonsmartins committed Dec 19, 2023
1 parent dd391a7 commit fc4fc95
Show file tree
Hide file tree
Showing 11 changed files with 1,609 additions and 25 deletions.
1,567 changes: 1,567 additions & 0 deletions docs/devices_sram.graphml

Large diffs are not rendered by default.

Binary file added docs/img/devices_sram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/devices_sram_resetbus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/devices_sram_test1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/devices_sram_test2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/specs.odt
Binary file not shown.
Binary file modified docs/specs.pdf
Binary file not shown.
12 changes: 10 additions & 2 deletions software/usbflashprog/backend/devices/parallel/dummy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,27 @@ class Dummy : public Device {
explicit Dummy(QObject *parent = nullptr);
/** @brief Destructor. */
virtual ~Dummy();

/* Reimplemented */
virtual void setSize(uint32_t value);

/* Reimplemented */
virtual bool getId(TDeviceID &result);
/* Reimplemented */
virtual bool read(QByteArray &buffer);
/* Reimplemented */
virtual bool program(const QByteArray &buffer, bool verify = false);
/* Reimplemented */
virtual bool verify(const QByteArray &buffer);
/* Reimplemented */
virtual bool erase(bool check = false);
/* Reimplemented */
virtual bool blankCheck();
/* Reimplemented */
virtual bool unprotect();

protected:
/* @brief The internal buffer. */
QByteArray buffer_;
/* @brief Indicates if is write protected. */
bool protected_;
};

Expand Down
30 changes: 12 additions & 18 deletions software/usbflashprog/backend/devices/parallel/sram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,25 @@ bool SRAM::program(const QByteArray &buffer, bool verify) {
runner_.vddSet(info_.voltage.vddProgram);
runner_.vddCtrl();
runner_.setCE();
if (!doPatternTest_(current, total)) {
error = true;
}
if (!doRandomTest_(current, total)) {
runner_.usDelay(30); // 30 uS
if (!doPatternTest_(current, total) || !doRandomTest_(current, total)) {
error = true;
}
resetBus_();
if (!error) {
error = runner_.hasError();
if (error) {
// fail (error)
emit onProgress(total, total, true, false);
}
}
runner_.close();
} else {
// fail (no open port)
emit onProgress(0, total, true, false);
}
if (!error) {
// success (done)
emit onProgress(total, total, true);
}
return !error;
Expand All @@ -71,26 +72,18 @@ bool SRAM::program(const QByteArray &buffer, bool verify) {
bool SRAM::doPatternTest_(uint32_t &current, uint32_t total) {
QByteArray buffer = generatePatternData_();
runner_.addrClr();
if (!program_(buffer, current, total)) {
return false;
}
if (!program_(buffer, current, total)) return false;
runner_.addrClr();
if (!verify_(buffer, current, total)) {
return false;
}
if (!verify_(buffer, current, total)) return false;
return !runner_.hasError();
}

bool SRAM::doRandomTest_(uint32_t &current, uint32_t total) {
QByteArray buffer = generateRandomData_();
runner_.addrClr();
if (!program_(buffer, current, total)) {
return false;
}
if (!program_(buffer, current, total)) return false;
runner_.addrClr();
if (!verify_(buffer, current, total)) {
return false;
}
if (!verify_(buffer, current, total)) return false;
return !runner_.hasError();
}

Expand All @@ -107,15 +100,16 @@ bool SRAM::resetBus_() {
runner_.vppOnOE(false);
runner_.vppOnWE(false);
runner_.dataClr();
runner_.usDelay(25); // 25 uS
return !runner_.hasError();
}

bool SRAM::write_(uint8_t data) {
runner_.dataSet(data);
runner_.setWE(true);
runner_.usDelay(twp_);
runner_.usDelay(twp_); // tWP uS
runner_.setWE(false);
runner_.usDelay(twc_);
runner_.usDelay(twc_); // tWC uS
return !runner_.hasError();
}

Expand Down
13 changes: 8 additions & 5 deletions software/usbflashprog/main/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,12 +528,15 @@ void MainWindow::createDevice_() {
if (device_) {
device_->disconnect();
delete device_;
device_ = nullptr;
}
createDeviceIfSRAM_(ui_->btnProgDevice->text());
if (!device_) {
device_ = new Dummy(this);
device_->setSize(2 * 1024);
ui_->actionDoProgram->setText(tr("Program"));
ui_->btnProgram->setToolTip(ui_->actionDoProgram->text());
}

// createDeviceIfSRAM_(ui_->btnProgDevice->text());
device_ = new Dummy(this);
device_->setSize(2 * 1024);

connect(device_, &Device::onProgress, this, &MainWindow::onActionProgress);
}

Expand Down
12 changes: 12 additions & 0 deletions software/usbflashprog/main/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2980,6 +2980,7 @@
<addaction name="actionEPROMElectricalErasable"/>
<addaction name="actionEEPROM"/>
<addaction name="actionFlash"/>
<addaction name="actionDummy"/>
</widget>
<addaction name="menuParallelMemory"/>
<addaction name="separator"/>
Expand Down Expand Up @@ -3438,6 +3439,17 @@
<string notr="true"/>
</property>
</action>
<action name="actionDummy">
<property name="text">
<string notr="true">Dummy</string>
</property>
<property name="iconText">
<string notr="true">Dummy</string>
</property>
<property name="toolTip">
<string notr="true">Dummy</string>
</property>
</action>
</widget>
<tabstops>
<tabstop>btnSave</tabstop>
Expand Down

0 comments on commit fc4fc95

Please sign in to comment.