diff --git a/atusb/fw/usb/atu2.c b/atusb/fw/usb/atu2.c index 17868a5..4b2d6b2 100644 --- a/atusb/fw/usb/atu2.c +++ b/atusb/fw/usb/atu2.c @@ -247,6 +247,12 @@ void usb_reset(void) } +void usb_enable_bus_reset(void) +{ + UDCON |= 1 << RSTCPU; /* reset CPU on bus reset */ +} + + void usb_init(void) { USBCON |= 1 << FRZCLK; /* freeze the clock */ @@ -263,7 +269,6 @@ void usb_init(void) UDCON &= ~(1 << DETACH); /* attach the pull-up */ UDIEN = 1 << EORSTE; /* enable device interrupts */ -// UDCON |= 1 << RSTCPU; /* reset CPU on bus reset */ ep_init(); } diff --git a/atusb/fw/usb/usb.c b/atusb/fw/usb/usb.c index 4fde778..54dd2cd 100644 --- a/atusb/fw/usb/usb.c +++ b/atusb/fw/usb/usb.c @@ -118,6 +118,7 @@ bool handle_setup(const struct setup_request *setup) case TO_DEVICE(SET_CONFIGURATION): if (setup->wValue != config_descriptor[5]) return 0; + usb_enable_bus_reset(); break; /* diff --git a/atusb/fw/usb/usb.h b/atusb/fw/usb/usb.h index 90dd423..403d694 100644 --- a/atusb/fw/usb/usb.h +++ b/atusb/fw/usb/usb.h @@ -153,6 +153,7 @@ bool handle_setup(const struct setup_request *setup); void set_addr(uint8_t addr); void usb_ep_change(struct ep_descr *ep); void usb_reset(void); +void usb_enable_bus_reset(void); void usb_init(void); #endif /* !USB_H */