* avr.c (avr_write_byte_default): Improve polling algorithm to speed up
programming of byte oriented parallel programmers. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@380 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
7e2ad83dda
commit
0b146ed206
29
ChangeLog
29
ChangeLog
|
@ -1,16 +1,21 @@
|
||||||
2003/11/14 Brian S. Dean <bsd@bsdhome.com>
|
2003-11-19 Theodore A. Roth <troth@openavr.org>
|
||||||
|
[Contributed by Jan-Hinnerk Reichert <jan-hinnerk_reichert@hamburg.de>]
|
||||||
|
|
||||||
* avrdude.conf.in:
|
* avr.c (avr_write_byte_default): Improve polling algorithm to speed up
|
||||||
Add ATmega64 part.
|
programming of byte oriented parallel programmers.
|
||||||
|
|
||||||
Contributed by Erik Christiansen <erik@dd.nec.com.au>
|
|
||||||
|
|
||||||
2003/11/08 Joerg Wunsch <j@uriah.heep.sax.de>
|
2003-11-14 Brian S. Dean <bsd@bsdhome.com>
|
||||||
|
[Contributed by Erik Christiansen <erik@dd.nec.com.au>]
|
||||||
|
|
||||||
* avrdude.conf.in:
|
* avrdude.conf.in:
|
||||||
Add "fuse" and "lock" definitions for the AT90S8535. Actually,
|
Add ATmega64 part.
|
||||||
this is stolen from the AT90S8515 since the datasheet says it's
|
|
||||||
the same there.
|
2003-11-08 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||||
|
|
||||||
|
* avrdude.conf.in:
|
||||||
|
Add "fuse" and "lock" definitions for the AT90S8535. Actually,
|
||||||
|
this is stolen from the AT90S8515 since the datasheet says it's
|
||||||
|
the same there.
|
||||||
|
|
||||||
2003-10-13 Bill Somerville <bill@classdesign.com>
|
2003-10-13 Bill Somerville <bill@classdesign.com>
|
||||||
|
|
||||||
|
@ -19,11 +24,11 @@
|
||||||
(stk500_paged_write): Send whole block at once.
|
(stk500_paged_write): Send whole block at once.
|
||||||
(stk500_paged_load): Limit blocks read to no bigger than memory
|
(stk500_paged_load): Limit blocks read to no bigger than memory
|
||||||
device size.
|
device size.
|
||||||
[This fixes bug #5713.]
|
[This fixes bug #5713.]
|
||||||
|
|
||||||
2003-10-13 Eric B. Weddington <eric@ecentral.com>
|
2003-10-13 Eric B. Weddington <eric@ecentral.com>
|
||||||
|
|
||||||
*avrdude.conf.in: Fix for unterminated character error.
|
* avrdude.conf.in: Fix for unterminated character error.
|
||||||
|
|
||||||
2003-10-13 Eric B. Weddington <eric@ecentral.com>
|
2003-10-13 Eric B. Weddington <eric@ecentral.com>
|
||||||
|
|
||||||
|
|
36
avr.c
36
avr.c
|
@ -25,6 +25,8 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
#include "avr.h"
|
#include "avr.h"
|
||||||
|
@ -521,11 +523,14 @@ int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
unsigned char r;
|
unsigned char r;
|
||||||
int ready;
|
int ready;
|
||||||
int tries;
|
int tries;
|
||||||
|
unsigned long start_time;
|
||||||
|
unsigned long prog_time;
|
||||||
unsigned char b;
|
unsigned char b;
|
||||||
unsigned short caddr;
|
unsigned short caddr;
|
||||||
OPCODE * writeop;
|
OPCODE * writeop;
|
||||||
int rc;
|
int rc;
|
||||||
int readok=0;
|
int readok=0;
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
if (!mem->paged) {
|
if (!mem->paged) {
|
||||||
/*
|
/*
|
||||||
|
@ -615,13 +620,6 @@ int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
tries = 0;
|
tries = 0;
|
||||||
ready = 0;
|
ready = 0;
|
||||||
while (!ready) {
|
while (!ready) {
|
||||||
usleep(mem->min_write_delay);
|
|
||||||
rc = avr_read_byte(pgm, p, mem, addr, &r);
|
|
||||||
if (rc != 0) {
|
|
||||||
pgm->pgm_led(pgm, OFF);
|
|
||||||
pgm->err_led(pgm, ON);
|
|
||||||
return -4;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((data == mem->readback[0]) ||
|
if ((data == mem->readback[0]) ||
|
||||||
(data == mem->readback[1])) {
|
(data == mem->readback[1])) {
|
||||||
|
@ -639,6 +637,29 @@ int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
return -5;
|
return -5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
gettimeofday (&tv, NULL);
|
||||||
|
start_time = (tv.tv_sec * 1000000) + tv.tv_usec;
|
||||||
|
do {
|
||||||
|
/*
|
||||||
|
* Do polling, but timeout after max_write_delay.
|
||||||
|
*/
|
||||||
|
rc = avr_read_byte(pgm, p, mem, addr, &r);
|
||||||
|
if (rc != 0) {
|
||||||
|
pgm->pgm_led(pgm, OFF);
|
||||||
|
pgm->err_led(pgm, ON);
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
gettimeofday (&tv, NULL);
|
||||||
|
prog_time = (tv.tv_sec * 1000000) + tv.tv_usec;
|
||||||
|
} while ((r != data) &&
|
||||||
|
((prog_time-start_time) < mem->max_write_delay));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* At this point we either have a valid readback or the
|
||||||
|
* max_write_delay is expired.
|
||||||
|
*/
|
||||||
|
|
||||||
if (r == data) {
|
if (r == data) {
|
||||||
ready = 1;
|
ready = 1;
|
||||||
|
@ -651,7 +672,6 @@ int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
* memory bits but not all. We only actually power-off the
|
* memory bits but not all. We only actually power-off the
|
||||||
* device if the data read back does not match what we wrote.
|
* device if the data read back does not match what we wrote.
|
||||||
*/
|
*/
|
||||||
usleep(mem->max_write_delay); /* maximum write delay */
|
|
||||||
pgm->pgm_led(pgm, OFF);
|
pgm->pgm_led(pgm, OFF);
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: this device must be powered off and back on to continue\n",
|
"%s: this device must be powered off and back on to continue\n",
|
||||||
|
|
Loading…
Reference in New Issue