+ /* explicitly clear interrupts */
+ cli();
+
+ /* move the vectors */
+
+ /* move interrupts from boot flash section */
+ /* NB */
+ /* you MUST use a variable during this process. even highly optimized,
+ * masking the bit, shifting, ANDing, and setting MCUCR will exceed
+ * 4 CPU cycles! set a variable with the desired value for MCUCR and
+ * then set the register once IVCE is enabled
+ */
+ x = MCUCR & ~(1 << IVSEL);
+
+ /* enable change of interrupt vectors */
+ /* NOTE: setting IVCE disables interrupts until the bit is auto-unset
+ * 4 cycles after being set or after IVSEL is written
+ */
+ MCUCR |= (1 << IVCE);
+ MCUCR = x;
+
+ /* disable the watchdog timer; this macro will disable interrupts for us */
+ /* NOTE: ensure that the WDRF flag is unset in the MCUSR or we will spinlock
+ * when the watchdog times out
+ */
+ MCUSR &= ~(1 << WDRF);
+ wdt_disable();
+
+ /* init the USART */
+ zigduino_init_uart0();
+
+ /* set the LED as an output */
+ led_init();
+
+ /* enable internal internal pull-up resister
+ in order to supress line noise that prevents
+ bootloader from timing out */
+ SPIDIR &= ~(1 << SPIPIN);
+ SPIOUT |= (1 << SPIPIN);
+
+ /* explicitly enable interrupts */
+ sei();