diff options
author | cpldcpu <cpldcpu@gmail.com> | 2014-07-03 22:41:08 +0200 |
---|---|---|
committer | cpldcpu <cpldcpu@gmail.com> | 2014-07-03 22:41:08 +0200 |
commit | 1e6cfd178fc302e5dd269444063745dd7b7a66c0 (patch) | |
tree | 5462d77f07aafc0f5774f30dff4c18386acffa4a /firmware | |
parent | 8acc614a0d65ef4021295c3d4681f76d24b70e96 (diff) | |
download | micronucleus-1e6cfd178fc302e5dd269444063745dd7b7a66c0.tar.gz micronucleus-1e6cfd178fc302e5dd269444063745dd7b7a66c0.tar.bz2 micronucleus-1e6cfd178fc302e5dd269444063745dd7b7a66c0.zip |
firmware: Stored OSCCAL can now be used by userprogram
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/main.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/firmware/main.c b/firmware/main.c index 625f026..0de341a 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -196,20 +196,6 @@ static void initHardware (void) WDTCR = 1<<WDP2 | 1<<WDP1 | 1<<WDP0; #endif - - /* save default OSCCAL calibration */ -#if OSCCAL_RESTORE_DEFAULT - osccal_default = OSCCAL; -#endif - -#if OSCCAL_SAVE_CALIB - // adjust clock to previous calibration value, so bootloader starts with proper clock calibration - unsigned char stored_osc_calibration = pgm_read_byte(BOOTLOADER_ADDRESS - TINYVECTOR_OSCCAL_OFFSET); - if (stored_osc_calibration != 0xFF) { - OSCCAL=stored_osc_calibration; - nop(); - } -#endif usbDeviceDisconnect(); /* do this while interrupts are disabled */ _delay_ms(300); @@ -243,6 +229,20 @@ static inline void leaveBootloader(void) { void USB_INTR_VECTOR(void); int main(void) { bootLoaderInit(); + + /* save default OSCCAL calibration */ +#if OSCCAL_RESTORE_DEFAULT + osccal_default = OSCCAL; +#endif + +#if OSCCAL_SAVE_CALIB + // adjust clock to previous calibration value, so bootloader starts with proper clock calibration + unsigned char stored_osc_calibration = pgm_read_byte(BOOTLOADER_ADDRESS - TINYVECTOR_OSCCAL_OFFSET); + if (stored_osc_calibration != 0xFF) { + OSCCAL=stored_osc_calibration; + nop(); + } +#endif if (bootLoaderStartCondition()||(pgm_read_byte(BOOTLOADER_ADDRESS - TINYVECTOR_RESET_OFFSET + 1)==0xff)) { |