mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 20:13:40 +00:00
b67351babe
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.
47 lines
702 B
Go
47 lines
702 B
Go
// +build nrf52840_mdk
|
|
|
|
package machine
|
|
|
|
const HasLowFrequencyCrystal = true
|
|
|
|
// LEDs on the nrf52840-mdk (nRF52840 dev board)
|
|
const (
|
|
LED Pin = LED_GREEN
|
|
LED_GREEN Pin = 22
|
|
LED_RED Pin = 23
|
|
LED_BLUE Pin = 24
|
|
)
|
|
|
|
// UART pins
|
|
const (
|
|
UART_TX_PIN Pin = 20
|
|
UART_RX_PIN Pin = 19
|
|
)
|
|
|
|
// Serial is the USB device
|
|
var Serial = USB
|
|
|
|
// I2C pins (unused)
|
|
const (
|
|
SDA_PIN = NoPin
|
|
SCL_PIN = NoPin
|
|
)
|
|
|
|
// SPI pins (unused)
|
|
const (
|
|
SPI0_SCK_PIN = NoPin
|
|
SPI0_SDO_PIN = NoPin
|
|
SPI0_SDI_PIN = NoPin
|
|
)
|
|
|
|
// USB CDC identifiers
|
|
const (
|
|
usb_STRING_PRODUCT = "Makerdiary nRF52840 MDK"
|
|
usb_STRING_MANUFACTURER = "Nordic Semiconductor ASA"
|
|
)
|
|
|
|
var (
|
|
usb_VID uint16 = 0x1915
|
|
usb_PID uint16 = 0xCAFE
|
|
)
|