dlgconjtag.cpp 4.25 KB
Newer Older
Alexander Steffens's avatar
Alexander Steffens committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
#include <QThread>
#include <QDateTime>
#include <QMessageBox>
#include "dlgstartup.h"
#include "dlgconjtag.h"
#include "ui_dlgjtag.h"

DlgConJtag::DlgConJtag(QWidget *parent, PromSettings *prs )
    : DlgJtag(parent,prs)
{
    _Proms      = prs;
    _MarocProgress = new QProgressBar();
    _MarocProgress->setRange(0,_Proms->MarocDevices);
    _MarocProgress->setValue(0);
    _MarocProgress->setFormat("%v / %m");

    ui->VerticalLayoutLog->addWidget(_MarocProgress);
    show();
}

DlgConJtag::~DlgConJtag()
{
}


bool    DlgConJtag::IProgram(int prom, int dev, bool ask)
{
    bool err = false;
    if (!ask||QMessageBox::question(this,"Program FPGA","Do you really want to PROGRAM the\nflash(s) and rest the fpga(s)\nof all connected Marocs ?",QMessageBox::Yes | QMessageBox::No)==QMessageBox::Yes) {
        for (quint32 i=0; i<_Proms->MarocMaxDevices; i++) {
            if ((_Proms->MarocAvailable&(0x00000001<<i))>0) {
                // Maroc selektieren
                _Proms->_Device->WriteLinkMemReg(_Proms->MarocSelReg,i,DEV_NO_CHECK);
                _MarocProgress->setValue(i+1);
                AddToLog(QString("Selecting Maroc %1...").arg(i));

                QDateTime qdt;
                quint64 st = qdt.currentMSecsSinceEpoch();
                AddToLog(QString("programming Device %1...").arg(dev));
                if (Jtag_Prom(JTAG_PROGRAM,dev,_Proms->Prom[prom].UserCode,_Proms->Prom[prom].PromFile,false)) {
                    AddToLog(QString("ERROR while programming Device %1...").arg(dev));
                    Jtag_Check();
                    err = true;
               } else Jtag_Check();
                quint64 et = qdt.currentMSecsSinceEpoch();
                AddToLog(QString("time - ")+qdt.fromMSecsSinceEpoch(et-st).toString("mm:ss"));
                IReset(dev,false);
            }
        }
    }
    return !err;
}

bool    DlgConJtag::IVerify(int prom, int dev, bool ask)
{
    bool err = false;
    if (!ask||QMessageBox::question(this,"Verify FPGA","Do you really want to VERIFY the\nfpga(s) of all connected Marocs ?",QMessageBox::Yes | QMessageBox::No)==QMessageBox::Yes) {
        for (quint32 i=0; i<_Proms->MarocMaxDevices; i++) {
            if ((_Proms->MarocAvailable&(0x00000001<<i))>0) {
                // Maroc selektieren
                _Proms->_Device->WriteLinkMemReg(_Proms->MarocSelReg,i,DEV_NO_CHECK);
                _MarocProgress->setValue(i+1);
                AddToLog(QString("Selecting Maroc %1...").arg(i));

                QDateTime qdt;
                quint64 st = qdt.currentMSecsSinceEpoch();
                AddToLog(QString("verifying Device %1...").arg(dev));

                if (Jtag_Prom(JTAG_VERIFY,dev,_Proms->Prom[prom].UserCode,_Proms->Prom[prom].PromFile,false)) {
                    AddToLog(QString("ERROR while verfying Device %1...").arg(dev));
                    Jtag_Check();
                    err =  true;
                } else Jtag_Check();

                quint64 et = qdt.currentMSecsSinceEpoch();
                AddToLog(QString("time - ")+qdt.fromMSecsSinceEpoch(et-st).toString("mm:ss"));
            }
        }
    }
    return !err;
}

void    DlgConJtag::IReset(int dev, bool ask)
{
    if (ask) {
        if (QMessageBox::question(this,"Reset FPGA","Do you really want to RESET the\nfpga(s) of all connected Marocs ?",QMessageBox::Yes | QMessageBox::No)==QMessageBox::Yes) {
            for (quint32 i=0; i<_Proms->MarocMaxDevices; i++) {
                if ((_Proms->MarocAvailable&(0x00000001<<i))>0) {
                    // Maroc selektieren
                    _Proms->_Device->WriteLinkMemReg(_Proms->MarocSelReg,i,DEV_NO_CHECK);
                    _MarocProgress->setValue(i+1);
                    AddToLog(QString("Selecting Maroc %1...").arg(i));

                    AddToLog(QString("resetting fpga..."));
                    if (!Jtag_Load(false,dev)) {
                        AddToLog(QString("ERROR while resetting Device %1...").arg(dev));
                    }
                }
            }
        }
    } else {
        AddToLog(QString("resetting fpga..."));
        if (!Jtag_Load(false,dev)) {
            AddToLog(QString("ERROR while resetting Device %1...").arg(dev));
        }
    }
}