Reset USB peripheral and wait for startup
This commit is contained in:
		| @@ -71,10 +71,19 @@ static void bus_reset(void) { | ||||
|  *------------------------------------------------------------------*/ | ||||
| bool dcd_init (uint8_t rhport) | ||||
| { | ||||
|   // Reset to get in a clean state. | ||||
|   USB->DEVICE.CTRLA.bit.SWRST = true; | ||||
|   while (USB->DEVICE.SYNCBUSY.bit.SWRST == 0) { | ||||
|  | ||||
|   } | ||||
|   while (USB->DEVICE.SYNCBUSY.bit.SWRST == 1) {} | ||||
|  | ||||
|   (void) rhport; | ||||
|   USB->DEVICE.DESCADD.reg = (uint32_t) &sram_registers; | ||||
|   USB->DEVICE.CTRLB.reg = USB_DEVICE_CTRLB_SPDCONF_FS; | ||||
|   USB->DEVICE.CTRLA.reg = USB_CTRLA_MODE_DEVICE | USB_CTRLA_ENABLE; | ||||
|   USB->DEVICE.CTRLA.reg = USB_CTRLA_MODE_DEVICE | USB_CTRLA_ENABLE | USB_CTRLA_RUNSTDBY; | ||||
|   while (USB->DEVICE.SYNCBUSY.bit.ENABLE == 1) {} | ||||
|  | ||||
|   USB->DEVICE.INTENSET.reg = USB_DEVICE_INTENSET_SOF | USB_DEVICE_INTENSET_EORST; | ||||
|  | ||||
|   return true; | ||||
|   | ||||
| @@ -72,9 +72,17 @@ static void bus_reset(void) { | ||||
| bool dcd_init (uint8_t rhport) | ||||
| { | ||||
|   (void) rhport; | ||||
|   // Reset to get in a clean state. | ||||
|   USB->DEVICE.CTRLA.bit.SWRST = true; | ||||
|   while (USB->DEVICE.SYNCBUSY.bit.SWRST == 0) { | ||||
|  | ||||
|   } | ||||
|   while (USB->DEVICE.SYNCBUSY.bit.SWRST == 1) {} | ||||
|  | ||||
|   USB->DEVICE.DESCADD.reg = (uint32_t) &sram_registers; | ||||
|   USB->DEVICE.CTRLB.reg = USB_DEVICE_CTRLB_SPDCONF_FS; | ||||
|   USB->DEVICE.CTRLA.reg = USB_CTRLA_MODE_DEVICE | USB_CTRLA_ENABLE; | ||||
|   USB->DEVICE.CTRLA.reg = USB_CTRLA_MODE_DEVICE | USB_CTRLA_ENABLE | USB_CTRLA_RUNSTDBY; | ||||
|   while (USB->DEVICE.SYNCBUSY.bit.ENABLE == 1) {} | ||||
|   USB->DEVICE.INTENSET.reg = USB_DEVICE_INTENSET_SOF | USB_DEVICE_INTENSET_EORST; | ||||
|  | ||||
|   return true; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Scott Shawcroft
					Scott Shawcroft