Browse Source

all: add Arduino Nano support

pull/861/head
Ayke van Laethem 5 years ago
committed by Ron Evans
parent
commit
aeb2e6f70a
  1. 2
      Makefile
  2. 27
      src/machine/board_arduino_nano.go
  3. 9
      targets/arduino-nano.json
  4. 14
      targets/arduino.json
  5. 14
      targets/atmega328p.json

2
Makefile

@ -265,6 +265,8 @@ smoketest:
ifneq ($(AVR), 0) ifneq ($(AVR), 0)
$(TINYGO) build -size short -o test.hex -target=arduino examples/blinky1 $(TINYGO) build -size short -o test.hex -target=arduino examples/blinky1
@$(MD5SUM) test.hex @$(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 $(TINYGO) build -size short -o test.hex -target=digispark examples/blinky1
@$(MD5SUM) test.hex @$(MD5SUM) test.hex
endif endif

27
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
)

9
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"
}

14
targets/arduino.json

@ -1,19 +1,9 @@
{ {
"inherits": ["avr"], "inherits": ["atmega328p"],
"llvm-target": "avr-atmel-none", "build-tags": ["arduino"],
"cpu": "atmega328p",
"build-tags": ["arduino", "atmega328p", "atmega", "avr5"],
"cflags": [
"-mmcu=atmega328p"
],
"ldflags": [ "ldflags": [
"-Wl,--defsym=_bootloader_size=512", "-Wl,--defsym=_bootloader_size=512",
"-Wl,--defsym=_stack_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" "flash-command": "avrdude -c arduino -p atmega328p -P {port} -U flash:w:{hex}:i"
} }

14
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"
]
}
Loading…
Cancel
Save