From 5a60659d9e3e8f23338cf0a176b465f8ef63e2bb Mon Sep 17 00:00:00 2001
From: bdean <bdean@81a1dc3b-b13d-400b-aceb-764788c761c2>
Date: Tue, 4 Mar 2003 02:11:41 +0000
Subject: [PATCH] Set extended device parameters for all firmware versions.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@249 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 stk500.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/stk500.c b/stk500.c
index 954b828f..3c9135cc 100644
--- a/stk500.c
+++ b/stk500.c
@@ -498,13 +498,13 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
   int tries;
   unsigned maj, min;
   int rc;
-  int do_extparms = 0;
+  int n_extparms = 3;
 
   stk500_getparm(pgm, Parm_STK_SW_MAJOR, &maj);
   stk500_getparm(pgm, Parm_STK_SW_MINOR, &min);
 
   if ((maj > 1) || ((maj == 1) && (min > 10)))
-    do_extparms = 1;
+    n_extparms = 4;
 
   tries = 0;
 
@@ -525,11 +525,17 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
     buf[3] = 1; /* device supports parallel only */
 
   if (p->flags & AVRPART_PARALLELOK) {
-    if (p->flags & AVRPART_PSEUDOPARALLEL)
+    if (p->flags & AVRPART_PSEUDOPARALLEL) {
       buf[4] = 0; /* pseudo parallel interface */
-    else
+      n_extparms = 0;
+    }
+    else {
       buf[4] = 1; /* full parallel interface */
+    }
   }
+
+  fprintf(stderr, "%s: stk500_initialize(): n_extparms = %d\n", 
+          progname, n_extparms);
     
   buf[5] = 1; /* polling supported - XXX need this in config file */
   buf[6] = 1; /* programming is self-timed - XXX need in config file */
@@ -626,8 +632,8 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
     return -1;
   }
 
-  if (do_extparms) {
-    buf[0] = 5;
+  if (n_extparms) {
+    buf[0] = n_extparms+1;
     /*
      * m is currently pointing to eeprom memory if the part has it
      */
@@ -639,12 +645,14 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
     buf[2] = p->pagel;
     buf[3] = p->bs2;
 
-    if (p->reset_disposition == RESET_DEDICATED)
-      buf[4] = 0;
-    else
-      buf[4] = 1;
+    if (n_extparms == 4) {
+      if (p->reset_disposition == RESET_DEDICATED)
+        buf[4] = 0;
+      else
+        buf[4] = 1;
+    }
 
-    rc = stk500_set_extended_parms(pgm, 5, buf);
+    rc = stk500_set_extended_parms(pgm, n_extparms+1, buf);
     if (rc) {
       fprintf(stderr, "%s: stk500_initialize(): failed\n", progname);
       exit(1);