Use -B <bitclock> rather than -b <baudrate> to specify the clock rate
in linuxspi driver. This offers the additional advantage of being able to parse kHz and MHz values (in main.c). git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1497 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
dd1255b0c8
commit
2aee540bfa
|
@ -1,3 +1,8 @@
|
||||||
|
2021-11-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||||
|
|
||||||
|
* linuxspi.c: Use -B <bitclock> rather than -b <baudrate>
|
||||||
|
to specify the clock rate
|
||||||
|
|
||||||
2021-11-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
2021-11-27 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||||
|
|
||||||
Improve defaults and documentation of linuxspi
|
Improve defaults and documentation of linuxspi
|
||||||
|
|
2
NEWS
2
NEWS
|
@ -21,6 +21,7 @@ Current:
|
||||||
- extended UPDI device context (> 64 Ki flash)
|
- extended UPDI device context (> 64 Ki flash)
|
||||||
- major overhaul of ft245r driver (patch #9327/#9328)
|
- major overhaul of ft245r driver (patch #9327/#9328)
|
||||||
- some improvements in linuxspi driver
|
- some improvements in linuxspi driver
|
||||||
|
- Use -B <bitclock> rather than -b <baudrate> for linuxspi driver
|
||||||
|
|
||||||
* New devices supported:
|
* New devices supported:
|
||||||
|
|
||||||
|
@ -124,6 +125,7 @@ Current:
|
||||||
patch #10030: linuxspi: Support inverted GPIO pin
|
patch #10030: linuxspi: Support inverted GPIO pin
|
||||||
patch #10031: linuxspi: Support GPIO uAPI v2
|
patch #10031: linuxspi: Support GPIO uAPI v2
|
||||||
(no-id): Improve documentation of linuxspi driver, provide portname default
|
(no-id): Improve documentation of linuxspi driver, provide portname default
|
||||||
|
(no-id): Use -B <bitclock> rather than -b <baudrate> for linuxspi driver
|
||||||
|
|
||||||
* Internals:
|
* Internals:
|
||||||
- New avrdude.conf keyword "family_id", used to verify SIB attributes
|
- New avrdude.conf keyword "family_id", used to verify SIB attributes
|
||||||
|
|
18
linuxspi.c
18
linuxspi.c
|
@ -78,8 +78,7 @@ static int linuxspi_spi_duplex(PROGRAMMER *pgm, const unsigned char *tx, unsigne
|
||||||
.rx_buf = (unsigned long)rx,
|
.rx_buf = (unsigned long)rx,
|
||||||
.len = len,
|
.len = len,
|
||||||
.delay_usecs = 1,
|
.delay_usecs = 1,
|
||||||
//should settle around 400Khz, a standard SPI speed. Adjust using baud parameter (-b)
|
.speed_hz = 1.0 / pgm->bitclock, // seconds to Hz
|
||||||
.speed_hz = pgm->baudrate == 0 ? 400000 : pgm->baudrate,
|
|
||||||
.bits_per_word = 8,
|
.bits_per_word = 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -213,6 +212,19 @@ static int linuxspi_open(PROGRAMMER *pgm, char *port)
|
||||||
if (ret)
|
if (ret)
|
||||||
goto close_out;
|
goto close_out;
|
||||||
|
|
||||||
|
if (pgm->baudrate != 0) {
|
||||||
|
avrdude_message(MSG_INFO,
|
||||||
|
"%s: obsolete use of -b <clock> option for bit clock; use -B <clock>\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;
|
return 0;
|
||||||
|
|
||||||
close_out:
|
close_out:
|
||||||
|
@ -306,7 +318,7 @@ static int linuxspi_program_enable(PROGRAMMER *pgm, AVRPART *p)
|
||||||
*/
|
*/
|
||||||
if (linuxspi_reset_mcu(pgm, false))
|
if (linuxspi_reset_mcu(pgm, false))
|
||||||
return -1;
|
return -1;
|
||||||
usleep(3 + (pgm->baudrate ? 500000 / pgm->baudrate : 1));
|
usleep(5);
|
||||||
if (linuxspi_reset_mcu(pgm, true))
|
if (linuxspi_reset_mcu(pgm, true))
|
||||||
return -1;
|
return -1;
|
||||||
usleep(20000);
|
usleep(20000);
|
||||||
|
|
Loading…
Reference in New Issue