From b1b897766d63c9f5060da456f62fb298f5d51495 Mon Sep 17 00:00:00 2001 From: WestfW Date: Sat, 6 Oct 2018 17:25:59 -0700 Subject: [PATCH] Don't do the BRG divisor analysis for SOFT_UART targets. (and improve the check that does happen for SOFT_UART.) --- optiboot/bootloaders/optiboot/Makefile | 5 +++-- optiboot/bootloaders/optiboot/optiboot.c | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/optiboot/bootloaders/optiboot/Makefile b/optiboot/bootloaders/optiboot/Makefile index 7a9d52df4..d214027f2 100644 --- a/optiboot/bootloaders/optiboot/Makefile +++ b/optiboot/bootloaders/optiboot/Makefile @@ -629,10 +629,11 @@ include Makefile.2560 include Makefile.tiny include Makefile.MCUdude +BAUDCHECK= ifndef PRODUCTION +ifndef SOFT_UART BAUDCHECK= baudcheck -else -BAUDCHECK= +endif endif #--------------------------------------------------------------------------- diff --git a/optiboot/bootloaders/optiboot/optiboot.c b/optiboot/bootloaders/optiboot/optiboot.c index 3bf7d060f..0bcd7a597 100644 --- a/optiboot/bootloaders/optiboot/optiboot.c +++ b/optiboot/bootloaders/optiboot/optiboot.c @@ -331,6 +331,7 @@ typedef union { #define UART 0 #endif +#ifndef SOFT_UART #ifdef SINGLESPEED /* Single speed option */ #define BAUD_SETTING (( (F_CPU + BAUD_RATE * 8L) / ((BAUD_RATE * 16L))) - 1 ) @@ -364,6 +365,7 @@ typedef union { #error Unachievable baud rate (too fast) BAUD_RATE #endif #endif // baud rate fast check +#endif // SOFT_UART /* Watchdog settings */ #define WATCHDOG_OFF (0) @@ -982,6 +984,13 @@ uint8_t getch(void) { #if UART_B_VALUE > 255 #error Baud rate too slow for soft UART #endif +#if UART_B_VALUE < 6 +// (this value is a "guess" at when loop/call overhead might become too +// significant for the soft uart to work. It tests OK with the popular +// "ATtinycore" chips that need SOFT_UART, at the usual clock/baud combos.) +#error Baud rate too high for soft UART +#endif + void uartDelay() { __asm__ __volatile__ (