diff options
Diffstat (limited to 'src/progs/pickit1/base')
-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 |
8 files changed, 342 insertions, 0 deletions
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 |