samd21,samd51: fix usbcdc initialization when -serial=uart (#2631)
machine/samd21,samd51: fix usbcdc initialization when -serial=uart by using machine.USB.Configured()
Этот коммит содержится в:
родитель
ccbe03795a
коммит
a1b4eafa07
4 изменённых файлов: 22 добавлений и 0 удалений
|
@ -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) {
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче