* avr910.c:

* fileio.c:
    * main.c:
    * stk500.c:
    More code cleanup to remove warnings.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@352 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
arcanum 2003-08-28 23:02:25 +00:00
parent b5c352760a
commit 51a3d56245
5 changed files with 43 additions and 38 deletions

View File

@ -1,3 +1,11 @@
2003-08-28 Eric B. Weddington <eric@ecentral.com>
* avr910.c:
* fileio.c:
* main.c:
* stk500.c:
More code cleanup to remove warnings.
2003-08-27 Theodore A. Roth <troth@openavr.org> 2003-08-27 Theodore A. Roth <troth@openavr.org>
* main.c (update_progress_no_tty): Properly terminate progress. Also * main.c (update_progress_no_tty): Properly terminate progress. Also

View File

@ -503,7 +503,7 @@ static int avr910_paged_write_flash(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
unsigned int max_addr = n_bytes; unsigned int max_addr = n_bytes;
unsigned int page_addr; unsigned int page_addr;
int page_bytes = page_size; int page_bytes = page_size;
int page_wr_cmd_pending; int page_wr_cmd_pending = 0;
avr910_write_setup(pgm, p, m); avr910_write_setup(pgm, p, m);

View File

@ -691,7 +691,7 @@ int fileio_rbin(struct fioparms * fio,
int fileio_imm(struct fioparms * fio, int fileio_imm(struct fioparms * fio,
char * filename, FILE * f, unsigned char * buf, int size) char * filename, FILE * f, unsigned char * buf, int size)
{ {
int rc; int rc = 0;
char * e, * p; char * e, * p;
unsigned long b; unsigned long b;
int loc; int loc;

6
main.c
View File

@ -611,7 +611,7 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, int nowrite,
/* /*
* write the buffer contents to the selected memory type * write the buffer contents to the selected memory type
*/ */
fprintf(stderr, "%s: writing %s (%d bytes):\n", fprintf(stderr, "%s: writing %s (%ld bytes):\n",
progname, upd->memtype, size); progname, upd->memtype, size);
if (!nowrite) { if (!nowrite) {
@ -635,7 +635,7 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, int nowrite,
vsize = rc; vsize = rc;
fprintf(stderr, "%s: %d bytes of %s written\n", progname, fprintf(stderr, "%s: %ld bytes of %s written\n", progname,
vsize, upd->memtype); vsize, upd->memtype);
} }
@ -713,13 +713,11 @@ int main(int argc, char * argv [])
int exitrc; /* exit code for main() */ int exitrc; /* exit code for main() */
int i; /* general loop counter */ int i; /* general loop counter */
int ch; /* options flag */ int ch; /* options flag */
int size; /* size of memory region */
int len; /* length for various strings */ int len; /* length for various strings */
struct avrpart * p; /* which avr part we are programming */ struct avrpart * p; /* which avr part we are programming */
struct avrpart * v; /* used for verify */ struct avrpart * v; /* used for verify */
int readorwrite; /* true if a chip read/write op was selected */ int readorwrite; /* true if a chip read/write op was selected */
int ppidata; /* cached value of the ppi data register */ int ppidata; /* cached value of the ppi data register */
int vsize=-1; /* number of bytes to verify */
AVRMEM * sig; /* signature data */ AVRMEM * sig; /* signature data */
struct stat sb; struct stat sb;
UPDATE * upd; UPDATE * upd;

View File

@ -934,41 +934,40 @@ static int stk500_set_fosc(PROGRAMMER * pgm, double v)
}; };
int idx, rc; int idx, rc;
if (v <= 0.0) { prescale = cmatch = 0;
prescale = cmatch = 0; if (v > 0.0) {
goto setclock; if (v > fbase / 2) {
} const char *unit;
if (v > fbase / 2) { if (v > 1e6) {
const char *unit; v /= 1e6;
if (v > 1e6) { unit = "MHz";
v /= 1e6; } else if (v > 1e3) {
unit = "MHz"; v /= 1e3;
} else if (v > 1e3) { unit = "kHz";
v /= 1e3; } else
unit = "kHz"; unit = "Hz";
fprintf(stderr,
"%s: stk500_set_fosc(): f = %.3f %s too high, using %.3f MHz\n",
progname, v, unit, fbase / 2e6);
fosc = fbase / 2;
} else } else
unit = "Hz"; fosc = (unsigned)v;
fprintf(stderr,
"%s: stk500_set_fosc(): f = %.3f %s too high, using %.3f MHz\n", for (idx = 0; idx < sizeof(ps) / sizeof(ps[0]); idx++) {
progname, v, unit, fbase / 2e6); if (fosc >= fbase / (256 * ps[idx] * 2)) {
fosc = fbase / 2; /* this prescaler value can handle our frequency */
} else prescale = idx + 1;
fosc = (unsigned)v; cmatch = (unsigned)(fbase / (2 * v * ps[idx]));
break;
for (idx = 0; idx < sizeof(ps) / sizeof(ps[0]); idx++) { }
if (fosc >= fbase / (256 * ps[idx] * 2)) { }
/* this prescaler value can handle our frequency */ if (idx == sizeof(ps) / sizeof(ps[0])) {
prescale = idx + 1; fprintf(stderr, "%s: stk500_set_fosc(): f = %u Hz too low, %u Hz min\n",
cmatch = (unsigned)(fbase / (2 * v * ps[idx])); progname, fosc, fbase / (256 * 1024 * 2));
break; return -1;
} }
} }
if (idx == sizeof(ps) / sizeof(ps[0])) {
fprintf(stderr, "%s: stk500_set_fosc(): f = %u Hz too low, %u Hz min\n",
progname, fosc, fbase / (256 * 1024 * 2));
return -1;
}
setclock:
if ((rc = stk500_setparm(pgm, Parm_STK_OSC_PSCALE, prescale)) != 0 if ((rc = stk500_setparm(pgm, Parm_STK_OSC_PSCALE, prescale)) != 0
|| (rc = stk500_setparm(pgm, Parm_STK_OSC_CMATCH, cmatch)) != 0) || (rc = stk500_setparm(pgm, Parm_STK_OSC_CMATCH, cmatch)) != 0)
return rc; return rc;