Skip to content

Commit 39230b1

Browse files
committed
Add HAS_BITCLOCK_ADJ
1 parent 5840859 commit 39230b1

File tree

12 files changed

+137
-45
lines changed

12 files changed

+137
-45
lines changed

src/avr910.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ static int avr910_open(PROGRAMMER *pgm, const char *port) {
334334

335335
(void) avr910_drain(pgm, 0);
336336

337+
if(pgm->bitclock != 0.0) {
338+
if(!(pgm->extra_features & HAS_BITCLOCK_ADJ))
339+
pmsg_warning("%s does not support adjustable bitclock speed. Ignoring -B flag\n", pgmid);
340+
}
341+
337342
return 0;
338343
}
339344

src/avrdude.conf.in

Lines changed: 86 additions & 38 deletions
Large diffs are not rendered by default.

src/avrftdi.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -702,13 +702,17 @@ static int avrftdi_open(PROGRAMMER *pgm, const char *port) {
702702

703703
write_flush(pdata);
704704

705-
if(pgm->baudrate) {
706-
set_frequency(pdata, pgm->baudrate);
707-
} else if(pgm->bitclock) {
708-
set_frequency(pdata, (uint32_t) (1.0f/pgm->bitclock));
709-
} else {
710-
set_frequency(pdata, pgm->baudrate? pgm->baudrate: 150000);
711-
}
705+
if(pgm->extra_features & HAS_BITCLOCK_ADJ) {
706+
if(pgm->baudrate)
707+
set_frequency(pdata, pgm->baudrate);
708+
else if(pgm->bitclock)
709+
set_frequency(pdata, (uint32_t) (1.0f/pgm->bitclock));
710+
else
711+
set_frequency(pdata, pgm->baudrate? pgm->baudrate: 150000);
712+
} else if(pgm->baudrate || pgm->bitclock) {
713+
pmsg_warning("%s does not support adjustable bitclock speed. Ignoring %s \n",
714+
pgmid ,pgm->baudrate && pgm->bitclock? "-b and -B flags": pgm->baudrate? "-b flag": "-B flag");
715+
}
712716

713717
// Set pin limit depending on chip type
714718
switch(pdata->ftdic->type) {

src/buspirate.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,13 @@ static int buspirate_open(PROGRAMMER *pgm, const char *port) {
457457
// Drain any extraneous input
458458
serial_drain(&pgm->fd, 0);
459459

460+
if(pgm->bitclock != 0.0) {
461+
if(!(pgm->extra_features & HAS_BITCLOCK_ADJ)) {
462+
pmsg_warning("%s does not support adjustable bitclock speed using -B.\n", pgmid);
463+
imsg_warning("Ignoring -B flag. Use -x help to view alternative SPI clock options\n");
464+
}
465+
}
466+
460467
return 0;
461468
}
462469

src/butterfly.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,11 @@ static int butterfly_open(PROGRAMMER *pgm, const char *port) {
335335
return -1;
336336
}
337337

338+
if(pgm->bitclock != 0.0) {
339+
if(!(pgm->extra_features & HAS_BITCLOCK_ADJ))
340+
pmsg_warning("%s does not support adjustable bitclock speed. Ignoring -B flag\n", pgmid);
341+
}
342+
338343
if(my.autoreset) {
339344
// This code assumes a negative-logic USB to TTL serial adapter
340345
// Set RTS/DTR high to discharge the series-capacitor, if present

src/ch341a.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ static int ch341a_open(PROGRAMMER *pgm, const char *port) {
250250
libusb_exit(my.ctx);
251251
return -1;
252252
}
253+
254+
if(pgm->bitclock != 0.0) {
255+
if(!(pgm->extra_features & HAS_BITCLOCK_ADJ))
256+
pmsg_warning("%s does not support adjustable bitclock speed. Ignoring -B flag\n", pgmid);
257+
}
258+
253259
return 0;
254260
}
255261

src/config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ TOKEN *new_constant(const char *con) {
348348
str_eq(con, "HAS_VTARG_READ")? HAS_VTARG_READ:
349349
str_eq(con, "HAS_FOSC_ADJ")? HAS_FOSC_ADJ:
350350
str_eq(con, "HAS_VAREF_ADJ")? HAS_VAREF_ADJ:
351+
str_eq(con, "HAS_BITCLOCK_ADJ")? HAS_BITCLOCK_ADJ:
351352
str_eq(con, "pseudo")? 2:
352353
str_eq(con, "yes") || str_eq(con, "true")? 1: str_eq(con, "no") || str_eq(con, "false")? 0: (assigned = 0);
353354

src/developer_opts.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ static char *extra_features_str(int m) {
145145
strcat(mode, " | HAS_FOSC_ADJ");
146146
if(m & HAS_VAREF_ADJ)
147147
strcat(mode, " | HAS_VAREF_ADJ");
148+
if(m & HAS_BITCLOCK_ADJ)
149+
strcat(mode, " | HAS_BITCLOCK_ADJ");
148150

149151
return mode + (mode[1] == 0? 0: 4);
150152
}

src/flip1.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ void flip1_initpgm(PROGRAMMER *pgm) {
181181

182182
static int flip1_open(PROGRAMMER *pgm, const char *port_spec) {
183183
FLIP1(pgm)->dfu = dfu_open(port_spec);
184+
185+
if(pgm->bitclock != 0.0) {
186+
if(!(pgm->extra_features & HAS_BITCLOCK_ADJ))
187+
pmsg_warning("%s does not support adjustable bitclock speed. Ignoring -B flag\n", pgmid);
188+
}
189+
184190
return (FLIP1(pgm)->dfu != NULL)? 0: -1;
185191
}
186192

src/flip2.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ void flip2_initpgm(PROGRAMMER *pgm) {
179179

180180
static int flip2_open(PROGRAMMER *pgm, const char *port_spec) {
181181
FLIP2(pgm)->dfu = dfu_open(port_spec);
182+
183+
if(pgm->bitclock != 0.0) {
184+
if(!(pgm->extra_features & HAS_BITCLOCK_ADJ))
185+
pmsg_warning("%s does not support adjustable bitclock speed. Ignoring -B flag\n", pgmid);
186+
}
187+
182188
return (FLIP2(pgm)->dfu != NULL)? 0: -1;
183189
}
184190

0 commit comments

Comments
 (0)