From ede97a0ed279105cc0d7492d8bd43c08d3954bd7 Mon Sep 17 00:00:00 2001 From: Colin O Flynn Date: Tue, 17 Jan 2006 21:11:39 +0000 Subject: [PATCH] * main.c, stk500v2.c: Added patch 4804 from eolson@mit.edu Which stops sck from being writtend needlessly git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@568 81a1dc3b-b13d-400b-aceb-764788c761c2 --- avrdude/ChangeLog | 2 ++ avrdude/main.c | 3 ++- avrdude/stk500v2.c | 25 +++++++++++++++++++++++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/avrdude/ChangeLog b/avrdude/ChangeLog index d13f21d4..683cd1c8 100644 --- a/avrdude/ChangeLog +++ b/avrdude/ChangeLog @@ -1,6 +1,8 @@ 2006-01-17 Colin O'Flynn * main.c: Fixed a typo in safemode variable names, fixed bug 15113 * avrdude.conf.in : Added BS2 and pagel to M162, Patch 4766 + * main.c, stk500v2.c: Added patch 4804 from eolson@mit.edu + Which stops sck from being writtend needlessly 2006-01-13 Joerg Wunsch diff --git a/avrdude/main.c b/avrdude/main.c index 65049839..bbb350b3 100644 --- a/avrdude/main.c +++ b/avrdude/main.c @@ -101,7 +101,7 @@ void usage(void) "Options:\n" " -p Required. Specify AVR device.\n" " -b Override RS-232 baud rate.\n" - " -B Specify JTAG bit clock period (us).\n" + " -B Specify JTAG/STK500v2 bit clock period (us).\n" " -C Specify location of configuration file.\n" " -c Specify programmer type.\n" " -D Disable auto erase for flash memory\n" @@ -1129,6 +1129,7 @@ int main(int argc, char * argv []) if (verbose) { fprintf(stderr, "%sSetting bit clk period: %.1f\n", progbuf, bitclock); } + pgm->bitclock = bitclock * 1e-6; } diff --git a/avrdude/stk500v2.c b/avrdude/stk500v2.c index 21b91e62..f42f897c 100644 --- a/avrdude/stk500v2.c +++ b/avrdude/stk500v2.c @@ -508,6 +508,11 @@ static int stk500v2_open(PROGRAMMER * pgm, char * port) stk500v2_drain(pgm, 0); + if (pgm->bitclock != 0.0) { + if (pgm->set_sck_period(pgm, pgm->bitclock) != 0) + return -1; + } + return 0; } @@ -940,8 +945,7 @@ static int stk500v2_getparm(PROGRAMMER * pgm, unsigned char parm, unsigned char return 0; } - -static int stk500v2_setparm(PROGRAMMER * pgm, unsigned char parm, unsigned char value) +static int stk500v2_setparm_real(PROGRAMMER * pgm, unsigned char parm, unsigned char value) { unsigned char buf[32]; @@ -958,6 +962,23 @@ static int stk500v2_setparm(PROGRAMMER * pgm, unsigned char parm, unsigned char return 0; } +static int stk500v2_setparm(PROGRAMMER * pgm, unsigned char parm, unsigned char value) +{ + unsigned char current_value; + int res; + + res = stk500v2_getparm(pgm, parm, ¤t_value); + if (res < 0) + fprintf(stderr, "%s: Unable to get parameter 0x%02x\n", progname, parm); + + // don't issue a write if the correct value is already set. + if (value == current_value) { + fprintf(stderr, "%s: Skipping paramter write; parameter value already set.\n", progname); + return 0; + } + + return stk500v2_setparm_real(pgm, parm, value); +} static void stk500v2_display(PROGRAMMER * pgm, char * p) {