summaryrefslogtreecommitdiff
path: root/lib/util.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2012-05-28 18:56:11 +0000
committerChristian Pointner <equinox@spreadspace.org>2012-05-28 18:56:11 +0000
commitdfd6d6010bec3c2b412e75b1f75d21a7261fd92a (patch)
tree9139d3f63ead287526593a9bf24c29f1123e7241 /lib/util.c
parentadded posibility to build external lufa lib (not perfect..) (diff)
added USBtoSerial Example Project to avr utils
git-svn-id: https://svn.spreadspace.org/avr/trunk@38 aa12f405-d877-488e-9caf-2d797e2a1cc7
Diffstat (limited to 'lib/util.c')
-rw-r--r--lib/util.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/util.c b/lib/util.c
index 76f5104..d927f8e 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -37,6 +37,21 @@ void cpu_init(void)
CPU_PRESCALE(0);
}
+#if defined(__BOARD_teensy1__)
+ #define BOOTLOADER_VEC 0x3E00
+#elif defined(__BOARD_teensy2__)
+ #define BOOTLOADER_VEC 0x7E00
+#elif defined(__BOARD_teensy1pp__)
+ #define BOOTLOADER_VEC 0xFC00
+#elif defined(__BOARD_teensy2pp__)
+ #define BOOTLOADER_VEC 0x1FC00
+#elif defined(__BOARD_hhd70dongle__)
+ #define BOOTLOADER_VEC 0x3800
+#endif
+
+typedef void (*f_ptr_type)(void);
+f_ptr_type start_bootloader = (f_ptr_type)BOOTLOADER_VEC;
+
void reset2bootloader(void)
{
#if defined(__BOARD_teensy1__) || defined(__BOARD_teensy1pp__) || defined(__BOARD_teensy2__) || defined(__BOARD_teensy2pp__) || defined(__BOARD_hhd70dongle__)
@@ -52,31 +67,27 @@ void reset2bootloader(void)
TIMSK0 = 0; TIMSK1 = 0; UCSR1B = 0;
DDRB = 0; DDRC = 0; DDRD = 0;
PORTB = 0; PORTC = 0; PORTD = 0;
- asm volatile("jmp 0x3E00");
#elif defined(__BOARD_teensy2__)
EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0;
TIMSK0 = 0; TIMSK1 = 0; TIMSK3 = 0; TIMSK4 = 0; UCSR1B = 0; TWCR = 0;
DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; TWCR = 0;
PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0;
- asm volatile("jmp 0x7E00");
- #elif defined(__BOARD_teensy2pp__)
+ #elif defined(__BOARD_teensy1pp__)
EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0;
TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0; TIMSK3 = 0; UCSR1B = 0; TWCR = 0;
DDRA = 0; DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0;
PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0;
- asm volatile("jmp 0xFC00");
#elif defined(__BOARD_teensy2pp__)
EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0;
TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0; TIMSK3 = 0; UCSR1B = 0; TWCR = 0;
DDRA = 0; DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0;
PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0;
- asm volatile("jmp 0x1FC00");
#elif defined(__BOARD_hhd70dongle__)
EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0;
TIMSK0 = 0; TIMSK1 = 0; TIMSK3 = 0; TIMSK4 = 0; UCSR1B = 0; TWCR = 0;
DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; TWCR = 0;
PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0;
- asm volatile("jmp 0x3800");
#endif
+ start_bootloader();
#endif
}