atsamd21,atsamd51,nrf52840: improve usb-device initialization

This commit is contained in:
sago35
2022-07-07 19:06:47 +09:00
committed by Ron Evans
parent 335a7ad0b7
commit f1e6997018
4 changed files with 49 additions and 11 deletions
+6
View File
@@ -151,6 +151,10 @@ const (
// Configure the USB peripheral. The config is here for compatibility with the UART interface.
func (dev *USBDevice) Configure(config UARTConfig) {
if dev.initcomplete {
return
}
// reset USB interface
sam.USB_DEVICE.CTRLA.SetBits(sam.USB_DEVICE_CTRLA_SWRST)
for sam.USB_DEVICE.SYNCBUSY.HasBits(sam.USB_DEVICE_SYNCBUSY_SWRST) ||
@@ -189,6 +193,8 @@ func (dev *USBDevice) Configure(config UARTConfig) {
interrupt.New(sam.IRQ_USB_SOF_HSOF, handleUSBIRQ).Enable()
interrupt.New(sam.IRQ_USB_TRCPT0, handleUSBIRQ).Enable()
interrupt.New(sam.IRQ_USB_TRCPT1, handleUSBIRQ).Enable()
dev.initcomplete = true
}
func (usbcdc *USBCDC) Configure(config UARTConfig) {