Skip to content

Commit

Permalink
0.2.rev.A. Fix serial communication; Add logger; UI improvements; Add…
Browse files Browse the repository at this point in the history
… settings dialog
  • Loading branch information
robsonsmartins committed Jan 10, 2024
1 parent 63d4ebf commit 0b43161
Show file tree
Hide file tree
Showing 21 changed files with 1,607 additions and 563 deletions.
14 changes: 9 additions & 5 deletions software/usbflashprog/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ elseif(NORMAL_BUILD)
backend/epromfile/qatmelfile.hpp
backend/epromfile/qepromfile.cpp
backend/epromfile/qepromfile.hpp
ui/qhexeditor.cpp
ui/qhexeditor.hpp
backend/devices/device.cpp
backend/devices/device.hpp
backend/devices/parallel/dummy.cpp
Expand All @@ -80,10 +78,16 @@ elseif(NORMAL_BUILD)
backend/devices/parallel/sram.hpp
backend/devices/parallel/eprom.cpp
backend/devices/parallel/eprom.hpp
main/mainwindow.cpp
main/mainwindow.hpp
main/mainwindow.ui
ui/qhexeditor.cpp
ui/qhexeditor.hpp
ui/mainwindow.cpp
ui/mainwindow.hpp
ui/mainwindow.ui
ui/settings.cpp
ui/settings.hpp
ui/settings.ui
main.cpp
main.hpp
)

set(PROJECT_RESOURCES
Expand Down
101 changes: 81 additions & 20 deletions software/usbflashprog/backend/devices/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,22 @@
*/
// ---------------------------------------------------------------------------

#include <QTextStream>
#include <QLoggingCategory>

#include "backend/devices/device.hpp"

// ---------------------------------------------------------------------------
// Logging

Q_LOGGING_CATEGORY(device, "device")

#define DEBUG qCDebug(device)
#define INFO qCInfo(device)
#define WARNING qCWarning(device)
#define CRITICAL qCCritical(device)
#define FATAL qCFatal(device)

// ---------------------------------------------------------------------------

TDeviceID::TDeviceID() : manufacturer(0), device(0) {}
Expand Down Expand Up @@ -102,6 +116,39 @@ TDeviceCapabilities::TDeviceCapabilities()
TDeviceInformation::TDeviceInformation()
: deviceType(kDeviceParallelMemory), name("") {}

QString TDeviceInformation::toString() const {
QString result;
QTextStream ts(&result);
ts << "Name: " << name;
ts << "; Type: ";
switch (deviceType) {
case kDeviceParallelMemory:
ts << "Parallel Memory";
break;
case kDeviceSerialMemory:
ts << "Serial Memory";
break;
default:
ts << "Unknown";
break;
}
ts << "; Capabilities: [";
ts << "hasProgram=" << (capability.hasProgram ? 1 : 0);
ts << ", hasVerify=" << (capability.hasVerify ? 1 : 0);
ts << ", hasErase=" << (capability.hasErase ? 1 : 0);
ts << ", hasGetId=" << (capability.hasGetId ? 1 : 0);
ts << ", hasRead=" << (capability.hasRead ? 1 : 0);
ts << ", hasBlankCheck=" << (capability.hasBlankCheck ? 1 : 0);
ts << ", hasUnprotect=" << (capability.hasUnprotect ? 1 : 0);
ts << ", hasSectorSize=" << (capability.hasSectorSize ? 1 : 0);
ts << ", hasFastProg=" << (capability.hasFastProg ? 1 : 0);
ts << ", hasSkipFF=" << (capability.hasSkipFF ? 1 : 0);
ts << ", hasVDD=" << (capability.hasVDD ? 1 : 0);
ts << ", hasVPP=" << (capability.hasVPP ? 1 : 0);
ts << "]";
return result;
}

// ---------------------------------------------------------------------------

Device::Device(QObject *parent)
Expand Down Expand Up @@ -146,89 +193,103 @@ QString Device::getPort() const {
}

void Device::setSize(uint32_t value) {
if (size_ == value) return;
if (value) size_ = value;
if (size_ != value) {
if (value) size_ = value;
}
DEBUG << "Size: " << QString("%1").arg(size_);
}

uint32_t Device::getSize() const {
return size_;
}

void Device::setTwp(uint32_t us) {
if (twp_ == us) return;
if (us) twp_ = us;
if (twp_ != us) {
if (us) twp_ = us;
}
DEBUG << "tWP: " << QString("%1").arg(twp_);
}

uint32_t Device::getTwp() const {
return twp_;
}

void Device::setTwc(uint32_t us) {
if (twc_ == us) return;
if (us) twc_ = us;
if (twc_ != us) {
if (us) twc_ = us;
}
DEBUG << "tWC: " << QString("%1").arg(twc_);
}

uint32_t Device::getTwc() const {
return twc_;
}

void Device::setVddRd(float value) {
if (vddRd_ == value) return;
if (value >= 0.0f) vddRd_ = value;
if (vddRd_ != value) {
if (value >= 0.0f) vddRd_ = value;
}
DEBUG << "VDD Read: " << QString("%1").arg(vddRd_, 4, 'f', 2);
}

float Device::getVddRd() const {
return vddRd_;
}

void Device::setVddWr(float value) {
if (vddWr_ == value) return;
if (value >= 0.0f) vddWr_ = value;
if (vddWr_ != value) {
if (value >= 0.0f) vddWr_ = value;
}
DEBUG << "VDD Prog: " << QString("%1").arg(vddWr_, 4, 'f', 2);
}

float Device::getVddWr() const {
return vddWr_;
}

void Device::setVpp(float value) {
if (vpp_ == value) return;
if (value >= 0.0f) vpp_ = value;
if (vpp_ != value) {
if (value >= 0.0f) vpp_ = value;
}
DEBUG << "VPP: " << QString("%1").arg(vpp_, 4, 'f', 2);
}

float Device::getVpp() const {
return vpp_;
}

void Device::setVee(float value) {
if (vee_ == value) return;
if (value >= 0.0f) vee_ = value;
if (vee_ != value) {
if (value >= 0.0f) vee_ = value;
}
DEBUG << "VEE: " << QString("%1").arg(vee_, 4, 'f', 2);
}

float Device::getVee() const {
return vee_;
}

void Device::setSkipFF(bool value) {
if (skipFF_ == value) return;
skipFF_ = value;
if (skipFF_ != value) skipFF_ = value;
DEBUG << "Skip 0xFF: " << QString("%1").arg(skipFF_ ? 1 : 0);
}

bool Device::getSkipFF() const {
return skipFF_;
}

void Device::setFastProg(bool value) {
if (fastProg_ == value) return;
fastProg_ = value;
if (fastProg_ != value) fastProg_ = value;
DEBUG << "Fast Prog/Erase: " << QString("%1").arg(fastProg_ ? 1 : 0);
}

bool Device::getFastProg() const {
return fastProg_;
}

void Device::setSectorSize(uint16_t value) {
if (sectorSize_ == value) return;
if (value) sectorSize_ = value;
if (sectorSize_ != value) sectorSize_ = value;
DEBUG << "Sector Size: " << QString("%1").arg(sectorSize_);
}

uint16_t Device::getSectorSize() const {
Expand Down
5 changes: 5 additions & 0 deletions software/usbflashprog/backend/devices/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ typedef struct TDeviceInformation {
TDeviceCapabilities capability;
/** @brief Constructor. */
TDeviceInformation();
/**
* @brief Converts contents to string.
* @return Device Info as QString.
*/
QString toString() const;
} TDeviceInformation;

// ---------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 0b43161

Please sign in to comment.