diff options
author | deadprogram <[email protected]> | 2020-12-28 15:33:09 +0100 |
---|---|---|
committer | Ayke <[email protected]> | 2020-12-29 12:20:33 +0100 |
commit | a5ee1ba4b3a4efae0a77c4f07be4de78fad057fc (patch) | |
tree | 12b4005095611612931323cf032cc1062c4ad38f | |
parent | fb0bb69f622c94e6aa2e6e340faa0ba2146cf440 (diff) | |
download | tinygo-a5ee1ba4b3a4efae0a77c4f07be4de78fad057fc.tar.gz tinygo-a5ee1ba4b3a4efae0a77c4f07be4de78fad057fc.zip |
machine/nrf52840: ensure that USB CDC interface is only initialized once
Signed-off-by: deadprogram <[email protected]>
-rw-r--r-- | src/machine/board_circuitplay_bluefruit.go | 2 | ||||
-rw-r--r-- | src/machine/board_clue_alpha.go | 2 | ||||
-rw-r--r-- | src/machine/board_feather-nrf52840.go | 2 | ||||
-rw-r--r-- | src/machine/board_itsybitsy-nrf52840.go | 2 | ||||
-rw-r--r-- | src/machine/board_particle_argon.go | 2 | ||||
-rw-r--r-- | src/machine/board_particle_boron.go | 2 | ||||
-rw-r--r-- | src/machine/board_particle_xenon.go | 2 | ||||
-rw-r--r-- | src/machine/usb_nrf52840.go | 11 |
8 files changed, 16 insertions, 9 deletions
diff --git a/src/machine/board_circuitplay_bluefruit.go b/src/machine/board_circuitplay_bluefruit.go index cb56ed348..bc6d6172d 100644 --- a/src/machine/board_circuitplay_bluefruit.go +++ b/src/machine/board_circuitplay_bluefruit.go @@ -58,7 +58,7 @@ const ( // UART0 is the USB device var ( - UART0 = USB + UART0 = &USB ) // I2C pins diff --git a/src/machine/board_clue_alpha.go b/src/machine/board_clue_alpha.go index d90b6889b..cb458062e 100644 --- a/src/machine/board_clue_alpha.go +++ b/src/machine/board_clue_alpha.go @@ -105,7 +105,7 @@ const ( // UART0 is the USB device var ( - UART0 = USB + UART0 = &USB ) // I2C pins diff --git a/src/machine/board_feather-nrf52840.go b/src/machine/board_feather-nrf52840.go index f353a3b7b..ae4b54e0f 100644 --- a/src/machine/board_feather-nrf52840.go +++ b/src/machine/board_feather-nrf52840.go @@ -77,7 +77,7 @@ const ( // UART0 is the USB device var ( - UART0 = USB + UART0 = &USB ) // I2C pins diff --git a/src/machine/board_itsybitsy-nrf52840.go b/src/machine/board_itsybitsy-nrf52840.go index e61be0061..4d98b669e 100644 --- a/src/machine/board_itsybitsy-nrf52840.go +++ b/src/machine/board_itsybitsy-nrf52840.go @@ -72,7 +72,7 @@ const ( // UART0 is the USB device var ( - UART0 = USB + UART0 = &USB ) // I2C pins diff --git a/src/machine/board_particle_argon.go b/src/machine/board_particle_argon.go index 5401c4ad9..44e5a51ba 100644 --- a/src/machine/board_particle_argon.go +++ b/src/machine/board_particle_argon.go @@ -41,7 +41,7 @@ const ( // UART var ( - Serial = USB + Serial = &USB UART0 = NRF_UART0 ) diff --git a/src/machine/board_particle_boron.go b/src/machine/board_particle_boron.go index cb05e7253..a50d87eb9 100644 --- a/src/machine/board_particle_boron.go +++ b/src/machine/board_particle_boron.go @@ -41,7 +41,7 @@ const ( // UART var ( - Serial = USB + Serial = &USB UART0 = NRF_UART0 ) diff --git a/src/machine/board_particle_xenon.go b/src/machine/board_particle_xenon.go index c16146364..7a94cf6d8 100644 --- a/src/machine/board_particle_xenon.go +++ b/src/machine/board_particle_xenon.go @@ -41,7 +41,7 @@ const ( // UART var ( - Serial = USB + Serial = &USB UART0 = NRF_UART0 ) diff --git a/src/machine/usb_nrf52840.go b/src/machine/usb_nrf52840.go index e51323357..8d056839b 100644 --- a/src/machine/usb_nrf52840.go +++ b/src/machine/usb_nrf52840.go @@ -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) { |