diff --git a/atusb/fw/Makefile b/atusb/fw/Makefile index 1e2ddf9..96cb1d6 100644 --- a/atusb/fw/Makefile +++ b/atusb/fw/Makefile @@ -58,7 +58,7 @@ endif # ----- Rules ----------------------------------------------------------------- -.PHONY: all clean upload prog version.c +.PHONY: all clean upload prog dfu version.c .PHONY: prog-app prog-read on off reset all: $(NAME).bin boot.hex @@ -143,6 +143,9 @@ prog-read: ssh $(HOST) avrdude -F -p $(CHIP) -c nanonote_atusb \ -U flash:r:mcu.bin:r +dfu: $(NAME).bin + dfu-util -d 20b7:1540 -D $(NAME).bin + on: ssh $(HOST) poke 0x10010318 4 diff --git a/atusb/fw/usb/atu2.c b/atusb/fw/usb/atu2.c index 917b680..6ab9146 100644 --- a/atusb/fw/usb/atu2.c +++ b/atusb/fw/usb/atu2.c @@ -167,24 +167,6 @@ stall: } -void usb_poll(void) -{ - uint8_t flags, i; - - flags = UDINT; - if (flags & EORSTI) { - UDINT &= ~(1 << EORSTI); - if (user_reset) - user_reset(); - } - flags = UEINT; - for (i = 0; i != NUM_EPS; i++) - if (1 || flags & (1 << i)) - handle_ep(i); - /* @@@ USB bus reset */ -} - - static void ep_init(void) { UENUM = 0; @@ -200,6 +182,25 @@ static void ep_init(void) } +void usb_poll(void) +{ + uint8_t flags, i; + + flags = UDINT; + if (flags & (1 << EORSTI)) { + if (user_reset) + user_reset(); + ep_init(); + UDINT &= ~(1 << EORSTI); + } + flags = UEINT; + for (i = 0; i != NUM_EPS; i++) + if (1 || flags & (1 << i)) + handle_ep(i); + /* @@@ USB bus reset */ +} + + void usb_reset(void) { UDCON |= 1 << DETACH; /* detach the pull-up */ @@ -222,7 +223,7 @@ void usb_init(void) USBCON &= ~(1 << FRZCLK); /* thaw the clock */ UDCON &= ~(1 << DETACH); /* attach the pull-up */ - UDCON |= 1 << RSTCPU; /* reset CPU on bus reset */ +// UDCON |= 1 << RSTCPU; /* reset CPU on bus reset */ ep_init(); }