Skip to content

Commit

Permalink
Merge pull request #11 from dougg3/shorts-to-5v
Browse files Browse the repository at this point in the history
Misc fixes
  • Loading branch information
dougg3 authored Aug 7, 2023
2 parents e6f85ef + e19b3fb commit 0b44ff6
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 33 deletions.
4 changes: 3 additions & 1 deletion ROMSIMMFlasher.pro
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ TEMPLATE = app
QMAKE_TARGET_BUNDLE_PREFIX = com.downtowndougbrown

SOURCES += main.cpp\
droppablegroupbox.cpp \
mainwindow.cpp \
programmer.cpp \
aboutbox.cpp

HEADERS += mainwindow.h \
droppablegroupbox.h \
programmer.h \
aboutbox.h

Expand Down Expand Up @@ -43,7 +45,7 @@ lessThan(QT_MAJOR_VERSION, 5) {
win32:RC_ICONS = SIMMProgrammer.ico
}

VERSION = 1.1.2
VERSION = 1.2.0
DEFINES += VERSION_STRING=\\\"$$VERSION\\\"

macx:QMAKE_INFO_PLIST = Info.plist
Expand Down
2 changes: 1 addition & 1 deletion aboutbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AboutBox;
class AboutBox : public QDialog
{
Q_OBJECT

public:
static AboutBox *instance();
private slots:
Expand Down
39 changes: 39 additions & 0 deletions droppablegroupbox.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "droppablegroupbox.h"
#include <QDropEvent>
#include <QMimeData>
#include <QDebug>

DroppableGroupBox::DroppableGroupBox(QWidget *parent) :
QGroupBox(parent)
{
setAcceptDrops(true);
}

void DroppableGroupBox::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData() && event->mimeData()->hasUrls())
{
QList<QUrl> urls = event->mimeData()->urls();
if (urls.count() == 1 &&
urls[0].isLocalFile() &&
QFile::exists(urls[0].toLocalFile()))
{
event->accept();
}
}
}

void DroppableGroupBox::dropEvent(QDropEvent *event)
{
if (event->mimeData() && event->mimeData()->hasUrls())
{
QList<QUrl> urls = event->mimeData()->urls();
if (urls.count() == 1 &&
urls[0].isLocalFile() &&
QFile::exists(urls[0].toLocalFile()))
{
event->accept();
emit fileDropped(urls[0].toLocalFile());
}
}
}
20 changes: 20 additions & 0 deletions droppablegroupbox.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef DROPPABLEGROUPBOX_H
#define DROPPABLEGROUPBOX_H

#include <QGroupBox>

class DroppableGroupBox : public QGroupBox
{
Q_OBJECT
public:
DroppableGroupBox(QWidget *parent = 0);

protected:
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);

signals:
void fileDropped(QString path);
};

#endif // DROPPABLEGROUPBOX_H
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ int main(int argc, char *argv[])
QApplication a(argc, argv);
MainWindow w;
w.show();

return a.exec();
}
56 changes: 36 additions & 20 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,23 @@ static Programmer *p;
#define verifyWhileWritingKey "verifyWhileWriting"
#define selectedEraseSizeKey "selectedEraseSize"

struct simmdesc {
uint32_t idx;
const char *text;
uint32_t size;
uint32_t chip_type;
struct SIMMDesc {
uint32_t saveValue;
const char *text;
uint32_t size;
uint32_t chipType;
};

simmdesc simmtable[] = {
{ 0, "128KB (4x 256Kb PLCC)", 128, SIMM_PLCC_x8 },
{ 1, "256KB (4x 512Kb PLCC)", 256, SIMM_PLCC_x8 },
{ 2, "512KB (4x 1Mb PLCC)", 512, SIMM_PLCC_x8 },
{ 3, "1MB (4x 2Mb PLCC)", 1024, SIMM_PLCC_x8 },
{ 4, "2MB (4x 4Mb PLCC)", 2048, SIMM_PLCC_x8 },
{ 5, "4MB (2x 16Mb TSOP)", 4096, SIMM_TSOP_x16 },
{ 6, "8MB (4x 16Mb TSOP)", 8192, SIMM_TSOP_x8 },
{ 7, "8MB (2x 32Mb TSOP)", 8192, SIMM_TSOP_x16 },
SIMMDesc simmTable[] ={
{0, "128KB (4x 256Kb PLCC)", 128, SIMM_PLCC_x8 },
{1, "256KB (4x 512Kb PLCC)", 256, SIMM_PLCC_x8 },
{2, "512KB (4x 1Mb PLCC)", 512, SIMM_PLCC_x8 },
{3, "1MB (4x 2Mb PLCC)", 1024, SIMM_PLCC_x8 },
{4, "2MB (4x 4Mb PLCC)", 2048, SIMM_PLCC_x8 },
{8, "2MB (2x 8Mb TSOP)", 2048, SIMM_TSOP_x16},
{5, "4MB (2x 16Mb TSOP)", 4096, SIMM_TSOP_x16},
{6, "8MB (4x 16Mb TSOP)", 8192, SIMM_TSOP_x8 },
{7, "8MB (2x 32Mb TSOP)", 8192, SIMM_TSOP_x16},
};

MainWindow::MainWindow(QWidget *parent) :
Expand All @@ -73,8 +74,9 @@ MainWindow::MainWindow(QWidget *parent) :
ui->actionUpdate_firmware->setEnabled(false);

// Fill in the list of SIMM chip capacities (programmer can support anywhere up to 8 MB of space)
for(size_t i=0; i<sizeof(simmtable)/sizeof(simmdesc); i++) {
ui->simmCapacityBox->addItem(simmtable[i].text, QVariant(simmtable[i].idx));
for (size_t i = 0; i < sizeof(simmTable)/sizeof(simmTable[0]); i++)
{
ui->simmCapacityBox->addItem(simmTable[i].text, QVariant(simmTable[i].saveValue));
}

// Select 2 MB by default (it's what most people will want), or load last-used setting
Expand Down Expand Up @@ -122,6 +124,8 @@ MainWindow::MainWindow(QWidget *parent) :
ui->howMuchToWriteBox->addItem("Only erase/write first 1 MB", QVariant(1024*1024));
ui->howMuchToWriteBox->addItem("Only erase/write first 1.5 MB", QVariant(3*512*1024));
ui->howMuchToWriteBox->addItem("Only erase/write first 2 MB", QVariant(2*1024*1024));
ui->howMuchToWriteBox->addItem("Only erase/write first 4 MB", QVariant(4*1024*1024));
ui->howMuchToWriteBox->addItem("Only erase/write first 8 MB", QVariant(8*1024*1024));

// Select "erase entire SIMM" by default, or load last-used setting
QVariant selectedEraseSize = settings.value(selectedEraseSizeKey, QVariant(0));
Expand Down Expand Up @@ -299,7 +303,7 @@ void MainWindow::on_writeToSIMMButton_clicked()
}
else
{
p->writeToSIMM(writeFile, 0, howMuchToErase);
p->writeToSIMM(writeFile, 0, qMin(howMuchToErase, p->SIMMCapacity()));
}
qDebug() << "Writing to SIMM...";
}
Expand Down Expand Up @@ -339,6 +343,18 @@ void MainWindow::on_chosenReadFile_textEdited(const QString &newText)
}
}

void MainWindow::on_writeGroupBox_fileDropped(const QString &filePath)
{
ui->chosenWriteFile->setText(filePath);
on_chosenWriteFile_textEdited(filePath);
}

void MainWindow::on_readGroupBox_fileDropped(const QString &filePath)
{
ui->chosenReadFile->setText(filePath);
on_chosenReadFile_textEdited(filePath);
}

void MainWindow::programmerWriteStatusChanged(WriteStatus newStatus)
{
switch (newStatus)
Expand Down Expand Up @@ -952,14 +968,14 @@ void MainWindow::resetAndShowStatusPage()

void MainWindow::on_simmCapacityBox_currentIndexChanged(int index)
{
uint32_t idx = static_cast<uint32_t>(ui->simmCapacityBox->itemData(index).toUInt());
p->setSIMMType(simmtable[idx].size*1024, simmtable[idx].chip_type);
p->setSIMMType(simmTable[index].size*1024, simmTable[index].chipType);
QSettings settings;
if (!initializing)
{
// If we're not initializing (it gets called while we're initializing),
// go ahead and save this as the new default.
settings.setValue(selectedCapacityKey, idx);
uint32_t saveValue = static_cast<uint32_t>(ui->simmCapacityBox->itemData(index).toUInt());
settings.setValue(selectedCapacityKey, saveValue);
}
}

Expand Down
7 changes: 5 additions & 2 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class MainWindow;
class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

private slots:
void on_selectWriteFileButton_clicked();
void on_selectReadFileButton_clicked();
Expand All @@ -46,6 +46,9 @@ private slots:
void on_chosenWriteFile_textEdited(const QString &newText);
void on_chosenReadFile_textEdited(const QString &newText);

void on_writeGroupBox_fileDropped(const QString &filePath);
void on_readGroupBox_fileDropped(const QString &filePath);

void programmerWriteStatusChanged(WriteStatus newStatus);
void programmerWriteTotalLengthChanged(uint32_t totalLen);
void programmerWriteCompletionLengthChanged(uint32_t len);
Expand Down
12 changes: 10 additions & 2 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</layout>
</item>
<item>
<widget class="QGroupBox" name="writeGroupBox">
<widget class="DroppableGroupBox" name="writeGroupBox">
<property name="title">
<string>Write file to SIMM</string>
</property>
Expand Down Expand Up @@ -113,7 +113,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="readGroupBox">
<widget class="DroppableGroupBox" name="readGroupBox">
<property name="title">
<string>Read from SIMM to file</string>
</property>
Expand Down Expand Up @@ -624,6 +624,14 @@
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>DroppableGroupBox</class>
<extends>QGroupBox</extends>
<header>droppablegroupbox.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
Expand Down
16 changes: 10 additions & 6 deletions programmer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <QDebug>
#include <QWaitCondition>
#include <QMutex>
#include <QTimer>

typedef enum ProgrammerCommandState
{
Expand Down Expand Up @@ -282,7 +283,7 @@ void Programmer::writeToSIMM(QIODevice *device, uint8_t chipsMask)

// Based on the SIMM type, tell the programmer board.
uint8_t setLayoutCommand;
if(SIMMChip()==SIMM_TSOP_x8)
if (SIMMChip() == SIMM_TSOP_x8)
{
setLayoutCommand = SetSIMMLayout_AddressShifted;
}
Expand Down Expand Up @@ -325,7 +326,7 @@ void Programmer::writeToSIMM(QIODevice *device, uint32_t startOffset, uint32_t l

// Based on the SIMM type, tell the programmer board.
uint8_t setLayoutCommand;
if (SIMMChip() == SIMM_TSOP_x8)
if (SIMMChip() == SIMM_TSOP_x8)
{
setLayoutCommand = SetSIMMLayout_AddressShifted;
}
Expand Down Expand Up @@ -905,7 +906,7 @@ void Programmer::handleChar(uint8_t c)

// READ SIMM STATE HANDLERS

// Expecting reply after we told the programmer to start reading
// Expecting reply after we told the programmer to start reading
case ReadSIMMWaitingStartReply:
case ReadSIMMWaitingStartOffsetReply:
switch (c)
Expand Down Expand Up @@ -1160,7 +1161,7 @@ void Programmer::handleChar(uint8_t c)
// If we got an error reply, we MAY still be OK unless we were
// requesting the large SIMM type, in which case the firmware
// doesn't support the large SIMM type so the user needs to know.
if (SIMMChip() != SIMM_PLCC_x8)
if (SIMMChip() != SIMM_PLCC_x8)
{
// Uh oh -- this is an old firmware that doesn't support a big
// SIMM. Let the caller know that the programmer board needs a
Expand Down Expand Up @@ -1396,6 +1397,10 @@ QString Programmer::electricalTestPinName(uint8_t index)
{
return "GND";
}
else if (index == VCC_FAIL_INDEX)
{
return "+5V";
}
else
{
return "?";
Expand Down Expand Up @@ -1480,7 +1485,6 @@ void Programmer::startBootloaderCommand(uint8_t commandByte, uint32_t newState)
sendByte(GetBootloaderState);
}

#include <QTimer>
void Programmer::portDiscovered(const QextPortInfo &info)
{
if ((foundState == ProgrammerBoardNotFound) &&
Expand Down Expand Up @@ -1545,7 +1549,7 @@ void Programmer::portRemoved(const QextPortInfo &info)
const bool matchingPortName = programmerBoardPortName != "" && info.portName == programmerBoardPortName;
if ((matchingVIDPID || matchingPortName) &&
(foundState == ProgrammerBoardFound))
{
{
programmerBoardPortName = "";
foundState = ProgrammerBoardNotFound;

Expand Down
1 change: 1 addition & 0 deletions programmer.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ typedef enum VerificationOption

// Electrical test indexes
#define GROUND_FAIL_INDEX 0xFF
#define VCC_FAIL_INDEX 0xFE

#define FIRST_ADDRESS_LINE_FAIL_INDEX 0
#define LAST_ADDRESS_LINE_FAIL_INDEX (FIRST_ADDRESS_LINE_FAIL_INDEX + 20)
Expand Down

0 comments on commit 0b44ff6

Please sign in to comment.