diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-24 18:42:24 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-24 18:42:24 +0000 |
commit | f508189682b6fba62e08feeb1596f682bad5fff9 (patch) | |
tree | 28aeb0e6c19386c385c1ce5edf8a92c1bca15281 /src/progs/psp | |
download | piklab-f508189682b6fba62e08feeb1596f682bad5fff9.tar.gz piklab-f508189682b6fba62e08feeb1596f682bad5fff9.zip |
Added KDE3 version of PikLab
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1095639 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/progs/psp')
-rw-r--r-- | src/progs/psp/Makefile.am | 3 | ||||
-rw-r--r-- | src/progs/psp/base/Makefile.am | 11 | ||||
-rw-r--r-- | src/progs/psp/base/base.pro | 6 | ||||
-rw-r--r-- | src/progs/psp/base/psp.cpp | 346 | ||||
-rw-r--r-- | src/progs/psp/base/psp.h | 63 | ||||
-rw-r--r-- | src/progs/psp/base/psp.xml | 195 | ||||
-rw-r--r-- | src/progs/psp/base/psp_data.h | 23 | ||||
-rw-r--r-- | src/progs/psp/base/psp_prog.cpp | 31 | ||||
-rw-r--r-- | src/progs/psp/base/psp_prog.h | 53 | ||||
-rw-r--r-- | src/progs/psp/base/psp_serial.cpp | 110 | ||||
-rw-r--r-- | src/progs/psp/base/psp_serial.h | 37 | ||||
-rw-r--r-- | src/progs/psp/gui/Makefile.am | 6 | ||||
-rw-r--r-- | src/progs/psp/gui/psp_group_ui.cpp | 22 | ||||
-rw-r--r-- | src/progs/psp/gui/psp_group_ui.h | 28 | ||||
-rw-r--r-- | src/progs/psp/psp.pro | 2 | ||||
-rw-r--r-- | src/progs/psp/xml/Makefile.am | 14 | ||||
-rw-r--r-- | src/progs/psp/xml/xml.pro | 17 | ||||
-rw-r--r-- | src/progs/psp/xml/xml_psp_parser.cpp | 45 |
18 files changed, 1012 insertions, 0 deletions
diff --git a/src/progs/psp/Makefile.am b/src/progs/psp/Makefile.am new file mode 100644 index 0000000..fccf96d --- /dev/null +++ b/src/progs/psp/Makefile.am @@ -0,0 +1,3 @@ +INCLUDES = -I$(top_srcdir)/src $(all_includes) +METASOURCES = AUTO +SUBDIRS = xml base gui diff --git a/src/progs/psp/base/Makefile.am b/src/progs/psp/base/Makefile.am new file mode 100644 index 0000000..93ce348 --- /dev/null +++ b/src/progs/psp/base/Makefile.am @@ -0,0 +1,11 @@ +INCLUDES = -I$(top_srcdir)/src $(all_includes) +METASOURCES = AUTO + +noinst_LTLIBRARIES = libpsp.la +libpsp_la_SOURCES = psp_prog.cpp psp_serial.cpp psp_data.cpp psp.cpp +libpsp_la_DEPENDENCIES = psp_data.cpp + +noinst_DATA = psp.xml +psp_data.cpp: ../xml/xml_psp_parser psp.xml + ../xml/xml_psp_parser +CLEANFILES = psp_data.cpp diff --git a/src/progs/psp/base/base.pro b/src/progs/psp/base/base.pro new file mode 100644 index 0000000..4dca18d --- /dev/null +++ b/src/progs/psp/base/base.pro @@ -0,0 +1,6 @@ +STOPDIR = ../../../.. +include($${STOPDIR}/lib.pro) + +TARGET = psp +HEADERS += psp.h psp_prog.h psp_data.h psp_serial.h +SOURCES += psp.cpp psp_prog.cpp psp_data.cpp psp_serial.cpp diff --git a/src/progs/psp/base/psp.cpp b/src/progs/psp/base/psp.cpp new file mode 100644 index 0000000..1b76bf5 --- /dev/null +++ b/src/progs/psp/base/psp.cpp @@ -0,0 +1,346 @@ +/*************************************************************************** + * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> * + * Copyright (C) 2002-2003 Stephen Landamore <stephen@landamore.com> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#include "psp.h" + +#include "common/global/global.h" +#include "common/common/misc.h" + +//----------------------------------------------------------------------------- +QMemArray<uchar> Psp::createConfigInfo(const Pic::Data &data) +{ + QMemArray<uchar> array(33); + array.fill(0x00); + + const Pic::Config &config = data.config(); + for (uint i=0; i<uint(config._words.count()); i++) { + BitValue v = config._words[i].usedMask(); + if ( data.nbBytesWord(Pic::MemoryRangeType::UserId)==1 ) array[i ^ 1] = v.byte(0); + else { + array[2*i] = v.byte(1); + array[2*i + 1] = v.byte(0); + } + } + for (uint i=0; i<16; i++) array[i + 16] = array[i]; + + // checksum + for (uint i=0; i<32; i++) array[32] += array[i]; + + return array; +} + +QMemArray<uchar> Psp::createDeviceInfo(const Pic::Data &data) +{ + QMemArray<uchar> config = createConfigInfo(data); + QMemArray<uchar> array(45); + array.fill(0x00); + + // memory code length + BitValue v = data.nbWords(Pic::MemoryRangeType::Code); + array[0] = v.byte(1); + array[1] = v.byte(0); + // address word width + v = data.mask(Pic::MemoryRangeType::Code); + array[2] = v.byte(1); + array[3] = v.byte(0); + // data word width + array[4] = v.byte(1); + array[5] = v.byte(0); + + if ( data.isReadable(Pic::MemoryRangeType::UserId) ) { + // user id width + v = data.userIdRecommendedMask(); + if ( data.nbBytesWord(Pic::MemoryRangeType::UserId)==1 ) v += v << 8; + array[6] = v.byte(1); + array[7] = v.byte(0); + // user id mask + array[8] = v.byte(1); + array[9] = v.byte(0); + } + + // memory config mask + array[10] = config[0]; + array[11] = config[1]; + array[12] = config[16]; + array[13] = config[17]; + + if ( data.isReadable(Pic::MemoryRangeType::Eeprom) ) { + // memory eeprom width + v = data.mask(Pic::MemoryRangeType::Eeprom); + array[14] = v.byte(1); + array[15] = v.byte(0); + // memory eeprom mask + array[16] = v.byte(1); + array[17] = v.byte(0); + } + + if ( data.isReadable(Pic::MemoryRangeType::Cal) ) { + // memory calibration width + v = data.mask(Pic::MemoryRangeType::Cal); + array[18] = v.byte(1); + array[19] = v.byte(0); + // memory calibration mask + array[20] = v.byte(1); + array[21] = v.byte(0); + } + + // memory code start + array[22] = 0x00; + array[23] = 0x00; + // memory code length + array[24] = 0x00; // array[0]; in lplab and for some devices in picp... + array[25] = 0x01; // array[1]; in lplab and for some devices in picp... + + if ( data.isReadable(Pic::MemoryRangeType::UserId) ) { + // user id start + v = data.range(Pic::MemoryRangeType::UserId).start.toUInt(); + array[26] = v.byte(1); + array[27] = v.byte(0); + // user id length + v = data.nbWords(Pic::MemoryRangeType::UserId); + if ( data.nbBytesWord(Pic::MemoryRangeType::UserId)==1 ) v >>= 1; + array[28] = v.byte(0); + } + + if ( data.isReadable(Pic::MemoryRangeType::Config) ) { + // config start + v = data.range(Pic::MemoryRangeType::Config).start.toUInt(); + array[29] = v.byte(1); + array[30] = v.byte(0); + // config length + v = data.nbWords(Pic::MemoryRangeType::Config); + if ( data.nbBytesWord(Pic::MemoryRangeType::Config)==1 ) v >>= 1; + array[31] = v.byte(0); + } + + if ( data.isReadable(Pic::MemoryRangeType::Config) ) { + // eeprom start + array[32] = 0x00; + array[33] = 0x00; + // eeprom length + v = data.nbWords(Pic::MemoryRangeType::Eeprom); + array[34] = v.byte(1); + array[35] = v.byte(0); + } + + if ( data.isReadable(Pic::MemoryRangeType::Cal) ) { + // calibration start + v = data.range(Pic::MemoryRangeType::Cal).start.toUInt(); + array[36] = v.byte(1); + array[37] = v.byte(0); + // calibration length + v = data.nbWords(Pic::MemoryRangeType::Cal); + array[38] = v.byte(1); + array[39] = v.byte(0); + } + + // programming + const Psp::Data &pdata = Psp::data(data.name()); + array[40] = pdata.overprogram; + array[41] = pdata.tries; + array[42] = pdata.algorithm; + if ( data.memoryTechnology()==Device::MemoryTechnology::Flash ) array[43] |= 0x01; + if ( data.isReadable(Pic::MemoryRangeType::UserId) ) array[43] |= 0x02; + if ( data.isReadable(Pic::MemoryRangeType::Config) ) array[43] |= 0x04; + if ( data.isReadable(Pic::MemoryRangeType::Eeprom) ) array[43] |= 0x08; + if ( data.isReadable(Pic::MemoryRangeType::Cal) ) array[43] |= 0x10; + if ( data.config().findMask("PARITY") ) array[43] |= 0x20; + + // checksum + for (uint i=0; i<44; i++) array[44] += array[i]; + + return array; +} + +//----------------------------------------------------------------------------- +Psp::Hardware::Hardware(::Programmer::Base &base, const QString &portDevice) + : Programmer::PicHardware(base, new SerialPort(portDevice, base), QString::null) +{} + +bool Psp::Hardware::internalConnectHardware() +{ + if ( !port()->open() ) return false; + if ( !port()->reset() ) return false; + // #### TODO: detect Warp13 or JuPic + QMemArray<uchar> a; + if ( !port()->command(0x88, 1, a) ) return false; + if ( a[0]!=0xAB ) { + log(Log::LineType::Error, i18n("Wrong programmer connected")); + return false; + } + return true; +} + +bool Psp::Hardware::getFirmwareVersion(VersionData &version) +{ + QMemArray<uchar> a1; + if ( !port()->commandAck(0x8D, 2, &a1) ) return false; + if ( a1[1]==0xFF ) { + log(Log::LineType::Warning, i18n("Invalid firmware version")); + version = VersionData(0xFF, 0, 0); + } else { + QMemArray<uchar> a2; + if ( !port()->receive(2, a2) ) return false; + version = VersionData(a1[1], a2[0], a2[1]); + } + return true; +} + +bool Psp::Hardware::setTarget() +{ + log(Log::DebugLevel::Max, "set target"); + // load device info + if ( !port()->commandAck(0x81) ) return false; + QMemArray<uchar> a = createDeviceInfo(device()); + if ( !port()->send(a) ) return false; + if ( !port()->receiveEnd() ) return false; + + // load config info + if ( !port()->commandAck(0x82) ) return false; + a = createConfigInfo(device()); + if ( !port()->send(a) ) return false; + if ( !port()->receiveEnd() ) return false; + + return true; +} + +bool Psp::Hardware::setRange(uint start, uint size) +{ + QMemArray<uchar> a(6); + a[0] = 0x8E; + a[1] = start >> 16; + a[2] = (start >> 8) & 0xFF; + a[3] = start & 0xFF; + a[4] = size >> 8; + a[5] = size & 0xFF; + if ( !port()->send(a) ) return false; + QMemArray<uchar> r; + if ( !port()->receive(6, r) ) return false; + for (uint i=0; i<6; i++) { + if ( r[i]!=a[i] ) { + log(Log::LineType::Error, i18n("Failed to set range")); + return false; + } + } + return true; +} + +char Psp::Hardware::readCommand(Pic::MemoryRangeType type) +{ + switch (type.type()) { + case Pic::MemoryRangeType::Code: return 'T'; + case Pic::MemoryRangeType::Eeprom: return 'd'; + case Pic::MemoryRangeType::Config: return 'f'; + case Pic::MemoryRangeType::UserId: return 'e'; + case Pic::MemoryRangeType::Cal: return 'c'; + case Pic::MemoryRangeType::DeviceId: + case Pic::MemoryRangeType::CalBackup: + case Pic::MemoryRangeType::DebugVector: + case Pic::MemoryRangeType::ProgramExecutive: + case Pic::MemoryRangeType::HardwareStack: + case Pic::MemoryRangeType::Nb_Types: break; + } + return 0; +} + +char Psp::Hardware::writeCommand(Pic::MemoryRangeType type) +{ + switch (type.type()) { + case Pic::MemoryRangeType::Code: return 'Q'; + case Pic::MemoryRangeType::Eeprom: return 'i'; + case Pic::MemoryRangeType::Config: return 'g'; + case Pic::MemoryRangeType::UserId: return 'h'; + case Pic::MemoryRangeType::Cal: return 'q'; + case Pic::MemoryRangeType::DeviceId: + case Pic::MemoryRangeType::CalBackup: + case Pic::MemoryRangeType::DebugVector: + case Pic::MemoryRangeType::ProgramExecutive: + case Pic::MemoryRangeType::HardwareStack: + case Pic::MemoryRangeType::Nb_Types: break; + } + return 0; +} + +bool Psp::Hardware::readMemory(Pic::MemoryRangeType type, Device::Array &data, const ::Programmer::VerifyData *vdata) +{ + QMemArray<uchar> a; + uint nbWords = device().nbWords(type); + data.resize(nbWords); + uint nbBytes = nbWords * device().nbBytesWord(type); + char c = readCommand(type); + switch (type.type()) { + case Pic::MemoryRangeType::Code: + if ( !setRange(0, nbWords) ) return false; + if ( !port()->commandAck(c) ) return false; + for (uint i=0; i<data.count(); i++) { + if ( !port()->receive(2, a) ) return false; + data[i] = (a[0] << 8) + a[1]; +// log(Log::DebugLevel::Max, QString("code data %1: %2 (%3, %4)").arg(i).arg(toHexLabel(data[i], 4)) +// .arg(toHexLabel(a[0], 2)).arg(toHexLabel(a[1], 2))); + } + if ( !port()->receiveEnd() ) return false; + break; + case Pic::MemoryRangeType::Eeprom: + if ( !port()->commandAck(c) ) return false; + for (uint i=0; i<data.count(); i++) { + if ( !port()->receive(1, a) ) return false; + data[i] = a[0]; + } + if ( !port()->receiveEnd() ) return false; + break; + case Pic::MemoryRangeType::UserId: + if ( !port()->commandAckEnd(c, nbBytes+2, a) ) return false; + for (uint i=0; i<data.count(); i++) data[i] = (a[1+2*i] << 8) + a[1+2*i+1]; + break; + case Pic::MemoryRangeType::Config: + if ( !port()->commandAckEnd(c, nbBytes+2, a) ) return false; + for (uint i=0; i<data.count(); i++) data[i] = (a[1+2*i] << 8) + a[1+2*i+1]; + break; + case Pic::MemoryRangeType::Cal: + if ( !setRange(0, nbWords) ) return false; + if ( !port()->commandAckEnd(c, nbBytes+2, a) ) return false; + for (uint i=0; i<data.count(); i++) data[i] = (a[1+2*i] << 8) + a[1+2*i+1]; + break; + case Pic::MemoryRangeType::DeviceId: + case Pic::MemoryRangeType::CalBackup: + data.resize(0); + return true; + case Pic::MemoryRangeType::DebugVector: + case Pic::MemoryRangeType::HardwareStack: + case Pic::MemoryRangeType::ProgramExecutive: + case Pic::MemoryRangeType::Nb_Types: Q_ASSERT(false); return false; + } + if (vdata) { + for (uint i=0; i<data.count(); i++) + if ( !verifyWord(i, data[i], type, *vdata) ) return false; + } + return true; +} + +bool Psp::Hardware::writeMemory(Pic::MemoryRangeType type, const Device::Array &data, bool force) +{ + Q_UNUSED(force); // #### TODO: optimize for program memory + if ( type==Pic::MemoryRangeType::Code && !setRange(0, data.count()) ) return false; + uint nbBytes = device().nbBytesWord(type); + if ( !port()->commandAck(writeCommand(type)) ) return false; + for (uint i=0; i<data.count(); i++) + if ( !port()->sendData(data[i].toUInt(), nbBytes) ) return false; + return port()->receiveEnd(); +} + +bool Psp::Hardware::eraseAll() +{ + QMemArray<uchar> a; + if ( !port()->commandAck(0x8F, 2, &a) ) return false; + if ( a[1]!=0x00 ) { + log(Log::LineType::Error, i18n("Erase failed")); + return false; + } + return true; +} diff --git a/src/progs/psp/base/psp.h b/src/progs/psp/base/psp.h new file mode 100644 index 0000000..ad4a160 --- /dev/null +++ b/src/progs/psp/base/psp.h @@ -0,0 +1,63 @@ +/*************************************************************************** + * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> * + * Copyright (C) 2002-2003 Stephen Landamore <stephen@landamore.com> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#ifndef PSP_H +#define PSP_H + +#include "devices/pic/prog/pic_prog.h" +#include "psp_serial.h" +#include "psp_data.h" + +namespace Psp +{ + extern QMemArray<uchar> createConfigInfo(const Pic::Data &data); + extern QMemArray<uchar> createDeviceInfo(const Pic::Data &data); + +//----------------------------------------------------------------------------- +class Hardware : public Programmer::PicHardware +{ +public: + Hardware(::Programmer::Base &base, const QString &portDevice); + SerialPort *port() { return static_cast<SerialPort *>(_port); } + virtual bool uploadFirmware(const Pic::Memory &) { return false; } + virtual bool setTarget(); + virtual bool getFirmwareVersion(VersionData &version); + virtual bool readMemory(Pic::MemoryRangeType type, Device::Array &data, const ::Programmer::VerifyData *vdata); + virtual bool writeMemory(Pic::MemoryRangeType type, const Device::Array &data, bool force); + virtual bool eraseAll(); + virtual bool internalConnectHardware(); + +private: + bool setRange(uint start, uint end); + static char readCommand(Pic::MemoryRangeType type); + static char writeCommand(Pic::MemoryRangeType type); +}; + +//----------------------------------------------------------------------------- +class DeviceSpecific : public ::Programmer::PicDeviceSpecific +{ +public: + DeviceSpecific(::Programmer::Base &base) : ::Programmer::PicDeviceSpecific(base) {} + virtual bool canEraseAll() const { return true; } + virtual bool canEraseRange(Pic::MemoryRangeType) const { return false; } + virtual bool canReadRange(Pic::MemoryRangeType type) const { return ( type!=Pic::MemoryRangeType::DeviceId ); } + virtual bool canWriteRange(Pic::MemoryRangeType) const { return true; } + Hardware &hardware() { return static_cast<Hardware &>(*_base.hardware()); } + virtual bool setPowerOff() { return false; } + virtual bool setPowerOn() { return false; } + virtual bool setTargetPowerOn(bool) { return true; } + virtual bool doEraseRange(Pic::MemoryRangeType) { return false; } + virtual bool doErase(bool) { return hardware().eraseAll(); } + virtual bool doRead(Pic::MemoryRangeType type, Device::Array &data, const ::Programmer::VerifyData *vdata) { return hardware().readMemory(type, data, vdata); } + virtual bool doWrite(Pic::MemoryRangeType type, const Device::Array &data, bool force) { return hardware().writeMemory(type, data, force); } +}; + +} // namespace + +#endif diff --git a/src/progs/psp/base/psp.xml b/src/progs/psp/base/psp.xml new file mode 100644 index 0000000..a009584 --- /dev/null +++ b/src/progs/psp/base/psp.xml @@ -0,0 +1,195 @@ +<!-- ************************************************************************* --> +<!-- * Copyright (C) 2005-2007 Nicolas Hadacek <hadacek@kde.org> * --> +<!-- * * --> +<!-- * This program is free software; you can redistribute it and/or modify * --> +<!-- * it under the terms of the GNU General Public License as published by * --> +<!-- * the Free Software Foundation; either version 2 of the License, or * --> +<!-- * (at your option) any later version. * --> +<!-- *************************************************************************/--> +<!DOCTYPE piklab> + +<type name="psp"> + <device name="10F200" family="generic" algorithm="29" overprogram="1" tries="1" /> + <device name="10F202" family="generic" algorithm="29" overprogram="1" tries="1" /> + <device name="10F204" family="generic" algorithm="29" overprogram="1" tries="1" /> + <device name="10F206" family="generic" algorithm="29" overprogram="1" tries="1" /> + + <device name="12C508" family="generic" algorithm="10" overprogram="11" tries="8" /> + <device name="12C508A" family="generic" algorithm="10" overprogram="11" tries="8" /> + <device name="12F508" family="generic" algorithm="28" overprogram="1" tries="1" /> + <device name="12C509" family="generic" algorithm="10" overprogram="11" tries="8" /> + <device name="12C509A" family="generic" algorithm="10" overprogram="11" tries="8" /> + <device name="12F509" family="generic" algorithm="28" overprogram="1" tries="1" /> + <device name="12C671" family="generic" algorithm="9" overprogram="3" tries="25" /> + <device name="12C672" family="generic" algorithm="9" overprogram="3" tries="25" /> + <device name="12CE518" family="generic" algorithm="10" overprogram="11" tries="8" /> + <device name="12CE519" family="generic" algorithm="10" overprogram="11" tries="8" /> + <device name="12CE673" family="generic" algorithm="9" overprogram="3" tries="25" /> + <device name="12CE674" family="generic" algorithm="9" overprogram="3" tries="25" /> + <device name="12CR509A" family="generic" algorithm="10" overprogram="11" tries="8" /> + <device name="12F629" family="generic" algorithm="15" overprogram="1" tries="1" support_type="tested" /> + <device name="12F675" family="generic" algorithm="15" overprogram="1" tries="1" support_type="tested" /> + <device name="12F683" family="generic" algorithm="15" overprogram="1" tries="1" support_type="tested" /> + + <device name="14000" family="generic" algorithm="1" overprogram="3" tries="25" /> + + <device name="16C505" family="generic" algorithm="10" overprogram="11" tries="8" /> + <device name="16C52" family="generic" algorithm="5" overprogram="11" tries="8" /> + <device name="16C54" family="generic" algorithm="5" overprogram="11" tries="8" /> + <device name="16C54A" family="generic" algorithm="5" overprogram="11" tries="8" /> + <device name="16C54B" family="generic" algorithm="5" overprogram="11" tries="8" /> + <device name="16C54C" family="generic" algorithm="5" overprogram="11" tries="8" /> + <device name="16C55" family="generic" algorithm="6" overprogram="11" tries="8" /> + <device name="16C554" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16C558" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16C55A" family="generic" algorithm="6" overprogram="11" tries="8" /> + <device name="16C56" family="generic" algorithm="5" overprogram="11" tries="8" /> + <device name="16C56A" family="generic" algorithm="5" overprogram="11" tries="8" /> + <device name="16C57" family="generic" algorithm="6" overprogram="11" tries="8" /> + <device name="16C57C" family="generic" algorithm="6" overprogram="11" tries="8" /> + <device name="16C58A" family="generic" algorithm="5" overprogram="11" tries="8" /> + <device name="16C58B" family="generic" algorithm="5" overprogram="11" tries="8" /> + <device name="16C61" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16C62" family="generic" algorithm="3" overprogram="3" tries="25" /> + <device name="16C620" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16C620A" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16C621" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16C621A" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16C622" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16C622A" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16C62A" family="generic" algorithm="3" overprogram="3" tries="25" /> + <device name="16C62B" family="generic" algorithm="3" overprogram="3" tries="25" /> + <device name="16C63" family="generic" algorithm="3" overprogram="3" tries="25" /> + <device name="16C63A" family="generic" algorithm="3" overprogram="3" tries="25" /> + <device name="16C64" family="generic" algorithm="4" overprogram="3" tries="25" /> + <device name="16C642" family="generic" algorithm="3" overprogram="3" tries="25" /> + <device name="16C64A" family="generic" algorithm="4" overprogram="3" tries="25" /> + <device name="16C65" family="generic" algorithm="4" overprogram="3" tries="25" /> + <device name="16C65A" family="generic" algorithm="4" overprogram="3" tries="25" /> + <device name="16C65B" family="generic" algorithm="4" overprogram="3" tries="25" /> + <device name="16C66" family="generic" algorithm="3" overprogram="3" tries="25" /> + <device name="16C662" family="generic" algorithm="4" overprogram="3" tries="25" /> + <device name="16C67" family="generic" algorithm="4" overprogram="3" tries="25" /> + <device name="16C71" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16C710" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16C711" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16C712" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16C715" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16C716" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16C717" family="generic" algorithm="12" overprogram="3" tries="25" /> + <device name="16C72" family="generic" algorithm="3" overprogram="3" tries="25" /> + <device name="16C72A" family="generic" algorithm="3" overprogram="3" tries="25" /> + <device name="16C73" family="generic" algorithm="3" overprogram="3" tries="25" /> + <device name="16C73A" family="generic" algorithm="3" overprogram="3" tries="25" /> + <device name="16C73B" family="generic" algorithm="3" overprogram="3" tries="25" /> + <device name="16C74" family="generic" algorithm="4" overprogram="3" tries="25" /> + <device name="16C745" family="generic" algorithm="3" overprogram="3" tries="25" /> + <device name="16C74A" family="generic" algorithm="4" overprogram="3" tries="25" /> + <device name="16C74B" family="generic" algorithm="4" overprogram="3" tries="25" /> + <device name="16C76" family="generic" algorithm="3" overprogram="3" tries="25" /> + <device name="16C765" family="generic" algorithm="4" overprogram="3" tries="25" /> + <device name="16C77" family="generic" algorithm="4" overprogram="3" tries="25" /> + <device name="16C770" family="generic" algorithm="8" overprogram="3" tries="25" /> + <device name="16C771" family="generic" algorithm="8" overprogram="3" tries="25" /> + <device name="16C773" family="generic" algorithm="4" overprogram="3" tries="25" /> + <device name="16C774" family="generic" algorithm="4" overprogram="3" tries="25" /> + <device name="16C781" family="generic" algorithm="8" overprogram="3" tries="25" /> + <device name="16C782" family="generic" algorithm="8" overprogram="3" tries="25" /> + <device name="16C84" family="generic" algorithm="2" overprogram="3" tries="1" /> + <device name="16C923" family="generic" algorithm="4" overprogram="3" tries="25" /> + <device name="16C924" family="generic" algorithm="4" overprogram="3" tries="25" /> + <device name="16C925" family="generic" algorithm="4" overprogram="3" tries="25" /> + <device name="16C926" family="generic" algorithm="4" overprogram="3" tries="25" /> + <device name="16CE623" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16CE624" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16CE625" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16CR620A" family="generic" algorithm="2" overprogram="3" tries="25" /> + <device name="16CR72" family="generic" algorithm="3" overprogram="3" tries="25" /> + + <device name="16F54" family="generic" algorithm="5" overprogram="11" tries="8" /> + <device name="16F57" family="generic" algorithm="6" overprogram="11" tries="8" /> + <device name="16F627" family="generic" algorithm="12" overprogram="0" tries="1" support_type="tested" /> + <device name="16F627A" family="generic" algorithm="19" overprogram="0" tries="1" /> + <device name="16F628" family="generic" algorithm="12" overprogram="0" tries="1" support_type="tested" /> + <device name="16F628A" family="generic" algorithm="19" overprogram="0" tries="1" /> + <device name="16F630" family="generic" algorithm="15" overprogram="0" tries="1" /> + <device name="16F648A" family="generic" algorithm="19" overprogram="1" tries="1" /> + <device name="16F676" family="generic" algorithm="15" overprogram="0" tries="1" /> + <device name="16F684" family="generic" algorithm="21" overprogram="0" tries="1" /> + <device name="16F688" family="generic" algorithm="21" overprogram="0" tries="1" /> + <device name="16F690" family="generic" algorithm="21" overprogram="0" tries="1" /> + <device name="16F716" family="generic" algorithm="22" overprogram="0" tries="1" /> + <device name="16F72" family="generic" algorithm="13" overprogram="0" tries="1" /> + <device name="16F73" family="generic" algorithm="13" overprogram="0" tries="1" /> + <device name="16F737" family="generic" algorithm="23" overprogram="3" tries="1" /> + <device name="16F74" family="generic" algorithm="13" overprogram="0" tries="1" /> + <device name="16F747" family="generic" algorithm="23" overprogram="3" tries="1" /> + <device name="16F76" family="generic" algorithm="13" overprogram="0" tries="1" /> + <device name="16F767" family="generic" algorithm="23" overprogram="3" tries="1" /> + <device name="16F77" family="generic" algorithm="13" overprogram="0" tries="1" /> + <device name="16F777" family="generic" algorithm="23" overprogram="3" tries="1" /> + <device name="16F818" family="generic" algorithm="16" overprogram="0" tries="1" /> + <device name="16F819" family="generic" algorithm="16" overprogram="0" tries="1" /> + <device name="16F83" family="generic" algorithm="2" overprogram="3" tries="1" /> + <device name="16F84" family="generic" algorithm="2" overprogram="3" tries="1" /> + <device name="16F84A" family="generic" algorithm="2" overprogram="0" tries="1" /> + <device name="16F87" family="generic" algorithm="20" overprogram="0" tries="1" /> + <device name="16F870" family="generic" algorithm="3" overprogram="0" tries="1" /> + <device name="16F871" family="generic" algorithm="4" overprogram="0" tries="1" /> + <device name="16F872" family="generic" algorithm="3" overprogram="0" tries="1" /> + <device name="16F873" family="generic" algorithm="4" overprogram="0" tries="1" support_type="tested" /> + <device name="16F873A" family="generic" algorithm="17" overprogram="0" tries="1" /> + <device name="16F874" family="generic" algorithm="4" overprogram="0" tries="1" /> + <device name="16F874A" family="generic" algorithm="17" overprogram="0" tries="1" /> + <device name="16F876" family="generic" algorithm="4" overprogram="0" tries="1" /> + <device name="16F876A" family="generic" algorithm="17" overprogram="0" tries="1" /> + <device name="16F877" family="generic" algorithm="4" overprogram="0" tries="1" /> + <device name="16F877A" family="generic" algorithm="17" overprogram="0" tries="1" /> + <device name="16F88" family="generic" algorithm="20" overprogram="0" tries="1" /> + <device name="16F913" family="generic" algorithm="32" overprogram="1" tries="3" /> + <device name="16F917" family="generic" algorithm="32" overprogram="1" tries="3" /> + <device name="16HV540" family="generic" algorithm="5" overprogram="11" tries="8" /> + + <device name="17C42" family="generic" algorithm="7" overprogram="3" tries="25" /> + <device name="17C42A" family="generic" algorithm="7" overprogram="3" tries="25" /> + <device name="17C43" family="generic" algorithm="7" overprogram="3" tries="25" /> + <device name="17C44" family="generic" algorithm="7" overprogram="3" tries="25" /> + <device name="17C752" family="generic" algorithm="7" overprogram="3" tries="25" /> + <device name="17C756" family="generic" algorithm="7" overprogram="3" tries="25" /> + <device name="17C756A" family="generic" algorithm="7" overprogram="3" tries="25" /> + <device name="17C762" family="generic" algorithm="7" overprogram="3" tries="25" /> + <device name="17C766" family="generic" algorithm="7" overprogram="3" tries="25" /> +<!-- + <device name="18C242" family="generic" algorithm="11" overprogram="3" tries="25" /> + <device name="18C252" family="generic" algorithm="11" overprogram="3" tries="25" /> + <device name="18C442" family="generic" algorithm="11" overprogram="3" tries="25" /> + <device name="18C452" family="generic" algorithm="11" overprogram="3" tries="25" /> + <device name="18C658" family="generic" algorithm="11" overprogram="3" tries="25" /> + <device name="18C858" family="generic" algorithm="11" overprogram="3" tries="25" /> + + <device name="18F1220" family="generic" algorithm="18" overprogram="1" tries="1" /> + <device name="18F1320" family="generic" algorithm="18" overprogram="1" tries="1" /> + <device name="18F2220" family="generic" algorithm="24" overprogram="1" tries="1" /> + <device name="18F2320" family="generic" algorithm="24" overprogram="1" tries="1" /> + <device name="18F242" family="generic" algorithm="14" overprogram="3" tries="25" /> + <device name="18F2455" family="generic" algorithm="30" overprogram="3" tries="13" /> + <device name="18F248" family="generic" algorithm="14" overprogram="3" tries="25" /> + <device name="18F252" family="generic" algorithm="14" overprogram="3" tries="25" /> + <device name="18F258" family="generic" algorithm="14" overprogram="3" tries="25" /> + <device name="18F2680" family="generic" algorithm="30" overprogram="3" tries="13" /> + <device name="18F4220" family="generic" algorithm="24" overprogram="1" tries="1" /> + <device name="18F4320" family="generic" algorithm="24" overprogram="1" tries="1" /> + <device name="18F442" family="generic" algorithm="14" overprogram="3" tries="25" /> + <device name="18F4431" family="generic" algorithm="14" overprogram="3" tries="25" /> + <device name="18F4455" family="generic" algorithm="30" overprogram="3" tries="13" /> + <device name="18F448" family="generic" algorithm="14" overprogram="3" tries="25" /> + <device name="18F452" family="generic" algorithm="14" overprogram="3" tries="25" /> + <device name="18F4550" family="generic" algorithm="14" overprogram="3" tries="25" /> + <device name="18F458" family="generic" algorithm="14" overprogram="3" tries="25" /> + <device name="18F6620" family="generic" algorithm="14" overprogram="3" tries="25" /> + <device name="18F6520" family="generic" algorithm="14" overprogram="3" tries="25" /> + <device name="18F6720" family="generic" algorithm="14" overprogram="3" tries="25" /> + <device name="18F8620" family="generic" algorithm="14" overprogram="3" tries="25" /> + <device name="18F8720" family="generic" algorithm="14" overprogram="3" tries="25" /> +--> +</type> diff --git a/src/progs/psp/base/psp_data.h b/src/progs/psp/base/psp_data.h new file mode 100644 index 0000000..c643961 --- /dev/null +++ b/src/progs/psp/base/psp_data.h @@ -0,0 +1,23 @@ +/*************************************************************************** + * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#ifndef PSP_DATA_H +#define PSP_DATA_H + +#include <qstring.h> + +namespace Psp +{ + struct Data { + uint algorithm, overprogram, tries; + }; + extern bool isSupported(const QString &device); + extern const Data &data(const QString &device); +} // namespace + +#endif diff --git a/src/progs/psp/base/psp_prog.cpp b/src/progs/psp/base/psp_prog.cpp new file mode 100644 index 0000000..891cb73 --- /dev/null +++ b/src/progs/psp/base/psp_prog.cpp @@ -0,0 +1,31 @@ +/*************************************************************************** + * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#include "psp_prog.h" + +//---------------------------------------------------------------------------- +bool Psp::Base::readFirmwareVersion() +{ + return hardware().getFirmwareVersion(_firmwareVersion); +} + +//---------------------------------------------------------------------------- +Programmer::Properties Psp::Group::properties() const +{ + return ::Programmer::Programmer | ::Programmer::HasFirmware | ::Programmer::CanReadMemory | ::Programmer::HasConnectedState; // | ::Programmer::CanUploadFirmware; +} + +Programmer::Hardware *Psp::Group::createHardware(::Programmer::Base &base, const ::Programmer::HardwareDescription &hd) const +{ + return new Hardware(base, hd.port.device); +} + +Programmer::DeviceSpecific *Psp::Group::createDeviceSpecific(::Programmer::Base &base) const +{ + return new DeviceSpecific(base); +} diff --git a/src/progs/psp/base/psp_prog.h b/src/progs/psp/base/psp_prog.h new file mode 100644 index 0000000..ef525cd --- /dev/null +++ b/src/progs/psp/base/psp_prog.h @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#ifndef PSP_PROG_H +#define PSP_PROG_H + +#include "common/global/global.h" +#include "psp.h" + +namespace Psp +{ +//----------------------------------------------------------------------------- +class Base : public Programmer::PicBase +{ +Q_OBJECT +public: + Base(const Programmer::Group &group, const Pic::Data *data) + : Programmer::PicBase(group, data, "psp_programmer_base") {} + virtual bool readFirmwareVersion(); + virtual bool setTarget() { return hardware().setTarget(); } + +protected: + Hardware &hardware() { return static_cast<Hardware &>(*_hardware); } + virtual VersionData firmwareVersion(Programmer::FirmwareVersionType type) const { return (type==Programmer::FirmwareVersionType::Min ? VersionData(4, 30, 3) : VersionData()); } +}; + +//----------------------------------------------------------------------------- +class Group : public ::Programmer::PicGroup +{ +public: + virtual QString name() const { return "psp"; } + virtual QString label() const { return i18n("Picstart Plus"); } + virtual QString xmlName() const { return "psp"; } + virtual ::Programmer::Properties properties() const; + virtual ::Programmer::TargetPowerMode targetPowerMode() const { return ::Programmer::TargetExternallyPowered; } + virtual bool isPortSupported(PortType type) const { return ( type==PortType::Serial ); } + virtual bool canReadVoltage(Pic::VoltageType type) const { return ( type==Pic::TargetVdd || type==Pic::TargetVpp ); } + +protected: + virtual void initSupported(); + virtual ::Programmer::Base *createBase(const Device::Data *data) const { return new ::Psp::Base(*this, static_cast<const Pic::Data *>(data)); } + virtual ::Programmer::Hardware *createHardware(::Programmer::Base &base, const ::Programmer::HardwareDescription &hd) const; + virtual ::Programmer::DeviceSpecific *createDeviceSpecific(::Programmer::Base &base) const; +}; + +} // namespace + +#endif diff --git a/src/progs/psp/base/psp_serial.cpp b/src/progs/psp/base/psp_serial.cpp new file mode 100644 index 0000000..964d604 --- /dev/null +++ b/src/progs/psp/base/psp_serial.cpp @@ -0,0 +1,110 @@ +/*************************************************************************** + * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> * + * Copyright (C) 2002-2003 Stephen Landamore <stephen@landamore.com> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#include "psp_serial.h" + +#include "common/global/global.h" +#include "common/common/misc.h" +#include "common/common/number.h" + +//----------------------------------------------------------------------------- +Psp::SerialPort::SerialPort(const QString &device, Log::Base &log) + : Port::Serial(device, NeedFlush, log) +{} + +bool Psp::SerialPort::open() +{ + if ( !Port::Serial::open() ) return false; + return setMode(NoInputFlag, ByteSize8 | IgnoreControlLines | EnableReceiver, S19200, 100); +} + +bool Psp::SerialPort::reset() +{ + if ( !setHardwareFlowControl(false) ) return false; + // reset + setPinOn(DTR, false, Port::PositiveLogic); + Port::msleep(250); + // remove reset + setPinOn(DTR, true, Port::PositiveLogic); + for (uint i=0; i<=100; i++) { + bool bit; + if ( !readPin(CTS, Port::PositiveLogic, bit) ) return false; + if ( bit ) break; + if ( i==100 ) { + log(Log::LineType::Error, i18n("Could not contact Picstart+")); + return false; + } + Port::msleep(1); + } + if ( !setHardwareFlowControl(true) ) return false; + return flush(0); +} + +bool Psp::SerialPort::command(uchar c, uint nbBytes, QMemArray<uchar> &a) +{ + log(Log::DebugLevel::Extra, QString("Command %1").arg(toHexLabel(c, 2))); + if ( !sendChar(c) ) return false; + return receive(nbBytes, a); +} + +bool Psp::SerialPort::checkAck(uchar ec, uchar rc) +{ + if ( ec==rc ) return true; + log(Log::LineType::Error, i18n("Incorrect ack: expecting %1, received %2") + .arg(QString(toHex(ec, 2))).arg(QString(toHex(rc, 2)))); + return false; +} + +bool Psp::SerialPort::checkEnd(uchar c) +{ + if ( c==0 ) return true; + log(Log::LineType::Error, i18n("Incorrect received data end: expecting 00, received %1") + .arg(QString(toHex(c, 2)))); + return false; +} + +bool Psp::SerialPort::commandAck(uchar c, uint nbBytes, QMemArray<uchar> *a) +{ + Q_ASSERT( nbBytes>=1 ); + QMemArray<uchar> tmp; + if ( !command(c, nbBytes, tmp) ) return false; + if ( !checkAck(c, tmp[0]) ) return false; + if (a) *a = tmp; + return true; +} + +bool Psp::SerialPort::receiveEnd() +{ + QMemArray<uchar> a; + if ( !receive(1, a) ) return false; + if ( !checkEnd(a[0]) ) return false; + return true; +} + +bool Psp::SerialPort::commandAckEnd(uchar c, uint nbBytes, QMemArray<uchar> &a) +{ + Q_ASSERT( nbBytes>=2 ); + if ( !command(c, nbBytes, a) ) return false; + if ( !checkAck(c, a[0]) ) return false; + if ( !checkEnd(a[nbBytes-1]) ) return false; + return true; +} + +bool Psp::SerialPort::sendData(uint value, uint nbBytes) +{ + Q_ASSERT( nbBytes==1 || nbBytes==2 ); + Q_ASSERT( value<uint(1 << 8*nbBytes) ); + QMemArray<uchar> a(nbBytes); + if ( nbBytes==2 ) { + a[0] = value / 256; + a[1] = value & 0xFF; + } else a[0] = value; + if ( !send(a) ) return false; + return receive(nbBytes, a); +} diff --git a/src/progs/psp/base/psp_serial.h b/src/progs/psp/base/psp_serial.h new file mode 100644 index 0000000..6f379dd --- /dev/null +++ b/src/progs/psp/base/psp_serial.h @@ -0,0 +1,37 @@ +/*************************************************************************** + * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> * + * Copyright (C) 2002-2003 Stephen Landamore <stephen@landamore.com> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#ifndef PSP_SERIAL_H +#define PSP_SERIAL_H + +#include "common/port/serial.h" + +namespace Psp +{ + +class SerialPort : public Port::Serial +{ +public: + SerialPort(const QString &portDevice, Log::Base &log); + bool open(); + bool reset(); + bool command(uchar c, uint nbBytes, QMemArray<uchar> &a); + bool commandAck(uchar c, uint nbBytes = 1, QMemArray<uchar> *a = 0); + bool commandAckEnd(uchar c, uint nbBytes, QMemArray<uchar> &a); + bool receiveEnd(); + bool sendData(uint value, uint nbBytes); + +private: + bool checkAck(uchar ec, uchar rc); + bool checkEnd(uchar c); +}; + +} // namespace + +#endif diff --git a/src/progs/psp/gui/Makefile.am b/src/progs/psp/gui/Makefile.am new file mode 100644 index 0000000..c11240d --- /dev/null +++ b/src/progs/psp/gui/Makefile.am @@ -0,0 +1,6 @@ +INCLUDES = -I$(top_srcdir)/src $(all_includes) +METASOURCES = AUTO + +noinst_LTLIBRARIES = libpspui.la +libpspui_la_LDFLAGS = $(all_libraries) +libpspui_la_SOURCES = psp_group_ui.cpp diff --git a/src/progs/psp/gui/psp_group_ui.cpp b/src/progs/psp/gui/psp_group_ui.cpp new file mode 100644 index 0000000..e3f2546 --- /dev/null +++ b/src/progs/psp/gui/psp_group_ui.cpp @@ -0,0 +1,22 @@ +/*************************************************************************** + * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#include "psp_group_ui.h" + +#include "progs/gui/prog_config_widget.h" +#include "devices/pic/gui/pic_prog_group_ui.h" + +::Programmer::ConfigWidget *Psp::GroupUI::createConfigWidget(QWidget *parent) const +{ + return new ::Programmer::ConfigWidget(static_cast<const ::Programmer::Group &>(group()), parent); +} + +::Programmer::AdvancedDialog *Psp::GroupUI::createAdvancedDialog(::Programmer::Base &base, QWidget *parent) const +{ + return new ::Programmer::PicAdvancedDialog(static_cast< ::Programmer::PicBase &>(base), parent, "psp_advanced_dialog"); +} diff --git a/src/progs/psp/gui/psp_group_ui.h b/src/progs/psp/gui/psp_group_ui.h new file mode 100644 index 0000000..fc1534a --- /dev/null +++ b/src/progs/psp/gui/psp_group_ui.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#ifndef PSP_GROUP_UI_H +#define PSP_GROUP_UI_H + +#include "devices/pic/gui/pic_prog_group_ui.h" + +namespace Psp +{ +class Group; + +class GroupUI : public ::Programmer::GroupUI +{ +public: + virtual ::Programmer::ConfigWidget *createConfigWidget(QWidget *parent) const; + virtual bool hasAdvancedDialog() const { return true; } + virtual ::Programmer::AdvancedDialog *createAdvancedDialog(::Programmer::Base &base, QWidget *parent) const; +}; + +} // namespace + +#endif diff --git a/src/progs/psp/psp.pro b/src/progs/psp/psp.pro new file mode 100644 index 0000000..60ac0f5 --- /dev/null +++ b/src/progs/psp/psp.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = xml base diff --git a/src/progs/psp/xml/Makefile.am b/src/progs/psp/xml/Makefile.am new file mode 100644 index 0000000..156e485 --- /dev/null +++ b/src/progs/psp/xml/Makefile.am @@ -0,0 +1,14 @@ +INCLUDES = -I$(top_srcdir)/src $(all_includes) +METASOURCES = AUTO + +noinst_PROGRAMS = xml_psp_parser +xml_psp_parser_SOURCES = xml_psp_parser.cpp +OBJECTS = $(top_builddir)/src/devices/list/libdevicelistnoui.la \ + $(top_builddir)/src/devices/pic/pic/libpic.la $(top_builddir)/src/devices/pic/base/libpicbase.la \ + $(top_builddir)/src/devices/pic/xml_data/libpicxml.la \ + $(top_builddir)/src/devices/mem24/mem24/libmem24.la $(top_builddir)/src/devices/mem24/base/libmem24base.la \ + $(top_builddir)/src/devices/mem24/xml_data/libmem24xml.la \ + $(top_builddir)/src/xml_to_data/libxmltodata.la $(top_builddir)/src/devices/base/libdevicebase.la \ + $(top_builddir)/src/common/common/libcommon.la +xml_psp_parser_DEPENDENCIES = $(OBJECTS) +xml_psp_parser_LDADD = $(OBJECTS) $(LIB_KDECORE) diff --git a/src/progs/psp/xml/xml.pro b/src/progs/psp/xml/xml.pro new file mode 100644 index 0000000..0c88b4c --- /dev/null +++ b/src/progs/psp/xml/xml.pro @@ -0,0 +1,17 @@ +STOPDIR = ../../../.. +include($${STOPDIR}/app.pro) + +TARGET = xml_psp_parser +SOURCES += xml_psp_parser.cpp +LIBS += ../../../devices/list/libdevicelist.a \ + ../../../devices/mem24/mem24/libmem24.a ../../../devices/mem24/xml_data/libmem24xml.a \ + ../../../devices/mem24/base/libmem24base.a \ + ../../../devices/pic/pic/libpic.a ../../../devices/pic/xml_data/libpicxml.a \ + ../../../devices/pic/base/libpicbase.a ../../../xml_to_data/libxmltodata.a \ + ../../../devices/base/libdevicebase.a ../../../common/global/libglobal.a \ + ../../../common/nokde/libnokde.a ../../../common/common/libcommon.a + +unix:QMAKE_POST_LINK = cd ../base && ../xml/xml_psp_parser +unix:QMAKE_CLEAN += ../base/psp_data.cpp +win32:QMAKE_POST_LINK = cd ..\base && ..\xml\xml_psp_parser.exe +win32:QMAKE_CLEAN += ..\base\psp_data.cpp diff --git a/src/progs/psp/xml/xml_psp_parser.cpp b/src/progs/psp/xml/xml_psp_parser.cpp new file mode 100644 index 0000000..5cdd289 --- /dev/null +++ b/src/progs/psp/xml/xml_psp_parser.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#include "xml_to_data/prog_xml_to_data.h" +#include "progs/psp/base/psp_data.h" + +//----------------------------------------------------------------------------- +namespace Psp +{ + +class XmlToData : public Programmer::XmlToData<Data> +{ +public: + XmlToData() : Programmer::XmlToData<Data>("psp", "Psp") {} + +private: + virtual void parseData(QDomElement element, Data &data); + virtual void outputData(const Data &data, QTextStream &s) const; +}; + +void Psp::XmlToData::parseData(QDomElement element, Data &data) +{ + bool ok; + data.algorithm = element.attribute("algorithm").toUInt(&ok); + if ( !ok ) qFatal("Missing or invalid algorithm"); + data.overprogram = element.attribute("overprogram").toUInt(&ok); + if ( !ok ) qFatal("Missing or invalid overprogram"); + data.tries = element.attribute("tries").toUInt(&ok); + if ( !ok ) qFatal("Missing or invalid tries"); +} + +void Psp::XmlToData::outputData(const Data &data, QTextStream &s) const +{ + s << data.algorithm << ", " << data.overprogram << ", " << data.tries; +} + +} // namespace + +//----------------------------------------------------------------------------- +XML_MAIN(Psp::XmlToData) |