From abda4d9276a096ef4e4c4de923388411d75e7c3d Mon Sep 17 00:00:00 2001
From: Joerg Wunsch <j@uriah.heep.sax.de>
Date: Sun, 13 Aug 2006 21:10:13 +0000
Subject: [PATCH] New file, extract high-voltage programming parameters from
 Atmel XML files, and produce an avrdude.conf[.in] snippet.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@603 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 ChangeLog               |   7 ++
 tools/get-hv-params.xsl | 205 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 212 insertions(+)
 create mode 100644 tools/get-hv-params.xsl

diff --git a/ChangeLog b/ChangeLog
index be0a9a30..0719971d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-08-13 Joerg Wunsch <j@uriah.heep.sax.de>
+
+	* tools: New directory.
+	* tools/get-hv-params.xsl: New file, extract high-voltage
+	programming parameters from Atmel XML files, and produce
+	an avrdude.conf[.in] snippet.
+
 2006-08-11 Joerg Wunsch <j@uriah.heep.sax.de>
 
 	* configure.ac (AC_CHECK_LIB([usb]): implement a private LIBUSB
diff --git a/tools/get-hv-params.xsl b/tools/get-hv-params.xsl
new file mode 100644
index 00000000..4743db23
--- /dev/null
+++ b/tools/get-hv-params.xsl
@@ -0,0 +1,205 @@
+<?xml version="1.0" encoding='ISO-8859-1' ?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<!--
+ * Copyright (c) 2006 Joerg Wunsch
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ *
+ * $Id$
+-->
+<!--
+ * Extract high-voltage (parallel and serial) programming parameters
+ * out of the Atmel XML files, and convert them into avrdude.conf
+ * snippets.
+ *
+ * Run this file together with the respective AVR's XML file through
+ * an XSLT processor (xsltproc, saxon), and capture the output for
+ * inclusion into avrdude.conf.in.
+-->
+    <xsl:output method="text"/>
+    <xsl:template match="/">
+    <xsl:for-each select="//*">
+    <xsl:if test='name() = "STK500_2"'>
+
+    <!--
+     * High-voltage parallel programming parameters.
+    -->
+    <xsl:for-each
+     select="*[starts-with(translate(name(),
+                                     'abcdefghijklmnopqrstuvwxyz',
+                                     'ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
+                                     'PP')]">
+        <xsl:if test="self::node()[name() = 'PPControlStack']"
+        >    pp_controlstack     =
+        <xsl:value-of select="translate(current(), ' ', ',')" />;
+</xsl:if> <!-- PPControlStack -->
+
+	<xsl:if test="self::node()[name() = 'PpEnterProgMode']">
+            <xsl:for-each select="*">
+                <xsl:if test="self::node()[name() = 'stabDelay']"
+                >    hventerstabdelay    = <xsl:value-of select="." />;
+</xsl:if>
+                <xsl:if test="self::node()[name() = 'progModeDelay']"
+                >    progmodedelay       = <xsl:value-of select="." />;
+</xsl:if>
+                <xsl:if test="self::node()[name() = 'latchCycles']"
+                >    latchcycles         = <xsl:value-of select="." />;
+</xsl:if>
+                <xsl:if test="self::node()[name() = 'toggleVtg']"
+                >    togglevtg           = <xsl:value-of select="." />;
+</xsl:if>
+                <xsl:if test="self::node()[name() = 'powerOffDelay']"
+                >    poweroffdelay       = <xsl:value-of select="." />;
+</xsl:if>
+                <xsl:if test="self::node()[name() = 'resetDelayMs']"
+                >    resetdelayms        = <xsl:value-of select="." />;
+</xsl:if>
+                <xsl:if test="self::node()[name() = 'resetDelayUs']"
+                >    resetdelayus        = <xsl:value-of select="." />;
+</xsl:if>
+            </xsl:for-each>
+        </xsl:if> <!-- PpEnterProgMode -->
+
+        <xsl:if test="self::node()[name() = 'PpLeaveProgMode']">
+            <xsl:for-each select="*">
+                <xsl:if test="self::node()[name() = 'stabDelay']"
+                >    hvleavestabdelay    = <xsl:value-of select="." />;
+</xsl:if>
+            </xsl:for-each>
+        </xsl:if> <!-- PpLeaveProgMode -->
+
+        <xsl:if test="self::node()[name() = 'PpChipErase']">
+            <xsl:for-each select="*">
+                <xsl:if test="self::node()[name() = 'pulseWidth']"
+                >    chiperasepulsewidth = <xsl:value-of select="." />;
+</xsl:if>
+                <xsl:if test="self::node()[name() = 'pollTimeout']"
+                >    chiperasepolltimeout = <xsl:value-of select="." />;
+</xsl:if>
+            </xsl:for-each>
+        </xsl:if> <!-- PpChipErase -->
+
+        <xsl:if test="self::node()[name() = 'PpProgramFuse']">
+            <xsl:for-each select="*">
+                <xsl:if test="self::node()[name() = 'pulseWidth']"
+                >    programfusepulsewidth = <xsl:value-of select="." />;
+</xsl:if>
+                <xsl:if test="self::node()[name() = 'pollTimeout']"
+                >    programfusepolltimeout = <xsl:value-of select="." />;
+</xsl:if>
+            </xsl:for-each>
+        </xsl:if> <!-- PpProgramFuse -->
+
+        <xsl:if test="self::node()[name() = 'PpProgramLock']">
+            <xsl:for-each select="*">
+                <xsl:if test="self::node()[name() = 'pulseWidth']"
+                >    programlockpulsewidth = <xsl:value-of select="." />;
+</xsl:if>
+                <xsl:if test="self::node()[name() = 'pollTimeout']"
+                >    programlockpolltimeout = <xsl:value-of select="." />;
+</xsl:if>
+            </xsl:for-each>
+        </xsl:if> <!-- PpProgramLock -->
+
+   </xsl:for-each> <!-- PP parameters -->
+
+   <!--
+    * High-voltage serial programming parameters.
+   -->
+   <xsl:for-each
+    select="*[starts-with(translate(name(),
+                          'abcdefghijklmnopqrstuvwxyz',
+                          'ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
+                          'HVSP')]">
+
+        <xsl:if test="self::node()[name() = 'HvspControlStack']"
+        >    hvsp_controlstack   =
+        <xsl:value-of select="translate(current(), ' ', ',')" />;
+</xsl:if> <!-- HvspControlStack -->
+
+        <xsl:if test="self::node()[name() = 'HvspEnterProgMode']">
+            <xsl:for-each select="*">
+                <xsl:if test="self::node()[name() = 'stabDelay']"
+                >    hventerstabdelay    = <xsl:value-of select="." />;
+</xsl:if>
+                <xsl:if test="self::node()[name() = 'cmdexeDelay']"
+                >    hvspcmdexedelay     = <xsl:value-of select="." />;
+</xsl:if>
+                <xsl:if test="self::node()[name() = 'synchCycles']"
+                >    synchcycles         = <xsl:value-of select="." />;
+</xsl:if>
+                <xsl:if test="self::node()[name() = 'latchCycles']"
+                >    latchcycles         = <xsl:value-of select="." />;
+</xsl:if>
+                <xsl:if test="self::node()[name() = 'toggleVtg']"
+                >    togglevtg           = <xsl:value-of select="." />;
+</xsl:if>
+                <xsl:if test="self::node()[name() = 'powoffDelay']"
+                >    poweroffdelay       = <xsl:value-of select="." />;
+</xsl:if>
+                <xsl:if test="self::node()[name() = 'resetDelay1']"
+                >    resetdelayms        = <xsl:value-of select="." />;
+</xsl:if>
+                <xsl:if test="self::node()[name() = 'resetDelay2']"
+                >    resetdelayus        = <xsl:value-of select="." />;
+</xsl:if>
+            </xsl:for-each>
+        </xsl:if> <!-- HvspEnterProgMode -->
+
+        <xsl:if test="self::node()[name() = 'HvspLeaveProgMode']">
+            <xsl:for-each select="*">
+                <xsl:if test="self::node()[name() = 'stabDelay']"
+                >    hvleavestabdelay    = <xsl:value-of select="." />;
+</xsl:if>
+                <xsl:if test="self::node()[name() = 'resetDelay']"
+                >    resetdelay          = <xsl:value-of select="." />;
+</xsl:if>
+              </xsl:for-each>
+        </xsl:if> <!-- HvspLeaveProgMode -->
+
+        <xsl:if test="self::node()[name() = 'HvspChipErase']">
+            <xsl:for-each select="*">
+                <xsl:if test="self::node()[name() = 'pollTimeout']"
+                >    chiperasepolltimeout = <xsl:value-of select="." />;
+</xsl:if>
+                <xsl:if test="self::node()[name() = 'eraseTime']"
+                >    chiperasetime       = <xsl:value-of select="." />;
+</xsl:if>
+            </xsl:for-each>
+        </xsl:if> <!-- HvspChipErase -->
+
+        <xsl:if test="self::node()[name() = 'HvspProgramFuse']">
+            <xsl:for-each select="*">
+                <xsl:if test="self::node()[name() = 'pollTimeout']"
+                >    programfusepolltimeout = <xsl:value-of select="." />;
+</xsl:if>
+            </xsl:for-each>
+        </xsl:if> <!-- HvspProgramFuse -->
+
+        <xsl:if test="self::node()[name() = 'HvspProgramLock']">
+            <xsl:for-each select="*">
+                <xsl:if test="self::node()[name() = 'pollTimeout']"
+                >    programlockpolltimeout = <xsl:value-of select="." />;
+</xsl:if>
+            </xsl:for-each>
+        </xsl:if> <!-- HvspProgramLock -->
+
+    </xsl:for-each> <!-- HVSP parameters -->
+
+    </xsl:if>  <!-- STK500_2 parameters -->
+    </xsl:for-each>  <!-- All nodes -->
+
+    </xsl:template>
+</xsl:stylesheet>