2 * fw/boot.c - DFU boot loader for ATUSB
4 * Written 2008-2011 by Werner Almesberger
5 * Copyright 2008-2011 Werner Almesberger
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
17 #include <avr/interrupt.h>
18 #include <avr/pgmspace.h>
20 #define F_CPU 8000000UL
21 #include <util/delay.h>
28 #include "atusb/ep0.h"
31 #define MS_TO_LOOPS(ms) ((uint32_t) (ms)*335)
34 static void (*run_payload)(void) = 0;
40 * pgm_read_byte gets cached and there doesn't seem to be any other
41 * way to dissuade gcc from doing this.
43 volatile int zero = 0;
49 /* now we should be at 8 MHz */
54 /* move interrupt vectors to the boot loader */
62 while (loop != MS_TO_LOOPS(2500)) {
63 if (dfu.state == dfuIDLE && pgm_read_byte(zero) != 0xff)
76 while (1); /* not reached */