all: add a flag to the command line to select the serial implementation
This can be very useful for some purposes: * It makes it possible to disable the UART in cases where it is not needed or needs to be disabled to conserve power. * It makes it possible to disable the serial output to reduce code size, which may be important for some chips. Sometimes, a few kB can be saved this way. * It makes it possible to override the default, for example you might want to use an actual UART to debug the USB-CDC implementation. It also lowers the dependency on having machine.Serial defined, which is often not defined when targeting a chip. Eventually, we might want to make it possible to write `-target=nrf52` or `-target=atmega328p` for example to target the chip itself with no board specific assumptions. The defaults don't change. I checked this by running `make smoketest` before and after and comparing the results.
Этот коммит содержится в:
родитель
75298bb84b
коммит
96e863f0f3
114 изменённых файлов: 185 добавлений и 104 удалений
2
Makefile
2
Makefile
|
@ -436,6 +436,8 @@ endif
|
|||
@$(MD5SUM) test.hex
|
||||
$(TINYGO) build -size short -o test.hex -target=pca10040 -opt=1 examples/blinky1
|
||||
@$(MD5SUM) test.hex
|
||||
$(TINYGO) build -size short -o test.hex -target=pca10040 -serial=none examples/echo
|
||||
@$(MD5SUM) test.hex
|
||||
$(TINYGO) build -o test.nro -target=nintendoswitch examples/serial
|
||||
@$(MD5SUM) test.nro
|
||||
$(TINYGO) build -size short -o test.hex -target=pca10040 -opt=0 ./testdata/stdlib.go
|
||||
|
|
|
@ -55,7 +55,7 @@ func (c *Config) GOARCH() string {
|
|||
|
||||
// BuildTags returns the complete list of build tags used during this build.
|
||||
func (c *Config) BuildTags() []string {
|
||||
tags := append(c.Target.BuildTags, []string{"tinygo", "gc." + c.GC(), "scheduler." + c.Scheduler()}...)
|
||||
tags := append(c.Target.BuildTags, []string{"tinygo", "gc." + c.GC(), "scheduler." + c.Scheduler(), "serial." + c.Serial()}...)
|
||||
for i := 1; i <= c.GoMinorVersion; i++ {
|
||||
tags = append(tags, fmt.Sprintf("go1.%d", i))
|
||||
}
|
||||
|
@ -113,6 +113,18 @@ func (c *Config) Scheduler() string {
|
|||
return "coroutines"
|
||||
}
|
||||
|
||||
// Serial returns the serial implementation for this build configuration: uart,
|
||||
// usb (meaning USB-CDC), or none.
|
||||
func (c *Config) Serial() string {
|
||||
if c.Options.Serial != "" {
|
||||
return c.Options.Serial
|
||||
}
|
||||
if c.Target.Serial != "" {
|
||||
return c.Target.Serial
|
||||
}
|
||||
return "none"
|
||||
}
|
||||
|
||||
// OptLevels returns the optimization level (0-2), size level (0-2), and inliner
|
||||
// threshold as used in the LLVM optimization pipeline.
|
||||
func (c *Config) OptLevels() (optLevel, sizeLevel int, inlinerThreshold uint) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
var (
|
||||
validGCOptions = []string{"none", "leaking", "extalloc", "conservative"}
|
||||
validSchedulerOptions = []string{"none", "tasks", "coroutines"}
|
||||
validSerialOptions = []string{"none", "uart", "usb"}
|
||||
validPrintSizeOptions = []string{"none", "short", "full"}
|
||||
validPanicStrategyOptions = []string{"print", "trap"}
|
||||
validOptOptions = []string{"none", "0", "1", "2", "s", "z"}
|
||||
|
@ -22,6 +23,7 @@ type Options struct {
|
|||
GC string
|
||||
PanicStrategy string
|
||||
Scheduler string
|
||||
Serial string
|
||||
PrintIR bool
|
||||
DumpSSA bool
|
||||
VerifyIR bool
|
||||
|
@ -59,6 +61,15 @@ func (o *Options) Verify() error {
|
|||
}
|
||||
}
|
||||
|
||||
if o.Serial != "" {
|
||||
valid := isInArray(validSerialOptions, o.Serial)
|
||||
if !valid {
|
||||
return fmt.Errorf(`invalid serial option '%s': valid values are %s`,
|
||||
o.Serial,
|
||||
strings.Join(validSerialOptions, ", "))
|
||||
}
|
||||
}
|
||||
|
||||
if o.PrintSizes != "" {
|
||||
valid := isInArray(validPrintSizeOptions, o.PrintSizes)
|
||||
if !valid {
|
||||
|
|
|
@ -31,6 +31,7 @@ type TargetSpec struct {
|
|||
BuildTags []string `json:"build-tags"`
|
||||
GC string `json:"gc"`
|
||||
Scheduler string `json:"scheduler"`
|
||||
Serial string `json:"serial"` // which serial output to use (uart, usb, none)
|
||||
Linker string `json:"linker"`
|
||||
RTLib string `json:"rtlib"` // compiler runtime library (libgcc, compiler-rt)
|
||||
Libc string `json:"libc"`
|
||||
|
|
2
main.go
2
main.go
|
@ -1009,6 +1009,7 @@ func main() {
|
|||
gc := flag.String("gc", "", "garbage collector to use (none, leaking, extalloc, conservative)")
|
||||
panicStrategy := flag.String("panic", "print", "panic strategy (print, trap)")
|
||||
scheduler := flag.String("scheduler", "", "which scheduler to use (none, coroutines, tasks)")
|
||||
serial := flag.String("serial", "", "which serial output to use (none, uart, usb)")
|
||||
printIR := flag.Bool("printir", false, "print LLVM IR")
|
||||
dumpSSA := flag.Bool("dumpssa", false, "dump internal Go SSA")
|
||||
verifyIR := flag.Bool("verifyir", false, "run extra verification steps on LLVM IR")
|
||||
|
@ -1081,6 +1082,7 @@ func main() {
|
|||
GC: *gc,
|
||||
PanicStrategy: *panicStrategy,
|
||||
Scheduler: *scheduler,
|
||||
Serial: *serial,
|
||||
PrintIR: *printIR,
|
||||
DumpSSA: *dumpSSA,
|
||||
VerifyIR: *verifyIR,
|
||||
|
|
|
@ -47,8 +47,6 @@ const (
|
|||
LED = D6
|
||||
)
|
||||
|
||||
var Serial = USB
|
||||
|
||||
// USBCDC pins
|
||||
const (
|
||||
USBCDC_DM_PIN Pin = PA24
|
||||
|
|
|
@ -35,8 +35,6 @@ const (
|
|||
LED3 Pin = PB03 // RX LED
|
||||
)
|
||||
|
||||
var Serial = USB
|
||||
|
||||
// ADC pins
|
||||
const (
|
||||
AREF Pin = PA03
|
||||
|
|
|
@ -74,5 +74,3 @@ const (
|
|||
PB30 Pin = 62
|
||||
PB31 Pin = 63
|
||||
)
|
||||
|
||||
var Serial = USB
|
||||
|
|
|
@ -15,8 +15,6 @@ const (
|
|||
BUTTON = PB31
|
||||
)
|
||||
|
||||
var Serial = USB
|
||||
|
||||
const (
|
||||
// https://ww1.microchip.com/downloads/en/DeviceDoc/70005321A.pdf
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ const (
|
|||
BUTTON = PA0
|
||||
)
|
||||
|
||||
var Serial = UART1
|
||||
var DefaultUART = UART1
|
||||
|
||||
// UART pins
|
||||
const (
|
||||
|
|
|
@ -57,8 +57,6 @@ const (
|
|||
UART_RX_PIN = P0_30 // PORTB
|
||||
)
|
||||
|
||||
var Serial = USB
|
||||
|
||||
// I2C pins
|
||||
const (
|
||||
SDA_PIN = P0_05 // I2C0 external
|
||||
|
|
|
@ -104,11 +104,6 @@ const (
|
|||
UART_TX_PIN = D1
|
||||
)
|
||||
|
||||
// Serial is the USB device
|
||||
var (
|
||||
Serial = USB
|
||||
)
|
||||
|
||||
// I2C pins
|
||||
const (
|
||||
SDA_PIN = D20 // I2C0 external
|
||||
|
|
|
@ -68,8 +68,6 @@ const (
|
|||
ADC3 Pin = IO39
|
||||
)
|
||||
|
||||
var Serial = UART0
|
||||
|
||||
// UART0 pins
|
||||
const (
|
||||
UART_TX_PIN = IO1
|
||||
|
|
|
@ -47,8 +47,6 @@ const (
|
|||
WS2812 = D8
|
||||
)
|
||||
|
||||
var Serial = USB
|
||||
|
||||
// USBCDC pins
|
||||
const (
|
||||
USBCDC_DM_PIN = PA24
|
||||
|
|
|
@ -40,8 +40,6 @@ const (
|
|||
WS2812 = D8
|
||||
)
|
||||
|
||||
var Serial = USB
|
||||
|
||||
// USBCDC pins
|
||||
const (
|
||||
USBCDC_DM_PIN = PA24
|
||||
|
|
|
@ -76,11 +76,6 @@ const (
|
|||
UART_TX_PIN = D1
|
||||
)
|
||||
|
||||
// Serial is the USB device
|
||||
var (
|
||||
Serial = USB
|
||||
)
|
||||
|
||||
// I2C pins
|
||||
const (
|
||||
SDA_PIN = D22 // I2C0 external
|
||||
|
|
|
@ -141,7 +141,7 @@ var (
|
|||
TxAltFuncSelector: AF7_USART1_2_3,
|
||||
RxAltFuncSelector: AF7_USART1_2_3,
|
||||
}
|
||||
Serial = UART1
|
||||
DefaultUART = UART1
|
||||
)
|
||||
|
||||
func initUART() {
|
||||
|
|
|
@ -142,8 +142,6 @@ const (
|
|||
WS2812 = NEOPIXEL_PIN
|
||||
)
|
||||
|
||||
var Serial = USB
|
||||
|
||||
// UART pins
|
||||
const (
|
||||
UART1_RX_PIN = D0 // (PB25)
|
||||
|
|
|
@ -35,7 +35,7 @@ const (
|
|||
LED_BLUE = P21
|
||||
)
|
||||
|
||||
var Serial = UART0
|
||||
var DefaultUART = UART0
|
||||
|
||||
const (
|
||||
// TODO: figure out the pin numbers for these.
|
||||
|
|
|
@ -37,8 +37,6 @@ const (
|
|||
LED = D13
|
||||
)
|
||||
|
||||
var Serial = USB
|
||||
|
||||
// USBCDC pins
|
||||
const (
|
||||
USBCDC_DM_PIN = PA24
|
||||
|
|
|
@ -70,11 +70,6 @@ const (
|
|||
UART_TX_PIN = D1
|
||||
)
|
||||
|
||||
// Serial is the USB device
|
||||
var (
|
||||
Serial = USB
|
||||
)
|
||||
|
||||
// I2C pins
|
||||
const (
|
||||
SDA_PIN = D21 // I2C0 external
|
||||
|
|
|
@ -54,7 +54,7 @@ const (
|
|||
I2C0_SDA_PIN = PA10
|
||||
)
|
||||
|
||||
var Serial = UART0
|
||||
var DefaultUART = UART0
|
||||
|
||||
var (
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ const (
|
|||
LED_BLUE = D14
|
||||
)
|
||||
|
||||
var Serial = UART0
|
||||
var DefaultUART = UART0
|
||||
|
||||
// Default pins for UARTHS.
|
||||
const (
|
||||
|
|
|
@ -41,8 +41,6 @@ const (
|
|||
WS2812 = D40
|
||||
)
|
||||
|
||||
var Serial = USB
|
||||
|
||||
// USBCDC pins
|
||||
const (
|
||||
USBCDC_DM_PIN = PA24
|
||||
|
|
|
@ -12,7 +12,7 @@ const (
|
|||
BUTTONB Pin = P11
|
||||
)
|
||||
|
||||
var Serial = UART0
|
||||
var DefaultUART = UART0
|
||||
|
||||
// UART pins
|
||||
const (
|
||||
|
|
|
@ -12,7 +12,7 @@ const (
|
|||
BUTTONB Pin = 26
|
||||
)
|
||||
|
||||
var Serial = UART0
|
||||
var DefaultUART = UART0
|
||||
|
||||
// UART pins
|
||||
const (
|
||||
|
|
|
@ -54,11 +54,6 @@ const (
|
|||
UART_TX_PIN = P0_08
|
||||
)
|
||||
|
||||
// Serial is the USB device
|
||||
var (
|
||||
Serial = USB
|
||||
)
|
||||
|
||||
// I2C pins
|
||||
const (
|
||||
SDA_PIN = P0_17 // I2C0 external
|
||||
|
|
|
@ -20,8 +20,6 @@ const (
|
|||
// Onboard blue LED (on the AI-Thinker module).
|
||||
const LED = D4
|
||||
|
||||
var Serial = UART0
|
||||
|
||||
// SPI pins
|
||||
const (
|
||||
SPI0_SCK_PIN = D5
|
||||
|
|
|
@ -23,9 +23,6 @@ const (
|
|||
UART_RX_PIN Pin = NoPin
|
||||
)
|
||||
|
||||
// Serial is the USB device
|
||||
var Serial = USB
|
||||
|
||||
// I2C pins (unused)
|
||||
const (
|
||||
SDA_PIN = NoPin
|
||||
|
|
|
@ -18,9 +18,6 @@ const (
|
|||
UART_RX_PIN Pin = 19
|
||||
)
|
||||
|
||||
// Serial is the USB device
|
||||
var Serial = USB
|
||||
|
||||
// I2C pins (unused)
|
||||
const (
|
||||
SDA_PIN = NoPin
|
||||
|
|
|
@ -34,7 +34,7 @@ var (
|
|||
Buffer: NewRingBuffer(),
|
||||
Bus: stm32.USART2,
|
||||
}
|
||||
Serial = UART2
|
||||
DefaultUART = UART2
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -38,7 +38,7 @@ var (
|
|||
TxAltFuncSelector: UART_ALT_FN,
|
||||
RxAltFuncSelector: UART_ALT_FN,
|
||||
}
|
||||
Serial = UART1
|
||||
DefaultUART = UART1
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -76,7 +76,7 @@ var (
|
|||
TxAltFuncSelector: 4,
|
||||
RxAltFuncSelector: 4,
|
||||
}
|
||||
Serial = UART1
|
||||
DefaultUART = UART1
|
||||
|
||||
// I2C1 is documented, alias to I2C0 as well
|
||||
I2C1 = &I2C{
|
||||
|
|
|
@ -78,7 +78,7 @@ var (
|
|||
TxAltFuncSelector: 7,
|
||||
RxAltFuncSelector: 3,
|
||||
}
|
||||
Serial = UART1
|
||||
DefaultUART = UART1
|
||||
|
||||
// I2C1 is documented, alias to I2C0 as well
|
||||
I2C1 = &I2C{
|
||||
|
|
|
@ -38,7 +38,7 @@ var (
|
|||
TxAltFuncSelector: UART_ALT_FN,
|
||||
RxAltFuncSelector: UART_ALT_FN,
|
||||
}
|
||||
Serial = UART1
|
||||
DefaultUART = UART1
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -41,7 +41,7 @@ const (
|
|||
|
||||
// UART
|
||||
var (
|
||||
Serial = UART0
|
||||
DefaultUART = UART0
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -41,7 +41,7 @@ const (
|
|||
|
||||
// UART
|
||||
var (
|
||||
Serial = UART0
|
||||
DefaultUART = UART0
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -41,7 +41,7 @@ const (
|
|||
|
||||
// UART
|
||||
var (
|
||||
Serial = UART0
|
||||
DefaultUART = UART0
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -19,7 +19,7 @@ const (
|
|||
LED_BLUE Pin = 23
|
||||
)
|
||||
|
||||
var Serial = UART0
|
||||
var DefaultUART = UART0
|
||||
|
||||
// UART pins
|
||||
const (
|
||||
|
|
|
@ -23,7 +23,7 @@ const (
|
|||
BUTTON4 Pin = 16
|
||||
)
|
||||
|
||||
var Serial = UART0
|
||||
var DefaultUART = UART0
|
||||
|
||||
// UART pins for NRF52840-DK
|
||||
const (
|
||||
|
|
|
@ -22,7 +22,7 @@ const (
|
|||
BUTTON4 Pin = 25
|
||||
)
|
||||
|
||||
var Serial = UART0
|
||||
var DefaultUART = UART0
|
||||
|
||||
// UART pins
|
||||
const (
|
||||
|
|
|
@ -34,11 +34,6 @@ const (
|
|||
UART_RX_PIN Pin = NoPin
|
||||
)
|
||||
|
||||
// Serial is the USB device
|
||||
var (
|
||||
Serial = USB
|
||||
)
|
||||
|
||||
// I2C pins (unused)
|
||||
const (
|
||||
SDA_PIN = NoPin
|
||||
|
|
|
@ -17,7 +17,7 @@ const (
|
|||
LED3 = LCD_BACKLIGHT_LOW
|
||||
)
|
||||
|
||||
var Serial = UART0
|
||||
var DefaultUART = UART0
|
||||
|
||||
// UART pins for PineTime. Note that RX is set to NoPin as RXD is not listed in
|
||||
// the PineTime schematic 1.0:
|
||||
|
|
|
@ -67,8 +67,6 @@ const (
|
|||
BUTTON_B_MASK = 128
|
||||
)
|
||||
|
||||
var Serial = USB
|
||||
|
||||
// USBCDC pins
|
||||
const (
|
||||
USBCDC_DM_PIN = PA24
|
||||
|
|
|
@ -70,8 +70,6 @@ const (
|
|||
BUTTON_B_MASK = 128
|
||||
)
|
||||
|
||||
var Serial = USB
|
||||
|
||||
// USBCDC pins
|
||||
const (
|
||||
USBCDC_DM_PIN = PA24
|
||||
|
|
|
@ -95,8 +95,6 @@ const (
|
|||
LED = D13
|
||||
)
|
||||
|
||||
var Serial = USB
|
||||
|
||||
// USBCDC pins
|
||||
const (
|
||||
USBCDC_DM_PIN = PA24
|
||||
|
|
|
@ -29,7 +29,7 @@ const (
|
|||
BUTTON Pin = 7
|
||||
)
|
||||
|
||||
var Serial = UART0
|
||||
var DefaultUART = UART0
|
||||
|
||||
// UART pins
|
||||
const (
|
||||
|
|
|
@ -38,7 +38,7 @@ var (
|
|||
TxAltFuncSelector: AF7_USART1_2_3,
|
||||
RxAltFuncSelector: AF7_USART1_2_3,
|
||||
}
|
||||
Serial = UART1
|
||||
DefaultUART = UART1
|
||||
)
|
||||
|
||||
// set up RX IRQ handler. Follow similar pattern for other UARTx instances
|
||||
|
|
|
@ -87,6 +87,8 @@ var (
|
|||
TeensyUART5 = UART4
|
||||
)
|
||||
|
||||
var DefaultUART = UART0
|
||||
|
||||
const (
|
||||
defaultUART0RX = D00
|
||||
defaultUART0TX = D01
|
||||
|
|
|
@ -136,9 +136,9 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
Serial = UART1
|
||||
UART1 = &_UART1
|
||||
_UART1 = UART{
|
||||
DefaultUART = UART1
|
||||
UART1 = &_UART1
|
||||
_UART1 = UART{
|
||||
Bus: nxp.LPUART6,
|
||||
Buffer: NewRingBuffer(),
|
||||
txBuffer: NewRingBuffer(),
|
||||
|
|
|
@ -325,8 +325,6 @@ const (
|
|||
OUTPUT_CTR_3V3 = PC15
|
||||
)
|
||||
|
||||
var Serial = USB
|
||||
|
||||
// USBCDC pins
|
||||
const (
|
||||
USBCDC_DM_PIN = PIN_USB_DM
|
||||
|
|
|
@ -27,4 +27,4 @@ const (
|
|||
|
||||
const HasLowFrequencyCrystal = true
|
||||
|
||||
var Serial = UART0
|
||||
var DefaultUART = UART0
|
||||
|
|
|
@ -122,7 +122,7 @@ func (i2c *I2C) readByte() byte {
|
|||
}
|
||||
|
||||
// Always use UART0 as the serial output.
|
||||
var Serial = UART0
|
||||
var DefaultUART = UART0
|
||||
|
||||
// UART
|
||||
var (
|
||||
|
|
|
@ -251,6 +251,8 @@ func (p Pin) mux() *volatile.Register32 {
|
|||
}
|
||||
}
|
||||
|
||||
var DefaultUART = UART0
|
||||
|
||||
var (
|
||||
UART0 = &_UART0
|
||||
_UART0 = UART{Bus: esp.UART0, Buffer: NewRingBuffer()}
|
||||
|
|
|
@ -139,6 +139,8 @@ func (p Pin) PortMaskClear() (*uint32, uint32) {
|
|||
return &esp.GPIO.GPIO_OUT_W1TC.Reg, 1 << p
|
||||
}
|
||||
|
||||
var DefaultUART = UART0
|
||||
|
||||
// UART0 is a hardware UART that supports both TX and RX.
|
||||
var UART0 = &_UART0
|
||||
var _UART0 = UART{Buffer: NewRingBuffer()}
|
||||
|
|
|
@ -11,6 +11,12 @@ var (
|
|||
USB = &UART{100}
|
||||
)
|
||||
|
||||
// The Serial port always points to the default UART in a simulated environment.
|
||||
//
|
||||
// TODO: perhaps this should be a special serial object that outputs via WASI
|
||||
// stdout calls.
|
||||
var Serial = UART0
|
||||
|
||||
const (
|
||||
PinInput PinMode = iota
|
||||
PinOutput
|
||||
|
@ -118,12 +124,6 @@ type UART struct {
|
|||
Bus uint8
|
||||
}
|
||||
|
||||
type UARTConfig struct {
|
||||
BaudRate uint32
|
||||
TX Pin
|
||||
RX Pin
|
||||
}
|
||||
|
||||
// Configure the UART.
|
||||
func (uart *UART) Configure(config UARTConfig) {
|
||||
uartConfigure(uart.Bus, config.TX, config.RX)
|
||||
|
|
|
@ -108,7 +108,7 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
var Serial = UART0
|
||||
var DefaultUART = UART0
|
||||
|
||||
func init() {
|
||||
UART0.Interrupt = interrupt.New(rp.IRQ_UART0_IRQ, _UART0.handleInterrupt)
|
||||
|
|
6
src/machine/serial-none.go
Обычный файл
6
src/machine/serial-none.go
Обычный файл
|
@ -0,0 +1,6 @@
|
|||
// +build baremetal,serial.none
|
||||
|
||||
package machine
|
||||
|
||||
// Serial is a null device: writes to it are ignored.
|
||||
var Serial = NullSerial{}
|
6
src/machine/serial-uart.go
Обычный файл
6
src/machine/serial-uart.go
Обычный файл
|
@ -0,0 +1,6 @@
|
|||
// +build baremetal,serial.uart
|
||||
|
||||
package machine
|
||||
|
||||
// Serial is implemented via the default (usually the first) UART on the chip.
|
||||
var Serial = DefaultUART
|
6
src/machine/serial-usb.go
Обычный файл
6
src/machine/serial-usb.go
Обычный файл
|
@ -0,0 +1,6 @@
|
|||
// +build baremetal,serial.usb
|
||||
|
||||
package machine
|
||||
|
||||
// Serial is implemented via USB (USB-CDC).
|
||||
var Serial = USB
|
46
src/machine/serial.go
Обычный файл
46
src/machine/serial.go
Обычный файл
|
@ -0,0 +1,46 @@
|
|||
package machine
|
||||
|
||||
import "errors"
|
||||
|
||||
var errNoByte = errors.New("machine: no byte read")
|
||||
|
||||
// UARTConfig is a struct with which a UART (or similar object) can be
|
||||
// configured. The baud rate is usually respected, but TX and RX may be ignored
|
||||
// depending on the chip and the type of object.
|
||||
type UARTConfig struct {
|
||||
BaudRate uint32
|
||||
TX Pin
|
||||
RX Pin
|
||||
}
|
||||
|
||||
// NullSerial is a serial version of /dev/null (or null router): it drops
|
||||
// everything that is written to it.
|
||||
type NullSerial struct {
|
||||
}
|
||||
|
||||
// Configure does nothing: the null serial has no configuration.
|
||||
func (ns NullSerial) Configure(config UARTConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// WriteByte is a no-op: the null serial doesn't write bytes.
|
||||
func (ns NullSerial) WriteByte(b byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ReadByte always returns an error because there aren't any bytes to read.
|
||||
func (ns NullSerial) ReadByte() (byte, error) {
|
||||
return 0, errNoByte
|
||||
}
|
||||
|
||||
// Buffered returns how many bytes are buffered in the UART. It always returns 0
|
||||
// as there are no bytes to read.
|
||||
func (ns NullSerial) Buffered() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// Write is a no-op: none of the data is being written and it will not return an
|
||||
// error.
|
||||
func (ns NullSerial) Write(p []byte) (n int, err error) {
|
||||
return len(p), nil
|
||||
}
|
|
@ -23,12 +23,6 @@ const (
|
|||
ParityOdd UARTParity = 2
|
||||
)
|
||||
|
||||
type UARTConfig struct {
|
||||
BaudRate uint32
|
||||
TX Pin
|
||||
RX Pin
|
||||
}
|
||||
|
||||
// To implement the UART interface for a board, you must declare a concrete type as follows:
|
||||
//
|
||||
// type UART struct {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["atsamd21g18a"],
|
||||
"build-tags": ["arduino_mkr1000"],
|
||||
"serial": "usb",
|
||||
"flash-command": "bossac -i -e -w -v -R -U --port={port} --offset=0x2000 {bin}",
|
||||
"flash-1200-bps-reset": "true"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["atsamd21g18a"],
|
||||
"build-tags": ["arduino_zero"],
|
||||
"serial": "usb",
|
||||
"flash-command": "bossac -i -e -w -v -R -U --port={port} --offset=0x2000 {bin}",
|
||||
"flash-1200-bps-reset": "true"
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"inherits": ["avr"],
|
||||
"cpu": "atmega1280",
|
||||
"build-tags": ["atmega1280", "atmega"],
|
||||
"serial": "uart",
|
||||
"cflags": [
|
||||
"-mmcu=atmega1280"
|
||||
],
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"inherits": ["avr"],
|
||||
"cpu": "atmega1284p",
|
||||
"build-tags": ["atmega1284p", "atmega"],
|
||||
"serial": "uart",
|
||||
"cflags": [
|
||||
"-mmcu=atmega1284p"
|
||||
],
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"inherits": ["avr"],
|
||||
"cpu": "atmega2560",
|
||||
"build-tags": ["atmega2560", "atmega"],
|
||||
"serial": "uart",
|
||||
"cflags": [
|
||||
"-mmcu=atmega2560"
|
||||
],
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"inherits": ["avr"],
|
||||
"cpu": "atmega328p",
|
||||
"build-tags": ["atmega328p", "atmega", "avr5"],
|
||||
"serial": "uart",
|
||||
"cflags": [
|
||||
"-mmcu=atmega328p"
|
||||
],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["cortex-m0plus"],
|
||||
"build-tags": ["atsamd21e18a", "atsamd21e18", "atsamd21", "sam"],
|
||||
"serial": "usb",
|
||||
"linkerscript": "targets/atsamd21.ld",
|
||||
"extra-files": [
|
||||
"src/device/sam/atsamd21e18a.s"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["cortex-m0plus"],
|
||||
"build-tags": ["atsamd21g18a", "atsamd21g18", "atsamd21", "sam"],
|
||||
"serial": "usb",
|
||||
"linkerscript": "targets/atsamd21.ld",
|
||||
"extra-files": [
|
||||
"src/device/sam/atsamd21g18a.s"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["atsame54p20a"],
|
||||
"build-tags": ["atsame54_xpro"],
|
||||
"serial": "usb",
|
||||
"flash-method": "openocd",
|
||||
"openocd-interface": "cmsis-dap",
|
||||
"default-stack-size": 4096
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["cortex-m3"],
|
||||
"build-tags": ["bluepill", "stm32f103", "stm32f1", "stm32"],
|
||||
"serial": "uart",
|
||||
"linkerscript": "targets/stm32.ld",
|
||||
"extra-files": [
|
||||
"src/device/stm32/stm32f103.s"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["nrf52840"],
|
||||
"build-tags": ["circuitplay_bluefruit","nrf52840_reset_uf2", "softdevice", "s140v6"],
|
||||
"serial": "usb",
|
||||
"flash-1200-bps-reset": "true",
|
||||
"flash-method": "msd",
|
||||
"serial-port": ["acm:239a:8045", "acm:239a:45"],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["nrf52840"],
|
||||
"build-tags": ["clue_alpha","nrf52840_reset_uf2", "softdevice", "s140v6"],
|
||||
"serial": "usb",
|
||||
"flash-1200-bps-reset": "true",
|
||||
"flash-method": "msd",
|
||||
"msd-volume-name": "CLUEBOOT",
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"cpu": "esp32",
|
||||
"build-tags": ["esp32", "esp"],
|
||||
"scheduler": "tasks",
|
||||
"serial": "uart",
|
||||
"linker": "xtensa-esp32-elf-ld",
|
||||
"default-stack-size": 2048,
|
||||
"cflags": [
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["atsame51j19a"],
|
||||
"build-tags": ["feather_m4_can"],
|
||||
"serial": "usb",
|
||||
"flash-1200-bps-reset": "true",
|
||||
"flash-method": "msd",
|
||||
"msd-volume-name": "FTHRCANBOOT",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["atsamd51j19a"],
|
||||
"build-tags": ["feather_m4"],
|
||||
"serial": "usb",
|
||||
"flash-1200-bps-reset": "true",
|
||||
"flash-method": "msd",
|
||||
"msd-volume-name": "FEATHERBOOT",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["nrf52840"],
|
||||
"build-tags": ["feather_nrf52840","nrf52840_reset_uf2", "softdevice", "s140v6"],
|
||||
"serial": "usb",
|
||||
"flash-1200-bps-reset": "true",
|
||||
"flash-method": "msd",
|
||||
"msd-volume-name": "FTHR840BOOT",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["cortex-m4"],
|
||||
"build-tags": ["feather_stm32f405", "stm32f405", "stm32f4", "stm32"],
|
||||
"serial": "uart",
|
||||
"automatic-stack-size": false,
|
||||
"linkerscript": "targets/stm32f405.ld",
|
||||
"extra-files": [
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["atsamd51p20a"],
|
||||
"build-tags": ["grandcentral_m4"],
|
||||
"serial": "usb",
|
||||
"flash-1200-bps-reset": "true",
|
||||
"flash-method": "msd",
|
||||
"msd-volume-name": "GCM4BOOT",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["fe310"],
|
||||
"build-tags": ["hifive1b", "qemu"],
|
||||
"serial": "uart",
|
||||
"linkerscript": "targets/hifive1-qemu.ld",
|
||||
"emulator": ["qemu-system-riscv32", "-machine", "sifive_e", "-nographic", "-kernel"]
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["fe310"],
|
||||
"build-tags": ["hifive1b"],
|
||||
"serial": "uart",
|
||||
"linkerscript": "targets/hifive1b.ld",
|
||||
"flash-method": "msd",
|
||||
"msd-volume-name": "HiFive",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["atsamd51g19a"],
|
||||
"build-tags": ["itsybitsy_m4"],
|
||||
"serial": "usb",
|
||||
"flash-1200-bps-reset": "true",
|
||||
"flash-method": "msd",
|
||||
"serial-port": ["acm:239a:802b", "acm:239a:002b"],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["nrf52840"],
|
||||
"build-tags": ["itsybitsy_nrf52840","nrf52840_reset_uf2", "softdevice", "s140v6"],
|
||||
"serial": "usb",
|
||||
"flash-1200-bps-reset": "true",
|
||||
"flash-method": "msd",
|
||||
"msd-volume-name": "ITSY840BOOT",
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
"build-tags": [
|
||||
"lgt92"
|
||||
],
|
||||
"serial": "uart",
|
||||
"linkerscript": "targets/stm32l072czt6.ld",
|
||||
"flash-method": "openocd",
|
||||
"openocd-interface": "stlink-v2",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["k210"],
|
||||
"build-tags": ["maixbit"],
|
||||
"serial": "uart",
|
||||
"linkerscript": "targets/maixbit.ld",
|
||||
"flash-command": "kflash -p {port} --noansi --verbose {bin}"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["atsamd51j19a"],
|
||||
"build-tags": ["metro_m4_airlift"],
|
||||
"serial": "usb",
|
||||
"flash-1200-bps-reset": "true",
|
||||
"flash-method": "msd",
|
||||
"msd-volume-name": "METROM4BOOT",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["nrf52833"],
|
||||
"build-tags": ["microbit_v2"],
|
||||
"serial": "uart",
|
||||
"flash-method": "msd",
|
||||
"openocd-interface": "cmsis-dap",
|
||||
"msd-volume-name": "MICROBIT",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["nrf51"],
|
||||
"build-tags": ["microbit"],
|
||||
"serial": "uart",
|
||||
"flash-method": "msd",
|
||||
"openocd-interface": "cmsis-dap",
|
||||
"msd-volume-name": "MICROBIT",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["nrf52840"],
|
||||
"build-tags": ["nicenano","nrf52840_reset_uf2", "softdevice", "s140v6"],
|
||||
"serial": "usb",
|
||||
"flash-1200-bps-reset": "true",
|
||||
"flash-method": "msd",
|
||||
"msd-volume-name": "NICENANO",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"inherits": ["esp8266"],
|
||||
"build-tags": ["nodemcu"]
|
||||
"build-tags": ["nodemcu"],
|
||||
"serial": "uart"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["nrf52840"],
|
||||
"build-tags": ["nrf52840_mdk_usb_dongle", "nrf52840_reset_uf2", "softdevice", "s140v6"],
|
||||
"serial": "usb",
|
||||
"flash-1200-bps-reset": "true",
|
||||
"flash-method": "msd",
|
||||
"msd-volume-name": "MDK-DONGLE",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["nrf52840"],
|
||||
"build-tags": ["nrf52840_mdk"],
|
||||
"serial": "usb",
|
||||
"flash-method": "openocd",
|
||||
"openocd-interface": "cmsis-dap"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["cortex-m3"],
|
||||
"build-tags": ["nucleof103rb", "stm32f103", "stm32f1","stm32"],
|
||||
"serial": "uart",
|
||||
"linkerscript": "targets/stm32f103rb.ld",
|
||||
"extra-files": [
|
||||
"src/device/stm32/stm32f103.s"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["cortex-m7"],
|
||||
"build-tags": ["nucleof722ze", "stm32f7x2", "stm32f7", "stm32"],
|
||||
"serial": "uart",
|
||||
"linkerscript": "targets/stm32f7x2zetx.ld",
|
||||
"extra-files": [
|
||||
"src/device/stm32/stm32f7x2.s"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["cortex-m0"],
|
||||
"build-tags": ["nucleol031k6", "stm32l031", "stm32l0x1", "stm32l0", "stm32"],
|
||||
"serial": "uart",
|
||||
"linkerscript": "targets/stm32l031k6.ld",
|
||||
"extra-files": [
|
||||
"src/device/stm32/stm32l0x1.s"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["cortex-m4"],
|
||||
"build-tags": ["nucleol432kc", "stm32l432", "stm32l4x2", "stm32l4", "stm32"],
|
||||
"serial": "uart",
|
||||
"linkerscript": "targets/stm32l4x2.ld",
|
||||
"extra-files": [
|
||||
"src/device/stm32/stm32l4x2.s"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["cortex-m33"],
|
||||
"build-tags": ["nucleol552ze", "stm32l552", "stm32l5x2", "stm32l5", "stm32"],
|
||||
"serial": "uart",
|
||||
"linkerscript": "targets/stm32l5x2xe.ld",
|
||||
"extra-files": [
|
||||
"src/device/stm32/stm32l552.s"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["nrf52840"],
|
||||
"build-tags": ["particle_3rd_gen"],
|
||||
"serial": "uart",
|
||||
"flash-method": "openocd",
|
||||
"openocd-interface": "cmsis-dap"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"inherits": ["nrf51"],
|
||||
"build-tags": ["pca10031"],
|
||||
"serial": "uart",
|
||||
"flash-command": "nrfjprog -f nrf51 --sectorerase --program {hex} --reset",
|
||||
"openocd-interface": "cmsis-dap"
|
||||
}
|
||||
|
|
Показаны не все изменённые файлы, т.к. их слишком много Показать больше
Загрузка…
Создание таблицы
Сослаться в новой задаче