machine: make USBCDC global a pointer

Make the USBCDC use a pointer receiver everywhere. This makes it easier
to pass around the object in the future.

This commit sometimes changes code size, but not significantly (a few
bytes) and usually in a positive way.

My eventual goal is the following:

  - Declare `machine.USB` (or similar, name TBD) as a pointer receiver
    for the USB-CDC interface.
  - Let `machine.UART0` always point to an UART, never actually to a
    USBCDC object.
  - Define `machine.Serial`, which is either a real UART or an USB-CDC,
    depending on the board.

This way, if you want a real UART you can use machine.UARTx and if you
just want to print to the default serial port, you can use
machine.Serial.

This change does have an effect on code size and memory consumption.
There is often a small reduction (-8 bytes) in RAM consumption and an
increase in flash consumption.
This commit is contained in:
Ayke van Laethem
2021-05-11 13:39:14 +02:00
committed by Ron Evans
parent 1646326164
commit 7c949ad386
11 changed files with 64 additions and 63 deletions
+1 -1
View File
@@ -105,7 +105,7 @@ const (
// UART0 is the USB device
var (
UART0 = &USB
UART0 = USB
)
// I2C pins