mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 10:37:46 +00:00
machine/nrf52840: ensure that USB CDC interface is only initialized once
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -58,7 +58,7 @@ const (
|
||||
|
||||
// UART0 is the USB device
|
||||
var (
|
||||
UART0 = USB
|
||||
UART0 = &USB
|
||||
)
|
||||
|
||||
// I2C pins
|
||||
|
||||
@@ -105,7 +105,7 @@ const (
|
||||
|
||||
// UART0 is the USB device
|
||||
var (
|
||||
UART0 = USB
|
||||
UART0 = &USB
|
||||
)
|
||||
|
||||
// I2C pins
|
||||
|
||||
@@ -77,7 +77,7 @@ const (
|
||||
|
||||
// UART0 is the USB device
|
||||
var (
|
||||
UART0 = USB
|
||||
UART0 = &USB
|
||||
)
|
||||
|
||||
// I2C pins
|
||||
|
||||
@@ -72,7 +72,7 @@ const (
|
||||
|
||||
// UART0 is the USB device
|
||||
var (
|
||||
UART0 = USB
|
||||
UART0 = &USB
|
||||
)
|
||||
|
||||
// I2C pins
|
||||
|
||||
@@ -41,7 +41,7 @@ const (
|
||||
|
||||
// UART
|
||||
var (
|
||||
Serial = USB
|
||||
Serial = &USB
|
||||
UART0 = NRF_UART0
|
||||
)
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ const (
|
||||
|
||||
// UART
|
||||
var (
|
||||
Serial = USB
|
||||
Serial = &USB
|
||||
UART0 = NRF_UART0
|
||||
)
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ const (
|
||||
|
||||
// UART
|
||||
var (
|
||||
Serial = USB
|
||||
Serial = &USB
|
||||
UART0 = NRF_UART0
|
||||
)
|
||||
|
||||
|
||||
@@ -12,8 +12,9 @@ import (
|
||||
|
||||
// USBCDC is the USB CDC aka serial over USB interface on the nRF52840
|
||||
type USBCDC struct {
|
||||
Buffer *RingBuffer
|
||||
interrupt interrupt.Interrupt
|
||||
Buffer *RingBuffer
|
||||
interrupt interrupt.Interrupt
|
||||
initcomplete bool
|
||||
}
|
||||
|
||||
// WriteByte writes a byte of data to the USB CDC interface.
|
||||
@@ -87,6 +88,10 @@ func exitCriticalSection() {
|
||||
|
||||
// Configure the USB CDC interface. The config is here for compatibility with the UART interface.
|
||||
func (usbcdc *USBCDC) Configure(config UARTConfig) {
|
||||
if usbcdc.initcomplete {
|
||||
return
|
||||
}
|
||||
|
||||
// Enable IRQ. Make sure this is higher than the SWI2 interrupt handler so
|
||||
// that it is possible to print to the console from a BLE interrupt. You
|
||||
// shouldn't generally do that but it is useful for debugging and panic
|
||||
@@ -107,6 +112,8 @@ func (usbcdc *USBCDC) Configure(config UARTConfig) {
|
||||
)
|
||||
|
||||
nrf.USBD.USBPULLUP.Set(0)
|
||||
|
||||
usbcdc.initcomplete = true
|
||||
}
|
||||
|
||||
func (usbcdc *USBCDC) handleInterrupt(interrupt.Interrupt) {
|
||||
|
||||
Reference in New Issue
Block a user