summaryrefslogtreecommitdiffstats
path: root/src/tools/pic30
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/pic30')
-rw-r--r--src/tools/pic30/Makefile.am9
-rw-r--r--src/tools/pic30/gui/Makefile.am6
-rw-r--r--src/tools/pic30/gui/pic30_ui.cpp26
-rw-r--r--src/tools/pic30/gui/pic30_ui.h36
-rw-r--r--src/tools/pic30/pic30.cpp137
-rw-r--r--src/tools/pic30/pic30.h54
-rw-r--r--src/tools/pic30/pic30_compile.cpp196
-rw-r--r--src/tools/pic30/pic30_compile.h128
-rw-r--r--src/tools/pic30/pic30_config.cpp9
-rw-r--r--src/tools/pic30/pic30_config.h25
-rw-r--r--src/tools/pic30/pic30_generator.cpp111
-rw-r--r--src/tools/pic30/pic30_generator.h27
12 files changed, 764 insertions, 0 deletions
diff --git a/src/tools/pic30/Makefile.am b/src/tools/pic30/Makefile.am
new file mode 100644
index 0000000..edf11c8
--- /dev/null
+++ b/src/tools/pic30/Makefile.am
@@ -0,0 +1,9 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libpic30.la
+libpic30_la_LDFLAGS = $(all_libraries)
+libpic30_la_SOURCES = pic30_compile.cpp pic30_config.cpp pic30.cpp \
+ pic30_generator.cpp
+
+SUBDIRS = gui \ No newline at end of file
diff --git a/src/tools/pic30/gui/Makefile.am b/src/tools/pic30/gui/Makefile.am
new file mode 100644
index 0000000..4ee894e
--- /dev/null
+++ b/src/tools/pic30/gui/Makefile.am
@@ -0,0 +1,6 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libpic30ui.la
+libpic30ui_la_LDFLAGS = $(all_libraries)
+libpic30ui_la_SOURCES = pic30_ui.cpp
diff --git a/src/tools/pic30/gui/pic30_ui.cpp b/src/tools/pic30/gui/pic30_ui.cpp
new file mode 100644
index 0000000..9d1b2c4
--- /dev/null
+++ b/src/tools/pic30/gui/pic30_ui.cpp
@@ -0,0 +1,26 @@
+/***************************************************************************
+ * 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 "pic30_ui.h"
+
+#include <qlabel.h>
+
+#include "common/gui/purl_gui.h"
+#include "tools/pic30/pic30_config.h"
+
+//----------------------------------------------------------------------------
+PIC30::ConfigWidget::ConfigWidget(Project *project)
+ : ToolConfigWidget(project)
+{}
+
+void PIC30::ConfigWidget::initEntries()
+{
+ if ( _category==Tool::Category::Compiler || _category==Tool::Category::Assembler || _category==Tool::Category::Linker )
+ createIncludeDirectoriesEntry();
+ if ( _category==Tool::Category::Linker ) createCustomLibrariesEntry();
+}
diff --git a/src/tools/pic30/gui/pic30_ui.h b/src/tools/pic30/gui/pic30_ui.h
new file mode 100644
index 0000000..d9890e7
--- /dev/null
+++ b/src/tools/pic30/gui/pic30_ui.h
@@ -0,0 +1,36 @@
+/***************************************************************************
+ * 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 PIC30_UI_H
+#define PIC30_UI_H
+
+#include "tools/gui/tool_config_widget.h"
+#include "tools/gui/tool_group_ui.h"
+
+namespace PIC30
+{
+
+//----------------------------------------------------------------------------
+class ConfigWidget : public ToolConfigWidget
+{
+Q_OBJECT
+public:
+ ConfigWidget(Project *project);
+ virtual void initEntries();
+};
+
+//----------------------------------------------------------------------------
+class GroupUI : public Tool::GroupUI
+{
+public:
+ virtual ::ToolConfigWidget *configWidgetFactory(Tool::Category, ::Project *project) const { return new ConfigWidget(project); }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/pic30/pic30.cpp b/src/tools/pic30/pic30.cpp
new file mode 100644
index 0000000..45b9270
--- /dev/null
+++ b/src/tools/pic30/pic30.cpp
@@ -0,0 +1,137 @@
+/***************************************************************************
+ * 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 "pic30.h"
+
+#include "devices/list/device_list.h"
+#include "devices/base/device_group.h"
+#include "pic30_compile.h"
+#include "pic30_config.h"
+#include "devices/pic/pic/pic_memory.h"
+#include "common/global/process.h"
+#include "pic30_generator.h"
+
+//----------------------------------------------------------------------------
+QString PIC30::Base::baseExecutable(bool, Tool::OutputExecutableType type) const
+{
+ QString s = "pic30-";
+ if ( type==Tool::OutputExecutableType::Coff ) s += "coff";
+ else s += "elf";
+ s += "-";
+ switch (_category.type()) {
+ case Tool::Category::Compiler: return s + "gcc";
+ case Tool::Category::Assembler: return s + "as";
+ case Tool::Category::Linker: return s + "ld";
+ case Tool::Category::Librarian: return s + "ar";
+ case Tool::Category::BinToHex: return s + "bin2hex";
+ case Tool::Category::Nb_Types: break;
+ }
+ Q_ASSERT(false);
+ return QString::null;
+}
+
+QStringList PIC30::Base::checkExecutableOptions(bool) const
+{
+ if ( _category!=Tool::Category::BinToHex ) return "--version";
+ return QStringList();
+}
+
+bool PIC30::Base::checkExecutableResult(bool, QStringList &lines) const
+{
+ if ( lines.count()==0 ) return false;
+ lines[0] = lines[0].stripWhiteSpace();
+ switch (_category.type()) {
+ case Tool::Category::Compiler: return lines[0].startsWith("pic30");
+ case Tool::Category::Assembler: return lines[0].startsWith("GNU assembler");
+ case Tool::Category::Linker: return lines[0].startsWith("GNU ld");
+ case Tool::Category::BinToHex: return lines.join(" ").contains("Microchip ");
+ case Tool::Category::Librarian: return lines[0].startsWith("GNU ar");
+ case Tool::Category::Nb_Types: break;
+ }
+ Q_ASSERT(false);
+ return false;
+}
+
+//----------------------------------------------------------------------------
+QString PIC30::Group::informationText() const
+{
+ return i18n("The <a href=\"%1\">PIC30 ToolChain</a> is a toolsuite for 16-bit PICs available from Microchip. Most of it is available under the GNU Public License.").arg("http://microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010065&part=SW006012");
+}
+
+Tool::Group::BaseData PIC30::Group::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Compiler || category==Tool::Category::Assembler
+ || category==Tool::Category::Linker || category==Tool::Category::BinToHex ) return BaseData(new ::PIC30::Base, Both);
+ if ( category==Tool::Category::Librarian ) return BaseData(new ::PIC30::Base, ProjectOnly);
+ return BaseData();
+}
+
+QValueList<const Device::Data *> PIC30::Group::getSupportedDevices(const QString &) const
+{
+ QValueList<const Device::Data *> list;
+ QValueVector<QString> devices = Device::lister().group("pic")->supportedDevices();
+ for (uint i=0; i<devices.count(); i++) {
+ const Device::Data *data = Device::lister().data(devices[i]);
+ if ( static_cast<const Pic::Data *>(data)->is16bitFamily() ) list.append(data);
+ }
+ return list;
+}
+
+Compile::Process *PIC30::Group::processFactory(const Compile::Data &data) const
+{
+ switch (data.category.type()) {
+ case Tool::Category::Compiler:
+ if (data.project) return new PIC30::CompileProjectFile;
+ return new PIC30::CompileStandaloneFile;
+ case Tool::Category::Assembler:
+ if (data.project) return new PIC30::AssembleProjectFile;
+ return new PIC30::AssembleStandaloneFile;
+ case Tool::Category::Linker:
+ if (data.project) return new PIC30::LinkProject;
+ return new PIC30::LinkStandalone;
+ case Tool::Category::Librarian:
+ Q_ASSERT(data.project);
+ return new PIC30::LibraryProject;
+ case Tool::Category::BinToHex: return new PIC30::BinToHex;
+ case Tool::Category::Nb_Types: break;
+ }
+ Q_ASSERT(false);
+ return 0;
+}
+
+Compile::Config *PIC30::Group::configFactory(::Project *project) const
+{
+ return new Config(project);
+}
+
+PURL::FileType PIC30::Group::implementationType(PURL::ToolType type) const
+{
+ if ( type==PURL::ToolType::Assembler ) return PURL::AsmPIC30;
+ if ( type==PURL::ToolType::Compiler ) return PURL::CSource;
+ return PURL::Nb_FileTypes;
+}
+
+Tool::SourceGenerator *PIC30::Group::sourceGeneratorFactory() const
+{
+ return new SourceGenerator;
+}
+
+PURL::Directory PIC30::Group::autodetectDirectory(Compile::DirectoryType type, const PURL::Directory &execDir, bool withWine) const
+{
+ if ( !withWine ) return PURL::Directory();
+ PURL::Directory baseDir = execDir.up();
+ switch (type.type()) {
+ case Compile::DirectoryType::LinkerScript: return baseDir.down("support/gld");
+ case Compile::DirectoryType::Header: return baseDir.down("support/h");
+ case Compile::DirectoryType::Library: return baseDir.down("lib");
+ case Compile::DirectoryType::Executable:
+ case Compile::DirectoryType::Source:
+ case Compile::DirectoryType::Nb_Types: Q_ASSERT(false); break;
+ }
+ return PURL::Directory();
+}
diff --git a/src/tools/pic30/pic30.h b/src/tools/pic30/pic30.h
new file mode 100644
index 0000000..a490ed0
--- /dev/null
+++ b/src/tools/pic30/pic30.h
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * 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 PIC30_H
+#define PIC30_H
+
+#include "tools/base/tool_group.h"
+
+namespace PIC30
+{
+
+//----------------------------------------------------------------------------
+class Base : public Tool::Base
+{
+public:
+ virtual QString baseExecutable(bool withWine, Tool::OutputExecutableType type) const;
+
+private:
+ virtual QStringList checkExecutableOptions(bool withWine) const;
+ virtual bool checkExecutableResult(bool withWine, QStringList &lines) const;
+};
+
+//----------------------------------------------------------------------------
+class Group : public Tool::Group
+{
+public:
+ virtual QString name() const { return "pic30"; }
+ virtual QString label() const { return i18n("PIC30 Toolchain"); }
+ virtual QString informationText() const;
+ virtual bool hasDirectory(Compile::DirectoryType type) const { return type==Compile::DirectoryType::Header || type==Compile::DirectoryType::LinkerScript || type==Compile::DirectoryType::Library; }
+ virtual PURL::Directory autodetectDirectory(Compile::DirectoryType type, const PURL::Directory &execDir, bool withWine) const;
+ virtual bool hasOutputExecutableType(Tool::OutputExecutableType type) const { return ( type==Tool::OutputExecutableType::Coff || type==Tool::OutputExecutableType::Elf ); }
+ virtual Tool::Category checkDevicesCategory() const { return Tool::Category::Nb_Types; }
+ virtual Tool::ExecutableType preferedExecutableType() const { return Tool::ExecutableType::Unix; }
+ virtual Tool::CompileType compileType() const { return Tool::SeparateFiles; }
+ virtual PURL::FileType linkerScriptType() const { return PURL::Gld; }
+ virtual PURL::FileType implementationType(PURL::ToolType type) const;
+
+private:
+ virtual BaseData baseFactory(Tool::Category category) const;
+ virtual QValueList<const Device::Data *> getSupportedDevices(const QString &s) const;
+ virtual Compile::Process *processFactory(const Compile::Data &data) const;
+ virtual Compile::Config *configFactory(::Project *project) const;
+ virtual Tool::SourceGenerator *sourceGeneratorFactory() const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/pic30/pic30_compile.cpp b/src/tools/pic30/pic30_compile.cpp
new file mode 100644
index 0000000..02cbb35
--- /dev/null
+++ b/src/tools/pic30/pic30_compile.cpp
@@ -0,0 +1,196 @@
+/***************************************************************************
+ * Copyright (C) 2006-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. *
+ ***************************************************************************/
+#include "pic30_compile.h"
+
+#include "config.h"
+#include "pic30_config.h"
+#include "devices/list/device_list.h"
+
+//-----------------------------------------------------------------------------
+QStringList PIC30::CompileFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += "-S"; // compile only
+ args += "$NO_AUTO_DEVICE(-mcpu=%DEVICE)";
+ args += config.includeDirs(Tool::Category::Compiler, "-I");
+ PURL::Directory purl = Compile::Config::directory(group(), Compile::DirectoryType::Header);
+ if ( !purl.isEmpty() ) args += "-I" + purl.path();
+ args += config.customOptions(Tool::Category::Compiler);
+ return args;
+}
+
+QString PIC30::CompileFile::outputFiles() const
+{
+ return "PURL::AsmPIC30";
+}
+
+void PIC30::CompileFile::logStderrLine(const QString &line)
+{
+ // #### TODO
+ doLog(Log::LineType::Normal, line, QString::null, 0); // unrecognized
+}
+
+//-----------------------------------------------------------------------------
+QStringList PIC30::CompileStandaloneFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = CompileFile::genericArguments(config);
+ args += "%I";
+ return args;
+}
+
+QString PIC30::CompileStandaloneFile::outputFiles() const
+{
+ return CompileFile::outputFiles() + " PURL::Object PURL::Elf";
+}
+
+//-----------------------------------------------------------------------------
+QStringList PIC30::CompileProjectFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = CompileFile::genericArguments(config);
+ args += "-g";
+ args += "%I";
+ return args;
+}
+
+//-----------------------------------------------------------------------------
+QStringList PIC30::AssembleFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += "-g";
+ args += "-a=%LIST"; // listing
+ args += "-o%O";
+ args += config.includeDirs(Tool::Category::Assembler, "-I");
+ args += config.customOptions(Tool::Category::Assembler);
+ return args;
+}
+
+QString PIC30::AssembleFile::outputFiles() const
+{
+ return "PURL::Object PURL::Lst";
+}
+
+void PIC30::AssembleFile::logStderrLine(const QString &line)
+{
+ // #### TODO
+ doLog(Log::LineType::Normal, line, QString::null, 0); // unrecognized
+}
+
+//-----------------------------------------------------------------------------
+QStringList PIC30::AssembleStandaloneFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = AssembleFile::genericArguments(config);
+ args += "$NO_AUTO_DEVICE(-p%DEVICE)";
+ args += "%I";
+ return args;
+}
+
+//-----------------------------------------------------------------------------
+QStringList PIC30::AssembleProjectFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = AssembleFile::genericArguments(config);
+ if ( !_data.items[0].generated ) args += "-p%DEVICE";
+ args += "%I";
+ return args;
+}
+
+//-----------------------------------------------------------------------------
+QString PIC30::Link::outputFilepath() const
+{
+ PURL::FileType type = Compile::Config::outputExecutableType(group()).data().type;
+ return filepath(type);
+}
+
+QStringList PIC30::Link::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += "-Map";
+ args += "%MAP";
+ args += "-o%O";
+ args += config.includeDirs(Tool::Category::Linker, "-L");
+ PURL::Directory purl = Compile::Config::directory(group(), Compile::DirectoryType::Library);
+ if ( !purl.isEmpty() ) args += "-L" + purl.path();
+ args += "$LKR(-T%LKR)";
+ args += config.customOptions(Tool::Category::Linker);
+ args += "%OBJS";
+ return args;
+}
+
+QString PIC30::Link::outputFiles() const
+{
+ PURL::FileType type = Compile::Config::outputExecutableType(group()).data().type;
+ return QString("PURL::Map PURL::") + type.key();
+}
+
+void PIC30::Link::logStderrLine(const QString &line)
+{
+ // #### TODO
+ doLog(Log::LineType::Normal, line, QString::null, 0); // unrecognized
+}
+
+//-----------------------------------------------------------------------------
+QStringList PIC30::LinkStandalone::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = Link::genericArguments(config);
+ args += config.customLibraries(Tool::Category::Linker);
+ return args;
+}
+
+//-----------------------------------------------------------------------------
+QStringList PIC30::LinkProject::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = Link::genericArguments(config);
+ args += "%LIBS";
+ args += config.customLibraries(Tool::Category::Linker);
+ return args;
+}
+
+//-----------------------------------------------------------------------------
+QStringList PIC30::LibraryProject::genericArguments(const Compile::Config &) const
+{
+ QStringList args;
+ args += "-rc"; // insert new + do not warn if creating library
+ args += "%O";
+ args += "%LIBS";
+ args += "%OBJS";
+ return args;
+}
+
+void PIC30::LibraryProject::logStderrLine(const QString &line)
+{
+ // #### TODO
+ doLog(Log::LineType::Normal, line, QString::null, 0); // unrecognized
+}
+
+QString PIC30::LibraryProject::outputFiles() const
+{
+ return "PURL::Library";
+}
+
+//-----------------------------------------------------------------------------
+QString PIC30::BinToHex::inputFilepath(uint) const
+{
+ PURL::FileType type = Compile::Config::outputExecutableType(group()).data().type;
+ return filepath(type);
+}
+
+QStringList PIC30::BinToHex::genericArguments(const Compile::Config &) const
+{
+ return "%I";
+}
+
+QString PIC30::BinToHex::outputFiles() const
+{
+ return "PURL::Hex";
+}
+
+void PIC30::BinToHex::logStderrLine(const QString &line)
+{
+ // #### TODO
+ doLog(Log::LineType::Normal, line, QString::null, 0); // unrecognized
+}
diff --git a/src/tools/pic30/pic30_compile.h b/src/tools/pic30/pic30_compile.h
new file mode 100644
index 0000000..c298eac
--- /dev/null
+++ b/src/tools/pic30/pic30_compile.h
@@ -0,0 +1,128 @@
+/***************************************************************************
+ * 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 PIC30_COMPILE_H
+#define PIC30_COMPILE_H
+
+#include "tools/list/compile_process.h"
+
+namespace PIC30
+{
+//-----------------------------------------------------------------------------
+class Process : public Compile::Process
+{
+Q_OBJECT
+protected:
+ virtual QString deviceName() const { return _data.device; }
+};
+
+//-----------------------------------------------------------------------------
+class CompileFile : public Process
+{
+Q_OBJECT
+protected:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+ virtual void logStderrLine(const QString &line);
+};
+
+//-----------------------------------------------------------------------------
+class CompileStandaloneFile : public CompileFile
+{
+Q_OBJECT
+protected:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+};
+
+//-----------------------------------------------------------------------------
+class CompileProjectFile : public CompileFile
+{
+Q_OBJECT
+protected:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class AssembleFile : public Process
+{
+Q_OBJECT
+protected:
+ virtual QString outputFilepath() const { return filepath(PURL::Object); }
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+ virtual void logStderrLine(const QString &line);
+};
+
+//-----------------------------------------------------------------------------
+class AssembleStandaloneFile : public AssembleFile
+{
+Q_OBJECT
+protected:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class AssembleProjectFile : public AssembleFile
+{
+Q_OBJECT
+protected:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class Link : public Process
+{
+Q_OBJECT
+protected:
+ virtual QString outputFilepath() const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+ virtual void logStderrLine(const QString &line);
+};
+
+//-----------------------------------------------------------------------------
+class LinkStandalone : public Link
+{
+Q_OBJECT
+protected:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class LinkProject : public Link
+{
+Q_OBJECT
+protected:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class LibraryProject : public Process
+{
+Q_OBJECT
+protected:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+ virtual void logStderrLine(const QString &line);
+};
+
+//-----------------------------------------------------------------------------
+class BinToHex : public Process
+{
+Q_OBJECT
+protected:
+ virtual QString inputFilepath(uint i) const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+ virtual void logStderrLine(const QString &line);
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/pic30/pic30_config.cpp b/src/tools/pic30/pic30_config.cpp
new file mode 100644
index 0000000..32ef7e0
--- /dev/null
+++ b/src/tools/pic30/pic30_config.cpp
@@ -0,0 +1,9 @@
+/***************************************************************************
+ * 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 "pic30_config.h"
diff --git a/src/tools/pic30/pic30_config.h b/src/tools/pic30/pic30_config.h
new file mode 100644
index 0000000..f0b1520
--- /dev/null
+++ b/src/tools/pic30/pic30_config.h
@@ -0,0 +1,25 @@
+/***************************************************************************
+ * 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 PIC30_CONFIG_H
+#define PIC30_CONFIG_H
+
+#include "tools/list/compile_config.h"
+
+namespace PIC30
+{
+//----------------------------------------------------------------------------
+class Config : public Compile::Config
+{
+public:
+ Config(Project *project) : Compile::Config(project) {}
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/pic30/pic30_generator.cpp b/src/tools/pic30/pic30_generator.cpp
new file mode 100644
index 0000000..fe874e3
--- /dev/null
+++ b/src/tools/pic30/pic30_generator.cpp
@@ -0,0 +1,111 @@
+/***************************************************************************
+ * Copyright (C) 2006-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. *
+ ***************************************************************************/
+#include "pic30_generator.h"
+
+#include "devices/pic/pic/pic_memory.h"
+
+SourceLine::List PIC30::SourceGenerator::configLines(PURL::ToolType type, const Device::Memory &memory, bool &ok) const
+{
+ const Pic::Memory &pmemory = static_cast<const Pic::Memory &>(memory);
+ const Pic::Data &data = pmemory.device();
+ const Pic::Config &config = data.config();
+ SourceLine::List lines;
+ for (uint i=0; i<data.nbWords(Pic::MemoryRangeType::Config); i++) {
+ const Pic::Config::Word &cword = config._words[i];
+ QStringList cnames = SourceLine::configNames(Pic::ConfigNameType::Default, pmemory, i, ok);
+ if ( cnames.isEmpty() ) continue;
+ QString code;
+ if ( type==PURL::ToolType::Assembler ) code += "config __" + cword.name + ", ";
+ else code += "_" + cword.name + "(";
+ code += cnames.join(" & ");
+ if ( type==PURL::ToolType::Compiler ) code += ");";
+ lines.appendNotIndentedCode(code);
+ }
+ return lines;
+}
+
+SourceLine::List PIC30::SourceGenerator::includeLines(PURL::ToolType type, const Device::Data &data) const
+{
+ SourceLine::List lines;
+ if ( type==PURL::ToolType::Assembler ) lines.appendIndentedCode(".include \"p" + data.name().lower() + ".inc\"");
+ else lines.appendNotIndentedCode("#include <p" + data.name().lower() + ".h>");
+ return lines;
+}
+
+SourceLine::List PIC30::SourceGenerator::sourceFileContent(PURL::ToolType type, const Device::Data &, bool &ok) const
+{
+ SourceLine::List lines;
+ if ( type==PURL::ToolType::Assembler ) {
+ lines.appendTitle(i18n("Global declarations"));
+ lines.appendIndentedCode(".global _wreg_init");
+ lines.appendIndentedCode(".global __reset", i18n("label for code start"));
+ lines.appendIndentedCode(".global __T1Interrrupt", i18n("declare Timer1 ISR"));
+ lines.appendEmpty();
+ lines.appendSeparator();
+ lines.appendTitle(i18n("Constants in program space"));
+ lines.appendIndentedCode(".section .constbuffer, code");
+ lines.appendIndentedCode(".palign 2");
+ lines.appendNotIndentedCode("const1:");
+ lines.appendIndentedCode(".hword 0x0001, 0x0002, 0X0003");
+ lines.appendEmpty();
+ lines.appendTitle(i18n("Unitialized variables in X-space"));
+ lines.appendIndentedCode(".section .xbss, bss, xmemory");
+ lines.appendNotIndentedCode("x_var1: .space 4", i18n("allocating 4 bytes"));
+ lines.appendEmpty();
+ lines.appendTitle(i18n("Unitialized variables in Y-space"));
+ lines.appendIndentedCode(".section .ybss, bss, ymemory");
+ lines.appendNotIndentedCode("y_var1: .space 2", i18n("allocating 2 bytes"));
+ lines.appendEmpty();
+ lines.appendTitle(i18n("Unitialized variables in near data memory"));
+ lines.appendIndentedCode(".section .nbss, bss, near");
+ lines.appendNotIndentedCode("var1: .space 4", i18n("allocating 4 bytes"));
+ lines.appendEmpty();
+ lines.appendSeparator();
+ lines.appendTitle("Code section");
+ lines.appendNotIndentedCode(".text");
+ lines.appendNotIndentedCode("__reset:");
+ lines.appendIndentedCode("MOV #__SP_init, W15", i18n("initialize stack pointer"));
+ lines.appendIndentedCode("MOV #__SPLIM_init, W0", i18n("initialize stack pointer limit register"));
+ lines.appendIndentedCode("MOV W0, SPLIM");
+ lines.appendIndentedCode("NOP", i18n("nop after SPLIM initialization"));
+ lines.appendIndentedCode("CALL _wreg_init", i18n("call _wreg_init subroutine"));
+ lines.appendEmpty();
+ lines.appendIndentedCode(QString::null, "<<" + i18n("insert code") + ">>");
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("done:");
+ lines.appendIndentedCode("BRA done", i18n("loop forever"));
+ lines.appendEmpty();
+ lines.appendSeparator();
+ lines.appendTitle(i18n("Subroutine to initialize W registers to 0x0000"));
+ lines.appendNotIndentedCode("_wreg_init:");
+ lines.appendIndentedCode("CLR W0");
+ lines.appendIndentedCode("MOV W0, W14");
+ lines.appendIndentedCode("REPEAT #12");
+ lines.appendIndentedCode("MOV W0, [++W14]");
+ lines.appendIndentedCode("CLR W14");
+ lines.appendIndentedCode("RETURN");
+ lines.appendEmpty();
+ lines.appendSeparator();
+ lines.appendTitle(i18n("Timer1 interrupt service routine"));
+ lines.appendNotIndentedCode("__T1Interrupt:");
+ lines.appendIndentedCode("PUSH.D W4", i18n("example of context saving (push W4 and W5)"));
+ lines.appendIndentedCode(QString::null, "<<" + i18n("insert interrupt code") + ">>");
+ lines.appendIndentedCode("BCLR IFS0, #T1IF", i18n("clear Timer1 interrupt flag status bit"));
+ lines.appendIndentedCode("POP.D W4", i18n("restore context from stack"));
+ lines.appendIndentedCode("RETFIE");
+ lines.appendEmpty();
+ lines.appendSeparator();
+ lines.appendTitle(i18n("End of all code sections"));
+ lines.appendNotIndentedCode(".end");
+ } else {
+ // #### TODO
+ ok = false;
+ }
+ return lines;
+}
diff --git a/src/tools/pic30/pic30_generator.h b/src/tools/pic30/pic30_generator.h
new file mode 100644
index 0000000..510a483
--- /dev/null
+++ b/src/tools/pic30/pic30_generator.h
@@ -0,0 +1,27 @@
+/***************************************************************************
+ * Copyright (C) 2006-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. *
+ ***************************************************************************/
+#ifndef PIC30_GENERATOR_H
+#define PIC30_GENERATOR_H
+
+#include "tools/base/tool_group.h"
+
+namespace PIC30
+{
+
+class SourceGenerator : public Tool::SourceGenerator
+{
+public:
+ virtual SourceLine::List configLines(PURL::ToolType type, const Device::Memory &memory, bool &ok) const;
+ virtual SourceLine::List sourceFileContent(PURL::ToolType type, const Device::Data &data, bool &ok) const;
+ virtual SourceLine::List includeLines(PURL::ToolType type, const Device::Data &data) const;
+};
+
+} // namespace
+
+#endif