tinygo/src/machine/board_pca10056.go
Ayke van Laethem b67351babe 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.
2021-05-13 16:43:37 +02:00

65 строки
912 Б
Go

// +build pca10056
package machine
const HasLowFrequencyCrystal = true
// LEDs on the pca10056
const (
LED Pin = LED1
LED1 Pin = 13
LED2 Pin = 14
LED3 Pin = 15
LED4 Pin = 16
)
// Buttons on the pca10056
const (
BUTTON Pin = BUTTON1
BUTTON1 Pin = 11
BUTTON2 Pin = 12
BUTTON3 Pin = 24
BUTTON4 Pin = 25
)
var Serial = UART0
// UART pins
const (
UART_TX_PIN Pin = 6
UART_RX_PIN Pin = 8
)
// ADC pins
const (
ADC0 Pin = 3
ADC1 Pin = 4
ADC2 Pin = 28
ADC3 Pin = 29
ADC4 Pin = 30
ADC5 Pin = 31
)
// I2C pins
const (
SDA_PIN Pin = 26 // P0.26
SCL_PIN Pin = 27 // P0.27
)
// SPI pins
const (
SPI0_SCK_PIN Pin = 47 // P1.15
SPI0_SDO_PIN Pin = 45 // P1.13
SPI0_SDI_PIN Pin = 46 // P1.14
)
// USB CDC identifiers
const (
usb_STRING_PRODUCT = "Nordic nRF52840DK (PCA10056)"
usb_STRING_MANUFACTURER = "Nordic Semiconductor"
)
var (
usb_VID uint16 = 0x239A
usb_PID uint16 = 0x8029
)