summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-04-04 15:29:48 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2012-04-04 15:29:48 +0200
commit0685014e127743b08951f93548b30a961afb7fa5 (patch)
treee9af87a6b0054e76f45c95ebb2c1130aad62458f
parentf3fe2ae138e26294256f9e6292f9f51d8841e7e4 (diff)
downloadat90usb-bootloader-master.tar.gz
at90usb-bootloader-master.tar.bz2
at90usb-bootloader-master.tar.xz
at90usb-bootloader-master.zip
Restoring interrupt vectors when jumping to user application.HEADmaster
-rw-r--r--.gitignore11
-rw-r--r--BootloaderCDC.c16
2 files changed, 26 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1a20f80
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,11 @@
+*.o
+*.lst
+*.elf
+*.eep
+*.hex
+*.lss
+*.map
+*.sym
+.*.swp
+.*.un~
+.dep/
diff --git a/BootloaderCDC.c b/BootloaderCDC.c
index 3ea56fc..fbc777f 100644
--- a/BootloaderCDC.c
+++ b/BootloaderCDC.c
@@ -77,6 +77,11 @@ int main(void)
sei();
/* Timer init */
+ TCCR0B_backup = TCCR0B;
+ TCCR0A_backup = TCCR0A;
+ TIMSK0_backup = TIMSK0;
+ TIFR0_backup = TIFR0;
+
TCCR0B = 1 << CS02 | 1 << CS00; // prescaler = / 1024, i.e. 15625 Hz
TCCR0A = 0; // 8-bit normal mode
TIMSK0 = 1 << TOIE0; // Enable Timer0
@@ -97,7 +102,16 @@ int main(void)
/* Jump to main program. */
cli();
- TIMSK0 = 0 << TOIE0; // Disable Timer0 interrupt
+
+ // Restore system state
+ TCCR0B = TCCR0B_backup;
+ TCCR0A = TCCR0A_backup;
+ TIMSK0 = TIMSK0_backup;
+ TIFR0 = TIFR0_backup;
+
+ MCUCR = (1 << IVCE);
+ MCUCR = (0 << IVSEL);
+
__asm("jmp 0x0000");
for (;;);