summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcpldcpu <cpldcpu@gmail.com>2014-02-02 18:34:47 +0100
committercpldcpu <cpldcpu@gmail.com>2014-02-02 18:34:47 +0100
commitd2cb718727dbe19f135dd51f1d9989d8cbcbc4f9 (patch)
tree671e5fc16bcb307a66f17091b558f45016278079
parent0594d9bfb2b3493952a03dcfed47e5647a83b489 (diff)
downloadmicronucleus-d2cb718727dbe19f135dd51f1d9989d8cbcbc4f9.tar.gz
micronucleus-d2cb718727dbe19f135dd51f1d9989d8cbcbc4f9.tar.bz2
micronucleus-d2cb718727dbe19f135dd51f1d9989d8cbcbc4f9.zip
firmware: added OSCCAL_HAVE_XTAL
-rw-r--r--firmware/bootloaderconfig.h13
-rw-r--r--firmware/main.c2
-rw-r--r--firmware/osccalASM.S4
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<<USB_INTR_PENDING_BIT)) {
diff --git a/firmware/osccalASM.S b/firmware/osccalASM.S
index 69bad9f..6b24b50 100644
--- a/firmware/osccalASM.S
+++ b/firmware/osccalASM.S
@@ -93,7 +93,7 @@
#endif
# define cnt16 cnt16L
-; extern void calibrateOscillatorASM(void);
+#if (OSCCAL_HAVE_XTAL == 0)
.global calibrateOscillatorASM
calibrateOscillatorASM:
@@ -171,6 +171,8 @@ usbCObinarysearch:
nop
ret
+#endif //OSCCAL_HAVE_XTAL
+
#undef i
#undef opV
#undef opD