1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-25 20:04:03 +02:00

atusb/fw/usb/: enable MCU reset on USB bus reset after config selection

This way the host can reset the MCU if it's hung (for example, in the
panic loop) and we don't need to unplug-replug.
This commit is contained in:
Werner Almesberger 2013-04-01 15:54:44 -03:00
parent 65722d417a
commit 9b2696b848
3 changed files with 8 additions and 1 deletions

View File

@ -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) void usb_init(void)
{ {
USBCON |= 1 << FRZCLK; /* freeze the clock */ USBCON |= 1 << FRZCLK; /* freeze the clock */
@ -263,7 +269,6 @@ void usb_init(void)
UDCON &= ~(1 << DETACH); /* attach the pull-up */ UDCON &= ~(1 << DETACH); /* attach the pull-up */
UDIEN = 1 << EORSTE; /* enable device interrupts */ UDIEN = 1 << EORSTE; /* enable device interrupts */
// UDCON |= 1 << RSTCPU; /* reset CPU on bus reset */
ep_init(); ep_init();
} }

View File

@ -118,6 +118,7 @@ bool handle_setup(const struct setup_request *setup)
case TO_DEVICE(SET_CONFIGURATION): case TO_DEVICE(SET_CONFIGURATION):
if (setup->wValue != config_descriptor[5]) if (setup->wValue != config_descriptor[5])
return 0; return 0;
usb_enable_bus_reset();
break; break;
/* /*

View File

@ -153,6 +153,7 @@ bool handle_setup(const struct setup_request *setup);
void set_addr(uint8_t addr); void set_addr(uint8_t addr);
void usb_ep_change(struct ep_descr *ep); void usb_ep_change(struct ep_descr *ep);
void usb_reset(void); void usb_reset(void);
void usb_enable_bus_reset(void);
void usb_init(void); void usb_init(void);
#endif /* !USB_H */ #endif /* !USB_H */