1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-16 23:11:55 +02:00

atusb/fw/boot.c (main): don't time out until there is an application

This prevents the boot loader from resetting all the time and makes
it easier to "catch" it with dfu-util.
This commit is contained in:
Werner Almesberger 2011-05-10 11:51:46 -03:00
parent fc1a334bf6
commit ddd0022350

View File

@ -14,6 +14,7 @@
#include <stdint.h> #include <stdint.h>
#include <avr/io.h> #include <avr/io.h>
#include <avr/pgmspace.h>
#define F_CPU 8000000UL #define F_CPU 8000000UL
#include <util/delay.h> #include <util/delay.h>
@ -34,6 +35,11 @@ static void (*run_payload)(void) = 0;
int main(void) int main(void)
{ {
/*
* pgm_read_byte gets cached and there doesn't seem to be any other
* way to dissuade gcc from doing this.
*/
volatile int zero = 0;
uint32_t loop = 0; uint32_t loop = 0;
board_init(); board_init();
@ -49,7 +55,7 @@ int main(void)
while (loop != MS_TO_LOOPS(2000)) { while (loop != MS_TO_LOOPS(2000)) {
usb_poll(); usb_poll();
if (dfu.state == dfuIDLE) if (dfu.state == dfuIDLE && pgm_read_byte(zero) != 0xff)
loop++; loop++;
else else
loop = 0; loop = 0;