diff --git a/Makefile b/Makefile index 2d4f2580..22cf6b2c 100644 --- a/Makefile +++ b/Makefile @@ -265,6 +265,8 @@ smoketest: ifneq ($(AVR), 0) $(TINYGO) build -size short -o test.hex -target=arduino examples/blinky1 @$(MD5SUM) test.hex + $(TINYGO) build -size short -o test.hex -target=arduino-nano examples/blinky1 + @$(MD5SUM) test.hex $(TINYGO) build -size short -o test.hex -target=digispark examples/blinky1 @$(MD5SUM) test.hex endif diff --git a/src/machine/board_arduino_nano.go b/src/machine/board_arduino_nano.go new file mode 100644 index 00000000..1e96c95f --- /dev/null +++ b/src/machine/board_arduino_nano.go @@ -0,0 +1,27 @@ +// +build arduino_nano + +package machine + +// Return the current CPU frequency in hertz. +func CPUFrequency() uint32 { + return 16000000 +} + +// LED on the Arduino +const LED Pin = 13 + +// ADC on the Arduino +const ( + ADC0 Pin = 0 + ADC1 Pin = 1 + ADC2 Pin = 2 + ADC3 Pin = 3 + ADC4 Pin = 4 // Used by TWI for SDA + ADC5 Pin = 5 // Used by TWI for SCL +) + +// UART pins +const ( + UART_TX_PIN Pin = 1 + UART_RX_PIN Pin = 0 +) diff --git a/targets/arduino-nano.json b/targets/arduino-nano.json new file mode 100644 index 00000000..b1f27809 --- /dev/null +++ b/targets/arduino-nano.json @@ -0,0 +1,9 @@ +{ + "inherits": ["atmega328p"], + "build-tags": ["arduino_nano"], + "ldflags": [ + "-Wl,--defsym=_bootloader_size=512", + "-Wl,--defsym=_stack_size=512" + ], + "flash-command": "avrdude -c arduino -p atmega328p -b 57600 -P {port} -U flash:w:{hex}:i" +} diff --git a/targets/arduino.json b/targets/arduino.json index 4c847e0a..fbbca7a8 100644 --- a/targets/arduino.json +++ b/targets/arduino.json @@ -1,19 +1,9 @@ { - "inherits": ["avr"], - "llvm-target": "avr-atmel-none", - "cpu": "atmega328p", - "build-tags": ["arduino", "atmega328p", "atmega", "avr5"], - "cflags": [ - "-mmcu=atmega328p" - ], + "inherits": ["atmega328p"], + "build-tags": ["arduino"], "ldflags": [ "-Wl,--defsym=_bootloader_size=512", "-Wl,--defsym=_stack_size=512" ], - "linkerscript": "src/device/avr/atmega328p.ld", - "extra-files": [ - "targets/avr.S", - "src/device/avr/atmega328p.s" - ], "flash-command": "avrdude -c arduino -p atmega328p -P {port} -U flash:w:{hex}:i" } diff --git a/targets/atmega328p.json b/targets/atmega328p.json new file mode 100644 index 00000000..84fd2915 --- /dev/null +++ b/targets/atmega328p.json @@ -0,0 +1,14 @@ +{ + "inherits": ["avr"], + "llvm-target": "avr-atmel-none", + "cpu": "atmega328p", + "build-tags": ["atmega328p", "atmega", "avr5"], + "cflags": [ + "-mmcu=atmega328p" + ], + "linkerscript": "src/device/avr/atmega328p.ld", + "extra-files": [ + "targets/avr.S", + "src/device/avr/atmega328p.s" + ] +}