1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-26 06:09:41 +02:00

atusb/fw: fixed USB bus reset handling by software

- usb/atu2.c (ep_init): moved before usb_poll
- usb/atu2.c (usb_poll): register bit was used as mask, not as shift
- usb/atu2.c (usb_poll): call ep_init on USB bus reset
- usb/atu2.c (usb_reset): don't make USB bus reset force a hardware reset
- Makefile (.PHONY, dfu): new target to upload the application with DFU
This commit is contained in:
Werner Almesberger 2011-05-09 21:13:41 -03:00
parent c5992bc675
commit eeb3af6a03
2 changed files with 24 additions and 20 deletions

View File

@ -58,7 +58,7 @@ endif
# ----- Rules ----------------------------------------------------------------- # ----- Rules -----------------------------------------------------------------
.PHONY: all clean upload prog version.c .PHONY: all clean upload prog dfu version.c
.PHONY: prog-app prog-read on off reset .PHONY: prog-app prog-read on off reset
all: $(NAME).bin boot.hex all: $(NAME).bin boot.hex
@ -143,6 +143,9 @@ prog-read:
ssh $(HOST) avrdude -F -p $(CHIP) -c nanonote_atusb \ ssh $(HOST) avrdude -F -p $(CHIP) -c nanonote_atusb \
-U flash:r:mcu.bin:r -U flash:r:mcu.bin:r
dfu: $(NAME).bin
dfu-util -d 20b7:1540 -D $(NAME).bin
on: on:
ssh $(HOST) poke 0x10010318 4 ssh $(HOST) poke 0x10010318 4

View File

@ -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) static void ep_init(void)
{ {
UENUM = 0; 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) void usb_reset(void)
{ {
UDCON |= 1 << DETACH; /* detach the pull-up */ UDCON |= 1 << DETACH; /* detach the pull-up */
@ -222,7 +223,7 @@ void usb_init(void)
USBCON &= ~(1 << FRZCLK); /* thaw the clock */ USBCON &= ~(1 << FRZCLK); /* thaw the clock */
UDCON &= ~(1 << DETACH); /* attach the pull-up */ 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(); ep_init();
} }