From d2cb718727dbe19f135dd51f1d9989d8cbcbc4f9 Mon Sep 17 00:00:00 2001 From: cpldcpu Date: Sun, 2 Feb 2014 18:34:47 +0100 Subject: firmware: added OSCCAL_HAVE_XTAL --- firmware/bootloaderconfig.h | 13 +++++++++---- firmware/main.c | 2 ++ firmware/osccalASM.S | 4 +++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/firmware/bootloaderconfig.h b/firmware/bootloaderconfig.h index 80922ca..43658dc 100644 --- a/firmware/bootloaderconfig.h +++ b/firmware/bootloaderconfig.h @@ -248,16 +248,21 @@ these macros are defined, the boot loader uses them. * This is the default behaviour of the Digispark. * Adds ~38 bytes. * + * OSCCAL_HAVE_XTAL Set this to '1' if you have an external crystal oscillator. In this case no attempt + * will be made to calibrate the oscillator. You should deactivate both options above + * if you use this to avoid redundant code. + * * If both options are selected, OSCCAL_RESTORE takes precedence. * * If no option is selected, OSCCAL will be left untouched and stay at either 16.0Mhz or 16.5Mhz depending * on whether the bootloader was activated. This will take the least memory. You can use this if your program - * comes with its own OSCCAL calibration or an external clock source is used. + * comes with its own OSCCAL calibration or an external clock source is used. */ - #define OSCCAL_RESTORE 1 - #define OSCCAL_16_5MHz 1 - +#define OSCCAL_RESTORE 1 +#define OSCCAL_16_5MHz 0 +#define OSCCAL_HAVE_XTAL 0 + /* * Defines handling of an indicator LED while the bootloader is active. * diff --git a/firmware/main.c b/firmware/main.c index aab826c..5381cee 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -259,7 +259,9 @@ int main(void) { if (!--resetctr) { // reset encountered usbNewDeviceAddr = 0; // bits from the reset handling of usbpoll() usbDeviceAddr = 0; +#if (OSCCAL_HAVE_XTAL == 0) calibrateOscillatorASM(); +#endif } if (USB_INTR_PENDING & (1<