diff --git a/GNUmakefile b/GNUmakefile index f4a144a4ac..87a63c64b4 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -634,7 +634,7 @@ smoketest: testchdir @$(MD5SUM) test.hex # test simulated boards on play.tinygo.org ifneq ($(WASM), 0) - GOOS=js GOARCH=wasm $(TINYGO) build -size short -o test.wasm -tags=arduino examples/blinky1 + GOOS=js GOARCH=wasm $(TINYGO) build -size short -o test.wasm -tags=arduino_uno examples/blinky1 @$(MD5SUM) test.wasm GOOS=js GOARCH=wasm $(TINYGO) build -size short -o test.wasm -tags=hifive1b examples/blinky1 @$(MD5SUM) test.wasm @@ -898,13 +898,13 @@ endif @$(MD5SUM) test.hex $(TINYGO) build -size short -o test.hex -target=atmega1284p examples/machinetest @$(MD5SUM) test.hex - $(TINYGO) build -size short -o test.hex -target=arduino examples/blinky1 + $(TINYGO) build -size short -o test.hex -target=arduino-uno examples/blinky1 @$(MD5SUM) test.hex $(TINYGO) build -size short -o test.hex -target=arduino-leonardo examples/blinky1 @$(MD5SUM) test.hex - $(TINYGO) build -size short -o test.hex -target=arduino examples/pwm + $(TINYGO) build -size short -o test.hex -target=arduino-uno examples/pwm @$(MD5SUM) test.hex - $(TINYGO) build -size short -o test.hex -target=arduino -scheduler=tasks examples/blinky1 + $(TINYGO) build -size short -o test.hex -target=arduino-uno -scheduler=tasks examples/blinky1 @$(MD5SUM) test.hex $(TINYGO) build -size short -o test.hex -target=arduino-mega1280 examples/blinky1 @$(MD5SUM) test.hex diff --git a/README.md b/README.md index 17d9f4fc70..b60db903b8 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ func main() { The above program can be compiled and run without modification on an Arduino Uno, an Adafruit ItsyBitsy M0, or any of the supported boards that have a built-in LED, just by setting the correct TinyGo compiler target. For example, this compiles and flashes an Arduino Uno: ```shell -tinygo flash -target arduino examples/blinky1 +tinygo flash -target arduino-uno examples/blinky1 ``` ## WebAssembly diff --git a/src/examples/pininterrupt/arduino.go b/src/examples/pininterrupt/arduino-uno.go similarity index 86% rename from src/examples/pininterrupt/arduino.go rename to src/examples/pininterrupt/arduino-uno.go index aefdacf968..da50f38c8c 100644 --- a/src/examples/pininterrupt/arduino.go +++ b/src/examples/pininterrupt/arduino-uno.go @@ -1,4 +1,4 @@ -//go:build arduino +//go:build arduino_uno package main diff --git a/src/examples/pwm/arduino.go b/src/examples/pwm/arduino-uno.go similarity index 88% rename from src/examples/pwm/arduino.go rename to src/examples/pwm/arduino-uno.go index bbbcf54e94..be785ea5c3 100644 --- a/src/examples/pwm/arduino.go +++ b/src/examples/pwm/arduino-uno.go @@ -1,4 +1,4 @@ -//go:build arduino +//go:build arduino_uno package main diff --git a/src/examples/pwm/pico2.go b/src/examples/pwm/pico2.go new file mode 100644 index 0000000000..8cdb02be5a --- /dev/null +++ b/src/examples/pwm/pico2.go @@ -0,0 +1,11 @@ +//go:build pico2 || pico_plus2 + +package main + +import "machine" + +var ( + pwm = machine.PWM0 // Pin 25 (LED on pico2) corresponds to PWM0. + //pinA = machine.LED + pinA = machine.GPIO16 +) diff --git a/src/machine/board_arduino.go b/src/machine/board_arduino_uno.go similarity index 95% rename from src/machine/board_arduino.go rename to src/machine/board_arduino_uno.go index a66889aee5..fb7a4e8cd6 100644 --- a/src/machine/board_arduino.go +++ b/src/machine/board_arduino_uno.go @@ -1,4 +1,4 @@ -//go:build arduino +//go:build arduino_uno package machine diff --git a/src/machine/board_atmega328p.go b/src/machine/board_atmega328p.go index 45a2c69405..4217b6de46 100644 --- a/src/machine/board_atmega328p.go +++ b/src/machine/board_atmega328p.go @@ -1,4 +1,4 @@ -//go:build (avr && atmega328p) || arduino || arduino_nano +//go:build (avr && atmega328p) || arduino_uno || arduino_nano package machine diff --git a/targets/arduino-uno.json b/targets/arduino-uno.json new file mode 100644 index 0000000000..8eda9722b8 --- /dev/null +++ b/targets/arduino-uno.json @@ -0,0 +1,11 @@ +{ + "inherits": ["atmega328p"], + "build-tags": ["arduino_uno"], + "ldflags": [ + "--defsym=_bootloader_size=512", + "--defsym=_stack_size=512" + ], + "flash-command": "avrdude -c arduino -p atmega328p -P {port} -U flash:w:{hex}:i", + "serial-port": ["2341:0043", "2341:0001", "2a03:0043", "2341:0243"], + "emulator": "simavr -m atmega328p -f 16000000 {}" +} diff --git a/targets/arduino.json b/targets/arduino.json index b5bd97758b..0b62af8653 100644 --- a/targets/arduino.json +++ b/targets/arduino.json @@ -1,11 +1,3 @@ { - "inherits": ["atmega328p"], - "build-tags": ["arduino"], - "ldflags": [ - "--defsym=_bootloader_size=512", - "--defsym=_stack_size=512" - ], - "flash-command": "avrdude -c arduino -p atmega328p -P {port} -U flash:w:{hex}:i", - "serial-port": ["2341:0043", "2341:0001", "2a03:0043", "2341:0243"], - "emulator": "simavr -m atmega328p -f 16000000 {}" + "inherits": ["arduino-uno"] }