mirror of
https://github.com/mariusgreuel/avrdude.git
synced 2025-09-28 15:05:27 +00:00
Move erase-rewrite cycle increment to within the chip erase routine so
that it is tracked no matter where the erase was initiated: command line mode or interactive mode, without code duplicaiton. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@141 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
27
avr.c
27
avr.c
@@ -41,7 +41,6 @@
|
||||
#include "pindefs.h"
|
||||
#include "ppi.h"
|
||||
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
extern char * progname;
|
||||
@@ -51,6 +50,8 @@ extern PROGRAMMER * pgm;
|
||||
|
||||
char * avr_version = "$Id$";
|
||||
|
||||
extern int do_cycles;
|
||||
|
||||
|
||||
AVRPART * avr_new_part(void)
|
||||
{
|
||||
@@ -821,6 +822,7 @@ int avr_chip_erase(int fd, AVRPART * p)
|
||||
{
|
||||
unsigned char cmd[4];
|
||||
unsigned char res[4];
|
||||
int cycles;
|
||||
|
||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
|
||||
fprintf(stderr, "chip erase instruction not defined for part \"%s\"\n",
|
||||
@@ -828,6 +830,19 @@ int avr_chip_erase(int fd, AVRPART * p)
|
||||
return -1;
|
||||
}
|
||||
|
||||
cycles = avr_get_cycle_count(fd, p);
|
||||
|
||||
/*
|
||||
* only print out the current cycle count if we aren't going to
|
||||
* display it below
|
||||
*/
|
||||
if (!do_cycles && ((cycles != -1) && (cycles != 0x00ffff))) {
|
||||
fprintf(stderr,
|
||||
"%s: current erase-rewrite cycle count is %d%s\n",
|
||||
progname, cycles,
|
||||
do_cycles ? "" : " (if being tracked)");
|
||||
}
|
||||
|
||||
LED_ON(fd, pgm->pinno[PIN_LED_PGM]);
|
||||
|
||||
memset(cmd, 0, sizeof(cmd));
|
||||
@@ -839,6 +854,16 @@ int avr_chip_erase(int fd, AVRPART * p)
|
||||
|
||||
LED_OFF(fd, pgm->pinno[PIN_LED_PGM]);
|
||||
|
||||
if (do_cycles && (cycles != -1)) {
|
||||
if (cycles == 0x00ffff) {
|
||||
cycles = 0;
|
||||
}
|
||||
cycles++;
|
||||
fprintf(stderr, "%s: erase-rewrite cycle count is now %d\n",
|
||||
progname, cycles);
|
||||
avr_put_cycle_count(fd, p, cycles);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user