mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 10:43:29 +00:00
samd21,samd51: fix usbcdc initialization when -serial=uart (#2631)
machine/samd21,samd51: fix usbcdc initialization when -serial=uart by using machine.USB.Configured()
This commit is contained in:
@@ -1742,6 +1742,7 @@ type USBCDC struct {
|
|||||||
waitTxc bool
|
waitTxc bool
|
||||||
waitTxcRetryCount uint8
|
waitTxcRetryCount uint8
|
||||||
sent bool
|
sent bool
|
||||||
|
configured bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -1923,6 +1924,13 @@ func (usbcdc *USBCDC) Configure(config UARTConfig) {
|
|||||||
// enable IRQ
|
// enable IRQ
|
||||||
intr := interrupt.New(sam.IRQ_USB, handleUSB)
|
intr := interrupt.New(sam.IRQ_USB, handleUSB)
|
||||||
intr.Enable()
|
intr.Enable()
|
||||||
|
|
||||||
|
usbcdc.configured = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configured returns whether usbcdc is configured or not.
|
||||||
|
func (usbcdc *USBCDC) Configured() bool {
|
||||||
|
return usbcdc.configured
|
||||||
}
|
}
|
||||||
|
|
||||||
func handlePadCalibration() {
|
func handlePadCalibration() {
|
||||||
|
|||||||
@@ -1965,6 +1965,7 @@ type USBCDC struct {
|
|||||||
waitTxc bool
|
waitTxc bool
|
||||||
waitTxcRetryCount uint8
|
waitTxcRetryCount uint8
|
||||||
sent bool
|
sent bool
|
||||||
|
configured bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -2149,6 +2150,13 @@ func (usbcdc *USBCDC) Configure(config UARTConfig) {
|
|||||||
interrupt.New(sam.IRQ_USB_SOF_HSOF, handleUSBIRQ).Enable()
|
interrupt.New(sam.IRQ_USB_SOF_HSOF, handleUSBIRQ).Enable()
|
||||||
interrupt.New(sam.IRQ_USB_TRCPT0, handleUSBIRQ).Enable()
|
interrupt.New(sam.IRQ_USB_TRCPT0, handleUSBIRQ).Enable()
|
||||||
interrupt.New(sam.IRQ_USB_TRCPT1, handleUSBIRQ).Enable()
|
interrupt.New(sam.IRQ_USB_TRCPT1, handleUSBIRQ).Enable()
|
||||||
|
|
||||||
|
usbcdc.configured = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configured returns whether usbcdc is configured or not.
|
||||||
|
func (usbcdc *USBCDC) Configured() bool {
|
||||||
|
return usbcdc.configured
|
||||||
}
|
}
|
||||||
|
|
||||||
func handlePadCalibration() {
|
func handlePadCalibration() {
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ func init() {
|
|||||||
|
|
||||||
// connect to USB CDC interface
|
// connect to USB CDC interface
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.Serial.Configure(machine.UARTConfig{})
|
||||||
|
if !machine.USB.Configured() {
|
||||||
|
machine.USB.Configure(machine.UARTConfig{})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func putchar(c byte) {
|
func putchar(c byte) {
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ func init() {
|
|||||||
|
|
||||||
// connect to USB CDC interface
|
// connect to USB CDC interface
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.Serial.Configure(machine.UARTConfig{})
|
||||||
|
if !machine.USB.Configured() {
|
||||||
|
machine.USB.Configure(machine.UARTConfig{})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func putchar(c byte) {
|
func putchar(c byte) {
|
||||||
|
|||||||
Reference in New Issue
Block a user