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.
37 строки
464 Б
Go
37 строки
464 Б
Go
// +build nodemcu
|
|
|
|
// Pinout for the NodeMCU dev kit.
|
|
|
|
package machine
|
|
|
|
// GPIO pins on the NodeMCU board.
|
|
const (
|
|
D0 Pin = 16
|
|
D1 Pin = 5
|
|
D2 Pin = 4
|
|
D3 Pin = 0
|
|
D4 Pin = 2
|
|
D5 Pin = 14
|
|
D6 Pin = 12
|
|
D7 Pin = 13
|
|
D8 Pin = 15
|
|
)
|
|
|
|
// Onboard blue LED (on the AI-Thinker module).
|
|
const LED = D4
|
|
|
|
var Serial = UART0
|
|
|
|
// SPI pins
|
|
const (
|
|
SPI0_SCK_PIN = D5
|
|
SPI0_SDO_PIN = D7
|
|
SPI0_SDI_PIN = D6
|
|
SPI0_CS0_PIN = D8
|
|
)
|
|
|
|
// I2C pins
|
|
const (
|
|
SDA_PIN = D2
|
|
SCL_PIN = D1
|
|
)
|