diff --git a/ChangeLog b/ChangeLog index ddeaaf4d..21619c14 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2021-11-27 Joerg Wunsch + + * linuxspi.c: Use -B rather than -b + to specify the clock rate + 2021-11-27 Joerg Wunsch Improve defaults and documentation of linuxspi diff --git a/NEWS b/NEWS index d9446c80..357f6244 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,7 @@ Current: - extended UPDI device context (> 64 Ki flash) - major overhaul of ft245r driver (patch #9327/#9328) - some improvements in linuxspi driver + - Use -B rather than -b for linuxspi driver * New devices supported: @@ -124,6 +125,7 @@ Current: patch #10030: linuxspi: Support inverted GPIO pin patch #10031: linuxspi: Support GPIO uAPI v2 (no-id): Improve documentation of linuxspi driver, provide portname default + (no-id): Use -B rather than -b for linuxspi driver * Internals: - New avrdude.conf keyword "family_id", used to verify SIB attributes diff --git a/linuxspi.c b/linuxspi.c index f83660b8..998bf9b6 100644 --- a/linuxspi.c +++ b/linuxspi.c @@ -78,8 +78,7 @@ static int linuxspi_spi_duplex(PROGRAMMER *pgm, const unsigned char *tx, unsigne .rx_buf = (unsigned long)rx, .len = len, .delay_usecs = 1, - //should settle around 400Khz, a standard SPI speed. Adjust using baud parameter (-b) - .speed_hz = pgm->baudrate == 0 ? 400000 : pgm->baudrate, + .speed_hz = 1.0 / pgm->bitclock, // seconds to Hz .bits_per_word = 8, }; @@ -213,6 +212,19 @@ static int linuxspi_open(PROGRAMMER *pgm, char *port) if (ret) goto close_out; + if (pgm->baudrate != 0) { + avrdude_message(MSG_INFO, + "%s: obsolete use of -b option for bit clock; use -B \n", + progname); + pgm->bitclock = 1E6 / pgm->baudrate; + } + if (pgm->bitclock == 0) { + avrdude_message(MSG_NOTICE, + "%s: defaulting bit clock to 200 kHz\n", + progname); + pgm->bitclock = 5E-6; // 200 kHz - 5 µs + } + return 0; close_out: @@ -306,7 +318,7 @@ static int linuxspi_program_enable(PROGRAMMER *pgm, AVRPART *p) */ if (linuxspi_reset_mcu(pgm, false)) return -1; - usleep(3 + (pgm->baudrate ? 500000 / pgm->baudrate : 1)); + usleep(5); if (linuxspi_reset_mcu(pgm, true)) return -1; usleep(20000);