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:
Ayke van Laethem
2021-05-13 14:07:22 +02:00
committed by Ron Evans
parent aa5b8d0df7
commit b67351babe
82 changed files with 171 additions and 156 deletions
+3 -3
View File
@@ -138,8 +138,8 @@ type UART struct {
// UART
var (
// UART0 is the hardware UART on the NRF SoC.
_NRF_UART0 = UART{Buffer: NewRingBuffer()}
NRF_UART0 = &_NRF_UART0
_UART0 = UART{Buffer: NewRingBuffer()}
UART0 = &_UART0
)
// Configure the UART.
@@ -165,7 +165,7 @@ func (uart *UART) Configure(config UARTConfig) {
nrf.UART0.INTENSET.Set(nrf.UART_INTENSET_RXDRDY_Msk)
// Enable RX IRQ.
intr := interrupt.New(nrf.IRQ_UART0, _NRF_UART0.handleInterrupt)
intr := interrupt.New(nrf.IRQ_UART0, _UART0.handleInterrupt)
intr.SetPriority(0xc0) // low priority
intr.Enable()
}