Skip to content

Commit

Permalink
Added detection for ST Nucleo debugger. Needs testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobyfab committed May 31, 2014
1 parent 8f398e4 commit 5f519d8
Show file tree
Hide file tree
Showing 11 changed files with 577 additions and 557 deletions.
2 changes: 1 addition & 1 deletion QStlink2.pro
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ win32:CONFIG += winusb

TEMPLATE = app
TARGET = qstlink2
VERSION = 1.1.2
VERSION = 1.1.3

message(Version $$VERSION)

Expand Down
2 changes: 1 addition & 1 deletion QtUsb
Submodule QtUsb updated 2 files
+1 −1 compat.h
+3 −0 qwinusb.cpp
2 changes: 1 addition & 1 deletion inc/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class MainWindow : public QMainWindow
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
transferThread *tfThread;
transferThread *mTfThread;

public slots:
bool Connect();
Expand Down
8 changes: 4 additions & 4 deletions inc/stlinkv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ This file is part of QSTLink2.
const quint16 USB_ST_VID = 0x0483;
const quint16 USB_STLINK_PID = 0x3744;
const quint16 USB_STLINKv2_PID = 0x3748;
const quint16 USB_NUCLEO_PID = 0x374b;
const quint8 USB_CONFIGURATION = 1; /* The sole configuration. */
const quint8 USB_PIPE_IN = 0x81; /* Bulk output endpoint for responses */
const quint8 USB_PIPE_OUT = 0x02; /* Bulk input endpoint for commands */
const quint8 USB_PIPE_ERR = 0x83; /* An apparently-unused bulk endpoint. */
const quint16 USB_TIMEOUT_MSEC = 300;
const QString USB_STLINK_GUID = "DBCE1CD9-A320-4b51-A365-A0C3F3C5FB29";
#ifdef WIN32
const GUID OSR_DEVICE_INTERFACE =
{ 0xDBCE1CD9, 0xA320, 0x4b51, { 0xA3, 0x65, 0xA0, 0xC3, 0xF3, 0xC5, 0xFB, 0x29 } };
#endif
const QString USB_NUCLEO_GUID = "8326506F-7260-4854-9C03-26E416F04494";

namespace STLink {
namespace Status {
Expand Down Expand Up @@ -182,6 +180,8 @@ class stlinkv2 : public QThread
public slots:
qint32 connect();
void disconnect();
void setSTLinkIDs(void);
void setNucleoIDs(void);
bool isConnected();
void clearBuffer();
void resetMCU();
Expand Down
42 changes: 21 additions & 21 deletions src/devices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ This file is part of QSTLink2.
Device::Device(QObject *parent) :
QObject(parent)
{
this->mType = "UNKNOWN";
this->mLoaderFile = "UNKNOWN";
mType = "UNKNOWN";
mLoaderFile = "UNKNOWN";
}

Device::Device(Device *device)
{
this->mType = device->mType;
this->mMap = device->mMap;
mType = device->mType;
mMap = device->mMap;
}

DeviceList::DeviceList(QObject *parent) :
QObject(parent)
{
this->mLoaded = false;
mLoaded = false;
qDebug("Loading device list.");
this->mDoc = new QDomDocument("stlink");
mDoc = new QDomDocument("stlink");

/* Try local path first */
QFile file("devices.xml");
Expand All @@ -60,7 +60,7 @@ DeviceList::DeviceList(QObject *parent) :
file.close();
qInformal() << "Devices list loaded.";

this->mDefaultDevice = new Device(this);
mDefaultDevice = new Device(this);
bool isInt;
QDomElement docElem = mDoc->documentElement();
QDomNode n = docElem.firstChild();
Expand All @@ -73,7 +73,7 @@ DeviceList::DeviceList(QObject *parent) :
for (int i = 0;i < childs.count();i++) {
QDomElement el = childs.at(i).toElement();
qDebug() << e.tagName() << "->" << el.tagName();
(*this->mDefaultDevice)[el.tagName()] = (quint32)el.text().toUInt(&isInt, 16);
(*mDefaultDevice)[el.tagName()] = (quint32)el.text().toUInt(&isInt, 16);
if (!isInt)
qCritical() << el.tagName() << "Failed to parse number!";
}
Expand All @@ -84,7 +84,7 @@ DeviceList::DeviceList(QObject *parent) :
QDomElement el = regs.at(a).toElement();
qDebug() << el.tagName() << "->" << el.text().toUInt(0, 16);

(*this->mDefaultDevice)[el.tagName()] = (quint32)el.text().toUInt(&isInt, 16);
(*mDefaultDevice)[el.tagName()] = (quint32)el.text().toUInt(&isInt, 16);
if (!isInt)
qCritical() << el.tagName() << "Failed to parse number!";
}
Expand All @@ -101,22 +101,22 @@ DeviceList::DeviceList(QObject *parent) :
if (e.tagName() == "devices") {
QDomNodeList devices = e.childNodes();
for (int a = 0;a < devices.count(); a++) {
this->mDevices.append(new Device(this->mDefaultDevice)); // Copy from the default device.
mDevices.append(new Device(mDefaultDevice)); // Copy from the default device.


QDomElement device = devices.at(a).toElement();
this->mDevices.last()->mType = device.attribute("type");
mDevices.last()->mType = device.attribute("type");

QDomNodeList childs = device.childNodes();
for (int i = 0;i < childs.count();i++) {
QDomElement el = childs.at(i).toElement();
qDebug() << device.tagName() << "->" << device.attribute("type") << "->" << el.tagName() ;
(*this->mDevices.last())[el.tagName()] = (quint32)el.text().toUInt(&isInt, 16);
(*mDevices.last())[el.tagName()] = (quint32)el.text().toUInt(&isInt, 16);
if (!isInt && el.tagName() != "loader")
qCritical() << el.tagName() << "Failed to parse number!";

if (el.tagName() == "loader") {
this->mDevices.last()->mLoaderFile = el.text();
mDevices.last()->mLoaderFile = el.text();
}
}
}
Expand All @@ -126,20 +126,20 @@ DeviceList::DeviceList(QObject *parent) :
n = n.nextSibling();
}

this->mLoaded = true;
mLoaded = true;
return;
}

bool DeviceList::IsLoaded() const {

return this->mLoaded;
return mLoaded;
}

bool DeviceList::search(const quint32 chip_id) {
qDebug() << "Looking for:" << QString::number(chip_id, 16);
for (int i=0; i < this->mDevices.count(); i++) {
if ((*this->mDevices.at(i))["chip_id"] == chip_id) {
this->mCurDevice = this->mDevices.at(i);
for (int i=0; i < mDevices.count(); i++) {
if ((*mDevices.at(i))["chip_id"] == chip_id) {
mCurDevice = mDevices.at(i);
qDebug() << "Found chipID";
qDebug() << mCurDevice->repr();
return true;
Expand All @@ -151,19 +151,19 @@ bool DeviceList::search(const quint32 chip_id) {

quint16 DeviceList::getDevicesCount() const {

return this->mDevices.count();
return mDevices.count();
}

QString Device::repr(void) const {

QMapIterator<QString, quint32> i(mMap);
QString tmp("\r\n");
tmp.append("Type: "+this->mType);
tmp.append("Type: "+mType);
while (i.hasNext()) {
i.next();
tmp.append("\r\n" + QString(i.key()) + ": 0x" + QString::number(i.value(), 16));
}
tmp.append("\r\nLoader: " + this->mLoaderFile);
tmp.append("\r\nLoader: " + mLoaderFile);
return tmp;
}

4 changes: 2 additions & 2 deletions src/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ Dialog::~Dialog()
void Dialog::setText(const QString &title, const QString &text)
{
this->setWindowTitle(title);
this->mUi->l_text->setText(text);
mUi->l_text->setText(text);
}

void Dialog::setHTML(const QString &title, const QString &html)
{
this->setWindowTitle(title);
this->mUi->l_text->setHtml(html);
mUi->l_text->setHtml(html);
}
4 changes: 2 additions & 2 deletions src/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ bool loader::loadBin(const QString &path) {
if (!file.open(QFile::ReadOnly))
return false;

this->mData = file.readAll();
mData = file.readAll();
file.close();

return true;
}

QByteArray& loader::refData(void) {

return this->mData;
return mData;
}
Loading

0 comments on commit 5f519d8

Please sign in to comment.