mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 10:43:29 +00:00
machine: define Serial as the default output
Previously, the machine.UART0 object had two meanings:
- it was the first UART on the chip
- it was the default output for println
These two meanings conflict, and resulted in workarounds like:
- Defining UART0 to refer to the USB-CDC interface (atsamd21,
atsamd51, nrf52840), even though that clearly isn't an UART.
- Defining NRF_UART0 to avoid a conflict with UART0 (which was
redefined as a USB-CDC interface).
- Defining aliases like UART0 = UART1, which refer to the same
hardware peripheral (stm32).
This commit changes this to use a new machine.Serial object for the
default serial port. It might refer to the first or second UART
depending on the board, or even to the USB-CDC interface. Also, UART0
now really refers to the first UART on the chip, no longer to a USB-CDC
interface.
The changes in the runtime package are all just search+replace. The
changes in the machine package are a mixture of search+replace and
manual modifications.
This commit does not affect binary size, in fact it doesn't affect the
resulting binary at all.
This commit is contained in:
committed by
Ron Evans
parent
aa5b8d0df7
commit
b67351babe
@@ -505,8 +505,7 @@ type UART struct {
|
||||
}
|
||||
|
||||
var (
|
||||
// UART0 is actually a USB CDC interface.
|
||||
UART0 = &USBCDC{Buffer: NewRingBuffer()}
|
||||
USB = &USBCDC{Buffer: NewRingBuffer()}
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -1985,7 +1984,7 @@ func handleUSB(intr interrupt.Interrupt) {
|
||||
|
||||
// Start of frame
|
||||
if (flags & sam.USB_DEVICE_INTFLAG_SOF) > 0 {
|
||||
UART0.Flush()
|
||||
USB.Flush()
|
||||
// if you want to blink LED showing traffic, this would be the place...
|
||||
}
|
||||
|
||||
@@ -2045,7 +2044,7 @@ func handleUSB(intr interrupt.Interrupt) {
|
||||
setEPINTFLAG(i, sam.USB_DEVICE_EPINTFLAG_TRCPT1)
|
||||
|
||||
if i == usb_CDC_ENDPOINT_IN {
|
||||
UART0.waitTxc = false
|
||||
USB.waitTxc = false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2359,7 +2358,7 @@ func handleEndpoint(ep uint32) {
|
||||
|
||||
// move to ring buffer
|
||||
for i := 0; i < count; i++ {
|
||||
UART0.Receive(byte((udd_ep_out_cache_buffer[ep][i] & 0xFF)))
|
||||
USB.Receive(byte((udd_ep_out_cache_buffer[ep][i] & 0xFF)))
|
||||
}
|
||||
|
||||
// set byte count to zero
|
||||
|
||||
Reference in New Issue
Block a user