File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -355,17 +355,18 @@ static int ft245r_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
355355}
356356
357357static int ft245r_set_bitclock (const PROGRAMMER * pgm ) {
358- // libftdi1 multiplies bitbang baudrate by 4:
359- int r , rate = 0 , ftdi_rate = 3000000 /4 ;
360-
361- // Bitclock is second; 1us = 0.000001; max rate for ft232r 750000
362- if (pgm -> bitclock ) {
363- rate = (uint32_t ) (1.0 /pgm -> bitclock );
364- } else if (pgm -> baudrate ) {
365- rate = pgm -> baudrate ;
366- } else {
367- rate = 150000 ; // Should work for all ftdi chips and the internal clock of 1 MHz
368- }
358+ // libftdi1 multiplies bitbang baudrate by 4
359+ int r , rate = 0 , ftdi_rate = 3000000 /4 ; // Max rate for ft232r is 750000
360+
361+ if (pgm -> baudrate || pgm -> bitclock )
362+ if (!(pgm -> extra_features & HAS_BITCLOCK_ADJ ))
363+ pmsg_warning ("setting bitclock despite HAS_BITCLOCK_ADJ missing in pgm->extra_features\n" );
364+
365+ if (pgm -> baudrate && pgm -> bitclock && (int ) (1.0 /pgm -> bitclock ) != pgm -> baudrate )
366+ pmsg_warning ("both -b baudrate and -B bitrate set; ignoring -b\n" );
367+
368+ // 150000 should work for all ftdi chips and the internal clock of 1 MHz
369+ rate = pgm -> bitclock ? (int ) (1.0 /pgm -> bitclock ): pgm -> baudrate ? pgm -> baudrate : 150000 ;
369370
370371#if FT245R_BITBANG_VARIABLE_PULSE_WIDTH_WORKAROUND
371372 my .baud_mult = rate > 0 && rate < ftdi_rate ? round ((ftdi_rate + rate - 1 )/rate ): 1 ;
You can’t perform that action at this time.
0 commit comments