diff options
Diffstat (limited to 'src/progs/pickit1')
-rw-r--r-- | src/progs/pickit1/Makefile.am | 3 | ||||
-rw-r--r-- | src/progs/pickit1/base/Makefile.am | 11 | ||||
-rw-r--r-- | src/progs/pickit1/base/base.pro | 6 | ||||
-rw-r--r-- | src/progs/pickit1/base/pickit1.cpp | 102 | ||||
-rw-r--r-- | src/progs/pickit1/base/pickit1.h | 73 | ||||
-rw-r--r-- | src/progs/pickit1/base/pickit1.xml | 52 | ||||
-rw-r--r-- | src/progs/pickit1/base/pickit1_data.h | 23 | ||||
-rw-r--r-- | src/progs/pickit1/base/pickit1_prog.cpp | 28 | ||||
-rw-r--r-- | src/progs/pickit1/base/pickit1_prog.h | 47 | ||||
-rw-r--r-- | src/progs/pickit1/gui/Makefile.am | 6 | ||||
-rw-r--r-- | src/progs/pickit1/gui/pickit1_group_ui.cpp | 23 | ||||
-rw-r--r-- | src/progs/pickit1/gui/pickit1_group_ui.h | 27 | ||||
-rw-r--r-- | src/progs/pickit1/pickit1.pro | 2 | ||||
-rw-r--r-- | src/progs/pickit1/xml/Makefile.am | 14 | ||||
-rw-r--r-- | src/progs/pickit1/xml/xml.pro | 18 | ||||
-rw-r--r-- | src/progs/pickit1/xml/xml_pickit1_parser.cpp | 61 |
16 files changed, 496 insertions, 0 deletions
diff --git a/src/progs/pickit1/Makefile.am b/src/progs/pickit1/Makefile.am new file mode 100644 index 0000000..fccf96d --- /dev/null +++ b/src/progs/pickit1/Makefile.am @@ -0,0 +1,3 @@ +INCLUDES = -I$(top_srcdir)/src $(all_includes) +METASOURCES = AUTO +SUBDIRS = xml base gui diff --git a/src/progs/pickit1/base/Makefile.am b/src/progs/pickit1/base/Makefile.am new file mode 100644 index 0000000..74d56f0 --- /dev/null +++ b/src/progs/pickit1/base/Makefile.am @@ -0,0 +1,11 @@ +INCLUDES = -I$(top_srcdir)/src $(all_includes) +METASOURCES = AUTO + +noinst_LTLIBRARIES = libpickit1.la +libpickit1_la_SOURCES = pickit1.cpp pickit1_prog.cpp pickit1_data.cpp +libpickit1_la_DEPENDENCIES = pickit1_data.cpp + +noinst_DATA = pickit1.xml +pickit1_data.cpp: ../xml/xml_pickit1_parser pickit1.xml + ../xml/xml_pickit1_parser +CLEANFILES = pickit1_data.cpp diff --git a/src/progs/pickit1/base/base.pro b/src/progs/pickit1/base/base.pro new file mode 100644 index 0000000..bdd257b --- /dev/null +++ b/src/progs/pickit1/base/base.pro @@ -0,0 +1,6 @@ +STOPDIR = ../../../.. +include($${STOPDIR}/lib.pro) + +TARGET = pickit1 +HEADERS += pickit1.h pickit1_prog.h pickit1_data.h +SOURCES += pickit1.cpp pickit1_prog.cpp pickit1_data.cpp diff --git a/src/progs/pickit1/base/pickit1.cpp b/src/progs/pickit1/base/pickit1.cpp new file mode 100644 index 0000000..c5ab021 --- /dev/null +++ b/src/progs/pickit1/base/pickit1.cpp @@ -0,0 +1,102 @@ +/*************************************************************************** + * 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 "pickit1.h" + +bool Pickit1::Baseline::init() +{ + Array cmd; + cmd[0] = 'c'; + cmd[1] = 0x00; // Load Configuration + cmd[2] = 0x02; // Load Program latches + cmd[3] = 0x03; // Load Data latches + cmd[4] = 0x04; // Read Program memory + cmd[5] = 0x05; // Read Data latches + cmd[6] = 0x06; // Increment Address + cmd[7] = 0x08; // Begin programming internally timed + if ( !hardware().port().command(cmd) ) return false; + cmd[0] = 0x08; // Begin Programming externally timed + cmd[1] = 0x0E; // End externally time programming cycle + cmd[2] = 0x09; // Bulk Erase program memory + cmd[3] = 0x0B; // Bulk Erase Data memory + cmd[4] = 0xFF; // Read Program memory + cmd[5] = 0xFF; // Read Data latches + cmd[6] = 0xFF; // Increment Address + cmd[7] = 0xFF; // Begin programming internally timed + return hardware().port().command(cmd); +} + +bool Pickit1::Baseline::incrementPC(uint nb) +{ + if ( (nb & 0xFF)!=0 ) return Pickit::Baseline::incrementPC(nb); + // work around bugs in firmware + Array cmd; + uint high = (nb >> 8) & 0xFF; + log(Log::DebugLevel::Extra, QString("work around bug in firmware (nb_inc=%1 high=%2)") + .arg(toHexLabel(nb, 4)).arg(toHexLabel(high, 2))); + if ( high==1 ) { + cmd[0] = 'I'; + cmd[1] = 0x40; + cmd[2] = 0x00; + cmd[3] = 'I'; + cmd[4] = 0xC0; + cmd[5] = 0x00; + } else { + cmd[0] = 'I'; + cmd[1] = 0x00; + cmd[2] = high-1; + } + return hardware().port().command(cmd); +} + +//---------------------------------------------------------------------------- +bool Pickit1::P16F::init() +{ + Array cmd; + cmd[0] = 'c'; + cmd[1] = 0x00; // Load Configuration + cmd[2] = 0x02; // Load Program latches + cmd[3] = 0x03; // Load Data latches + cmd[4] = 0x04; // Read Program memory + cmd[5] = 0x05; // Read Data latches + cmd[6] = 0x06; // Increment Address + cmd[7] = 0x08; // Begin programming internally timed + if ( !hardware().port().command(cmd) ) return false; + cmd[0] = 0x18; // Begin Programming externally timed + cmd[1] = 0x0A; // End externally time programming cycle + cmd[2] = 0x09; // Bulk Erase program memory + cmd[3] = 0x0B; // Bulk Erase Data memory + cmd[4] = 0xFF; // Read Program memory + cmd[5] = 0xFF; // Read Data latches + cmd[6] = 0xFF; // Increment Address + cmd[7] = 0xFF; // Begin programming internally timed + return hardware().port().command(cmd); +} + +bool Pickit1::P16F716::init() +{ + Array cmd; + cmd[0] = 'c'; + cmd[1] = 0x00; // Load Configuration + cmd[2] = 0x02; // Load Program latches + cmd[3] = 0x03; // Load Data latches + cmd[4] = 0x04; // Read Program memory + cmd[5] = 0x05; // Read Data latches + cmd[6] = 0x06; // Increment Address + cmd[7] = 0x08; // Begin programming internally timed + if ( !hardware().port().command(cmd) ) return false; + cmd[0] = 0x18; // Begin Programming externally timed + cmd[1] = 0x0E; // End externally time programming cycle + cmd[2] = 0x09; // Bulk Erase program memory + cmd[3] = 0x0B; // Bulk Erase Data memory + cmd[4] = 0xFF; // Read Program memory + cmd[5] = 0xFF; // Read Data latches + cmd[6] = 0xFF; // Increment Address + cmd[7] = 0xFF; // Begin programming internally timed + return hardware().port().command(cmd); +} diff --git a/src/progs/pickit1/base/pickit1.h b/src/progs/pickit1/base/pickit1.h new file mode 100644 index 0000000..75e1d82 --- /dev/null +++ b/src/progs/pickit1/base/pickit1.h @@ -0,0 +1,73 @@ +/*************************************************************************** + * 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 PICKIT1_H +#define PICKIT1_H + +#include "progs/pickit2/base/pickit.h" +#include "pickit1_data.h" + +namespace Pickit1 +{ +//----------------------------------------------------------------------------- +class Array : public Pickit::Array +{ +public: + Array() : Pickit::Array(8, 'Z', PrintAlphaNum) {} +}; + +//----------------------------------------------------------------------------- +class USBPort : public Pickit::USBPort +{ +public: + USBPort(Log::Base &log) : Pickit::USBPort(0x0032, log) {} + virtual Pickit::Array array() const { return Array(); } + +private: + virtual uint readEndPoint() const { return 0x81; } + virtual uint writeEndPoint() const { return 0x01; } +}; + +//----------------------------------------------------------------------------- +class Hardware : public Pickit::Hardware +{ +public: + Hardware(::Programmer::Base &base) : Pickit::Hardware(base, new USBPort(base)) {} +}; + +//---------------------------------------------------------------------------- +class Baseline : public Pickit::Baseline +{ +public: + Baseline(::Programmer::Base &base) : Pickit::Baseline(base) {} + virtual char entryMode() const { return data(device().name()).entryMode; } + virtual bool init(); + virtual uint nbWrites(Pic::MemoryRangeType) const { return 1; } + virtual bool incrementPC(uint nb); +}; + +//---------------------------------------------------------------------------- +class P16F : public Pickit::P16F +{ +public: + P16F(::Programmer::Base &base) : Pickit::P16F(base) {} + virtual char entryMode() const { return data(device().name()).entryMode; } + virtual bool init(); + virtual uint nbWrites(Pic::MemoryRangeType) const { return 1; } +}; + +class P16F716 : public P16F +{ +public: + P16F716(::Programmer::Base &base) : P16F(base) {} + virtual bool init(); +}; + +} // namespace + +#endif diff --git a/src/progs/pickit1/base/pickit1.xml b/src/progs/pickit1/base/pickit1.xml new file mode 100644 index 0000000..899b504 --- /dev/null +++ b/src/progs/pickit1/base/pickit1.xml @@ -0,0 +1,52 @@ +<!-- ************************************************************************* --> +<!-- * 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. * --> +<!-- *************************************************************************/--> +<!DOCTYPE piklab> + +<type name="pickit1"> + <device name="10F200" family="Baseline" entry="O" support_type="tested" /> + <device name="10F202" family="Baseline" entry="O" support_type="tested" /> + <device name="10F204" family="Baseline" entry="O" support_type="tested" /> + <device name="10F206" family="Baseline" entry="O" support_type="tested" /> + <device name="10F220" family="Baseline" entry="O" /> + <device name="10F222" family="Baseline" entry="O" /> + <device name="12F508" family="Baseline" entry="O" support_type="tested" /> + <device name="12F509" family="Baseline" entry="O" support_type="tested" /> + <device name="12F510" family="Baseline" entry="O" support_type="tested" /> + <device name="16F505" family="Baseline" entry="O" /> + <device name="16F506" family="Baseline" entry="O" /> + <device name="16F54" family="Baseline" entry="O" /> + <device name="16F57" family="Baseline" entry="O" /> + <device name="16F59" family="Baseline" entry="O" /> + + <device name="12F629" family="P16F" entry="P" regen="true" support_type="tested" /> + <device name="12F635" family="P16F" entry="P" support_type="tested" /> + <device name="12F675" family="P16F" entry="P" regen="true" support_type="tested" /> + <device name="12F683" family="P16F" entry="P" support_type="tested" /> + <device name="16F627A" family="P16F" entry="P" /> + <device name="16F628A" family="P16F" entry="P" /> + <device name="16F630" family="P16F" entry="P" regen="true" support_type="tested" /> + <device name="16F636" family="P16F" entry="P" support_type="tested" /> + <device name="16F639" family="P16F" entry="P" support_type="tested" /> + <device name="16F648A" family="P16F" entry="P" /> + <device name="16F676" family="P16F" entry="P" regen="true" support_type="tested" /> + <device name="16F684" family="P16F" entry="P" support_type="tested" /> + <device name="16F685" family="P16F" entry="P" /> + <device name="16F687" family="P16F" entry="P" /> + <device name="16F688" family="P16F" entry="P" support_type="tested" /> + <device name="16F689" family="P16F" entry="P" /> + <device name="16F690" family="P16F" entry="P" /> + <device name="16F716" family="P16F716" entry="O" /> + <device name="16F785" family="P16F" entry="P" /> + <device name="16F877A" family="P16F" entry="O" /> + <device name="16F913" family="P16F" entry="O" /> + <device name="16F914" family="P16F" entry="O" /> + <device name="16F916" family="P16F" entry="O" /> + <device name="16F917" family="P16F" entry="O" /> + <device name="16F946" family="P16F" entry="O" /> +</type> diff --git a/src/progs/pickit1/base/pickit1_data.h b/src/progs/pickit1/base/pickit1_data.h new file mode 100644 index 0000000..767fc4b --- /dev/null +++ b/src/progs/pickit1/base/pickit1_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 PICKIT1_DATA_H +#define PICKIT1_DATA_H + +#include <qstring.h> + +namespace Pickit1 +{ + struct Data { + char entryMode; + bool regenerateOsccal; + }; + extern const Data &data(const QString &device); +} // namespace + +#endif diff --git a/src/progs/pickit1/base/pickit1_prog.cpp b/src/progs/pickit1/base/pickit1_prog.cpp new file mode 100644 index 0000000..b43a19c --- /dev/null +++ b/src/progs/pickit1/base/pickit1_prog.cpp @@ -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. * + ***************************************************************************/ +#include "pickit1_prog.h" + +#include "pickit1.h" + +//---------------------------------------------------------------------------- +bool Pickit1::Base::deviceHasOsccalRegeneration() const +{ + return data(device()->name()).regenerateOsccal; +} + +bool Pickit1::Base::setTarget() +{ + return static_cast<Pickit::DeviceSpecific *>(_specific)->init(); +} + +//---------------------------------------------------------------------------- +Programmer::Hardware *Pickit1::Group::createHardware(Programmer::Base &base, const ::Programmer::HardwareDescription &) const +{ + return new Hardware(base); +} diff --git a/src/progs/pickit1/base/pickit1_prog.h b/src/progs/pickit1/base/pickit1_prog.h new file mode 100644 index 0000000..c0763b4 --- /dev/null +++ b/src/progs/pickit1/base/pickit1_prog.h @@ -0,0 +1,47 @@ +/*************************************************************************** + * 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 PICKIT1_PROG_H +#define PICKIT1_PROG_H + +#include "progs/pickit2/base/pickit_prog.h" + +namespace Pickit1 +{ +//---------------------------------------------------------------------------- +class Base : public Pickit::Base +{ +Q_OBJECT +public: + Base(const Programmer::Group &group, const Pic::Data *data) : Pickit::Base(group, data) {} + virtual bool deviceHasOsccalRegeneration() const; + virtual bool canReadVoltage(Pic::VoltageType) const { return false; } + virtual bool setTarget(); + +private: + virtual VersionData firmwareVersion(Programmer::FirmwareVersionType) const { return VersionData(2, 0, 0); } +}; + +//---------------------------------------------------------------------------- +class Group : public Pickit::Group +{ +public: + virtual QString name() const { return "pickit1"; } + virtual QString label() const { return i18n("PICkit1"); } + virtual Programmer::Properties properties() const { return ::Programmer::Programmer | ::Programmer::HasFirmware | ::Programmer::CanReadMemory | ::Programmer::HasConnectedState; } + +protected: + virtual void initSupported(); + virtual Programmer::Base *createBase(const Device::Data *data) const { return new ::Pickit1::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/pickit1/gui/Makefile.am b/src/progs/pickit1/gui/Makefile.am new file mode 100644 index 0000000..239184b --- /dev/null +++ b/src/progs/pickit1/gui/Makefile.am @@ -0,0 +1,6 @@ +INCLUDES = -I$(top_srcdir)/src $(all_includes) +METASOURCES = AUTO + +noinst_LTLIBRARIES = libpickit1ui.la +libpickit1ui_la_SOURCES = pickit1_group_ui.cpp +libpickit1ui_la_LDFLAGS = $(all_libraries) diff --git a/src/progs/pickit1/gui/pickit1_group_ui.cpp b/src/progs/pickit1/gui/pickit1_group_ui.cpp new file mode 100644 index 0000000..2c862fb --- /dev/null +++ b/src/progs/pickit1/gui/pickit1_group_ui.cpp @@ -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. * + ***************************************************************************/ +#include "pickit1_group_ui.h" + +#include "progs/gui/prog_config_widget.h" +#include "progs/pickit2/gui/pickit2_group_ui.h" +#include "progs/pickit1/base/pickit1_prog.h" + +::Programmer::ConfigWidget *Pickit1::GroupUI::createConfigWidget(QWidget *parent) const +{ + return new ::Programmer::ConfigWidget(static_cast<const ::Programmer::Group &>(group()), parent); +} + +::Programmer::AdvancedDialog *Pickit1::GroupUI::createAdvancedDialog(::Programmer::Base &base, QWidget *parent) const +{ + return new Pickit::AdvancedDialog(static_cast<Base &>(base), parent, "pickit1_advanced_dialog"); +} diff --git a/src/progs/pickit1/gui/pickit1_group_ui.h b/src/progs/pickit1/gui/pickit1_group_ui.h new file mode 100644 index 0000000..5fb8ad6 --- /dev/null +++ b/src/progs/pickit1/gui/pickit1_group_ui.h @@ -0,0 +1,27 @@ +/*************************************************************************** + * 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 PICKIT1_GROUP_UI_H +#define PICKIT1_GROUP_UI_H + +#include "devices/pic/gui/pic_prog_group_ui.h" + +namespace Pickit1 +{ + +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/pickit1/pickit1.pro b/src/progs/pickit1/pickit1.pro new file mode 100644 index 0000000..60ac0f5 --- /dev/null +++ b/src/progs/pickit1/pickit1.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = xml base diff --git a/src/progs/pickit1/xml/Makefile.am b/src/progs/pickit1/xml/Makefile.am new file mode 100644 index 0000000..f0cc91a --- /dev/null +++ b/src/progs/pickit1/xml/Makefile.am @@ -0,0 +1,14 @@ +INCLUDES = -I$(top_srcdir)/src $(all_includes) +METASOURCES = AUTO + +noinst_PROGRAMS = xml_pickit1_parser +xml_pickit1_parser_SOURCES = xml_pickit1_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_pickit1_parser_DEPENDENCIES = $(OBJECTS) +xml_pickit1_parser_LDADD = $(OBJECTS) $(LIB_KDECORE) diff --git a/src/progs/pickit1/xml/xml.pro b/src/progs/pickit1/xml/xml.pro new file mode 100644 index 0000000..e368c49 --- /dev/null +++ b/src/progs/pickit1/xml/xml.pro @@ -0,0 +1,18 @@ +STOPDIR = ../../../.. +include($${STOPDIR}/app.pro) + +TARGET = xml_pickit1_parser +SOURCES += xml_pickit1_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_pickit1_parser +unix:QMAKE_CLEAN += ../base/pickit1_data.cpp +win32:QMAKE_POST_LINK = cd ..\base && ..\xml\xml_pickit1_parser.exe +win32:QMAKE_CLEAN += ..\base\pickit1_data.cpp + diff --git a/src/progs/pickit1/xml/xml_pickit1_parser.cpp b/src/progs/pickit1/xml/xml_pickit1_parser.cpp new file mode 100644 index 0000000..e5d1b78 --- /dev/null +++ b/src/progs/pickit1/xml/xml_pickit1_parser.cpp @@ -0,0 +1,61 @@ +/*************************************************************************** + * 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/pickit1/base/pickit1_data.h" + +namespace Pickit1 +{ + +class XmlToData : public Programmer::XmlToData<Data> +{ +public: + XmlToData() : Programmer::XmlToData<Data>("pickit1", "Pickit1") {} + +private: + virtual void parseData(QDomElement element, Data &data); + virtual void outputData(const Data &data, QTextStream &s) const; + virtual void outputFunctions(QTextStream &s) const; +}; + +void Pickit1::XmlToData::parseData(QDomElement element, Data &data) +{ + QString s = element.attribute("entry"); + if ( s.length()!=1 || (s[0]!='O' && s[0]!='P') ) qFatal("Invalid or missing entry mode"); + data.entryMode = s[0].latin1(); + s = element.attribute("regen"); + if ( s.isEmpty() || s=="false" ) data.regenerateOsccal = false; + else if ( s=="true" ) data.regenerateOsccal = true; + else qFatal("Invalid regen value"); +} + +void Pickit1::XmlToData::outputData(const Data &data, QTextStream &s) const +{ + s << "'" << data.entryMode << "', " << (data.regenerateOsccal ? "true" : "false"); +} + +void Pickit1::XmlToData::outputFunctions(QTextStream &s) const +{ + Programmer::XmlToData<Data>::outputFunctions(s); + s << "::Programmer::DeviceSpecific *Group::createDeviceSpecific(Programmer::Base &base) const" << endl; + s << "{" << endl; + s << " uint i = family(static_cast< ::Pickit1::Base &>(base).device()->name());" << endl; + s << " switch(i) {" << endl; + for (uint i=0; i<uint(families().count()); i++) { + s << " case " + QString::number(i) + ": return new " + families()[i] + "(base);" << endl; + } + s << " }" << endl; + s << " Q_ASSERT(false);" << endl; + s << " return 0;" << endl; + s << "}" << endl; +} + +} // namespace + +//----------------------------------------------------------------------------- +XML_MAIN(Pickit1::XmlToData) |